Display image dimensions and aspect ratio in status bar#2013
Display image dimensions and aspect ratio in status bar#2013j03l wants to merge 2 commits intoPintaProject:masterfrom
Conversation
Add a new status bar widget showing image dimensions and simplified aspect ratio (e.g. "800 × 600 · 4:3"). The label updates on resize, rotate, undo/redo, and document switching. Also hide the selection size widget when no selection is active, instead of showing the full canvas dimensions. Ref: PintaProject#1994
|
Thanks for working on this! I'll look through the code more closely later but gave it a quick try
statusbar.mp4 |
…dows - Render the color palette as a Gtk.Overlay child on top of the info widgets (selection, cursor, image size, zoom) so it overlaps instead of being compressed when the window is too narrow. - Pass through clicks on empty palette areas to info widgets underneath. - Use view-fullscreen-symbolic icon for image dimensions widget. - Reduce WidthChars from 24 to 16 with dynamic growth to minimize gap. Avoided using vertical containers (Box or Grid) inside the horizontal status bar, as the alternating-orientation nesting triggers the GTK box layout measurement warning from PintaProject#1356. Even a multi-line label with a newline causes the same issue since Pango's height-for-width measurement creates the same non-monotonic dependency. All status bar children remain flat/horizontal to prevent this.
|
Added an overlay approach for the status bar so the color palette renders on top of the info widgets when the window is narrow, rather than being squished. One thing worth noting: I originally wanted to stack the cursor position and image dimensions vertically (two lines) to save horizontal space, but any vertical container (Gtk.Box, Gtk.Grid, or even a single Gtk.Label with So the info widgets stay flat/horizontal to avoid this. The image dimensions label uses |
| ); | ||
| // Use an overlay so the palette renders on top of the info widgets | ||
| // when the window is too narrow, instead of being squished. | ||
| var overlay = Gtk.Overlay.New (); |
| return $"{w / gcd}:{h / gcd}"; | ||
| } | ||
|
|
||
| private static int GCD (int a, int b) |
There was a problem hiding this comment.
I just remembered we have some existing code that could be used for this:
| var selection_size = Gtk.Label.New (""); | ||
| selection_size.Xalign = 0.0f; | ||
| selection_size.Halign = Gtk.Align.Start; | ||
| selection_size.WidthChars = 11; |
There was a problem hiding this comment.
I think we should keep the original comments about left aligned with enough space to display coordinates up to tens of thousands (e.g. 10000, 10000) to explain the magic numbers like having WidthChars = 11, or perhaps we could also define a constant to use for these?
| selection_size.SetVisible (false); | ||
| return; | ||
| } | ||
| var bounds = workspaceManager.ActiveDocument.Selection.GetBounds (); |
There was a problem hiding this comment.
This wasn't something you changed, but looking more closely it'd be safer to do GetBounds().ToInt() here since this is a RectangleD, to avoid any chance of having the status bar show non-integer values to the user
| var image_size = Gtk.Label.New (""); | ||
| image_size.Xalign = 0.0f; | ||
| image_size.Halign = Gtk.Align.Start; | ||
| image_size.WidthChars = 16; |
There was a problem hiding this comment.
For the selection size and mouse position, we pre-allocate enough space so that the status bar layout doesn't shift around as you move the mouse.
The image size doesn't change as often, so maybe try removing the logic for setting WidthChars here (and below when the size changes)? That would minimize the extra padding and free up more space in the status bar


Add a new status bar widget showing image dimensions and simplified aspect ratio (e.g. "800 × 600 · 4:3"). The label updates on resize, rotate, undo/redo, and document switching.
The selection size widget previously showed the canvas dimensions (e.g., "800, 600") even when no selection was active. This was because ResetSelectionPaths() in Document.cs creates an invisible selection rectangle covering the full canvas, and the status bar handler read its bounds without checking Selection.Visible.
Before my changes, this was arguably useful, it was the only place showing the canvas dimensions. But now that I've added a dedicated image dimensions widget ("800 × 600 · 4:3"), showing the same numbers in the selection widget is redundant and misleading. It looks like there's an active selection when there isn't one. So I hide the selection widget entirely until the user actually makes a selection.
Ref: #1994