[gimp] app: add crosshair drawing to GimpCanvasAnchor and use it in GimpPaintTool
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: add crosshair drawing to GimpCanvasAnchor and use it in GimpPaintTool
- Date: Tue, 18 Nov 2014 22:08:30 +0000 (UTC)
commit c17e8b0412d1698ed130d2449680893aa0c723f6
Author: Michael Natterer <mitch gimp org>
Date: Tue Nov 18 23:06:43 2014 +0100
app: add crosshair drawing to GimpCanvasAnchor and use it in GimpPaintTool
instead of drawing the crosshair cursor manually.
app/display/display-enums.c | 2 +
app/display/display-enums.h | 3 +-
app/display/gimpcanvashandle.c | 19 +++++++++++++++++
app/tools/gimpdrawtool.c | 1 +
app/tools/gimpdrawtool.h | 9 ++++---
app/tools/gimppainttool.c | 43 ++++++++++++++--------------------------
6 files changed, 44 insertions(+), 33 deletions(-)
---
diff --git a/app/display/display-enums.c b/app/display/display-enums.c
index 908ecb1..70e0958 100644
--- a/app/display/display-enums.c
+++ b/app/display/display-enums.c
@@ -92,6 +92,7 @@ gimp_handle_type_get_type (void)
{ GIMP_HANDLE_DIAMOND, "GIMP_HANDLE_DIAMOND", "diamond" },
{ GIMP_HANDLE_FILLED_DIAMOND, "GIMP_HANDLE_FILLED_DIAMOND", "filled-diamond" },
{ GIMP_HANDLE_CROSS, "GIMP_HANDLE_CROSS", "cross" },
+ { GIMP_HANDLE_CROSSHAIR, "GIMP_HANDLE_CROSSHAIR", "crosshair" },
{ 0, NULL, NULL }
};
@@ -104,6 +105,7 @@ gimp_handle_type_get_type (void)
{ GIMP_HANDLE_DIAMOND, "GIMP_HANDLE_DIAMOND", NULL },
{ GIMP_HANDLE_FILLED_DIAMOND, "GIMP_HANDLE_FILLED_DIAMOND", NULL },
{ GIMP_HANDLE_CROSS, "GIMP_HANDLE_CROSS", NULL },
+ { GIMP_HANDLE_CROSSHAIR, "GIMP_HANDLE_CROSSHAIR", NULL },
{ 0, NULL, NULL }
};
diff --git a/app/display/display-enums.h b/app/display/display-enums.h
index cbc0cfa..01ef767 100644
--- a/app/display/display-enums.h
+++ b/app/display/display-enums.h
@@ -60,7 +60,8 @@ typedef enum
GIMP_HANDLE_FILLED_CIRCLE,
GIMP_HANDLE_DIAMOND,
GIMP_HANDLE_FILLED_DIAMOND,
- GIMP_HANDLE_CROSS
+ GIMP_HANDLE_CROSS,
+ GIMP_HANDLE_CROSSHAIR
} GimpHandleType;
diff --git a/app/display/gimpcanvashandle.c b/app/display/gimpcanvashandle.c
index 8a4146d..b76cf91 100644
--- a/app/display/gimpcanvashandle.c
+++ b/app/display/gimpcanvashandle.c
@@ -272,6 +272,7 @@ gimp_canvas_handle_transform (GimpCanvasItem *item,
case GIMP_HANDLE_CIRCLE:
case GIMP_HANDLE_FILLED_CIRCLE:
case GIMP_HANDLE_CROSS:
+ case GIMP_HANDLE_CROSSHAIR:
case GIMP_HANDLE_DIAMOND:
case GIMP_HANDLE_FILLED_DIAMOND:
gimp_canvas_item_shift_to_center (private->anchor,
@@ -369,6 +370,22 @@ gimp_canvas_handle_draw (GimpCanvasItem *item,
_gimp_canvas_item_stroke (item, cr);
break;
+ case GIMP_HANDLE_CROSSHAIR:
+ cairo_move_to (cr, x - private->width / 2, y);
+ cairo_line_to (cr, x - private->width * 0.4, y);
+
+ cairo_move_to (cr, x + private->width / 2 - 0.5, y);
+ cairo_line_to (cr, x + private->width * 0.4, y);
+
+ cairo_move_to (cr, x, y - private->height / 2);
+ cairo_line_to (cr, x, y - private->height * 0.4 - 0.5);
+
+ cairo_move_to (cr, x, y + private->height / 2 - 0.5);
+ cairo_line_to (cr, x, y + private->height * 0.4 - 0.5);
+
+ _gimp_canvas_item_stroke (item, cr);
+ break;
+
default:
break;
}
@@ -399,6 +416,7 @@ gimp_canvas_handle_get_extents (GimpCanvasItem *item)
case GIMP_HANDLE_CIRCLE:
case GIMP_HANDLE_FILLED_CIRCLE:
case GIMP_HANDLE_CROSS:
+ case GIMP_HANDLE_CROSSHAIR:
case GIMP_HANDLE_DIAMOND:
case GIMP_HANDLE_FILLED_DIAMOND:
rectangle.x = x - private->width / 2 - 2.0;
@@ -453,6 +471,7 @@ gimp_canvas_handle_hit (GimpCanvasItem *item,
case GIMP_HANDLE_CIRCLE:
case GIMP_HANDLE_FILLED_CIRCLE:
case GIMP_HANDLE_CROSS:
+ case GIMP_HANDLE_CROSSHAIR:
{
gint width = private->width;
diff --git a/app/tools/gimpdrawtool.c b/app/tools/gimpdrawtool.c
index c1b6bab..1f707f0 100644
--- a/app/tools/gimpdrawtool.c
+++ b/app/tools/gimpdrawtool.c
@@ -1033,6 +1033,7 @@ gimp_draw_tool_on_handle (GimpDrawTool *draw_tool,
case GIMP_HANDLE_SQUARE:
case GIMP_HANDLE_FILLED_SQUARE:
case GIMP_HANDLE_CROSS:
+ case GIMP_HANDLE_CROSSHAIR:
gimp_canvas_item_shift_to_north_west (anchor,
handle_tx, handle_ty,
width, height,
diff --git a/app/tools/gimpdrawtool.h b/app/tools/gimpdrawtool.h
index 1540933..6f358c4 100644
--- a/app/tools/gimpdrawtool.h
+++ b/app/tools/gimpdrawtool.h
@@ -22,10 +22,11 @@
#include "gimptool.h"
-#define GIMP_TOOL_HANDLE_SIZE_CIRCLE 13
-#define GIMP_TOOL_HANDLE_SIZE_CROSS 15
-#define GIMP_TOOL_HANDLE_SIZE_LARGE 25
-#define GIMP_TOOL_HANDLE_SIZE_SMALL 7
+#define GIMP_TOOL_HANDLE_SIZE_CIRCLE 13
+#define GIMP_TOOL_HANDLE_SIZE_CROSS 15
+#define GIMP_TOOL_HANDLE_SIZE_CROSSHAIR 43
+#define GIMP_TOOL_HANDLE_SIZE_LARGE 25
+#define GIMP_TOOL_HANDLE_SIZE_SMALL 7
#define GIMP_TYPE_DRAW_TOOL (gimp_draw_tool_get_type ())
diff --git a/app/tools/gimppainttool.c b/app/tools/gimppainttool.c
index d8f475a..f3dabc7 100644
--- a/app/tools/gimppainttool.c
+++ b/app/tools/gimppainttool.c
@@ -795,39 +795,26 @@ gimp_paint_tool_draw (GimpDrawTool *draw_tool)
}
else if (paint_tool->draw_circle)
{
- /** Lets make a sensible fallback cursor
+ /* Lets make a sensible fallback cursor
*
* Sensible cursor is
* * crossed to indicate draw point
* * reactive to options alterations
- * * not a full circle that would be in the way */
-
-
- /* size as it could be */
- gint size = (gint) paint_tool->circle_radius;
- gdouble view_scale = MAX (core->cur_coords.xscale, core->cur_coords.xscale);
- gdouble cross_size = 25.0 / view_scale;
- gdouble cross_gap = 18.0 / view_scale;
-
- /* Cross to mark the spot*/
- gimp_draw_tool_add_line (draw_tool,
- cur_x + cross_gap, cur_y,
- cur_x + cross_size, cur_y);
-
- gimp_draw_tool_add_line (draw_tool,
- cur_x - cross_size, cur_y,
- cur_x - cross_gap, cur_y);
-
- gimp_draw_tool_add_line (draw_tool,
- cur_x, cur_y - cross_size,
- cur_x, cur_y - cross_gap);
+ * * not a full circle that would be in the way
+ */
+ gint size = (gint) paint_tool->circle_radius;
- gimp_draw_tool_add_line (draw_tool,
- cur_x, cur_y + cross_gap,
- cur_x, cur_y + cross_size);
+ /* Cross to mark the spot */
+ gimp_draw_tool_add_handle (draw_tool,
+ GIMP_HANDLE_CROSSHAIR,
+ cur_x, cur_y,
+ GIMP_TOOL_HANDLE_SIZE_CROSSHAIR,
+ GIMP_TOOL_HANDLE_SIZE_CROSSHAIR,
+ GIMP_HANDLE_ANCHOR_CENTER);
#define TICKMARK_ANGLE 48
#define ROTATION_ANGLE G_PI / 4
+
/* marks for indicating full size */
gimp_draw_tool_add_arc (draw_tool,
FALSE,
@@ -870,10 +857,10 @@ gimp_paint_tool_draw (GimpDrawTool *draw_tool)
*/
if (! line_drawn)
gimp_draw_tool_add_handle (draw_tool,
- GIMP_HANDLE_CIRCLE,
+ GIMP_HANDLE_CROSSHAIR,
cur_x, cur_y,
- GIMP_TOOL_HANDLE_SIZE_SMALL,
- GIMP_TOOL_HANDLE_SIZE_SMALL,
+ GIMP_TOOL_HANDLE_SIZE_CROSSHAIR,
+ GIMP_TOOL_HANDLE_SIZE_CROSSHAIR,
GIMP_HANDLE_ANCHOR_CENTER);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]