[gegl] property meta data, add ui_steps to double and int
- From: Øyvind Kolås <ok src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gegl] property meta data, add ui_steps to double and int
- Date: Tue, 20 May 2014 01:42:50 +0000 (UTC)
commit 1b8c1da3ffeddf75e636c84a4f0af17fddff51cb
Author: Øyvind Kolås <pippin gimp org>
Date: Mon May 19 22:09:32 2014 +0200
property meta data, add ui_steps to double and int
Add the ability to specify small and big step increments for properties in
GEGL augmented GParamSpecs for integers and doubles.
gegl/gegl-op.h | 91 ++++++++++++++++++++++++++++++++-
gegl/property-types/gegl-paramspecs.c | 27 ++++++++++
gegl/property-types/gegl-paramspecs.h | 12 ++++
3 files changed, 129 insertions(+), 1 deletions(-)
---
diff --git a/gegl/gegl-op.h b/gegl/gegl-op.h
index 64f1cf5..5571b29 100644
--- a/gegl/gegl-op.h
+++ b/gegl/gegl-op.h
@@ -233,6 +233,7 @@ gegl_module_register (GTypeModule *module)
#define value_range(min,max)
#define ui_range(min,max)
#define ui_gamma(gamma)
+#define ui_steps(small_increment, big_increment)
#define ui_meta(key,val)
#define ITEM(name,label,def_val, type)
@@ -906,10 +907,90 @@ gegl_op_constructor (GType type,
}
static void
+param_spec_update_ui (GParamSpec *pspec,
+ gboolean ui_range_set,
+ gboolean ui_steps_set)
+{
+ if (GEGL_IS_PARAM_SPEC_DOUBLE (pspec))
+ {
+ GeglParamSpecDouble *upspec = GEGL_PARAM_SPEC_DOUBLE (pspec);
+ GParamSpecDouble *vpspec = G_PARAM_SPEC_DOUBLE (pspec);
+
+ if (!ui_steps_set)
+ {
+ if (!ui_range_set)
+ {
+ upspec->ui_maximum = vpspec->maximum;
+ upspec->ui_minimum = vpspec->minimum;
+ }
+
+ if (upspec->ui_maximum <= 5.0)
+ {
+ upspec->ui_step_small = 0.01;
+ upspec->ui_step_big = 0.10;
+ }
+ else if (upspec->ui_maximum <= 50)
+ {
+ upspec->ui_step_small = 0.1;
+ upspec->ui_step_big = 1.0;
+ }
+ else if (upspec->ui_maximum <= 500)
+ {
+ upspec->ui_step_small = 1.0;
+ upspec->ui_step_big = 10.0;
+ }
+ else if (upspec->ui_maximum <= 5000)
+ {
+ upspec->ui_step_small = 1.0;
+ upspec->ui_step_big = 100.0;
+ }
+ }
+ }
+ else if (GEGL_IS_PARAM_SPEC_INT (pspec))
+ {
+ GeglParamSpecInt *upspec = GEGL_PARAM_SPEC_INT (pspec);
+ GParamSpecInt *vpspec = G_PARAM_SPEC_INT (pspec);
+
+ if (!ui_steps_set)
+ {
+ if (!ui_range_set)
+ {
+ upspec->ui_maximum = vpspec->maximum;
+ upspec->ui_minimum = vpspec->minimum;
+ }
+
+ if (upspec->ui_maximum <= 5)
+ {
+ upspec->ui_step_small = 1;
+ upspec->ui_step_big = 2;
+ }
+ else if (upspec->ui_maximum <= 50)
+ {
+ upspec->ui_step_small = 1;
+ upspec->ui_step_big = 5;
+ }
+ else if (upspec->ui_maximum <= 500)
+ {
+ upspec->ui_step_small = 1;
+ upspec->ui_step_big = 10;
+ }
+ else if (upspec->ui_maximum <= 5000)
+ {
+ upspec->ui_step_small = 1;
+ upspec->ui_step_big = 100;
+ }
+
+ }
+ }
+}
+
+static void
gegl_op_class_intern_init (gpointer klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
int current_prop = -1;
+ gboolean G_GNUC_UNUSED ui_range_set = FALSE;
+ gboolean G_GNUC_UNUSED ui_steps_set = FALSE;
GParamFlags flags G_GNUC_UNUSED = G_PARAM_READWRITE | G_PARAM_CONSTRUCT | GEGL_PARAM_PAD_INPUT;
object_class->set_property = set_property;
@@ -922,13 +1003,16 @@ gegl_op_class_intern_init (gpointer klass)
#undef description
#undef value_range
#undef ui_range
+#undef ui_steps
#undef ui_gamma
#undef ui_meta
#define REGISTER_IF_ANY \
if (pspec && current_prop >=0) {\
+ param_spec_update_ui (pspec, ui_range_set, ui_steps_set);\
g_object_class_install_property (object_class, current_prop, pspec);\
pspec = NULL; current_prop = -1;\
+ ui_range_set = ui_steps_set = FALSE;\
}
#define description(blurb) \
@@ -937,7 +1021,11 @@ gegl_op_class_intern_init (gpointer klass)
vpspec->minimum = min; vpspec->maximum = max; \
upspec->ui_minimum = min; upspec->ui_maximum = max;
#define ui_range(min,max) \
- upspec->ui_minimum = min; upspec->ui_maximum = max;
+ upspec->ui_minimum = min; upspec->ui_maximum = max;\
+ ui_range_set = TRUE;
+#define ui_steps(step_small,step_big) \
+ upspec->ui_step_small = step_small; upspec->ui_step_big = step_big; \
+ ui_steps_set = TRUE;
#define ui_gamma(gamma) \
upspec->ui_gamma = gamma;
#define ui_meta(key,val) \
@@ -1078,6 +1166,7 @@ gegl_op_class_intern_init (gpointer klass)
#undef description
#undef value_range
#undef ui_range
+#undef ui_steps
#undef ui_gamma
#undef ui_meta
#undef property_double
diff --git a/gegl/property-types/gegl-paramspecs.c b/gegl/property-types/gegl-paramspecs.c
index 23fd73b..b4b2b24 100644
--- a/gegl/property-types/gegl-paramspecs.c
+++ b/gegl/property-types/gegl-paramspecs.c
@@ -98,10 +98,25 @@ gegl_param_spec_double (const gchar *name,
pspec->ui_minimum = ui_minimum;
pspec->ui_maximum = ui_maximum;
pspec->ui_gamma = ui_gamma;
+ gegl_param_spec_double_set_steps (pspec, 0.1, 1.0);
return G_PARAM_SPEC (pspec);
}
+void
+gegl_param_spec_double_set_steps (GeglParamSpecDouble *pspec,
+ gdouble step_small,
+ gdouble step_big)
+{
+ g_return_if_fail (GEGL_IS_PARAM_SPEC_DOUBLE (pspec));
+
+ pspec->ui_step_small = step_small;
+ pspec->ui_step_big = step_big;
+}
+
+gdouble gegl_param_spec_double_get_step_size (GeglParamSpecDouble *pspec);
+gdouble gegl_param_spec_double_get_page_size (GeglParamSpecDouble *pspec);
+
static void gegl_param_int_class_init (GParamSpecClass *klass);
static void gegl_param_int_init (GParamSpec *pspec);
@@ -171,9 +186,21 @@ gegl_param_spec_int (const gchar *name,
pspec->ui_maximum = ui_maximum;
pspec->ui_gamma = ui_gamma;
+ gegl_param_spec_int_set_steps (pspec, 0.1, 1.0);
return G_PARAM_SPEC (pspec);
}
+void
+gegl_param_spec_int_set_steps (GeglParamSpecInt *pspec,
+ gint step_small,
+ gint step_big)
+{
+ g_return_if_fail (GEGL_IS_PARAM_SPEC_INT (pspec));
+
+ pspec->ui_step_small = step_small;
+ pspec->ui_step_big = step_big;
+}
+
/*
* GEGL_TYPE_PARAM_STRING
*/
diff --git a/gegl/property-types/gegl-paramspecs.h b/gegl/property-types/gegl-paramspecs.h
index dd2e0e2..caa1e2b 100644
--- a/gegl/property-types/gegl-paramspecs.h
+++ b/gegl/property-types/gegl-paramspecs.h
@@ -59,6 +59,8 @@ struct _GeglParamSpecDouble
or gaussian blur radius - where more
detailed control of small values is needed
*/
+ gdouble ui_step_small;
+ gdouble ui_step_big;
};
GType gegl_param_double_get_type (void) G_GNUC_CONST;
@@ -92,6 +94,10 @@ GParamSpec * gegl_param_spec_double (const gchar *name,
GParamFlags flags);
+void gegl_param_spec_double_set_steps (GeglParamSpecDouble *pspec,
+ gdouble small_step,
+ gdouble big_step);
+
/*
* GEGL_TYPE_PARAM_INT
*/
@@ -107,6 +113,8 @@ struct _GeglParamSpecInt
gint ui_minimum; /* reasonable range to present to user */
gint ui_maximum;
gdouble ui_gamma;
+ gint ui_step_small;
+ gint ui_step_big;
};
GType gegl_param_int_get_type (void) G_GNUC_CONST;
@@ -140,6 +148,10 @@ GParamSpec * gegl_param_spec_int (const gchar *name,
GParamFlags flags);
+void gegl_param_spec_int_set_steps (GeglParamSpecInt *pspec,
+ gint small_step,
+ gint big_step);
+
/*
* GEGL_TYPE_PARAM_STRING
*/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]