gimp r25397 - in trunk: . app/tools



Author: weskaggs
Date: Mon Apr  7 17:32:31 2008
New Revision: 25397
URL: http://svn.gnome.org/viewvc/gimp?rev=25397&view=rev

Log:
Bill Skaggs  <weskaggs primate ucdavis edu>

	* app/tools/gimprectangletool.[ch]: add "force_narrow"
	parameter.

	* app/tools/gimptexttool.c: Force rectangle to always
	be narrow, and squash a few bugs.


Modified:
   trunk/ChangeLog
   trunk/app/tools/gimprectangletool.c
   trunk/app/tools/gimprectangletool.h
   trunk/app/tools/gimptexttool.c

Modified: trunk/app/tools/gimprectangletool.c
==============================================================================
--- trunk/app/tools/gimprectangletool.c	(original)
+++ trunk/app/tools/gimprectangletool.c	Mon Apr  7 17:32:31 2008
@@ -180,6 +180,12 @@
    */
   gboolean                narrow_mode;
 
+  /* Whether to force the rectangle to always be in narrow mode.  This
+   * parameter is especially useful for the text tool, where interior
+   * handles would interfere with the text.
+   */
+  gboolean                force_narrow;
+
   /* For what scale the handle sizes is calculated. We must cache this so that
    * we can differentiate between when the tool is resumed because of zoom level
    * just has changed or because the highlight has just been updated.
@@ -457,7 +463,9 @@
 void
 gimp_rectangle_tool_init (GimpRectangleTool *rect_tool)
 {
-  /* No need to initialize anything yet. */
+  GimpRectangleToolPrivate *private = GIMP_RECTANGLE_TOOL_GET_PRIVATE (rect_tool);
+
+  private->force_narrow = FALSE;
 }
 
 /**
@@ -882,8 +890,11 @@
 
       gimp_rectangle_tool_update_handle_sizes (rect_tool);
 
-      /* Created rectangles should not be started in narrow-mode */
-      private->narrow_mode = FALSE;
+      if (! private->force_narrow)
+        {
+          /* Created rectangles should not be started in narrow-mode*/
+          private->narrow_mode = FALSE;
+        }
 
       /* If the rectangle is being modified we want the center on fixed_center to be
        * at the center of the currently existing rectangle, otherwise we want the
@@ -1834,10 +1845,12 @@
                               &visible_rectangle_width,
                               &visible_rectangle_height);
 
-    /* Determine if we are in narrow-mode or not. */
-    private->narrow_mode = visible_rectangle_width  < NARROW_MODE_THRESHOLD ||
-                           visible_rectangle_height < NARROW_MODE_THRESHOLD;
-
+    if (! private->force_narrow)
+      {
+        /* Determine if we are in narrow-mode or not. */
+        private->narrow_mode = (visible_rectangle_width  < NARROW_MODE_THRESHOLD ||
+                                visible_rectangle_height < NARROW_MODE_THRESHOLD);
+      }
   }
 
   if (private->narrow_mode)
@@ -4118,13 +4131,25 @@
 }
 
 /**
- * gimp_rectangle_tool_rectangle_is_narrow:
+ * gimp_rectangle_tool_set_always_narrow:
  *
- * Returns TRUE if the handles are being shown outside the
- * rectangle, FALSE if they are inside
+ * Makes sure that the rectangle is always shown with handles
+ * outside.  Mainly intended for use in the text tool, where
+ * handles inside interfere with the text.  If this function
+ * is called while a rectangle is being shown, the draw tool
+ * must first be paused.
  */
-gboolean
-gimp_rectangle_tool_rectangle_is_narrow (GimpRectangleTool *rect_tool)
+void
+gimp_rectangle_tool_set_force_narrow (GimpRectangleTool *rect_tool,
+                                      gboolean           force_narrow)
 {
-  return GIMP_RECTANGLE_TOOL_GET_PRIVATE (rect_tool)->narrow_mode;
+  GimpRectangleToolPrivate *private = GIMP_RECTANGLE_TOOL_GET_PRIVATE (rect_tool);
+
+  private->force_narrow = force_narrow ? TRUE : FALSE;
+
+  if (force_narrow  && ! private->narrow_mode)
+    {
+      private->narrow_mode = TRUE;
+    }
 }
