[gimp] app: add functions to set the vectors' cairo style
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: add functions to set the vectors' cairo style
- Date: Fri, 17 Sep 2010 20:51:24 +0000 (UTC)
commit cca92570184a0b1bd901776fb053601fcdad6cec
Author: Michael Natterer <mitch gimp org>
Date: Fri Sep 17 22:50:20 2010 +0200
app: add functions to set the vectors' cairo style
so all style constants are in one place. Also draw the active path in
red on white instead of black on white.
app/display/gimpdisplayshell-draw.c | 22 +++++++++++-------
app/display/gimpdisplayshell-style.c | 40 ++++++++++++++++++++++++++++++++++
app/display/gimpdisplayshell-style.h | 8 ++++++
3 files changed, 61 insertions(+), 9 deletions(-)
---
diff --git a/app/display/gimpdisplayshell-draw.c b/app/display/gimpdisplayshell-draw.c
index a968b05..9926178 100644
--- a/app/display/gimpdisplayshell-draw.c
+++ b/app/display/gimpdisplayshell-draw.c
@@ -587,7 +587,8 @@ static void
gimp_display_shell_draw_one_vectors (GimpDisplayShell *shell,
cairo_t *cr,
GimpVectors *vectors,
- gdouble width)
+ gdouble width,
+ gboolean active)
{
GimpStroke *stroke;
@@ -598,17 +599,13 @@ gimp_display_shell_draw_one_vectors (GimpDisplayShell *shell,
const GimpBezierDesc *desc = gimp_vectors_get_bezier (vectors);
if (desc)
- {
- cairo_append_path (cr, (cairo_path_t *) desc);
- }
+ cairo_append_path (cr, (cairo_path_t *) desc);
}
- cairo_set_source_rgba (cr, 1.0, 1.0, 1.0, 0.6);
- cairo_set_line_width (cr, 3 * width);
+ gimp_display_shell_set_vectors_bg_style (shell, cr, width, active);
cairo_stroke_preserve (cr);
- cairo_set_source_rgba (cr, 0.0, 0.0, 0.0, 0.8);
- cairo_set_line_width (cr, width);
+ gimp_display_shell_set_vectors_fg_style (shell, cr, width, active);
cairo_stroke (cr);
}
@@ -647,7 +644,14 @@ gimp_display_shell_draw_vectors (GimpDisplayShell *shell,
GimpVectors *vectors = list->data;
if (gimp_item_get_visible (GIMP_ITEM (vectors)))
- gimp_display_shell_draw_one_vectors (shell, cr, vectors, width);
+ {
+ gboolean active;
+
+ active = (vectors == gimp_image_get_active_vectors (image));
+
+ gimp_display_shell_draw_one_vectors (shell, cr, vectors,
+ width, active);
+ }
}
g_list_free (all_vectors);
diff --git a/app/display/gimpdisplayshell-style.c b/app/display/gimpdisplayshell-style.c
index bed3678..4da0baf 100644
--- a/app/display/gimpdisplayshell-style.c
+++ b/app/display/gimpdisplayshell-style.c
@@ -63,6 +63,12 @@ static const GimpRGB selection_out_bg = { 0.5, 0.5, 0.5, 1.0 };
static const GimpRGB selection_in_fg = { 0.0, 0.0, 0.0, 1.0 };
static const GimpRGB selection_in_bg = { 1.0, 1.0, 1.0, 1.0 };
+static const GimpRGB vectors_normal_bg = { 1.0, 1.0, 1.0, 0.6 };
+static const GimpRGB vectors_normal_fg = { 0.0, 0.0, 0.0, 0.8 };
+
+static const GimpRGB vectors_active_bg = { 1.0, 1.0, 1.0, 0.6 };
+static const GimpRGB vectors_active_fg = { 1.0, 0.0, 0.0, 0.8 };
+
/* public functions */
@@ -275,3 +281,37 @@ gimp_display_shell_set_selection_in_style (GimpDisplayShell *shell,
cairo_set_source (cr, pattern);
cairo_pattern_destroy (pattern);
}
+
+void
+gimp_display_shell_set_vectors_bg_style (GimpDisplayShell *shell,
+ cairo_t *cr,
+ gdouble width,
+ gboolean active)
+{
+ g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
+ g_return_if_fail (cr != NULL);
+
+ cairo_set_line_width (cr, width * 3.0);
+
+ if (active)
+ gimp_cairo_set_source_rgba (cr, &vectors_active_bg);
+ else
+ gimp_cairo_set_source_rgba (cr, &vectors_normal_bg);
+}
+
+void
+gimp_display_shell_set_vectors_fg_style (GimpDisplayShell *shell,
+ cairo_t *cr,
+ gdouble width,
+ gboolean active)
+{
+ g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
+ g_return_if_fail (cr != NULL);
+
+ cairo_set_line_width (cr, width);
+
+ if (active)
+ gimp_cairo_set_source_rgba (cr, &vectors_active_fg);
+ else
+ gimp_cairo_set_source_rgba (cr, &vectors_normal_fg);
+}
diff --git a/app/display/gimpdisplayshell-style.h b/app/display/gimpdisplayshell-style.h
index 8be7eea..8fad2af 100644
--- a/app/display/gimpdisplayshell-style.h
+++ b/app/display/gimpdisplayshell-style.h
@@ -46,6 +46,14 @@ void gimp_display_shell_set_selection_out_style (GimpDisplayShell *shell,
void gimp_display_shell_set_selection_in_style (GimpDisplayShell *shell,
cairo_t *cr,
gint index);
+void gimp_display_shell_set_vectors_bg_style (GimpDisplayShell *shell,
+ cairo_t *cr,
+ gdouble width,
+ gboolean active);
+void gimp_display_shell_set_vectors_fg_style (GimpDisplayShell *shell,
+ cairo_t *cr,
+ gdouble width,
+ gboolean active);
#endif /* __GIMP_DISPLAY_SHELL_STYLE_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]