[gimp] app: fix positioning of the text tool's style overlay



commit 3c9272ef96bca5dd506dd45e91bc4f516fd371e3
Author: Michael Natterer <mitch gimp org>
Date:   Tue May 22 01:59:26 2018 +0200

    app: fix positioning of the text tool's style overlay

 app/display/gimpdisplayshell.c |   40 +++++++++++++++++++++++++++++++++++-----
 1 files changed, 35 insertions(+), 5 deletions(-)
---
diff --git a/app/display/gimpdisplayshell.c b/app/display/gimpdisplayshell.c
index 1f7d230..ae8cac0 100644
--- a/app/display/gimpdisplayshell.c
+++ b/app/display/gimpdisplayshell.c
@@ -114,11 +114,12 @@ typedef struct _GimpDisplayShellOverlay GimpDisplayShellOverlay;
 
 struct _GimpDisplayShellOverlay
 {
-  gdouble          image_x;
-  gdouble          image_y;
-  GimpHandleAnchor anchor;
-  gint             spacing_x;
-  gint             spacing_y;
+  GimpDisplayShell *shell;
+  gdouble           image_x;
+  gdouble           image_y;
+  GimpHandleAnchor  anchor;
+  gint              spacing_x;
+  gint              spacing_y;
 };
 
 
@@ -160,6 +161,9 @@ static void      gimp_display_shell_zoom_button_callback
 static void      gimp_display_shell_sync_config    (GimpDisplayShell  *shell,
                                                     GimpDisplayConfig *config);
 
+static void    gimp_display_shell_overlay_allocate (GtkWidget        *child,
+                                                    GtkAllocation    *allocation,
+                                                    GimpDisplayShellOverlay *overlay);
 static void      gimp_display_shell_remove_overlay (GtkWidget        *canvas,
                                                     GtkWidget        *child,
                                                     GimpDisplayShell *shell);
@@ -1041,10 +1045,31 @@ gimp_display_shell_sync_config (GimpDisplayShell  *shell,
 }
 
 static void
+gimp_display_shell_overlay_allocate (GtkWidget               *child,
+                                     GtkAllocation           *allocation,
+                                     GimpDisplayShellOverlay *overlay)
+{
+  gdouble x, y;
+
+  gimp_display_shell_transform_overlay (overlay->shell, child, &x, &y);
+
+  gimp_overlay_box_set_child_position (GIMP_OVERLAY_BOX (overlay->shell->canvas),
+                                       child, x, y);
+}
+
+static void
 gimp_display_shell_remove_overlay (GtkWidget        *canvas,
                                    GtkWidget        *child,
                                    GimpDisplayShell *shell)
 {
+  GimpDisplayShellOverlay *overlay;
+
+  overlay = g_object_get_data (G_OBJECT (child), "image-coords-overlay");
+
+  g_signal_handlers_disconnect_by_func (child,
+                                        gimp_display_shell_overlay_allocate,
+                                        overlay);
+
   shell->children = g_list_remove (shell->children, child);
 }
 
@@ -1154,6 +1179,7 @@ gimp_display_shell_add_overlay (GimpDisplayShell *shell,
 
   overlay = g_new0 (GimpDisplayShellOverlay, 1);
 
+  overlay->shell     = shell;
   overlay->image_x   = image_x;
   overlay->image_y   = image_y;
   overlay->anchor    = anchor;
@@ -1165,6 +1191,10 @@ gimp_display_shell_add_overlay (GimpDisplayShell *shell,
 
   shell->children = g_list_prepend (shell->children, child);
 
+  g_signal_connect (child, "size-allocate",
+                    G_CALLBACK (gimp_display_shell_overlay_allocate),
+                    overlay);
+
   gimp_display_shell_transform_overlay (shell, child, &x, &y);
 
   gimp_overlay_box_add_child (GIMP_OVERLAY_BOX (shell->canvas), child, 0.0, 0.0);


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