[gdl: 1/2] Center dock item button images




commit eb4145c1eff7941b7d6f75223369df0be61c5c59
Author: Thomas Holder <thomas thomas-holder de>
Date:   Mon Nov 16 14:07:51 2020 +0100

    Center dock item button images
    
    Fixes upstream inkscape issue
    https://gitlab.com/inkscape/inkscape/-/issues/2012

 gdl/gdl-dock-item-button-image.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
---
diff --git a/gdl/gdl-dock-item-button-image.c b/gdl/gdl-dock-item-button-image.c
index 7d52f15..ebdd23c 100644
--- a/gdl/gdl-dock-item-button-image.c
+++ b/gdl/gdl-dock-item-button-image.c
@@ -35,7 +35,7 @@
  */
 
 
-#define ICON_SIZE 13
+#define ICON_SIZE 16
 
 G_DEFINE_TYPE (GdlDockItemButtonImage,
                gdl_dock_item_button_image,
@@ -48,10 +48,16 @@ gdl_dock_item_button_image_draw (GtkWidget      *widget,
     GdlDockItemButtonImage *button_image;
     GtkStyleContext *context;
     GdkRGBA color;
+    int offset_x, offset_y;
 
     g_return_val_if_fail (widget != NULL, 0);
     button_image = GDL_DOCK_ITEM_BUTTON_IMAGE (widget);
 
+    /* Center the icon inside the widget */
+    offset_x = (gtk_widget_get_allocated_width (widget) - ICON_SIZE) / 2;
+    offset_y = (gtk_widget_get_allocated_height (widget) - ICON_SIZE) / 2;
+    cairo_translate (cr, offset_x, offset_y);
+
     /* Set up the pen */
     cairo_set_line_width(cr, 1.0);
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]