+

Modified: trunk/app/tools/gimprectangletool.h
==============================================================================
--- trunk/app/tools/gimprectangletool.h	(original)
+++ trunk/app/tools/gimprectangletool.h	Mon Apr  7 17:32:31 2008
@@ -139,11 +139,11 @@
                                                      const gchar             *width_property,
                                                      const gchar             *height_property);
 gboolean    gimp_rectangle_tool_rectangle_is_new    (GimpRectangleTool       *rect_tool);
-gboolean    gimp_rectangle_tool_rectangle_is_narrow (GimpRectangleTool       *rect_tool);
 gboolean    gimp_rectangle_tool_point_in_rectangle  (GimpRectangleTool       *rect_tool,
                                                      gdouble                  x,
                                                      gdouble                  y);
-
+void        gimp_rectangle_tool_set_force_narrow    (GimpRectangleTool       *rect_tool,
+                                                     gboolean                 force_narrow);
 /*  convenience functions  */
 
 void        gimp_rectangle_tool_install_properties  (GObjectClass *klass);

Modified: trunk/app/tools/gimptexttool.c
==============================================================================
--- trunk/app/tools/gimptexttool.c	(original)
+++ trunk/app/tools/gimptexttool.c	Mon Apr  7 17:32:31 2008
@@ -230,6 +230,8 @@
   object = G_OBJECT_CLASS (parent_class)->constructor (type, n_params, params);
 
   gimp_rectangle_tool_constructor (object);
+  gimp_rectangle_tool_set_force_narrow (GIMP_RECTANGLE_TOOL (object),
+                                        TRUE);
 
   text_tool = GIMP_TEXT_TOOL (object);
   options   = GIMP_TEXT_TOOL_GET_OPTIONS (text_tool);
@@ -322,7 +324,8 @@
 
   /* bail out now if the rectangle is narrow and the button
      press is outside the layer */
-  if (gimp_rectangle_tool_rectangle_is_narrow (rect_tool))
+  if (text_tool->layer &&
+      gimp_rectangle_tool_get_function (rect_tool) != GIMP_RECTANGLE_TOOL_CREATING)
     {
       GimpItem *item = GIMP_ITEM (text_tool->layer);
       gdouble   x    = coords->x - item->offset_x;
@@ -1281,6 +1284,7 @@
                     "y2", &y2,
                     NULL);
 
+      text_tool->text_box_fixed = TRUE;
       if (! text)
         {
           /*
@@ -1289,7 +1293,6 @@
            * so we need to make a special note that will remind
            * us what to do when we actually create the layer
            */
-          text_tool->text_box_fixed = TRUE;
           return TRUE;
         }
 
@@ -1349,6 +1352,9 @@
 
   gimp_draw_tool_pause (GIMP_DRAW_TOOL (rect_tool));
 
+  gimp_rectangle_tool_set_function (rect_tool,
+                                    GIMP_RECTANGLE_TOOL_CREATING);
+
   g_object_set (rect_tool,
                 "x1", offset_x,
                 "y1", offset_y,
@@ -1356,8 +1362,12 @@
                 "y2", offset_y + height,
                 NULL);
 
-  gimp_rectangle_tool_set_function (rect_tool,
-                                    GIMP_RECTANGLE_TOOL_MOVING);
+  /*
+   * kludge to force handle sizes to update.  This call may be
+   * harmful if this function is ever moved out of the text tool code.
+   */
+  gimp_rectangle_tool_set_constraint (rect_tool,
+                                      GIMP_RECTANGLE_CONSTRAIN_NONE);
 
   gimp_draw_tool_resume (GIMP_DRAW_TOOL (rect_tool));
 }



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