pqiv
pqiv copied to clipboard
Status bar instead of info box ?
Currently the info box overlaps with the image. Could we put the same information in a statusbar, in the same style as zathura ?
It would be cool to have the status of the currently highlighted image in montage mode in the status bar, as a bonus.
This should be fairly straight forward: pqiv will automatically center images within the window (unless scaling is disabled - that's required for some tiling WMs), and moving the status bar itself around is as simple as drawing it at a different position.
See the bottom-bar branch for a simple demo. All that needs to be done is that the math must be done correctly and the feature must be configurable. I'll see when I find the time, but if you'd like to ramp this up to a full feature I'll also happily merge a PR :-)
(Adding the status bar in montage mode is a different thing, lets come back to that once we got the basic bottom status bar working.)
Unfortunately the info bar is still drawn over the image
I’d like something like this : https://github.com/sloonz/pqiv/commit/87bc6f7bcac9fd73d90b85972f15090f82082bee
My end goal is to have it available in montage mode in order to see the filename of the highlighted file. OK, not my end goal, I have other ideas, but let’s discuss this first ;)
I updated my branch to demonstrate what I envisioned : https://github.com/sloonz/pqiv/tree/status-bar
With this the status bar is available in montage mode, and can be set by an external command.
The idea is (for example) that in browsing images in a tagsistant filesystem, I can easily tags of the current image (both in normal and montage mode) with pqiv --status-bar-text='>echo $BASEFILENAME $(cat ${FILENAME}.tags)' store/ALL/@@
Thoughts on these changes ?
Unfortunately the info bar is still drawn over the image
Interesting. It shouldn't / isn't for me - when I disable the box this part of the screen simply remains black, unless I've zoomed in, that is. Maybe that's font size related, but it's certainly something which is fixable.
I updated my branch to demonstrate what I envisioned : https://github.com/sloonz/pqiv/tree/status-bar
Awesome, thanks.
- I would like to stick with moving the info box to the bottom and calculating sizes manually instead of adding an additional bar using Gtk Widgets. (Assuming that no one will ever want to have both.) I've seen lots of weird behaviour with different WMs, and there are quite a few special cases considered throughout the code - which makes me afraid that adding a Gtk Layout might break something for some people. Also, that'd keep code changes down to a minimum.
- Having the ability to run an external command to create the status/info text is a great thing. I wanted to suggest to integrate it to
--window-titlebut then found you already did that - awesome. - While we're at it, we could easily allow to place the status bar in N (full top status bar), S (full bottom status bar), or NE/NW/SE/SW + n px (info box as before, but freely placeable)
I’ve used GtkLabel because there is some nice things coming with it, like pango markup, set_line_wrap and set_ellipsize that would be a pain to do by hand. Maybe we can do it with raw pango. Or maybe we can position a label in a drawing area without a GtkBox. I’ll have a look at it.
OK, seems possible with pango-cairo.
Before remaking the first part of the patch, a few questions :
- Do you prefer a status bar in addition to the info text, or just modify the info text ?
- If second option, with respect to overlap : right now the info text overlaps the image, which I don't want. Do I add an option to avoid overlap, or do I avoid overlap without option ? If I add an option, what’s its name ?
Do you prefer a status bar in addition to the info text, or just modify the info text ?
Modify the info text - the less new code we have to add the better. And it makes sense to have this as a replacement, I can't imagine anyone would want to have both.
If second option, with respect to overlap : right now the info text overlaps the image, which I don't want. Do I add an option to avoid overlap, or do I avoid overlap without option ? If I add an option, what’s its name ?
See above for an idea: --info-box-position=POS and set_info_box_position(POS) where POS may be:
Nfor a top status bar (image is sized such that it doesn't overlap)Sfor a bottom status bar (image is sized such that it doesn't overlap)NWfor the current behaviourNEfor current behaviour, but aligned to the top/right cornerSWfor current behaviour, but aligned to the bottom/left cornerSEfor current behaviour, but aligned to the bottom/right corner- (optional:)
Wfor left side, image sized such that it doesn't overlap, text rotated by 90°,Esame on the right side - (optional:)
cycle, only available in the action, to choose the next option based on the current value
The info box has some font-size magic in place, it tries to find the maximal font size for which the text can be rendered inside the window. It would be nice to reuse that code for the non-overlapping modes, but I think that the height (in S/N mode) respectively width (in W/E mode) should be fixed instead of changing with the font size - anything else might be too irritating for users.
What do you think?
I have advanced a bit but I’m stuck on something, maybe you can enlighten me.
If the size of the info box changes (which is detected at the start of window_draw_callback), I have to recalculate the scale level based on main_window_height - info_box_height. I’m confused a lot by how it works in the current code.
Let’s say that scale mode is AUTO_SCALEUP (I test with -t). The scale level seems to be decided by calculate_auto_scale_level_for_screen (called by set_scale_level_for_screen)
scale_level = screen_width * option_scale_screen_fraction / image_width;
If the scale level cause the image to be too high, it is scaled down to screen size:
if((option_scale == AUTO_SCALEUP || option_scale == AUTO_SCALEDOWN) && image_height * scale_level > screen_height * option_scale_screen_fraction) {
// If the height exceeds screen size, scale down
scale_level = screen_height * option_scale_screen_fraction / image_height;
}
This is not the behavior I observe. According to this code, the image should fit 80% of screen size (since option_scale_screen_fraction is .8 by default). Instead, with -t, the image fit 100% of the window. But if I call set_scale_level_for_screen in window_draw_callback (before drawing the image), I observe the behavior of "fit 80% of the screen", not the usual behavior of "fit 100% of the window". I thought that I was mistaken and set_scale_level_for_screen was not the function adjusting the scale level, but adding debug traces show that it is called, and moreover it is called when pressing t — when it is called outside of window_draw_callback (pressing t for example), the image fit at 100% window size.
How do this works ?
JFYI, I'm in an extended vacation for 3 more weeks and will reply as soon as I'm back. Sorry for the delay :)
The logic pqiv uses is to calculate the size of the image based on the scale option, then request a change of the window's size and then make it's final decision on how to draw the image based on what actually happened to the window in calculate_scale_level_to_fit. That's because window managers might choose to override pqiv's window size request.
The other special case is NO_SCALING, where images aren't centered within the window, in addition. See calculate_base_draw_pos_and_size() for the reasons for that.
Just chiming in, I think I'd prefer the status bar/infobox to show up at the bottom by default.
Also on the topic of status bars, the original qiv showed a message in its status bar when modes were toggled on or off (ex. slideshow mode on, slideshow mode off) which I found to be useful feedback.
Also on the topic of status bars, the original qiv showed a message in its status bar when modes were toggled on or off (ex. slideshow mode on, slideshow mode off) which I found to be useful feedback.
pqiv does this as well. If it doesn't, please open a bug and tell me how to reproduce :-)
I have updated my own version of the status-bar branch with a WIP version (that is, it's a hack & doesn't always produce the right result). The first commit is for moving the status bar around the screen & introduces the option/action/etc. required for the functionality, the second one is the WIP one for support for "N" and "S" placement of the status bar.
To test, use Ctrl-i to toggle between status bar positions.
You're right about the mode statuses. I must have missed it somehow when I made that comment.
I tested out the status-bar branch. Not sure if this is intentional, but starting pqiv with --info-box-placement=NE gives different behavior than in NW, SW and SE modes. Specifically, NE aligns the infobox to the window, whereas the others align to their respective corners of the image.
Maybe you could add T and B modes for top and bottom of the window, like in the bottom-bar branch?