diff options
| author | Felipe Corr??a da Silva Sanches <juca@members.fsf.org> | 2008-02-15 03:00:10 +0000 |
|---|---|---|
| committer | JucaBlues <JucaBlues@users.sourceforge.net> | 2008-02-15 03:00:10 +0000 |
| commit | 0d6c6b814ab12495be29baa217c5a9c2284e4d1e (patch) | |
| tree | fde5c47fdd34e23cd1f0232ac5d64c502db6f340 /src/ui/widget/attr-widget.h | |
| parent | update (diff) | |
| download | inkscape-0d6c6b814ab12495be29baa217c5a9c2284e4d1e.tar.gz inkscape-0d6c6b814ab12495be29baa217c5a9c2284e4d1e.zip | |
fix for bug #184671 (Filter effects properties not updating correctly)
(bzr r4733)
Diffstat (limited to 'src/ui/widget/attr-widget.h')
| -rw-r--r-- | src/ui/widget/attr-widget.h | 75 |
1 files changed, 74 insertions, 1 deletions
diff --git a/src/ui/widget/attr-widget.h b/src/ui/widget/attr-widget.h index acf44b2d0..c87e860d5 100644 --- a/src/ui/widget/attr-widget.h +++ b/src/ui/widget/attr-widget.h @@ -3,6 +3,7 @@ * * Authors: * Nicholas Bishop <nicholasbishop@gmail.com> + * Rodrigo Kumpera <kumpera@gmail.com> * * Copyright (C) 2007 Authors * @@ -20,11 +21,81 @@ namespace Inkscape { namespace UI { namespace Widget { +enum DefaultValueType +{ + T_NONE, + T_DOUBLE, + T_VECT_DOUBLE, + T_BOOL +}; + +class DefaultValueHolder +{ + DefaultValueType type; + union { + double d_val; + std::vector<double>* vt_val; + bool b_val; + } value; + + //FIXME remove copy ctor and assignment operator as private to avoid double free of the vector +public: + DefaultValueHolder () { + type = T_NONE; + } + + DefaultValueHolder (double d) { + type = T_DOUBLE; + value.d_val = d; + } + + DefaultValueHolder (std::vector<double>* d) { + type = T_VECT_DOUBLE; + value.vt_val = d; + } + + DefaultValueHolder (bool d) { + type = T_BOOL; + value.b_val = d; + } + + ~DefaultValueHolder() { + if (type == T_VECT_DOUBLE) + delete value.vt_val; + } + + bool as_bool() { + g_assert (type == T_BOOL); + return value.b_val; + } + + double as_double() { + g_assert (type == T_DOUBLE); + return value.d_val; + } + + std::vector<double>* as_vector() { + g_assert (type == T_VECT_DOUBLE); + return value.vt_val; + } +}; + class AttrWidget { public: + AttrWidget(const SPAttributeEnum a, double value) + : _attr(a), + _default(value) + {} + + AttrWidget(const SPAttributeEnum a, bool value) + : _attr(a), + _default(value) + {} + AttrWidget(const SPAttributeEnum a) - : _attr(a) + : _attr(a), + _default() {} virtual ~AttrWidget() @@ -43,6 +114,7 @@ public: return _signal; } protected: + DefaultValueHolder* get_default() { return &_default; } const gchar* attribute_value(SPObject* o) const { const gchar* name = (const gchar*)sp_attribute_name(_attr); @@ -55,6 +127,7 @@ protected: private: const SPAttributeEnum _attr; + DefaultValueHolder _default; sigc::signal<void> _signal; }; |
