[gimp] libgimpwidgets: improve a bit the position of progress and normal text.
- From: Jehan <jehanp src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] libgimpwidgets: improve a bit the position of progress and normal text.
- Date: Thu, 17 Feb 2022 22:14:01 +0000 (UTC)
commit dfd05c0717031e83994c4f1610d02edde8e123ad
Author: Jehan <jehan girinstud io>
Date: Wed Feb 16 17:42:53 2022 +0100
libgimpwidgets: improve a bit the position of progress and normal text.
The logics to get the progress position is not proper because the text
area (as returned by gtk_entry_get_text_area()) is actually slightly
smaller than the progress area. Unfortunately it doesn't look like there
is an API to get the exact progress area. This commit improves a bit the
situation by starting the progress rectangle when excluding the
intersection of 2 rectangles in pango at the start of the text area (not
at 0).
It's still not perfect as the progress width will be anyway a bit too
small and we don't have the data to compute it properly, but it's better
than it used to be. I also set several variables to double instead of
int to be more accurate, though this part doesn't help much.
Finally I used the ink extents rather than the logical extents. Since we
are here to draw, this is the ink extents which is really needed.
Note: for the bug to be visible, you need to have a different text color
for the progress and non-progress part of the scale.
Also I'm unsure about the right-to-left logics which seems very broken.
libgimpwidgets/gimpspinscale.c | 26 +++++++++++++-------------
1 file changed, 13 insertions(+), 13 deletions(-)
---
diff --git a/libgimpwidgets/gimpspinscale.c b/libgimpwidgets/gimpspinscale.c
index 7a7329c820..f9b6a8a8de 100644
--- a/libgimpwidgets/gimpspinscale.c
+++ b/libgimpwidgets/gimpspinscale.c
@@ -373,16 +373,16 @@ gimp_spin_scale_draw (GtkWidget *widget,
GtkStateFlags state;
gint minimum_width;
gint natural_width;
- PangoRectangle logical;
+ PangoRectangle ink;
gint layout_offset_x;
gint layout_offset_y;
GdkRGBA text_color;
GdkRGBA bar_text_color;
gdouble progress_fraction;
- gint progress_x;
- gint progress_y;
- gint progress_width;
- gint progress_height;
+ gdouble progress_x;
+ gdouble progress_y;
+ gdouble progress_width;
+ gdouble progress_height;
gtk_widget_get_allocation (widget, &allocation);
@@ -417,16 +417,16 @@ gimp_spin_scale_draw (GtkWidget *widget,
pango_layout_set_width (private->layout,
PANGO_SCALE *
(allocation.width - minimum_width));
- pango_layout_get_pixel_extents (private->layout, NULL, &logical);
+ pango_layout_get_pixel_extents (private->layout, &ink, NULL);
gtk_entry_get_layout_offsets (GTK_ENTRY (widget), NULL, &layout_offset_y);
if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
- layout_offset_x = text_area.x + text_area.width - logical.width - 2;
+ layout_offset_x = text_area.x + text_area.width - ink.width - 2;
else
layout_offset_x = text_area.x + 2;
- layout_offset_x -= logical.x;
+ layout_offset_x -= ink.x;
gtk_style_context_get_color (style, state, &text_color);
@@ -441,16 +441,16 @@ gimp_spin_scale_draw (GtkWidget *widget,
{
progress_fraction = 1.0 - progress_fraction;
- progress_x = text_area.width * progress_fraction;
- progress_y = 0;
+ progress_x = (gdouble) text_area.width * progress_fraction + text_area.x;
+ progress_y = 0.0;
progress_width = text_area.width - progress_x;
progress_height = text_area.height;
}
else
{
- progress_x = 0;
- progress_y = 0;
- progress_width = text_area.width * progress_fraction;
+ progress_x = text_area.x;
+ progress_y = 0.0;
+ progress_width = (gdouble) text_area.width * progress_fraction;
progress_height = text_area.height;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]