[gimp/gimp-2-10] app: in GimpDial, add "clockwise-angles" property ...
- From: Ell <ell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/gimp-2-10] app: in GimpDial, add "clockwise-angles" property ...
- Date: Tue, 24 Jul 2018 06:29:17 +0000 (UTC)
commit 49ce2422f9d76c385c65ae4505a76c50dc629466
Author: Ell <ell_se yahoo com>
Date: Tue Jul 24 01:57:03 2018 -0400
app: in GimpDial, add "clockwise-angles" property ...
... and rename "clockwise" to "clockwise-delta"
Add a boolean "clockwise-angles" property to GimpDial, which, when
set, causes the dial legs' angles to be measured clockwise, rather
than counter-clockwise. The property is FALSE by default.
Rename the "clockwise" property, which controls the direction of
the measured delta between the two angles, to "clockwise-delta", to
avoid confusion, and adapt the rest of the code.
(cherry picked from commit 0c477564ad356fe39c0b4b988ade63256c3bc5e9)
app/propgui/gimppropgui-color-rotate.c | 16 ++++----
app/widgets/gimpdial.c | 67 +++++++++++++++++++++++++---------
app/widgets/gimppropwidgets.c | 2 +-
3 files changed, 59 insertions(+), 26 deletions(-)
---
diff --git a/app/propgui/gimppropgui-color-rotate.c b/app/propgui/gimppropgui-color-rotate.c
index 9813b929fc..1461084d1f 100644
--- a/app/propgui/gimppropgui-color-rotate.c
+++ b/app/propgui/gimppropgui-color-rotate.c
@@ -47,15 +47,15 @@ invert_segment_clicked (GtkWidget *button,
gboolean clockwise;
g_object_get (dial,
- "alpha", &alpha,
- "beta", &beta,
- "clockwise", &clockwise,
+ "alpha", &alpha,
+ "beta", &beta,
+ "clockwise-delta", &clockwise,
NULL);
g_object_set (dial,
- "alpha", beta,
- "beta", alpha,
- "clockwise", ! clockwise,
+ "alpha", beta,
+ "beta", alpha,
+ "clockwise-delta", ! clockwise,
NULL);
}
@@ -67,8 +67,8 @@ select_all_clicked (GtkWidget *button,
gboolean clockwise;
g_object_get (dial,
- "alpha", &alpha,
- "clockwise", &clockwise,
+ "alpha", &alpha,
+ "clockwise-delta", &clockwise,
NULL);
beta = alpha - (clockwise ? -1 : 1) * 0.00001;
diff --git a/app/widgets/gimpdial.c b/app/widgets/gimpdial.c
index dd0cd74184..0bffc21ab6 100644
--- a/app/widgets/gimpdial.c
+++ b/app/widgets/gimpdial.c
@@ -47,7 +47,8 @@ enum
PROP_DRAW_BETA,
PROP_ALPHA,
PROP_BETA,
- PROP_CLOCKWISE
+ PROP_CLOCKWISE_ANGLES,
+ PROP_CLOCKWISE_DELTA
};
typedef enum
@@ -63,7 +64,8 @@ struct _GimpDialPrivate
{
gdouble alpha;
gdouble beta;
- gboolean clockwise;
+ gboolean clockwise_angles;
+ gboolean clockwise_delta;
gboolean draw_beta;
DialTarget target;
@@ -96,7 +98,7 @@ static void gimp_dial_draw_arrows (cairo_t *cr,
gint size,
gdouble alpha,
gdouble beta,
- gboolean clockwise,
+ gboolean clockwise_delta,
DialTarget highlight,
gboolean draw_beta);
@@ -140,8 +142,15 @@ gimp_dial_class_init (GimpDialClass *klass)
GIMP_PARAM_READWRITE |
G_PARAM_CONSTRUCT));
- g_object_class_install_property (object_class, PROP_CLOCKWISE,
- g_param_spec_boolean ("clockwise",
+ g_object_class_install_property (object_class, PROP_CLOCKWISE_ANGLES,
+ g_param_spec_boolean ("clockwise-angles",
+ NULL, NULL,
+ FALSE,
+ GIMP_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT));
+
+ g_object_class_install_property (object_class, PROP_CLOCKWISE_DELTA,
+ g_param_spec_boolean ("clockwise-delta",
NULL, NULL,
FALSE,
GIMP_PARAM_READWRITE |
@@ -185,8 +194,13 @@ gimp_dial_set_property (GObject *object,
gtk_widget_queue_draw (GTK_WIDGET (dial));
break;
- case PROP_CLOCKWISE:
- dial->priv->clockwise = g_value_get_boolean (value);
+ case PROP_CLOCKWISE_ANGLES:
+ dial->priv->clockwise_angles = g_value_get_boolean (value);
+ gtk_widget_queue_draw (GTK_WIDGET (dial));
+ break;
+
+ case PROP_CLOCKWISE_DELTA:
+ dial->priv->clockwise_delta = g_value_get_boolean (value);
gtk_widget_queue_draw (GTK_WIDGET (dial));
break;
@@ -219,8 +233,12 @@ gimp_dial_get_property (GObject *object,
g_value_set_double (value, dial->priv->beta);
break;
- case PROP_CLOCKWISE:
- g_value_set_boolean (value, dial->priv->clockwise);
+ case PROP_CLOCKWISE_ANGLES:
+ g_value_set_boolean (value, dial->priv->clockwise_angles);
+ break;
+
+ case PROP_CLOCKWISE_DELTA:
+ g_value_set_boolean (value, dial->priv->clockwise_delta);
break;
case PROP_DRAW_BETA:
@@ -246,6 +264,8 @@ gimp_dial_expose_event (GtkWidget *widget,
GtkAllocation allocation;
gint size;
cairo_t *cr;
+ gdouble alpha = dial->priv->alpha;
+ gdouble beta = dial->priv->beta;
g_object_get (widget,
"size", &size,
@@ -261,9 +281,15 @@ gimp_dial_expose_event (GtkWidget *widget,
(gdouble) allocation.x + (allocation.width - size) / 2.0,
(gdouble) allocation.y + (allocation.height - size) / 2.0);
+ if (dial->priv->clockwise_angles)
+ {
+ alpha = -alpha;
+ beta = -beta;
+ }
+
gimp_dial_draw_arrows (cr, size,
- dial->priv->alpha, dial->priv->beta,
- dial->priv->clockwise,
+ alpha, beta,
+ dial->priv->clockwise_delta,
dial->priv->target,
dial->priv->draw_beta);
@@ -290,6 +316,10 @@ gimp_dial_button_press_event (GtkWidget *widget,
angle = _gimp_circle_get_angle_and_distance (GIMP_CIRCLE (dial),
bevent->x, bevent->y,
NULL);
+
+ if (dial->priv->clockwise_angles && angle)
+ angle = 2.0 * G_PI - angle;
+
dial->priv->last_angle = angle;
switch (dial->priv->target)
@@ -322,6 +352,9 @@ gimp_dial_motion_notify_event (GtkWidget *widget,
mevent->x, mevent->y,
&distance);
+ if (dial->priv->clockwise_angles && angle)
+ angle = 2.0 * G_PI - angle;
+
if (_gimp_circle_has_grab (GIMP_CIRCLE (dial)))
{
gdouble delta;
@@ -450,9 +483,9 @@ gimp_dial_draw_segment (cairo_t *cr,
gdouble radius,
gdouble alpha,
gdouble beta,
- gboolean clockwise)
+ gboolean clockwise_delta)
{
- gint direction = clockwise ? -1 : 1;
+ gint direction = clockwise_delta ? -1 : 1;
gint segment_dist;
gint tick;
gdouble slice;
@@ -471,7 +504,7 @@ gimp_dial_draw_segment (cairo_t *cr,
cairo_new_sub_path (cr);
- if (clockwise)
+ if (clockwise_delta)
slice = -gimp_dial_normalize_angle (alpha - beta);
else
slice = gimp_dial_normalize_angle (beta - alpha);
@@ -485,7 +518,7 @@ gimp_dial_draw_arrows (cairo_t *cr,
gint size,
gdouble alpha,
gdouble beta,
- gboolean clockwise,
+ gboolean clockwise_delta,
DialTarget highlight,
gboolean draw_beta)
{
@@ -509,7 +542,7 @@ gimp_dial_draw_arrows (cairo_t *cr,
gimp_dial_draw_arrow (cr, radius, beta);
if ((highlight & DIAL_TARGET_BOTH) != DIAL_TARGET_BOTH)
- gimp_dial_draw_segment (cr, radius, alpha, beta, clockwise);
+ gimp_dial_draw_segment (cr, radius, alpha, beta, clockwise_delta);
}
cairo_set_line_width (cr, 3.0);
@@ -532,7 +565,7 @@ gimp_dial_draw_arrows (cairo_t *cr,
gimp_dial_draw_arrow (cr, radius, beta);
if ((highlight & DIAL_TARGET_BOTH) == DIAL_TARGET_BOTH)
- gimp_dial_draw_segment (cr, radius, alpha, beta, clockwise);
+ gimp_dial_draw_segment (cr, radius, alpha, beta, clockwise_delta);
}
cairo_set_line_width (cr, 3.0);
diff --git a/app/widgets/gimppropwidgets.c b/app/widgets/gimppropwidgets.c
index 8695979e28..aea3f6f4f8 100644
--- a/app/widgets/gimppropwidgets.c
+++ b/app/widgets/gimppropwidgets.c
@@ -1041,7 +1041,7 @@ gimp_prop_angle_range_dial_new (GObject *config,
NULL, NULL);
g_object_bind_property (config, clockwise_property_name,
- dial, "clockwise",
+ dial, "clockwise-delta",
G_BINDING_BIDIRECTIONAL |
G_BINDING_SYNC_CREATE);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]