Commit d96091d5 authored by Michael Natterer's avatar Michael Natterer 😴

app: port GimpMagnifyTool away from draw_tool_pause()/resume()

parent accc12a3
......@@ -340,3 +340,24 @@ gimp_canvas_rectangle_new (GimpDisplayShell *shell,
"filled", filled,
NULL);
}
void
gimp_canvas_rectangle_set (GimpCanvasItem *rectangle,
gdouble x,
gdouble y,
gdouble width,
gdouble height)
{
g_return_if_fail (GIMP_IS_CANVAS_RECTANGLE (rectangle));
gimp_canvas_item_begin_change (rectangle);
g_object_set (rectangle,
"x", x,
"y", y,
"width", width,
"height", height,
NULL);
gimp_canvas_item_end_change (rectangle);
}
......@@ -56,5 +56,11 @@ GimpCanvasItem * gimp_canvas_rectangle_new (GimpDisplayShell *shell,
gdouble height,
gboolean filled);
void gimp_canvas_rectangle_set (GimpCanvasItem *rectangle,
gdouble x,
gdouble y,
gdouble width,
gdouble height);
#endif /* __GIMP_CANVAS_RECTANGLE_H__ */
......@@ -29,6 +29,7 @@
#include "widgets/gimphelp-ids.h"
#include "display/gimpcanvasrectangle.h"
#include "display/gimpdisplay.h"
#include "display/gimpdisplayshell.h"
#include "display/gimpdisplayshell-scale.h"
......@@ -69,6 +70,8 @@ static void gimp_magnify_tool_cursor_update (GimpTool *tool,
static void gimp_magnify_tool_draw (GimpDrawTool *draw_tool);
static void gimp_magnify_tool_update_items (GimpMagnifyTool *magnify);
G_DEFINE_TYPE (GimpMagnifyTool, gimp_magnify_tool, GIMP_TYPE_DRAW_TOOL)
......@@ -308,12 +311,10 @@ gimp_magnify_tool_motion (GimpTool *tool,
{
GimpMagnifyTool *magnify = GIMP_MAGNIFY_TOOL (tool);
gimp_draw_tool_pause (GIMP_DRAW_TOOL (tool));
magnify->w = coords->x - magnify->x;
magnify->h = coords->y - magnify->y;
gimp_draw_tool_resume (GIMP_DRAW_TOOL (tool));
gimp_magnify_tool_update_items (magnify);
}
static void
......@@ -362,9 +363,23 @@ gimp_magnify_tool_draw (GimpDrawTool *draw_tool)
{
GimpMagnifyTool *magnify = GIMP_MAGNIFY_TOOL (draw_tool);
gimp_draw_tool_add_rectangle (draw_tool, FALSE,
magnify->x,
magnify->y,
magnify->w,
magnify->h);
magnify->rectangle =
gimp_draw_tool_add_rectangle (draw_tool, FALSE,
magnify->x,
magnify->y,
magnify->w,
magnify->h);
}
static void
gimp_magnify_tool_update_items (GimpMagnifyTool *magnify)
{
if (gimp_draw_tool_is_active (GIMP_DRAW_TOOL (magnify)))
{
gimp_canvas_rectangle_set (magnify->rectangle,
magnify->x,
magnify->y,
magnify->w,
magnify->h);
}
}
......@@ -37,10 +37,12 @@ typedef struct _GimpMagnifyToolClass GimpMagnifyToolClass;
struct _GimpMagnifyTool
{
GimpDrawTool parent_instance;
GimpDrawTool parent_instance;
gdouble x, y; /* upper left hand coordinate */
gdouble w, h; /* width and height */
gdouble x, y; /* upper left hand coordinate */
gdouble w, h; /* width and height */
GimpCanvasItem *rectangle;
};
struct _GimpMagnifyToolClass
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment