diff --git a/app/tools/gimpblendtool.c b/app/tools/gimpblendtool.c index 3b89ae56c0..07924dc798 100644 --- a/app/tools/gimpblendtool.c +++ b/app/tools/gimpblendtool.c @@ -56,6 +56,7 @@ #include "gimp-intl.h" +#define SHOW_LINE TRUE #define HANDLE_CROSS_DIAMETER 18 #define HANDLE_DIAMETER 40 @@ -109,6 +110,8 @@ 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); @@ -290,12 +293,11 @@ 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_draw_tool_resume (draw_tool); + + gimp_blend_tool_update_item_hilight (blend_tool); } static void @@ -307,7 +309,6 @@ 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; @@ -318,13 +319,11 @@ 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 (draw_tool)) + if (gimp_draw_tool_is_active (GIMP_DRAW_TOOL (blend_tool))) { gimp_tool_control (tool, GIMP_TOOL_ACTION_COMMIT, display); gimp_tool_control (tool, GIMP_TOOL_ACTION_HALT, display); @@ -347,8 +346,7 @@ gimp_blend_tool_button_press (GimpTool *tool, state & gimp_get_constrain_behavior_mask ()); tool->display = display; - - gimp_draw_tool_resume (draw_tool); + gimp_blend_tool_update_items (blend_tool); if (blend_tool->grabbed_point != POINT_FILL_MODE && blend_tool->grabbed_point != POINT_INIT_MODE) @@ -403,15 +401,10 @@ gimp_blend_tool_motion (GimpTool *tool, GimpDisplay *display) { GimpBlendTool *blend_tool = GIMP_BLEND_TOOL (tool); - GimpDrawTool *draw_tool = GIMP_DRAW_TOOL (tool); - gdouble last_x; - gdouble last_y; - - gimp_draw_tool_pause (draw_tool); /* Save the mouse coordinates from last call */ - last_x = blend_tool->mouse_x; - last_y = blend_tool->mouse_y; + gdouble last_x = blend_tool->mouse_x; + gdouble last_y = blend_tool->mouse_y; blend_tool->mouse_x = coords->x; blend_tool->mouse_y = coords->y; @@ -443,7 +436,7 @@ gimp_blend_tool_motion (GimpTool *tool, gimp_tool_pop_status (tool, display); gimp_blend_tool_push_status (blend_tool, state, display); - gimp_draw_tool_resume (draw_tool); + gimp_blend_tool_update_items (blend_tool); gimp_blend_tool_update_preview_coords (blend_tool); gimp_image_map_apply (blend_tool->image_map, NULL); @@ -520,17 +513,16 @@ 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); } @@ -578,18 +570,27 @@ gimp_blend_tool_cursor_update (GimpTool *tool, static void gimp_blend_tool_draw (GimpDrawTool *draw_tool) { - GimpBlendTool *blend_tool = GIMP_BLEND_TOOL (draw_tool); - GimpCanvasItem *start_handle_cross, *end_handle_cross; - GimpBlendToolPoint hilight_point; - gboolean start_visible, end_visible; + GimpBlendTool *blend_tool = GIMP_BLEND_TOOL (draw_tool); - 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->line = + gimp_draw_tool_add_line (draw_tool, + blend_tool->start_x, + blend_tool->start_y, + blend_tool->end_x, + blend_tool->end_y); - start_handle_cross = + gimp_canvas_item_set_visible (blend_tool->line, SHOW_LINE); + + 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 = gimp_draw_tool_add_handle (draw_tool, GIMP_HANDLE_CROSS, blend_tool->start_x, @@ -598,7 +599,16 @@ gimp_blend_tool_draw (GimpDrawTool *draw_tool) HANDLE_CROSS_DIAMETER, GIMP_HANDLE_ANCHOR_CENTER); - end_handle_cross = + 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 = gimp_draw_tool_add_handle (draw_tool, GIMP_HANDLE_CROSS, blend_tool->end_x, @@ -607,78 +617,98 @@ gimp_blend_tool_draw (GimpDrawTool *draw_tool) HANDLE_CROSS_DIAMETER, GIMP_HANDLE_ANCHOR_CENTER); - /* Calculate handle visibility */ - if (blend_tool->grabbed_point) + gimp_blend_tool_update_item_hilight (blend_tool); +} + +static void +gimp_blend_tool_update_items (GimpBlendTool *blend_tool) +{ + if (gimp_draw_tool_is_active (GIMP_DRAW_TOOL (blend_tool))) { - start_visible = FALSE; - end_visible = FALSE; + 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); } - else +} + +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)) { - 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); + GimpBlendToolPoint hilight_point; + gboolean start_visible, end_visible; - start_visible = dist < FULL_HANDLE_THRESHOLD_SQ; + /* 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); - 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); + start_visible = dist < FULL_HANDLE_THRESHOLD_SQ; - end_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); - /* 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); + end_visible = dist < FULL_HANDLE_THRESHOLD_SQ; + } - if (start_visible) - { - GimpCanvasItem *start_handle_circle; + gimp_canvas_item_set_visible (blend_tool->start_handle_circle, + start_visible); + gimp_canvas_item_set_visible (blend_tool->end_handle_circle, + end_visible); - 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); + /* 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 (start_handle_circle, + gimp_canvas_item_set_highlight (blend_tool->start_handle_circle, + hilight_point == POINT_START); + gimp_canvas_item_set_highlight (blend_tool->start_handle_cross, hilight_point == POINT_START); - } - 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, + gimp_canvas_item_set_highlight (blend_tool->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); + gimp_canvas_item_set_highlight (blend_tool->end_handle_cross, + hilight_point == POINT_END); + } } static GimpBlendToolPoint diff --git a/app/tools/gimpblendtool.h b/app/tools/gimpblendtool.h index 0105aead7c..0362b0b51b 100644 --- a/app/tools/gimpblendtool.h +++ b/app/tools/gimpblendtool.h @@ -60,6 +60,12 @@ 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;