From 87676ab077cf4afb88cbb50276f6696fbf4af5e5 Mon Sep 17 00:00:00 2001 From: Hans Petter Jansson Date: Mon, 23 Dec 2024 21:03:55 +0100 Subject: [PATCH] chafa: Honor --stretch in grid tiles --- tools/chafa/chafa.c | 1 + tools/chafa/grid-layout.c | 12 +++++++++++- tools/chafa/grid-layout.h | 1 + 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/tools/chafa/chafa.c b/tools/chafa/chafa.c index 931e4e7..7dd4483 100644 --- a/tools/chafa/chafa.c +++ b/tools/chafa/chafa.c @@ -3284,6 +3284,7 @@ run_grid (GList *filenames) grid_layout_set_grid_size (grid_layout, options.grid_width, options.grid_height); grid_layout_set_canvas_config (grid_layout, canvas_config); grid_layout_set_term_info (grid_layout, options.term_info); + grid_layout_set_tuck (grid_layout, options.stretch ? CHAFA_TUCK_STRETCH : CHAFA_TUCK_FIT); for (l = filenames; l; l = g_list_next (l)) { diff --git a/tools/chafa/grid-layout.c b/tools/chafa/grid-layout.c index 40c4b95..0bb1e14 100644 --- a/tools/chafa/grid-layout.c +++ b/tools/chafa/grid-layout.c @@ -30,6 +30,7 @@ struct GridLayout gint n_cols, n_rows; ChafaCanvasConfig *canvas_config; ChafaTermInfo *term_info; + ChafaTuck tuck; GList *paths, *next_path; gint n_items; guint finished_push : 1; @@ -147,7 +148,7 @@ format_item (GridLayout *grid, const gchar *path, GString ***gsa) canvas = build_canvas (pixel_type, pixels, src_width, src_height, src_rowstride, grid->canvas_config, -1, - CHAFA_TUCK_FIT); + grid->tuck); chafa_canvas_print_rows (canvas, grid->term_info, gsa, NULL); success = TRUE; @@ -341,6 +342,7 @@ grid_layout_new (void) GridLayout *grid; grid = g_new0 (GridLayout, 1); + grid->tuck = CHAFA_TUCK_FIT; return grid; } @@ -403,6 +405,14 @@ grid_layout_set_grid_size (GridLayout *grid, gint n_cols, gint n_rows) update_geometry (grid); } +void +grid_layout_set_tuck (GridLayout *grid, ChafaTuck tuck) +{ + g_return_if_fail (grid != NULL); + + grid->tuck = tuck; +} + void grid_layout_push_path (GridLayout *grid, const gchar *path) { diff --git a/tools/chafa/grid-layout.h b/tools/chafa/grid-layout.h index 3655ae3..bc05a6a 100644 --- a/tools/chafa/grid-layout.h +++ b/tools/chafa/grid-layout.h @@ -33,6 +33,7 @@ void grid_layout_set_canvas_config (GridLayout *grid, ChafaCanvasConfig *canvas_ void grid_layout_set_term_info (GridLayout *grid, ChafaTermInfo *term_info); void grid_layout_set_view_size (GridLayout *grid, gint width, gint height); void grid_layout_set_grid_size (GridLayout *grid, gint n_cols, gint n_rows); +void grid_layout_set_tuck (GridLayout *grid, ChafaTuck tuck); void grid_layout_push_path (GridLayout *grid, const gchar *path);