[gimp/soc-2012-unified-transformation: 11/21] transformtool: Enable hit detection for new handles
- From: Mikael Magnusson <mikachu src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/soc-2012-unified-transformation: 11/21] transformtool: Enable hit detection for new handles
- Date: Sat, 16 Jun 2012 12:40:38 +0000 (UTC)
commit f96de2af03226ffd0c8c30db1b8a546d4d6a519a
Author: Mikael Magnusson <mikachu src gnome org>
Date: Thu Jun 14 04:29:37 2012 +0200
transformtool: Enable hit detection for new handles
app/tools/gimptransformtool.c | 2 +-
app/tools/gimpunifiedtransformationtool.c | 60 ++++++++++++++++++++++++++++-
2 files changed, 60 insertions(+), 2 deletions(-)
---
diff --git a/app/tools/gimptransformtool.c b/app/tools/gimptransformtool.c
index 7bf7d1e..94fc800 100644
--- a/app/tools/gimptransformtool.c
+++ b/app/tools/gimptransformtool.c
@@ -341,7 +341,7 @@ gimp_transform_tool_button_press (GimpTool *tool,
GimpTransformTool *tr_tool = GIMP_TRANSFORM_TOOL (tool);
if (tr_tool->function == TRANSFORM_CREATING)
- gimp_transform_tool_oper_update (tool, coords, state, TRUE, display);
+ GIMP_TOOL_CLASS (G_OBJECT_GET_CLASS (tool))->oper_update (tool, coords, state, TRUE, display);
tr_tool->lastx = tr_tool->mousex = coords->x;
tr_tool->lasty = tr_tool->mousey = coords->y;
diff --git a/app/tools/gimpunifiedtransformationtool.c b/app/tools/gimpunifiedtransformationtool.c
index c93a0b8..97a79a9 100644
--- a/app/tools/gimpunifiedtransformationtool.c
+++ b/app/tools/gimpunifiedtransformationtool.c
@@ -70,6 +70,11 @@ enum
/* local function prototypes */
+static void gimp_transform_tool_oper_update (GimpTool *tool,
+ const GimpCoords *coords,
+ GdkModifierType state,
+ gboolean proximity,
+ GimpDisplay *display);
static void gimp_unified_transformation_tool_draw (GimpDrawTool *draw_tool);
static void gimp_unified_transformation_tool_dialog (GimpTransformTool *tr_tool);
static void gimp_unified_transformation_tool_dialog_update (GimpTransformTool *tr_tool);
@@ -105,7 +110,8 @@ static void
gimp_unified_transformation_tool_class_init (GimpUnifiedTransformationToolClass *klass)
{
GimpTransformToolClass *trans_class = GIMP_TRANSFORM_TOOL_CLASS (klass);
- GimpDrawToolClass *draw_class = GIMP_DRAW_TOOL_CLASS (klass);
+ GimpToolClass *tool_class = GIMP_TOOL_CLASS (klass);
+ GimpDrawToolClass *draw_class = GIMP_DRAW_TOOL_CLASS (klass);
trans_class->dialog = gimp_unified_transformation_tool_dialog;
trans_class->dialog_update = gimp_unified_transformation_tool_dialog_update;
@@ -114,6 +120,8 @@ gimp_unified_transformation_tool_class_init (GimpUnifiedTransformationToolClass
trans_class->recalc_matrix = gimp_unified_transformation_tool_recalc_matrix;
trans_class->get_undo_desc = gimp_unified_transformation_tool_get_undo_desc;
+ tool_class->oper_update = gimp_transform_tool_oper_update;
+
draw_class->draw = gimp_unified_transformation_tool_draw;
}
@@ -135,6 +143,56 @@ gimp_unified_transformation_tool_init (GimpUnifiedTransformationTool *unified_to
tr_tool->use_pivot = TRUE;
}
+/*hack*/
+static void
+gimp_transform_tool_set_function (GimpTransformTool *tr_tool,
+ TransformAction function)
+{
+ if (function != tr_tool->function)
+ {
+ if (tr_tool->handles[tr_tool->function] &&
+ gimp_draw_tool_is_active (GIMP_DRAW_TOOL (tr_tool)))
+ {
+ gimp_canvas_item_set_highlight (tr_tool->handles[tr_tool->function],
+ FALSE);
+ }
+
+ tr_tool->function = function;
+
+ if (tr_tool->handles[tr_tool->function] &&
+ gimp_draw_tool_is_active (GIMP_DRAW_TOOL (tr_tool)))
+ {
+ gimp_canvas_item_set_highlight (tr_tool->handles[tr_tool->function],
+ TRUE);
+ }
+ }
+}
+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;
+ TransformAction i;
+
+ if (display != tool->display || draw_tool->item == NULL)
+ {
+ gimp_transform_tool_set_function (tr_tool, TRANSFORM_HANDLE_NONE);
+ return;
+ }
+
+ for (i = TRANSFORM_HANDLE_NONE + 1; i < TRANSFORM_HANDLE_NUM; i++) {
+ if (gimp_canvas_item_hit (tr_tool->handles[i], coords->x, coords->y))
+ function = i;
+ /* don't break here, or swap order of center/pivot in the enum */
+ }
+
+ gimp_transform_tool_set_function (tr_tool, function);
+}
/* hack */
static void
gimp_transform_tool_handles_recalc (GimpTransformTool *tr_tool,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]