Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flexible flow layout to fill space #66

Open
xeruf opened this issue Nov 30, 2021 · 7 comments
Open

Flexible flow layout to fill space #66

xeruf opened this issue Nov 30, 2021 · 7 comments

Comments

@xeruf
Copy link

xeruf commented Nov 30, 2021

I want to give timg multiple images scaled to a certain height, and want them to be placed right next to each other without worrying about columns.

@hzeller
Copy link
Owner

hzeller commented Nov 30, 2021

If you just want to fill the available space in the width and use whatever makes sense in the height you can tell it to have the number of columns you need, say you want to have 5 columns:

timg --grid=5x1 *.jpg

The 5x1 means: fill the width with 5 columns and take whatever space is needed up to the height of the terminal.

If you want to limit the height in a particular way, you need to also give the geometry.

timg --grid=5x1 -g 100x50 *.jpg

Will make the images at most 50 characters high and attempts to fit 5 columns in the 100 character width.

Ideally, you'd just give the height and let timg figure out the width, but currently timg only does either full automatic or full manual (so here, we ideally would like to have something like -gx50, meaning only the height is specified). I think this would be a good feature to have; let me think about that.

@hzeller
Copy link
Owner

hzeller commented Nov 30, 2021

Alright, added the feature to only partially specify the geometry. So now, it is possible to tell timg to have a specific number of columns evenly spaced into the available width of the terminal whlie not exceeding a certain height:

timg --grid=5x1 -gx50`

@hzeller
Copy link
Owner

hzeller commented Dec 2, 2021

Does this solve your feature need ?

@xeruf
Copy link
Author

xeruf commented Dec 3, 2021

No, unfortunately not, though that is a nice step - I don't want them evenly spaced but right next to each other, so I don't want a fixed grid at all.

@hzeller
Copy link
Owner

hzeller commented Dec 3, 2021

So you'd like to have something like a 'flowing' layout, in which we fill a row with as many images as possible of a particular height, and then start the next row. Depending on the width of the pictures we might get more or less in one row.
Something like that ?

@xeruf
Copy link
Author

xeruf commented Dec 5, 2021

Exactly :)

@xeruf xeruf changed the title Fill horizontal space Flexible flow layout to fill space Feb 9, 2022
@acxz
Copy link

acxz commented Apr 14, 2022

I think this could be done by having an option to update the x_offset based on the image width instead of the fixed column size.

const int x_offset = current_column_ * column_width_;

Essentially keep a running tally of the current x offset and as you loop through the images keep on adding the image width to the x_offset.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants