Tomas-M / xlunch

Graphical app launcher for X with minimal dependencies
http://xlunch.org
GNU General Public License v3.0
219 stars 37 forks source link

New centering does not allow for specifying --columns and does not center vertically #61

Closed Tomas-M closed 6 years ago

Tomas-M commented 6 years ago

I am not using --textafter so I didn't notice this earlier. When using --center --columns 1 for example, and --textafter, it doesn't put there the text properly. I'm not sure how this should be resolved. Maybe make the --textafter parameter accept an argument, like --textafter 200, which means to make the column width 200px? Or maybe disable --center if --textafter is specified?

PMunch commented 6 years ago

Uhm, --textafter already takes an argument which is the padding between entries when using the option. The problem here is that --textafter uses the maximum available size to draw text before truncating it. That means that the cell_width is updated after the useable_<width|height> variables are set. To be honest I'm not quite sure what I'd expect --textafter to do in combination with --center since it ignores borders (why does it do this by the way?). If borders were used normally to calculate where icons should be when a row is full then this would all make more sense.

When thinking about it though the argument to --textafter pretty much does the same thing as --leastmargin, however only in the horizontal direction. Maybe the solution here is to rethink how --leastmargin and --textafter works. Have two separate --leasthmargin and --leastvmargin options and then make --textafter not take an argument at all. Then border, margins, and columns/rows should be able to calculate everything, including --textafter and --center together.

Tomas-M commented 6 years ago

I've 'fixed' this by ignoring --center when user uses --textafter. This is sufficient for me for now. 25d3acf309acd03edb3b4598e2dd0c070614419d

PMunch commented 6 years ago

Okay, I had a go at this today. Now --center centers all entries on the last row of entries if it has fewer entries than the other lines. So if you have set --columns to 4 but the last line only has 3 entries then they will be centered. This works even if the amount of columns are auto-calculated (eg. from --border and --leastmargin) or if you have --textafter specified. Since we've added --leastmargin I also made --textafter not take an argument and use --leastmargin for it's spacing instead.

Tomas-M commented 6 years ago

Hm, this does not work as I intended. I will show you some screenshots. I need to be able to provide the following layout: (as you can see, icons are centered horizontally and vertically)

1

However I find it impossible after your changes.

When I run xlunch --center --columns 3, I get this:

2

When I run xlunch --center (without the columns parameter, I get this): (note that it is centered only in the row, but the row is top aligned)

3

Furthermore, when I have 6 icons, I am now unable to make 3 columns with 2 rows and everything centered to the center of the screen, because specifying --columns breaks centering now.

So I am afraid your changes ruined my idea of centering :) What you consider intuitive (centering the last row) seems counterintuitive to me, because I would rather want to have 5 icons, 3 in first row, 2 in second row (left aligned to the upper row) but everything as a whole centered in the middle of the screen, making spacing between app icons with --leastmargin.

Tomas-M commented 6 years ago

I've reopened this and changed the title.

Tomas-M commented 6 years ago

Ah, now I read help message for --center "Center entries when there are fewer entries on a row than the maximum" Yeah xlunch now works this way. Unfortunately this feature (centering only fewer icons than maximum) is something I don't need at all :-)

I am looking for a way to center the block containing all icons at once (left aligned icons, need to say), as like if I was specifying border (which I cannot specify, because different users screens have different sizes and thus different borders are needed). So I could have for example 3 icons, put 2 rows 2 columns, and have a very nice pattern (2 icons on top, 1 icon under them left aligned under the first icon from the first row). Like this:

4

PMunch commented 6 years ago

Aah, I misunderstood then what you meant by centering. Maybe we can make the --border option optionally take the keyword auto or autocenter which will create borders that automatically centers the entire block?

EDIT: love the look you're going for in those screenshots by the way. Looks super clean and nice!

Tomas-M commented 6 years ago

Maybe if user does not specify border at all, then enable centering, instead of making it 10%?

I am fine with any form of parameters, as long as I could achieve the design I want. I'm happy you like it :)

PMunch commented 6 years ago

But if they don't specify borders how do we know how many entries they want? Currently the amount of entries per row is calculated by how many can fit in the usable space (screen width - borders). I think the --border auto could be cool, I'll try to implement it later.

Tomas-M commented 6 years ago

Well, if they do not specify border, calculate max entries from usable space (screen width) with no border, I see no problem in that :) When user specifies --columns, then we know how many columns he wants. Similarly if he specifies --rows, then we know rows.

Anyway, I will be happy even with --border auto, sounds good too :)

PMunch commented 6 years ago

Implemented in https://github.com/Tomas-M/xlunch/commit/49e88fbd8c7c0ba387f9914e9cf9c507bf26050a. Now --border and --sideborder accept the auto value which centers the content of the block based on how many rows/columns you have specified (along with margins of course). I also added an option -V, --leastvmargin to specify a vertical minimum margin. --textafter doesn't work with the auto value, but to be honest I'm not quite sure what anyone would expect that to do..

Tomas-M commented 6 years ago

Excellent! :] Thank you very much, I tested it and it works just perfect. Also in combination with the --center option, user has the possibility to create any cool layouts he likes. I've marked this as version 3.1.3

PMunch commented 6 years ago

Added another feature I think you will like for your menus. The option to have shortcuts! With -U, --shortcuts you can pass a string of UTF-8 characters, each character will sequentially be used as shortcuts for the entries. For your previous menus you could for example use --shortcuts "lrs" which would make 'l' a shortcut for "Log out", 'r' a shortcut for "Restart" and 's' a shortcut for "Shut down".

Tomas-M commented 6 years ago

Very interesting idea. Unfortunately I guess that most users will not know what is the shortcut for which icon.

Would be absolutely awesome if there was a way to mark text label to underline some characters, like &Logout would underline the L character so user could see the L is underlined and thus it must be a shortcut. As like Windows does. Would be maybe useful if we could put shortcuts to the entries file as well, like:

&Logout;iconfile;command;Ll
Re&boot;iconfile;command;Bb
Shut&down;iconfile;command;Dd

Because sometimes you want to underline uppercase L but you happily accept both uppercase and lowercase characters.

But this is just an idea to think about, I believe that underlining the proper character on the screen may be hard to implement.

PMunch commented 6 years ago

Yeah I considered that as well, problem is that since the entries file is often auto-generated it might accidentally contain most symbols breaking regular search. Underlining is definitely a benefit though.

There are some technical challenges in underlining the correct character for sure, but nothing that's completely impossible to overcome. What I implemented now was just the easiest solution I could think of that wouldn't break anything and would provide a way to define shortcuts for any given input file.