[gimp] app: add a "highlight" mode for the tool FG style



commit d1d89e0ddecd93994927bcc1ad32ef3e0bec4672
Author: Michael Natterer <mitch gimp org>
Date:   Thu Sep 23 19:25:22 2010 +0200

    app: add a "highlight" mode for the tool FG style
    
    such a hack, but looks better than dashed lines

 app/display/gimpcanvasitem.c         |   21 ++++++++++++++++++---
 app/display/gimpcanvasitem.h         |    3 +++
 app/display/gimpdisplayshell-style.c |    9 +++++++--
 app/display/gimpdisplayshell-style.h |    3 ++-
 4 files changed, 30 insertions(+), 6 deletions(-)
---
diff --git a/app/display/gimpcanvasitem.c b/app/display/gimpcanvasitem.c
index 08bcd71..b6aeaee 100644
--- a/app/display/gimpcanvasitem.c
+++ b/app/display/gimpcanvasitem.c
@@ -36,7 +36,7 @@ typedef struct _GimpCanvasItemPrivate GimpCanvasItemPrivate;
 
 struct _GimpCanvasItemPrivate
 {
-  gint unused;  /*  gobject doesn't like empty private structs  */
+  gboolean highlight;
 };
 
 #define GET_PRIVATE(item) \
@@ -118,6 +118,17 @@ gimp_canvas_item_get_extents (GimpCanvasItem   *item,
   return GIMP_CANVAS_ITEM_GET_CLASS (item)->get_extents (item, shell);
 }
 
+void
+gimp_canvas_item_set_highlight (GimpCanvasItem *item,
+                                gboolean        highlight)
+{
+  GimpCanvasItemPrivate *private = GET_PRIVATE (item);
+
+  g_return_if_fail (GIMP_IS_CANVAS_ITEM (item));
+
+  private->highlight = highlight ? TRUE : FALSE;
+}
+
 
 /*  protexted functions  */
 
@@ -126,10 +137,12 @@ _gimp_canvas_item_stroke (GimpCanvasItem   *item,
                           GimpDisplayShell *shell,
                           cairo_t          *cr)
 {
+  GimpCanvasItemPrivate *private = GET_PRIVATE (item);
+
   gimp_display_shell_set_tool_bg_style (shell, cr);
   cairo_stroke_preserve (cr);
 
-  gimp_display_shell_set_tool_fg_style (shell, cr);
+  gimp_display_shell_set_tool_fg_style (shell, cr, private->highlight);
   cairo_stroke (cr);
 }
 
@@ -138,10 +151,12 @@ _gimp_canvas_item_fill (GimpCanvasItem   *item,
                         GimpDisplayShell *shell,
                         cairo_t          *cr)
 {
+  GimpCanvasItemPrivate *private = GET_PRIVATE (item);
+
   gimp_display_shell_set_tool_bg_style (shell, cr);
   cairo_set_line_width (cr, 2.0);
   cairo_stroke_preserve (cr);
 
-  gimp_display_shell_set_tool_fg_style (shell, cr);
+  gimp_display_shell_set_tool_fg_style (shell, cr, private->highlight);
   cairo_fill (cr);
 }
diff --git a/app/display/gimpcanvasitem.h b/app/display/gimpcanvasitem.h
index f939ae8..7543ca4 100644
--- a/app/display/gimpcanvasitem.h
+++ b/app/display/gimpcanvasitem.h
@@ -61,6 +61,9 @@ void        gimp_canvas_item_draw         (GimpCanvasItem   *item,
 GdkRegion * gimp_canvas_item_get_extents  (GimpCanvasItem   *item,
                                            GimpDisplayShell *shell);
 
+void        gimp_canvas_item_set_highlight(GimpCanvasItem   *item,
+                                           gboolean          highlight);
+
 
 /*  protected  */
 
diff --git a/app/display/gimpdisplayshell-style.c b/app/display/gimpdisplayshell-style.c
index e0f2146..3feb98b 100644
--- a/app/display/gimpdisplayshell-style.c
+++ b/app/display/gimpdisplayshell-style.c
@@ -71,6 +71,7 @@ static const GimpRGB vectors_active_fg   = { 1.0, 0.0, 0.0, 0.8 };
 
 static const GimpRGB tool_bg             = { 1.0, 1.0, 1.0, 0.6 };
 static const GimpRGB tool_fg             = { 0.0, 0.0, 0.0, 0.8 };
+static const GimpRGB tool_fg_highlight   = { 0.0, 1.0, 1.0, 0.8 };
 
 
 /*  public functions  */
@@ -337,7 +338,8 @@ gimp_display_shell_set_tool_bg_style (GimpDisplayShell *shell,
 
 void
 gimp_display_shell_set_tool_fg_style (GimpDisplayShell *shell,
-                                      cairo_t          *cr)
+                                      cairo_t          *cr,
+                                      gboolean          highlight)
 {
   g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
   g_return_if_fail (cr != NULL);
@@ -346,5 +348,8 @@ gimp_display_shell_set_tool_fg_style (GimpDisplayShell *shell,
   cairo_set_line_cap (cr, CAIRO_LINE_CAP_SQUARE);
   cairo_set_line_join (cr, CAIRO_LINE_JOIN_ROUND);
 
-  gimp_cairo_set_source_rgba (cr, &tool_fg);
+  if (highlight)
+    gimp_cairo_set_source_rgba (cr, &tool_fg_highlight);
+  else
+    gimp_cairo_set_source_rgba (cr, &tool_fg);
 }
diff --git a/app/display/gimpdisplayshell-style.h b/app/display/gimpdisplayshell-style.h
index 592c150..a450a3c 100644
--- a/app/display/gimpdisplayshell-style.h
+++ b/app/display/gimpdisplayshell-style.h
@@ -57,7 +57,8 @@ void   gimp_display_shell_set_vectors_fg_style    (GimpDisplayShell *shell,
 void   gimp_display_shell_set_tool_bg_style       (GimpDisplayShell *shell,
                                                    cairo_t          *cr);
 void   gimp_display_shell_set_tool_fg_style       (GimpDisplayShell *shell,
-                                                   cairo_t          *cr);
+                                                   cairo_t          *cr,
+                                                   gboolean          highlight);
 
 
 #endif /* __GIMP_DISPLAY_SHELL_STYLE_H__ */



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