From 14f8fc7aa7586a9a22b924be2eb11f513dfaf825 Mon Sep 17 00:00:00 2001 From: Nicola Fontana Date: Sun, 17 Jan 2010 19:48:20 +0100 Subject: [PATCH] [AdgDim] Added "centered" property New property to manage the quote position: when "centered" is ON, the quote must be forced in the middle of the base line, when OFF the "pos" property is used as reference and when UNDEFINED (the default case), the ADG should deduct the better strategy depending on the available space and on the quote size. Fixing issue #2: http://dev.entidi.com/p/adg/issues/2/ --- adg/adg-dim-private.h | 1 + adg/adg-dim.c | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++ adg/adg-dim.h | 3 +++ 3 files changed, 65 insertions(+) diff --git a/adg/adg-dim-private.h b/adg/adg-dim-private.h index 1fb43b34..0901e62c 100644 --- a/adg/adg-dim-private.h +++ b/adg/adg-dim-private.h @@ -40,6 +40,7 @@ struct _AdgDimPrivate { AdgPoint *pos; gdouble level; AdgThreeState outside; + AdgThreeState centered; gchar *value; gchar *min; gchar *max; diff --git a/adg/adg-dim.c b/adg/adg-dim.c index d80fc1ec..799bdf6a 100644 --- a/adg/adg-dim.c +++ b/adg/adg-dim.c @@ -53,6 +53,7 @@ enum { PROP_POS, PROP_LEVEL, PROP_OUTSIDE, + PROP_CENTERED, PROP_VALUE, PROP_MIN, PROP_MAX @@ -155,6 +156,13 @@ adg_dim_class_init(AdgDimClass *klass) G_PARAM_READWRITE); g_object_class_install_property(gobject_class, PROP_OUTSIDE, param); + param = g_param_spec_enum("centered", + P_("Centered"), + P_("Where the quote must be positioned: in the middle of the base line (ADG_THREE_STATE_ON), near the pos point (ADG_THREE_STATE_OFF) or should be automatically deducted depending on the available space"), + ADG_TYPE_THREE_STATE, ADG_THREE_STATE_UNKNOWN, + G_PARAM_READWRITE); + g_object_class_install_property(gobject_class, PROP_CENTERED, param); + param = g_param_spec_string("value", P_("Basic Value"), P_("The theoretically exact value for this quote: set to NULL to automatically get the default value"), @@ -189,6 +197,7 @@ adg_dim_init(AdgDim *dim) data->pos = NULL; data->level = 1; data->outside = ADG_THREE_STATE_UNKNOWN; + data->centered = ADG_THREE_STATE_UNKNOWN; data->value = NULL; data->min = NULL; data->max = NULL; @@ -259,6 +268,9 @@ get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) case PROP_OUTSIDE: g_value_set_enum(value, data->outside); break; + case PROP_CENTERED: + g_value_set_enum(value, data->centered); + break; case PROP_VALUE: g_value_set_string(value, data->value); break; @@ -309,6 +321,9 @@ set_property(GObject *object, guint prop_id, case PROP_OUTSIDE: data->outside = g_value_get_enum(value); break; + case PROP_CENTERED: + data->centered = g_value_get_enum(value); + break; case PROP_VALUE: set_value(dim, g_value_get_string(value)); break; @@ -718,6 +733,52 @@ adg_dim_get_outside(AdgDim *dim) } /** + * adg_dim_set_centered: + * @dim: an #AdgDim + * @centered: the new centered state + * + * Sets a new state for the #AdgDim:centered flag: check the property + * documentation for further details. + * + * This is used by dimensions where the centering of the quote is + * applicable. In the other cases (such as with #AdgRDim dimensions) + * the property is not used. + **/ +void +adg_dim_set_centered(AdgDim *dim, AdgThreeState centered) +{ + AdgDimPrivate *data; + + g_return_if_fail(ADG_IS_DIM(dim)); + + data = dim->data; + data->centered = centered; + + g_object_notify((GObject *) dim, "centered"); +} + +/** + * adg_dim_get_centered: + * @dim: an #AdgDim + * + * Gets the state of the #AdgDim:centered property: check the property + * documentation for further details. + * + * Returns: the current flag state + **/ +AdgThreeState +adg_dim_get_centered(AdgDim *dim) +{ + AdgDimPrivate *data; + + g_return_val_if_fail(ADG_IS_DIM(dim), ADG_THREE_STATE_UNKNOWN); + + data = dim->data; + + return data->centered; +} + +/** * adg_dim_set_value: * @dim: an #AdgDim * @value: the value text diff --git a/adg/adg-dim.h b/adg/adg-dim.h index 275b5a48..f115aefb 100644 --- a/adg/adg-dim.h +++ b/adg/adg-dim.h @@ -87,6 +87,9 @@ gdouble adg_dim_get_level (AdgDim *dim); void adg_dim_set_outside (AdgDim *dim, AdgThreeState outside); AdgThreeState adg_dim_get_outside (AdgDim *dim); +void adg_dim_set_centered (AdgDim *dim, + AdgThreeState centered); +AdgThreeState adg_dim_get_centered (AdgDim *dim); void adg_dim_set_value (AdgDim *dim, const gchar *value); const gchar * adg_dim_get_value (AdgDim *dim); -- 2.11.4.GIT