[gimp] app: Refactor GimpBlendTool to not use update methods.
- From: Michael Henning <mhenning src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: Refactor GimpBlendTool to not use update methods.
- Date: Mon, 8 Sep 2014 21:09:40 +0000 (UTC)
commit 8a2a9775b97a5423d0a000a1054462328efda5ab
Author: Michael Henning <drawoc darkrefraction com>
Date: Sat Sep 6 23:21:02 2014 -0400
app: Refactor GimpBlendTool to not use update methods.
Simply call draw_tool_pause/resume instead.
app/tools/gimpblendtool.c | 213 +++++++++++++++++++--------------------------
app/tools/gimpblendtool.h | 6 --
2 files changed, 91 insertions(+), 128 deletions(-)
---
diff --git a/app/tools/gimpblendtool.c b/app/tools/gimpblendtool.c
index 07924dc..fb54c3a 100644
--- a/app/tools/gimpblendtool.c
+++ b/app/tools/gimpblendtool.c
@@ -56,7 +56,6 @@
#include "gimp-intl.h"
-#define SHOW_LINE TRUE
#define HANDLE_CROSS_DIAMETER 18
#define HANDLE_DIAMETER 40
@@ -110,8 +109,6 @@ static void gimp_blend_tool_cursor_update (GimpTool *tool,
GimpDisplay *display);
static void gimp_blend_tool_draw (GimpDrawTool *draw_tool);
-static void gimp_blend_tool_update_items (GimpBlendTool *blend_tool);
-static void gimp_blend_tool_update_item_hilight (GimpBlendTool *blend_tool);
static GimpBlendToolPoint gimp_blend_tool_get_point_under_cursor (GimpBlendTool *blend_tool);
@@ -293,11 +290,12 @@ gimp_blend_tool_oper_update (GimpTool *tool,
GimpDisplay *display)
{
GimpBlendTool *blend_tool = GIMP_BLEND_TOOL (tool);
+ GimpDrawTool *draw_tool = GIMP_DRAW_TOOL (tool);
+ gimp_draw_tool_pause (draw_tool);
blend_tool->mouse_x = coords->x;
blend_tool->mouse_y = coords->y;
-
- gimp_blend_tool_update_item_hilight (blend_tool);
+ gimp_draw_tool_resume (draw_tool);
}
static void
@@ -309,6 +307,7 @@ gimp_blend_tool_button_press (GimpTool *tool,
GimpDisplay *display)
{
GimpBlendTool *blend_tool = GIMP_BLEND_TOOL (tool);
+ GimpDrawTool *draw_tool = GIMP_DRAW_TOOL (tool);
blend_tool->mouse_x = coords->x;
blend_tool->mouse_y = coords->y;
@@ -319,11 +318,13 @@ gimp_blend_tool_button_press (GimpTool *tool,
gimp_blend_tool_halt_preview (blend_tool);
}
+ gimp_draw_tool_pause (draw_tool);
+
blend_tool->grabbed_point = gimp_blend_tool_get_point_under_cursor (blend_tool);
if (blend_tool->grabbed_point == POINT_NONE)
{
- if (gimp_draw_tool_is_active (GIMP_DRAW_TOOL (blend_tool)))
+ if (gimp_draw_tool_is_active (draw_tool))
{
gimp_tool_control (tool, GIMP_TOOL_ACTION_COMMIT, display);
gimp_tool_control (tool, GIMP_TOOL_ACTION_HALT, display);
@@ -346,7 +347,8 @@ gimp_blend_tool_button_press (GimpTool *tool,
state & gimp_get_constrain_behavior_mask ());
tool->display = display;
- gimp_blend_tool_update_items (blend_tool);
+
+ gimp_draw_tool_resume (draw_tool);
if (blend_tool->grabbed_point != POINT_FILL_MODE &&
blend_tool->grabbed_point != POINT_INIT_MODE)
@@ -401,6 +403,9 @@ gimp_blend_tool_motion (GimpTool *tool,
GimpDisplay *display)
{
GimpBlendTool *blend_tool = GIMP_BLEND_TOOL (tool);
+ GimpDrawTool *draw_tool = GIMP_DRAW_TOOL (tool);
+
+ gimp_draw_tool_pause (draw_tool);
/* Save the mouse coordinates from last call */
gdouble last_x = blend_tool->mouse_x;
@@ -436,7 +441,7 @@ gimp_blend_tool_motion (GimpTool *tool,
gimp_tool_pop_status (tool, display);
gimp_blend_tool_push_status (blend_tool, state, display);
- gimp_blend_tool_update_items (blend_tool);
+ gimp_draw_tool_resume (draw_tool);
gimp_blend_tool_update_preview_coords (blend_tool);
gimp_image_map_apply (blend_tool->image_map, NULL);
@@ -513,16 +518,17 @@ gimp_blend_tool_active_modifier_key (GimpTool *tool,
GimpDisplay *display)
{
GimpBlendTool *blend_tool = GIMP_BLEND_TOOL (tool);
+ GimpDrawTool *draw_tool = GIMP_DRAW_TOOL (tool);
if (key == gimp_get_constrain_behavior_mask ())
{
+ gimp_draw_tool_pause (draw_tool);
gimp_blend_tool_point_motion (blend_tool, press);
+ gimp_draw_tool_resume (draw_tool);
gimp_tool_pop_status (tool, display);
gimp_blend_tool_push_status (blend_tool, state, display);
- gimp_blend_tool_update_items (blend_tool);
-
gimp_blend_tool_update_preview_coords (blend_tool);
gimp_image_map_apply (blend_tool->image_map, NULL);
}
@@ -570,27 +576,16 @@ gimp_blend_tool_cursor_update (GimpTool *tool,
static void
gimp_blend_tool_draw (GimpDrawTool *draw_tool)
{
- GimpBlendTool *blend_tool = GIMP_BLEND_TOOL (draw_tool);
-
- blend_tool->line =
- gimp_draw_tool_add_line (draw_tool,
- blend_tool->start_x,
- blend_tool->start_y,
- blend_tool->end_x,
- blend_tool->end_y);
+ GimpBlendTool *blend_tool = GIMP_BLEND_TOOL (draw_tool);
+ GimpCanvasItem *start_handle_cross, *end_handle_cross;
- gimp_canvas_item_set_visible (blend_tool->line, SHOW_LINE);
+ gimp_draw_tool_add_line (draw_tool,
+ blend_tool->start_x,
+ blend_tool->start_y,
+ blend_tool->end_x,
+ blend_tool->end_y);
- blend_tool->start_handle_circle =
- gimp_draw_tool_add_handle (draw_tool,
- GIMP_HANDLE_CIRCLE,
- blend_tool->start_x,
- blend_tool->start_y,
- HANDLE_DIAMETER,
- HANDLE_DIAMETER,
- GIMP_HANDLE_ANCHOR_CENTER);
-
- blend_tool->start_handle_cross =
+ start_handle_cross =
gimp_draw_tool_add_handle (draw_tool,
GIMP_HANDLE_CROSS,
blend_tool->start_x,
@@ -599,16 +594,7 @@ gimp_blend_tool_draw (GimpDrawTool *draw_tool)
HANDLE_CROSS_DIAMETER,
GIMP_HANDLE_ANCHOR_CENTER);
- blend_tool->end_handle_circle =
- gimp_draw_tool_add_handle (draw_tool,
- GIMP_HANDLE_CIRCLE,
- blend_tool->end_x,
- blend_tool->end_y,
- HANDLE_DIAMETER,
- HANDLE_DIAMETER,
- GIMP_HANDLE_ANCHOR_CENTER);
-
- blend_tool->end_handle_cross =
+ end_handle_cross =
gimp_draw_tool_add_handle (draw_tool,
GIMP_HANDLE_CROSS,
blend_tool->end_x,
@@ -617,98 +603,81 @@ gimp_blend_tool_draw (GimpDrawTool *draw_tool)
HANDLE_CROSS_DIAMETER,
GIMP_HANDLE_ANCHOR_CENTER);
- gimp_blend_tool_update_item_hilight (blend_tool);
-}
+ GimpBlendToolPoint hilight_point;
+ gboolean start_visible, end_visible;
-static void
-gimp_blend_tool_update_items (GimpBlendTool *blend_tool)
-{
- if (gimp_draw_tool_is_active (GIMP_DRAW_TOOL (blend_tool)))
+ /* Calculate handle visibility */
+ if (blend_tool->grabbed_point)
{
- gimp_canvas_line_set (blend_tool->line,
- blend_tool->start_x,
- blend_tool->start_y,
- blend_tool->end_x,
- blend_tool->end_y);
-
- gimp_canvas_handle_set_position (blend_tool->start_handle_circle,
- blend_tool->start_x,
- blend_tool->start_y);
-
- gimp_canvas_handle_set_position (blend_tool->start_handle_cross,
- blend_tool->start_x,
- blend_tool->start_y);
-
- gimp_canvas_handle_set_position (blend_tool->end_handle_circle,
- blend_tool->end_x,
- blend_tool->end_y);
-
- gimp_canvas_handle_set_position (blend_tool->end_handle_cross,
- blend_tool->end_x,
- blend_tool->end_y);
-
- gimp_blend_tool_update_item_hilight (blend_tool);
+ start_visible = FALSE;
+ end_visible = FALSE;
}
-}
-
-static void
-gimp_blend_tool_update_item_hilight (GimpBlendTool *blend_tool)
-{
- GimpDrawTool *draw_tool = GIMP_DRAW_TOOL (blend_tool);
- if (gimp_draw_tool_is_active (draw_tool))
+ else
{
- GimpBlendToolPoint hilight_point;
- gboolean start_visible, end_visible;
-
- /* Calculate handle visibility */
- if (blend_tool->grabbed_point)
- {
- start_visible = FALSE;
- end_visible = FALSE;
- }
- else
- {
- gdouble dist;
- dist = gimp_draw_tool_calc_distance_square (draw_tool,
- draw_tool->display,
- blend_tool->mouse_x,
- blend_tool->mouse_y,
- blend_tool->start_x,
- blend_tool->start_y);
-
- start_visible = dist < FULL_HANDLE_THRESHOLD_SQ;
-
- dist = gimp_draw_tool_calc_distance_square (draw_tool,
- draw_tool->display,
- blend_tool->mouse_x,
- blend_tool->mouse_y,
- blend_tool->end_x,
- blend_tool->end_y);
-
- end_visible = dist < FULL_HANDLE_THRESHOLD_SQ;
- }
-
- gimp_canvas_item_set_visible (blend_tool->start_handle_circle,
- start_visible);
- gimp_canvas_item_set_visible (blend_tool->end_handle_circle,
- end_visible);
+ gdouble dist;
+ dist = gimp_draw_tool_calc_distance_square (draw_tool,
+ draw_tool->display,
+ blend_tool->mouse_x,
+ blend_tool->mouse_y,
+ blend_tool->start_x,
+ blend_tool->start_y);
+
+ start_visible = dist < FULL_HANDLE_THRESHOLD_SQ;
+
+ dist = gimp_draw_tool_calc_distance_square (draw_tool,
+ draw_tool->display,
+ blend_tool->mouse_x,
+ blend_tool->mouse_y,
+ blend_tool->end_x,
+ blend_tool->end_y);
+
+ end_visible = dist < FULL_HANDLE_THRESHOLD_SQ;
+ }
- /* Update hilights */
- if (blend_tool->grabbed_point)
- hilight_point = blend_tool->grabbed_point;
- else
- hilight_point = gimp_blend_tool_get_point_under_cursor (blend_tool);
+ /* Update hilights */
+ if (blend_tool->grabbed_point)
+ hilight_point = blend_tool->grabbed_point;
+ else
+ hilight_point = gimp_blend_tool_get_point_under_cursor (blend_tool);
- gimp_canvas_item_set_highlight (blend_tool->start_handle_circle,
- hilight_point == POINT_START);
- gimp_canvas_item_set_highlight (blend_tool->start_handle_cross,
+ if (start_visible)
+ {
+ GimpCanvasItem *start_handle_circle;
+
+ start_handle_circle =
+ gimp_draw_tool_add_handle (draw_tool,
+ GIMP_HANDLE_CIRCLE,
+ blend_tool->start_x,
+ blend_tool->start_y,
+ HANDLE_DIAMETER,
+ HANDLE_DIAMETER,
+ GIMP_HANDLE_ANCHOR_CENTER);
+
+ gimp_canvas_item_set_highlight (start_handle_circle,
hilight_point == POINT_START);
+ }
- gimp_canvas_item_set_highlight (blend_tool->end_handle_circle,
- hilight_point == POINT_END);
- gimp_canvas_item_set_highlight (blend_tool->end_handle_cross,
+ if (end_visible)
+ {
+ GimpCanvasItem *end_handle_circle;
+
+ end_handle_circle =
+ gimp_draw_tool_add_handle (draw_tool,
+ GIMP_HANDLE_CIRCLE,
+ blend_tool->end_x,
+ blend_tool->end_y,
+ HANDLE_DIAMETER,
+ HANDLE_DIAMETER,
+ GIMP_HANDLE_ANCHOR_CENTER);
+
+ gimp_canvas_item_set_highlight (end_handle_circle,
hilight_point == POINT_END);
- }
+ }
+
+ gimp_canvas_item_set_highlight (start_handle_cross,
+ hilight_point == POINT_START);
+ gimp_canvas_item_set_highlight (end_handle_cross,
+ hilight_point == POINT_END);
}
static GimpBlendToolPoint
diff --git a/app/tools/gimpblendtool.h b/app/tools/gimpblendtool.h
index 0362b0b..0105aea 100644
--- a/app/tools/gimpblendtool.h
+++ b/app/tools/gimpblendtool.h
@@ -60,12 +60,6 @@ struct _GimpBlendTool
gdouble mouse_x; /* pointer x coord */
gdouble mouse_y; /* pointer y coord */
- GimpCanvasItem *line;
- GimpCanvasItem *start_handle_circle;
- GimpCanvasItem *start_handle_cross;
- GimpCanvasItem *end_handle_circle;
- GimpCanvasItem *end_handle_cross;
-
GeglNode *graph;
GeglNode *render_node;
GimpImageMap *image_map;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]