Commit 907939ed authored by Michael Natterer's avatar Michael Natterer 😴

app: add gimp_prop_angle_range_dial_new()

which is by no means general and needs to be improved if ever widely
used.
parent 7261c6b3
......@@ -739,7 +739,7 @@ deg_to_rad (GBinding *binding,
gdouble *lower = user_data;
gdouble value = g_value_get_double (from_value);
if (*lower != 0.0)
if (lower && *lower != 0.0)
{
if (value < 0.0)
value += 360.0;
......@@ -763,7 +763,7 @@ rad_to_deg (GBinding *binding,
value *= 180.0 / G_PI;
if (*lower != 0.0)
if (lower && *lower != 0.0)
{
if (value > (*lower + 360.0))
value -= 360.0;
......@@ -841,6 +841,61 @@ gimp_prop_angle_dial_new (GObject *config,
return dial;
}
GtkWidget *
gimp_prop_angle_range_dial_new (GObject *config,
const gchar *alpha_property_name,
const gchar *beta_property_name,
const gchar *clockwise_property_name)
{
GParamSpec *alpha_param_spec;
GParamSpec *beta_param_spec;
GParamSpec *clockwise_param_spec;
GtkWidget *dial;
alpha_param_spec = find_param_spec (config, alpha_property_name, G_STRFUNC);
if (! alpha_param_spec)
return NULL;
beta_param_spec = find_param_spec (config, beta_property_name, G_STRFUNC);
if (! beta_param_spec)
return NULL;
clockwise_param_spec = find_param_spec (config, clockwise_property_name, G_STRFUNC);
if (! clockwise_param_spec)
return NULL;
dial = gimp_dial_new ();
g_object_set (dial,
"size", 96,
"border-width", 0,
"background", GIMP_CIRCLE_BACKGROUND_HSV,
NULL);
g_object_bind_property_full (config, alpha_property_name,
dial, "alpha",
G_BINDING_BIDIRECTIONAL |
G_BINDING_SYNC_CREATE,
deg_to_rad,
rad_to_deg,
NULL, NULL);
g_object_bind_property_full (config, beta_property_name,
dial, "beta",
G_BINDING_BIDIRECTIONAL |
G_BINDING_SYNC_CREATE,
deg_to_rad,
rad_to_deg,
NULL, NULL);
g_object_bind_property (config, clockwise_property_name,
dial, "clockwise",
G_BINDING_BIDIRECTIONAL |
G_BINDING_SYNC_CREATE);
return dial;
}
/**********/
/* view */
......
......@@ -68,6 +68,10 @@ void gimp_prop_widget_set_factor (GtkWidget *widget,
GtkWidget * gimp_prop_angle_dial_new (GObject *config,
const gchar *property_name);
GtkWidget * gimp_prop_angle_range_dial_new (GObject *config,
const gchar *alpha_property_name,
const gchar *beta_property_name,
const gchar *clockwise_property_name);
/* GParamObject (GimpViewable) */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment