1 /*
2 * Filter effect selection selection widget
3 *
4 * Author:
5 * Nicholas Bishop <nicholasbishop@gmail.com>
6 *
7 * Copyright (C) 2007 Authors
8 *
9 * Released under GNU GPL, read the file 'COPYING' for more information
10 */
12 #include <glibmm/i18n.h>
14 #include "desktop.h"
15 #include "desktop-handles.h"
16 #include "document.h"
17 #include "filter-effect-chooser.h"
18 #include "inkscape.h"
20 namespace Inkscape {
21 namespace UI {
22 namespace Widget {
24 SimpleFilterModifier::SimpleFilterModifier(int flags)
25 : _lb_blend(_("_Blend mode:")),
26 _lb_blur(_("_Blur:"), Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER, true),
27 _blend(BlendModeConverter, SP_ATTR_INVALID, false),
28 _blur(0, 0, 100, 1, 0.01, 1)
29 {
30 _flags = flags;
32 if (flags & BLEND) {
33 add(_hb_blend);
34 _hb_blend.pack_start(_lb_blend, false, false);
35 _hb_blend.pack_start(_blend);
36 }
37 if (flags & BLUR) {
38 add(_vb_blur);
39 _vb_blur.add(_lb_blur);
40 _vb_blur.add(_blur);
41 }
43 show_all_children();
45 _hb_blend.set_spacing(12);
46 _lb_blend.set_use_underline();
47 _lb_blend.set_mnemonic_widget(_blend);
48 _lb_blur.set_use_underline();
49 _lb_blur.set_mnemonic_widget(_blur.get_scale());
50 _blend.signal_changed().connect(signal_blend_blur_changed());
51 _blur.set_update_policy(Gtk::UPDATE_DELAYED);
52 _blur.signal_value_changed().connect(signal_blend_blur_changed());
53 }
55 sigc::signal<void>& SimpleFilterModifier::signal_blend_blur_changed()
56 {
57 return _signal_blend_blur_changed;
58 }
60 const Glib::ustring SimpleFilterModifier::get_blend_mode()
61 {
62 if (!(_flags & BLEND)) {
63 return "normal";
64 }
65 if (_blend.get_active_row_number() == 5) {
66 return "normal";
67 } else {
68 const Util::EnumData<Inkscape::Filters::FilterBlendMode> *d = _blend.get_active_data();
69 if (d) {
70 return _blend.get_active_data()->key;
71 } else
72 return "normal";
73 }
74 }
76 void SimpleFilterModifier::set_blend_mode(const int val)
77 {
78 _blend.set_active(val);
79 }
81 double SimpleFilterModifier::get_blur_value() const
82 {
83 return _blur.get_value();
84 }
86 void SimpleFilterModifier::set_blur_value(const double val)
87 {
88 _blur.set_value(val);
89 }
91 void SimpleFilterModifier::set_blur_sensitive(const bool s)
92 {
93 _blur.set_sensitive(s);
94 }
96 }
97 }
98 }
100 /*
101 Local Variables:
102 mode:c++
103 c-file-style:"stroustrup"
104 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
105 indent-tabs-mode:nil
106 fill-column:99
107 End:
108 */
109 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :