[gimp] app: move the wilber drawing functions to gimpcairo.c
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: move the wilber drawing functions to gimpcairo.c
- Date: Sat, 28 Aug 2010 13:30:31 +0000 (UTC)
commit 02abdff8aa558c7b263c76657c39f72ddf3974de
Author: Michael Natterer <mitch gimp org>
Date: Sat Aug 28 15:30:02 2010 +0200
app: move the wilber drawing functions to gimpcairo.c
app/display/gimpcanvas.c | 47 ----------------
app/display/gimpcanvas.h | 2 -
app/display/gimpdisplayshell-callbacks.c | 3 +-
app/widgets/gimpcairo.c | 89 ++++++++++++++++++++++++++++++
app/widgets/gimpcairo.h | 5 ++
app/widgets/gimptoolbox.c | 31 +---------
6 files changed, 99 insertions(+), 78 deletions(-)
---
diff --git a/app/display/gimpcanvas.c b/app/display/gimpcanvas.c
index f068de9..f60858f 100644
--- a/app/display/gimpcanvas.c
+++ b/app/display/gimpcanvas.c
@@ -27,7 +27,6 @@
#include "config/gimpdisplayconfig.h"
-#include "widgets/gimpcairo-wilber.h"
#include "widgets/gimpwidgets-utils.h"
#include "gimpcanvas.h"
@@ -551,52 +550,6 @@ gimp_canvas_get_layout (GimpCanvas *canvas,
return canvas->layout;
}
-void
-gimp_canvas_draw_drop_zone (GimpCanvas *canvas,
- cairo_t *cr)
-{
- GtkWidget *widget = GTK_WIDGET (canvas);
- GtkStyle *style = gtk_widget_get_style (widget);
- GtkStateType state = gtk_widget_get_state (widget);
- GtkAllocation allocation;
- gdouble wilber_width;
- gdouble wilber_height;
- gdouble width;
- gdouble height;
- gdouble side;
- gdouble factor;
-
- gtk_widget_get_allocation (widget, &allocation);
-
- gimp_cairo_wilber_get_size (cr, &wilber_width, &wilber_height);
-
- wilber_width /= 2;
- wilber_height /= 2;
-
- side = MIN (MIN (allocation.width, allocation.height),
- MAX (allocation.width, allocation.height) / 2);
-
- width = MAX (wilber_width, side);
- height = MAX (wilber_height, side);
-
- factor = MIN (width / wilber_width, height / wilber_height);
-
- cairo_scale (cr, factor, factor);
-
- /* magic factors depend on the image used, everything else is generic
- */
- gimp_cairo_wilber (cr,
- - wilber_width * 0.6,
- allocation.height / factor - wilber_height * 1.1);
-
- cairo_set_source_rgba (cr,
- style->fg[state].red / 65535.0,
- style->fg[state].green / 65535.0,
- style->fg[state].blue / 65535.0,
- 0.15);
- cairo_fill (cr);
-}
-
/**
* gimp_canvas_set_clip_rect:
* @canvas: a #GimpCanvas widget
diff --git a/app/display/gimpcanvas.h b/app/display/gimpcanvas.h
index 6373ff9..060424b 100644
--- a/app/display/gimpcanvas.h
+++ b/app/display/gimpcanvas.h
@@ -115,8 +115,6 @@ void gimp_canvas_draw_segments (GimpCanvas *canvas,
PangoLayout *gimp_canvas_get_layout (GimpCanvas *canvas,
const gchar *format,
...) G_GNUC_PRINTF (2, 3);
-void gimp_canvas_draw_drop_zone (GimpCanvas *canvas,
- cairo_t *cr);
void gimp_canvas_set_clip_rect (GimpCanvas *canvas,
GimpCanvasStyle style,
diff --git a/app/display/gimpdisplayshell-callbacks.c b/app/display/gimpdisplayshell-callbacks.c
index 483c465..9ac7573 100644
--- a/app/display/gimpdisplayshell-callbacks.c
+++ b/app/display/gimpdisplayshell-callbacks.c
@@ -48,6 +48,7 @@
#include "tools/tool_manager.h"
#include "tools/tools-enums.h"
+#include "widgets/gimpcairo.h"
#include "widgets/gimpcontrollers.h"
#include "widgets/gimpcontrollerkeyboard.h"
#include "widgets/gimpcontrollerwheel.h"
@@ -2352,5 +2353,5 @@ gimp_display_shell_canvas_expose_drop_zone (GimpDisplayShell *shell,
g_free (rects);
- gimp_canvas_draw_drop_zone (GIMP_CANVAS (shell->canvas), cr);
+ gimp_cairo_draw_drop_wilber (shell->canvas, cr);
}
diff --git a/app/widgets/gimpcairo.c b/app/widgets/gimpcairo.c
index 03f7f30..c115f74 100644
--- a/app/widgets/gimpcairo.c
+++ b/app/widgets/gimpcairo.c
@@ -31,6 +31,7 @@
#include "widgets-types.h"
#include "gimpcairo.h"
+#include "gimpcairo-wilber.h"
static cairo_user_data_key_t surface_data_key = { 0, };
@@ -110,3 +111,91 @@ gimp_cairo_add_segments (cairo_t *cr,
}
}
}
+
+void
+gimp_cairo_draw_toolbox_wilber (GtkWidget *widget,
+ cairo_t *cr)
+{
+ GtkStyle *style;
+ GtkStateType state;
+ GtkAllocation allocation;
+ gdouble wilber_width;
+ gdouble wilber_height;
+ gdouble factor;
+
+ g_return_if_fail (GTK_IS_WIDGET (widget));
+ g_return_if_fail (cr != NULL);
+
+ style = gtk_widget_get_style (widget);
+ state = gtk_widget_get_state (widget);
+
+ gtk_widget_get_allocation (widget, &allocation);
+
+ gimp_cairo_wilber_get_size (cr, &wilber_width, &wilber_height);
+
+ factor = allocation.width / wilber_width * 0.9;
+
+ cairo_scale (cr, factor, factor);
+
+ gimp_cairo_wilber (cr,
+ (allocation.width / factor - wilber_width) / 2.0,
+ (allocation.height / factor - wilber_height) / 2.0);
+
+ cairo_set_source_rgba (cr,
+ style->fg[state].red / 65535.0,
+ style->fg[state].green / 65535.0,
+ style->fg[state].blue / 65535.0,
+ 0.10);
+ cairo_fill (cr);
+}
+
+void
+gimp_cairo_draw_drop_wilber (GtkWidget *widget,
+ cairo_t *cr)
+{
+ GtkStyle *style;
+ GtkStateType state;
+ GtkAllocation allocation;
+ gdouble wilber_width;
+ gdouble wilber_height;
+ gdouble width;
+ gdouble height;
+ gdouble side;
+ gdouble factor;
+
+ g_return_if_fail (GTK_IS_WIDGET (widget));
+ g_return_if_fail (cr != NULL);
+
+ style = gtk_widget_get_style (widget);
+ state = gtk_widget_get_state (widget);
+
+ gtk_widget_get_allocation (widget, &allocation);
+
+ gimp_cairo_wilber_get_size (cr, &wilber_width, &wilber_height);
+
+ wilber_width /= 2;
+ wilber_height /= 2;
+
+ side = MIN (MIN (allocation.width, allocation.height),
+ MAX (allocation.width, allocation.height) / 2);
+
+ width = MAX (wilber_width, side);
+ height = MAX (wilber_height, side);
+
+ factor = MIN (width / wilber_width, height / wilber_height);
+
+ cairo_scale (cr, factor, factor);
+
+ /* magic factors depend on the image used, everything else is generic
+ */
+ gimp_cairo_wilber (cr,
+ - wilber_width * 0.6,
+ allocation.height / factor - wilber_height * 1.1);
+
+ cairo_set_source_rgba (cr,
+ style->fg[state].red / 65535.0,
+ style->fg[state].green / 65535.0,
+ style->fg[state].blue / 65535.0,
+ 0.15);
+ cairo_fill (cr);
+}
diff --git a/app/widgets/gimpcairo.h b/app/widgets/gimpcairo.h
index 15d907d..52cb071 100644
--- a/app/widgets/gimpcairo.h
+++ b/app/widgets/gimpcairo.h
@@ -33,5 +33,10 @@ void gimp_cairo_add_segments (cairo_t *cr,
GdkSegment *segs,
gint n_segs);
+void gimp_cairo_draw_toolbox_wilber (GtkWidget *widget,
+ cairo_t *cr);
+void gimp_cairo_draw_drop_wilber (GtkWidget *widget,
+ cairo_t *cr);
+
#endif /* __GIMP_CAIRO_H__ */
diff --git a/app/widgets/gimptoolbox.c b/app/widgets/gimptoolbox.c
index 2130af8..f107d54 100644
--- a/app/widgets/gimptoolbox.c
+++ b/app/widgets/gimptoolbox.c
@@ -37,7 +37,7 @@
#include "file/file-open.h"
#include "file/file-utils.h"
-#include "gimpcairo-wilber.h"
+#include "gimpcairo.h"
#include "gimpdevices.h"
#include "gimpdialogfactory.h"
#include "gimpdockwindow.h"
@@ -674,38 +674,13 @@ gimp_toolbox_expose_event (GtkWidget *widget,
&header_allocation,
&clip_rect))
{
- GtkStyle *style = gtk_widget_get_style (widget);
- GtkStateType state = gtk_widget_get_state (widget);
- cairo_t *cr;
- gint header_height;
- gint header_width;
- gdouble wilber_width;
- gdouble wilber_height;
- gdouble factor;
+ cairo_t *cr;
cr = gdk_cairo_create (gtk_widget_get_window (widget));
gdk_cairo_rectangle (cr, &clip_rect);
cairo_clip (cr);
- header_width = header_allocation.width;
- header_height = header_allocation.height;
-
- gimp_cairo_wilber_get_size (cr, &wilber_width, &wilber_height);
-
- factor = header_width / wilber_width * 0.9;
-
- cairo_scale (cr, factor, factor);
-
- gimp_cairo_wilber (cr,
- (header_width / factor - wilber_width) / 2.0,
- (header_height / factor - wilber_height) / 2.0);
-
- cairo_set_source_rgba (cr,
- style->fg[state].red / 65535.0,
- style->fg[state].green / 65535.0,
- style->fg[state].blue / 65535.0,
- 0.10);
- cairo_fill (cr);
+ gimp_cairo_draw_toolbox_wilber (toolbox->p->header, cr);
cairo_destroy (cr);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]