transformtool: Make real_pick_function and real_draw_gui implementations of vfuncs

This commit is contained in:
Mikael Magnusson 2012-08-21 20:06:00 +02:00
parent b1acd93f5e
commit 8dfc72dca9
1 changed files with 239 additions and 222 deletions

View File

@ -131,6 +131,14 @@ static GeglBuffer *
gint orig_offset_y,
gint *new_offset_x,
gint *new_offset_y);
static void gimp_transform_tool_real_draw_gui (GimpTransformTool *tr_tool,
gint handle_w,
gint handle_h);
static TransformAction
gimp_transform_tool_real_pick_function (GimpTransformTool *tr_tool,
const GimpCoords *coords,
GdkModifierType state,
GimpDisplay *display);
static void gimp_transform_tool_set_function (GimpTransformTool *tr_tool,
TransformAction function);
@ -190,6 +198,8 @@ gimp_transform_tool_class_init (GimpTransformToolClass *klass)
klass->recalc_matrix = NULL;
klass->get_undo_desc = NULL;
klass->transform = gimp_transform_tool_real_transform;
klass->pick_function = gimp_transform_tool_real_pick_function;
klass->draw_gui = gimp_transform_tool_real_draw_gui;
}
static void
@ -531,29 +541,15 @@ gimp_transform_tool_modifier_key (GimpTool *tool,
}
}
static void
gimp_transform_tool_oper_update (GimpTool *tool,
static TransformAction
gimp_transform_tool_real_pick_function (GimpTransformTool *tr_tool,
const GimpCoords *coords,
GdkModifierType state,
gboolean proximity,
GimpDisplay *display)
{
GimpTransformTool *tr_tool = GIMP_TRANSFORM_TOOL (tool);
GimpDrawTool *draw_tool = GIMP_DRAW_TOOL (tool);
GimpDrawTool *draw_tool = GIMP_DRAW_TOOL (tr_tool);
TransformAction function = TRANSFORM_HANDLE_NONE;
if (display != tool->display || draw_tool->item == NULL)
{
gimp_transform_tool_set_function (tr_tool, function);
return;
}
if (GIMP_TRANSFORM_TOOL_GET_CLASS (tr_tool)->pick_function)
{
function = GIMP_TRANSFORM_TOOL_GET_CLASS (tr_tool)->pick_function (tr_tool, coords, state, display);
}
else
{
if (tr_tool->use_handles)
{
gdouble closest_dist;
@ -632,8 +628,29 @@ gimp_transform_tool_oper_update (GimpTool *tool,
{
function = TRANSFORM_HANDLE_CENTER;
}
return function;
}
static void
gimp_transform_tool_oper_update (GimpTool *tool,
const GimpCoords *coords,
GdkModifierType state,
gboolean proximity,
GimpDisplay *display)
{
GimpTransformTool *tr_tool = GIMP_TRANSFORM_TOOL (tool);
GimpDrawTool *draw_tool = GIMP_DRAW_TOOL (tool);
TransformAction function = TRANSFORM_HANDLE_NONE;
if (display != tool->display || draw_tool->item == NULL)
{
gimp_transform_tool_set_function (tr_tool, function);
return;
}
function = GIMP_TRANSFORM_TOOL_GET_CLASS (tr_tool)->pick_function (tr_tool, coords, state, display);
gimp_transform_tool_set_function (tr_tool, function);
}
@ -779,59 +796,9 @@ gimp_transform_tool_options_notify (GimpTool *tool,
}
static void
gimp_transform_tool_draw (GimpDrawTool *draw_tool)
{
GimpTool *tool = GIMP_TOOL (draw_tool);
GimpTransformTool *tr_tool = GIMP_TRANSFORM_TOOL (draw_tool);
GimpTransformOptions *options = GIMP_TRANSFORM_TOOL_GET_OPTIONS (tool);
GimpImage *image = gimp_display_get_image (tool->display);
gint handle_w;
gint handle_h;
gint i;
for (i = 0; i < G_N_ELEMENTS (tr_tool->handles); i++)
tr_tool->handles[i] = NULL;
if (tr_tool->use_grid)
{
if (gimp_transform_options_show_preview (options))
{
GimpMatrix3 matrix = tr_tool->transform;
if (options->direction == GIMP_TRANSFORM_BACKWARD)
gimp_matrix3_invert (&matrix);
gimp_draw_tool_add_transform_preview (draw_tool,
tool->drawable,
&matrix,
tr_tool->x1,
tr_tool->y1,
tr_tool->x2,
tr_tool->y2,
GIMP_IS_PERSPECTIVE_TOOL (tr_tool) ||
GIMP_IS_UNIFIED_TRANSFORM_TOOL (tr_tool),
options->preview_opacity);
}
gimp_draw_tool_add_transform_guides (draw_tool,
&tr_tool->transform,
options->grid_type,
options->grid_size,
tr_tool->x1,
tr_tool->y1,
tr_tool->x2,
tr_tool->y2);
}
gimp_transform_tool_handles_recalc (tr_tool, tool->display,
&handle_w, &handle_h);
if (GIMP_TRANSFORM_TOOL_GET_CLASS (tr_tool)->draw_gui)
{
GIMP_TRANSFORM_TOOL_GET_CLASS (tr_tool)->draw_gui (tr_tool, handle_w, handle_h);
}
else
gimp_transform_tool_real_draw_gui (GimpTransformTool *tr_tool, gint handle_w, gint handle_h)
{
GimpDrawTool *draw_tool = GIMP_DRAW_TOOL (tr_tool);
if (tr_tool->use_handles)
{
@ -962,6 +929,56 @@ gimp_transform_tool_draw (GimpDrawTool *draw_tool)
}
}
static void
gimp_transform_tool_draw (GimpDrawTool *draw_tool)
{
GimpTool *tool = GIMP_TOOL (draw_tool);
GimpTransformTool *tr_tool = GIMP_TRANSFORM_TOOL (draw_tool);
GimpTransformOptions *options = GIMP_TRANSFORM_TOOL_GET_OPTIONS (tool);
GimpImage *image = gimp_display_get_image (tool->display);
gint handle_w;
gint handle_h;
gint i;
for (i = 0; i < G_N_ELEMENTS (tr_tool->handles); i++)
tr_tool->handles[i] = NULL;
if (tr_tool->use_grid)
{
if (gimp_transform_options_show_preview (options))
{
GimpMatrix3 matrix = tr_tool->transform;
if (options->direction == GIMP_TRANSFORM_BACKWARD)
gimp_matrix3_invert (&matrix);
gimp_draw_tool_add_transform_preview (draw_tool,
tool->drawable,
&matrix,
tr_tool->x1,
tr_tool->y1,
tr_tool->x2,
tr_tool->y2,
GIMP_IS_PERSPECTIVE_TOOL (tr_tool) ||
GIMP_IS_UNIFIED_TRANSFORM_TOOL (tr_tool),
options->preview_opacity);
}
gimp_draw_tool_add_transform_guides (draw_tool,
&tr_tool->transform,
options->grid_type,
options->grid_size,
tr_tool->x1,
tr_tool->y1,
tr_tool->x2,
tr_tool->y2);
}
gimp_transform_tool_handles_recalc (tr_tool, tool->display,
&handle_w, &handle_h);
GIMP_TRANSFORM_TOOL_GET_CLASS (tr_tool)->draw_gui (tr_tool, handle_w, handle_h);
if (tr_tool->handles[tr_tool->function])
{
gimp_canvas_item_set_highlight (tr_tool->handles[tr_tool->function],