diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2016-09-23 15:23:47 -0500 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2016-09-27 14:59:32 -0500 |
commit | feafcbf61d4ef04a1a0c84fc2b0d764f7c232d06 (patch) | |
tree | 2daee1a4f2680a273ee32c7ae97829532abc9b16 /libs/surfaces/push2 | |
parent | 7594e7644ab2c3f7b697d518c5747d542b9edbdf (diff) |
fix various aspects of knob function
Diffstat (limited to 'libs/surfaces/push2')
-rw-r--r-- | libs/surfaces/push2/knob.cc | 59 | ||||
-rw-r--r-- | libs/surfaces/push2/knob.h | 11 |
2 files changed, 38 insertions, 32 deletions
diff --git a/libs/surfaces/push2/knob.cc b/libs/surfaces/push2/knob.cc index 29dffe31bb..270aca913b 100644 --- a/libs/surfaces/push2/knob.cc +++ b/libs/surfaces/push2/knob.cc @@ -29,6 +29,7 @@ #include "gtkmm2ext/rgb_macros.h" #include "canvas/colors.h" +#include "canvas/text.h" #include "knob.h" #include "push2.h" @@ -44,18 +45,19 @@ using namespace ArdourCanvas; Push2Knob::Element Push2Knob::default_elements = Push2Knob::Element (Push2Knob::Arc); Push2Knob::Push2Knob (Push2& p, Item* parent, Element e, Flags flags) - : Item (parent) + : Container (parent) , p2 (p) , _elements (e) , _flags (flags) , _r (0) , _val (0) , _normal (0) - , text (this) { Pango::FontDescription fd ("Sans 10"); - text.set_font_description (fd); - text.set_position (Duple (0, -20)); /* changed when radius changes */ + + text = new Text (this); + text->set_font_description (fd); + text->set_position (Duple (0, -20)); /* changed when radius changes */ /* typically over-ridden */ @@ -71,36 +73,19 @@ Push2Knob::~Push2Knob () void Push2Knob::set_text_color (Color c) { - text.set_color (c); + text->set_color (c); } void Push2Knob::set_radius (double r) { _r = r; - text.set_position (Duple (-_r, -_r - 20)); + text->set_position (Duple (-_r, -_r - 20)); + _bounding_box_dirty = true; redraw (); } void -Push2Knob::compute_bounding_box () const -{ - if (!_canvas || _r == 0) { - _bounding_box = boost::optional<Rect> (); - _bounding_box_dirty = false; - return; - } - - if (_bounding_box_dirty) { - Rect r = Rect (0, 0, _r * 2.0, _r * 2.0); - _bounding_box = r; - _bounding_box_dirty = false; - } - - add_child_bounding_boxes (); -} - -void Push2Knob::render (Rect const & area, Cairo::RefPtr<Cairo::Context> context) const { if (!_controllable) { @@ -244,6 +229,24 @@ Push2Knob::render (Rect const & area, Cairo::RefPtr<Cairo::Context> context) con render_children (area, context); } + void +Push2Knob::compute_bounding_box () const +{ + if (!_canvas || _r == 0) { + _bounding_box = boost::optional<Rect> (); + _bounding_box_dirty = false; + return; + } + + if (_bounding_box_dirty) { + Rect r = Rect (_position.x - _r, _position.y - _r, _position.x + _r, _position.y + _r); + _bounding_box = r; + _bounding_box_dirty = false; + } + + add_child_bounding_boxes (); +} + void Push2Knob::set_controllable (boost::shared_ptr<AutomationControl> c) { @@ -273,7 +276,7 @@ Push2Knob::set_pan_azimuth_text (double pos) char buf[64]; snprintf (buf, sizeof (buf), _("L:%3d R:%3d"), (int) rint (100.0 * (1.0 - pos)), (int) rint (100.0 * pos)); - text.set (buf); + text->set (buf); } void @@ -281,7 +284,7 @@ Push2Knob::set_pan_width_text (double val) { char buf[16]; snprintf (buf, sizeof (buf), "%d%%", (int) floor (val*100)); - text.set (buf); + text->set (buf); } void @@ -294,7 +297,7 @@ Push2Knob::set_gain_text (double) */ snprintf (buf, sizeof (buf), "%.1f dB", accurate_coefficient_to_dB (_controllable->get_value())); - text.set (buf); + text->set (buf); } void @@ -319,7 +322,7 @@ Push2Knob::controllable_changed () break; default: - text.set (std::string()); + text->set (std::string()); } } diff --git a/libs/surfaces/push2/knob.h b/libs/surfaces/push2/knob.h index 0ae54d68a1..71cdf8db32 100644 --- a/libs/surfaces/push2/knob.h +++ b/libs/surfaces/push2/knob.h @@ -8,8 +8,11 @@ #include "pbd/signals.h" -#include "canvas/item.h" -#include "canvas/text.h" +#include "canvas/container.h" + +namespace ArdourCanvas { + class Text; +} namespace ARDOUR { class AutomationControl; @@ -24,7 +27,7 @@ namespace ArdourSurface { class Push2; -class Push2Knob : public sigc::trackable, public ArdourCanvas::Item +class Push2Knob : public sigc::trackable, public ArdourCanvas::Container { public: enum Element { @@ -77,7 +80,7 @@ public: ArdourCanvas::Color text_color; ArdourCanvas::Color arc_start_color; ArdourCanvas::Color arc_end_color; - ArdourCanvas::Text text; + ArdourCanvas::Text* text; void set_pan_azimuth_text (double); void set_pan_width_text (double); |