Skip to content

Commit

Permalink
chafa: Honor --stretch in grid tiles
Browse files Browse the repository at this point in the history
  • Loading branch information
hpjansson committed Dec 23, 2024
1 parent 506c0d9 commit 87676ab
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions tools/chafa/chafa.c
Original file line number Diff line number Diff line change
Expand Up @@ -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))
{
Expand Down
12 changes: 11 additions & 1 deletion tools/chafa/grid-layout.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -341,6 +342,7 @@ grid_layout_new (void)
GridLayout *grid;

grid = g_new0 (GridLayout, 1);
grid->tuck = CHAFA_TUCK_FIT;
return grid;
}

Expand Down Expand Up @@ -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)
{
Expand Down
1 change: 1 addition & 0 deletions tools/chafa/grid-layout.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit 87676ab

Please sign in to comment.