gimp r26236 - in trunk: . app/display app/widgets



Author: martinn
Date: Sat Jul 19 19:00:08 2008
New Revision: 26236
URL: http://svn.gnome.org/viewvc/gimp?rev=26236&view=rev

Log:
2008-07-19  Martin Nordholts  <martinn svn gnome org>

	* app/widgets/gimpnavigationview.[ch]: Don't expose implementation
	details and extend the interface with trivial new functions.

	* app/display/gimpnavigationeditor.c
	(gimp_navigation_editor_popup): Use the new interface instead of
	directly accessing the members of the navigation view.


Modified:
   trunk/ChangeLog
   trunk/app/display/gimpnavigationeditor.c
   trunk/app/widgets/gimpnavigationview.c
   trunk/app/widgets/gimpnavigationview.h

Modified: trunk/app/display/gimpnavigationeditor.c
==============================================================================
--- trunk/app/display/gimpnavigationeditor.c	(original)
+++ trunk/app/display/gimpnavigationeditor.c	Sat Jul 19 19:00:08 2008
@@ -231,6 +231,10 @@
   GdkScreen            *screen;
   gint                  x, y;
   gint                  x_org, y_org;
+  gint                  view_marker_x;
+  gint                  view_marker_y;
+  gint                  view_marker_width;
+  gint                  view_marker_height;
 
   g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
   g_return_if_fail (GTK_IS_WIDGET (widget));
@@ -272,14 +276,20 @@
   /* decide where to put the popup */
   gdk_window_get_origin (widget->window, &x_org, &y_org);
 
+  gimp_navigation_view_get_local_marker (view,
+                                         &view_marker_x,
+                                         &view_marker_y,
+                                         &view_marker_width,
+                                         &view_marker_height);
+
   x = (x_org + click_x -
-       view->p_x -
-       0.5 * (view->p_width  - BORDER_PEN_WIDTH) -
+       view_marker_x -
+       0.5 * (view_marker_width  - BORDER_PEN_WIDTH) -
        2   * style->xthickness);
 
   y = (y_org + click_y -
-       view->p_y -
-       0.5 * (view->p_height - BORDER_PEN_WIDTH) -
+       view_marker_y -
+       0.5 * (view_marker_height - BORDER_PEN_WIDTH) -
        2   * style->ythickness);
 
   /* If the popup doesn't fit into the screen, we have a problem.
@@ -305,9 +315,9 @@
   gdk_flush ();
 
   /* fill in then grab pointer */
-  view->motion_offset_x = 0.5 * (view->p_width  - BORDER_PEN_WIDTH);
-  view->motion_offset_y = 0.5 * (view->p_height - BORDER_PEN_WIDTH);
-
+  gimp_navigation_view_set_motion_offset (view,
+                                          0.5 * (view_marker_width  - BORDER_PEN_WIDTH),
+                                          0.5 * (view_marker_height - BORDER_PEN_WIDTH));
   gimp_navigation_view_grab_pointer (view);
 }
 

Modified: trunk/app/widgets/gimpnavigationview.c
==============================================================================
--- trunk/app/widgets/gimpnavigationview.c	(original)
+++ trunk/app/widgets/gimpnavigationview.c	Sat Jul 19 19:00:08 2008
@@ -50,6 +50,30 @@
 };
 
 
+struct _GimpNavigationView
+{
+  GimpView     parent_instance;
+
+  /*  values in image coordinates  */
+  gdouble      x;
+  gdouble      y;
+  gdouble      width;
+  gdouble      height;
+
+  /*  values in view coordinates  */
+  gint         p_x;
+  gint         p_y;
+  gint         p_width;
+  gint         p_height;
+
+  gint         motion_offset_x;
+  gint         motion_offset_y;
+  gboolean     has_grab;
+
+  GdkGC       *gc;
+};
+
+
 static void     gimp_navigation_view_realize        (GtkWidget      *widget);
 static void     gimp_navigation_view_unrealize      (GtkWidget      *widget);
 static void     gimp_navigation_view_size_allocate  (GtkWidget      *widget,
@@ -135,7 +159,6 @@
 
   gtk_widget_add_events (GTK_WIDGET (view), (GDK_POINTER_MOTION_MASK |
                                              GDK_KEY_PRESS_MASK));
-
   view->x               = 0.0;
   view->y               = 0.0;
   view->width           = 0.0;
@@ -575,3 +598,29 @@
   if (GTK_WIDGET_DRAWABLE (view))
     gimp_navigation_view_draw_marker (nav_view, NULL);
 }
+
+void
+gimp_navigation_view_set_motion_offset (GimpNavigationView *view,
+                                        gint                motion_offset_x,
+                                        gint                motion_offset_y)
+{
+  g_return_if_fail (GIMP_IS_NAVIGATION_VIEW (view));
+
+  view->motion_offset_x = motion_offset_x;
+  view->motion_offset_y = motion_offset_y;
+}
+
+void
+gimp_navigation_view_get_local_marker (GimpNavigationView *view,
+                                       gint               *x,
+                                       gint               *y,
+                                       gint               *width,
+                                       gint               *height)
+{
+  g_return_if_fail (GIMP_IS_NAVIGATION_VIEW (view));
+
+  if (x)      *x      = view->p_x;
+  if (y)      *y      = view->p_y;
+  if (width)  *width  = view->p_width;
+  if (height) *height = view->p_height;
+}

Modified: trunk/app/widgets/gimpnavigationview.h
==============================================================================
--- trunk/app/widgets/gimpnavigationview.h	(original)
+++ trunk/app/widgets/gimpnavigationview.h	Sat Jul 19 19:00:08 2008
@@ -38,29 +38,6 @@
 
 typedef struct _GimpNavigationViewClass  GimpNavigationViewClass;
 
-struct _GimpNavigationView
-{
-  GimpView     parent_instance;
-
-  /*  values in image coordinates  */
-  gdouble      x;
-  gdouble      y;
-  gdouble      width;
-  gdouble      height;
-
-  /*  values in view coordinates  */
-  gint         p_x;
-  gint         p_y;
-  gint         p_width;
-  gint         p_height;
-
-  gint         motion_offset_x;
-  gint         motion_offset_y;
-  gboolean     has_grab;
-
-  GdkGC       *gc;
-};
-
 struct _GimpNavigationViewClass
 {
   GimpViewClass  parent_class;
@@ -82,6 +59,16 @@
                                            gdouble             y,
                                            gdouble             width,
                                            gdouble             height);
+void    gimp_navigation_view_set_motion_offset
+                                          (GimpNavigationView *view,
+                                           gint                motion_offset_x,
+                                           gint                motion_offset_y);
+void    gimp_navigation_view_get_local_marker
+                                          (GimpNavigationView *view,
+                                           gint               *x,
+                                           gint               *y,
+                                           gint               *width,
+                                           gint               *height);
 void    gimp_navigation_view_grab_pointer (GimpNavigationView *view);
 
 



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