From 928d259a282d5e0aa49e6e81a6b9168ca29d35ea Mon Sep 17 00:00:00 2001 From: Nicola Fontana Date: Thu, 20 Aug 2009 21:28:23 +0200 Subject: [PATCH] [AdgDim] Added "outside" property This three-state flag will allow forcing the arrows (or any other marker implied by the style) inside or outside the extension lines. By default, the inside/outside rendering will be selected depending on the space available between the two extension line (yet to be done though). --- adg/adg-dim-private.h | 5 ++--- adg/adg-dim.c | 61 +++++++++++++++++++++++++++++++++++++++++++++++++-- adg/adg-dim.h | 3 +++ 3 files changed, 64 insertions(+), 5 deletions(-) diff --git a/adg/adg-dim-private.h b/adg/adg-dim-private.h index 0e0f5b65..788c9726 100644 --- a/adg/adg-dim-private.h +++ b/adg/adg-dim-private.h @@ -21,9 +21,7 @@ #ifndef __ADG_DIM_PRIVATE_H__ #define __ADG_DIM_PRIVATE_H__ -#include -#include -#include +#include G_BEGIN_DECLS @@ -37,6 +35,7 @@ struct _AdgDimPrivate { AdgPair pos2; gdouble angle; gdouble level; + AdgThreeState outside; gchar *value; gchar *value_min; gchar *value_max; diff --git a/adg/adg-dim.c b/adg/adg-dim.c index 80f74be5..5daf9da7 100644 --- a/adg/adg-dim.c +++ b/adg/adg-dim.c @@ -36,8 +36,9 @@ #include "adg-dim.h" #include "adg-dim-private.h" #include "adg-dim-style.h" +#include "adg-toy-text.h" +#include "adg-type-builtins.h" #include "adg-intl.h" -#include #define PARENT_OBJECT_CLASS ((GObjectClass *) adg_dim_parent_class) @@ -50,6 +51,7 @@ enum { PROP_POS2, PROP_ANGLE, PROP_LEVEL, + PROP_OUTSIDE, PROP_VALUE, PROP_VALUE_MIN, PROP_VALUE_MAX, @@ -147,6 +149,13 @@ adg_dim_class_init(AdgDimClass *klass) G_PARAM_READWRITE | G_PARAM_CONSTRUCT); g_object_class_install_property(gobject_class, PROP_LEVEL, param); + param = g_param_spec_enum("outside", + P_("Outside"), + P_("Whether the arrows must be inside the extension lines (ADG_THREE_STATE_OFF), must be extended outside the extension lines (ADG_THREE_STATE_ON) or should be automatically handled depending on the available space"), + ADG_TYPE_THREE_STATE, ADG_THREE_STATE_UNKNOWN, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT); + g_object_class_install_property(gobject_class, PROP_OUTSIDE, 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"), @@ -261,6 +270,9 @@ get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) case PROP_LEVEL: g_value_set_double(value, data->level); break; + case PROP_OUTSIDE: + g_value_set_enum(value, data->outside); + break; case PROP_VALUE: g_value_set_string(value, data->value); break; @@ -308,6 +320,9 @@ set_property(GObject *object, guint prop_id, case PROP_LEVEL: data->level = g_value_get_double(value); break; + case PROP_OUTSIDE: + data->outside = g_value_get_enum(value); + break; case PROP_VALUE: set_value(dim, g_value_get_string(value)); break; @@ -648,7 +663,7 @@ adg_dim_set_angle(AdgDim *dim, gdouble angle) * Returns: the level value **/ gdouble -adg_dim_get_level(AdgDim *dim) +adg_dim_get_level(AdgDim *dim) { AdgDimPrivate *data; @@ -682,6 +697,48 @@ adg_dim_set_level(AdgDim *dim, gdouble level) } /** + * adg_dim_get_outside: + * @dim: an #AdgDim + * + * Gets the state of the #AdgDim:outside property: check the property + * documentation for further details. + * + * Returns: the current flag state + **/ +AdgThreeState +adg_dim_get_outside(AdgDim *dim) +{ + AdgDimPrivate *data; + + g_return_val_if_fail(ADG_IS_DIM(dim), ADG_THREE_STATE_UNKNOWN); + + data = dim->data; + + return data->outside; +} + +/** + * adg_dim_set_outside: + * @dim: an #AdgDim + * @outside: the new outside state + * + * Sets a new state for the #AdgDim:outside flag: check the property + * documentation for further details. + **/ +void +adg_dim_set_outside(AdgDim *dim, AdgThreeState outside) +{ + AdgDimPrivate *data; + + g_return_if_fail(ADG_IS_DIM(dim)); + + data = dim->data; + data->outside = outside; + + g_object_notify((GObject *) dim, "outside"); +} + +/** * adg_dim_get_value: * @dim: an #AdgDim * diff --git a/adg/adg-dim.h b/adg/adg-dim.h index e7a006ef..b52380a2 100644 --- a/adg/adg-dim.h +++ b/adg/adg-dim.h @@ -87,6 +87,9 @@ void adg_dim_set_pos_explicit (AdgDim *dim, gdouble adg_dim_get_level (AdgDim *dim); void adg_dim_set_level (AdgDim *dim, gdouble level); +AdgThreeState adg_dim_get_outside (AdgDim *dim); +void adg_dim_set_outside (AdgDim *dim, + AdgThreeState outside); const gchar * adg_dim_get_value (AdgDim *dim); void adg_dim_set_value (AdgDim *dim, const gchar *value); -- 2.11.4.GIT