[gimp] app: add arc slices to GimpCanvasHandle
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: add arc slices to GimpCanvasHandle
- Date: Thu, 23 Sep 2010 23:33:36 +0000 (UTC)
commit 6ebc29818eff59714bfefb9d7e175a6c4ec3ebd8
Author: Michael Natterer <mitch gimp org>
Date: Fri Sep 24 01:32:09 2010 +0200
app: add arc slices to GimpCanvasHandle
app/display/gimpcanvashandle.c | 73 ++++++++++++++++++++++++++++++++++++++--
app/display/gimpcanvashandle.h | 19 ++++++----
2 files changed, 81 insertions(+), 11 deletions(-)
---
diff --git a/app/display/gimpcanvashandle.c b/app/display/gimpcanvashandle.c
index 4f59d5e..534a91a 100644
--- a/app/display/gimpcanvashandle.c
+++ b/app/display/gimpcanvashandle.c
@@ -41,7 +41,9 @@ enum
PROP_X,
PROP_Y,
PROP_WIDTH,
- PROP_HEIGHT
+ PROP_HEIGHT,
+ PROP_START_ANGLE,
+ PROP_SLICE_ANGLE
};
@@ -55,6 +57,8 @@ struct _GimpCanvasHandlePrivate
gdouble y;
gint width;
gint height;
+ gdouble start_angle;
+ gdouble slice_angle;;
};
#define GET_PRIVATE(handle) \
@@ -132,12 +136,26 @@ gimp_canvas_handle_class_init (GimpCanvasHandleClass *klass)
3, 1001, 7,
GIMP_PARAM_READWRITE));
+ g_object_class_install_property (object_class, PROP_START_ANGLE,
+ g_param_spec_double ("start-angle", NULL, NULL,
+ -1000, 1000, 0,
+ GIMP_PARAM_READWRITE));
+
+ g_object_class_install_property (object_class, PROP_SLICE_ANGLE,
+ g_param_spec_double ("slice-angle", NULL, NULL,
+ -1000, 1000, 2 * G_PI,
+ GIMP_PARAM_READWRITE));
+
g_type_class_add_private (klass, sizeof (GimpCanvasHandlePrivate));
}
static void
gimp_canvas_handle_init (GimpCanvasHandle *handle)
{
+ GimpCanvasHandlePrivate *private = GET_PRIVATE (handle);
+
+ private->start_angle = 0.0;
+ private->slice_angle = 2.0 * G_PI;
}
static void
@@ -168,6 +186,12 @@ gimp_canvas_handle_set_property (GObject *object,
case PROP_HEIGHT:
private->height = g_value_get_int (value);
break;
+ case PROP_START_ANGLE:
+ private->start_angle = g_value_get_double (value);
+ break;
+ case PROP_SLICE_ANGLE:
+ private->slice_angle = g_value_get_double (value);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -203,6 +227,12 @@ gimp_canvas_handle_get_property (GObject *object,
case PROP_HEIGHT:
g_value_set_int (value, private->height);
break;
+ case PROP_START_ANGLE:
+ g_value_set_double (value, private->start_angle);
+ break;
+ case PROP_SLICE_ANGLE:
+ g_value_set_double (value, private->slice_angle);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -400,13 +430,37 @@ gimp_canvas_handle_draw (GimpCanvasItem *item,
break;
case GIMP_HANDLE_CIRCLE:
- cairo_arc (cr, x, y, private->width / 2, 0, 2 * G_PI);
+ if (private->slice_angle >= 0)
+ {
+ cairo_arc_negative (cr, x, y, private->width / 2,
+ - private->start_angle,
+ - private->start_angle - private->slice_angle);
+ }
+ else
+ {
+ cairo_arc (cr, x, y, private->width / 2,
+ - private->start_angle,
+ - private->start_angle - private->slice_angle);
+ }
_gimp_canvas_item_stroke (item, shell, cr);
break;
case GIMP_HANDLE_FILLED_CIRCLE:
- cairo_arc (cr, x, y, (gdouble) private->width / 2.0, 0, 2 * G_PI);
+ cairo_move_to (cr, x, y);
+
+ if (private->slice_angle >= 0)
+ {
+ cairo_arc_negative (cr, x, y, (gdouble) private->width / 2.0,
+ - private->start_angle,
+ - private->start_angle - private->slice_angle);
+ }
+ else
+ {
+ cairo_arc (cr, x, y, (gdouble) private->width / 2.0,
+ - private->start_angle,
+ - private->start_angle - private->slice_angle);
+ }
_gimp_canvas_item_fill (item, shell, cr);
break;
@@ -479,3 +533,16 @@ gimp_canvas_handle_new (GimpHandleType type,
"height", height,
NULL);
}
+
+void
+gimp_canvas_handle_set_angles (GimpCanvasHandle *handle,
+ gdouble start_angle,
+ gdouble slice_angle)
+{
+ g_return_if_fail (GIMP_IS_CANVAS_HANDLE (handle));
+
+ g_object_set (handle,
+ "start-angle", start_angle,
+ "slice-angle", slice_angle,
+ NULL);
+}
diff --git a/app/display/gimpcanvashandle.h b/app/display/gimpcanvashandle.h
index 3172168..1691c84 100644
--- a/app/display/gimpcanvashandle.h
+++ b/app/display/gimpcanvashandle.h
@@ -47,14 +47,17 @@ struct _GimpCanvasHandleClass
};
-GType gimp_canvas_handle_get_type (void) G_GNUC_CONST;
-
-GimpCanvasItem * gimp_canvas_handle_new (GimpHandleType type,
- GtkAnchorType anchor,
- gdouble x,
- gdouble y,
- gint width,
- gint height);
+GType gimp_canvas_handle_get_type (void) G_GNUC_CONST;
+
+GimpCanvasItem * gimp_canvas_handle_new (GimpHandleType type,
+ GtkAnchorType anchor,
+ gdouble x,
+ gdouble y,
+ gint width,
+ gint height);
+void gimp_canvas_handle_set_angles (GimpCanvasHandle *handle,
+ gdouble start_handle,
+ gdouble slice_handle);
#endif /* __GIMP_CANVAS_HANDLE_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]