1 // SPDX-License-Identifier: GPL-2.0-or-later 2 /* 3 * Author: 4 * Nicholas Bishop <nicholasbishop@gmail.com> 5 * 6 * Copyright (C) 2007 Author 7 * 8 * Released under GNU GPL v2+, read the file 'COPYING' for more information. 9 */ 10 11 #ifndef INKSCAPE_UI_WIDGET_SPIN_SLIDER_H 12 #define INKSCAPE_UI_WIDGET_SPIN_SLIDER_H 13 14 #include <gtkmm/adjustment.h> 15 #include <gtkmm/box.h> 16 #include <gtkmm/scale.h> 17 #include <gtkmm/togglebutton.h> 18 #include "spinbutton.h" 19 #include "attr-widget.h" 20 21 namespace Inkscape { 22 namespace UI { 23 namespace Widget { 24 25 /** 26 * Groups an HScale and a SpinButton together using the same Adjustment. 27 */ 28 class SpinSlider : public Gtk::Box, public AttrWidget 29 { 30 public: 31 SpinSlider(double value, double lower, double upper, double step_inc, 32 double climb_rate, int digits, const SPAttr a = SPAttr::INVALID, const char* tip_text = nullptr); 33 34 Glib::ustring get_as_attribute() const override; 35 void set_from_attribute(SPObject*) override; 36 37 // Shortcuts to _adjustment 38 Glib::SignalProxy0<void> signal_value_changed(); 39 double get_value() const; 40 void set_value(const double); 41 42 const Gtk::Scale& get_scale() const; 43 Gtk::Scale& get_scale(); 44 45 const Inkscape::UI::Widget::SpinButton& get_spin_button() const; 46 Inkscape::UI::Widget::SpinButton& get_spin_button(); 47 48 // Change the SpinSlider into a SpinButton with AttrWidget support) 49 void remove_scale(); 50 private: 51 Glib::RefPtr<Gtk::Adjustment> _adjustment; 52 Gtk::Scale _scale; 53 Inkscape::UI::Widget::SpinButton _spin; 54 55 public: 56 const decltype(_adjustment) get_adjustment() const; 57 decltype(_adjustment) get_adjustment(); 58 }; 59 60 /** 61 * Contains two SpinSliders for controlling number-opt-number attributes. 62 * 63 * @see SpinSlider 64 */ 65 class DualSpinSlider : public Gtk::Box, public AttrWidget 66 { 67 public: 68 DualSpinSlider(double value, double lower, double upper, double step_inc, 69 double climb_rate, int digits, const SPAttr, char* tip_text1, char* tip_text2); 70 71 Glib::ustring get_as_attribute() const override; 72 void set_from_attribute(SPObject*) override; 73 74 sigc::signal<void>& signal_value_changed(); 75 76 const SpinSlider& get_spinslider1() const; 77 SpinSlider& get_spinslider1(); 78 79 const SpinSlider& get_spinslider2() const; 80 SpinSlider& get_spinslider2(); 81 82 void remove_scale(); 83 private: 84 void link_toggled(); 85 void update_linked(); 86 sigc::signal<void> _signal_value_changed; 87 SpinSlider _s1, _s2; 88 Gtk::ToggleButton _link; 89 }; 90 91 } // namespace Widget 92 } // namespace UI 93 } // namespace Inkscape 94 95 #endif // INKSCAPE_UI_WIDGET_SPIN_SLIDER_H 96 97 /* 98 Local Variables: 99 mode:c++ 100 c-file-style:"stroustrup" 101 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) 102 indent-tabs-mode:nil 103 fill-column:99 104 End: 105 */ 106 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : 107