diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2016-07-10 13:02:42 -0400 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2016-09-27 14:59:31 -0500 |
commit | a4324d79a7278d0fb89db3f266b1cdfe6e2ee14b (patch) | |
tree | 279f273f494aecf49764c104869b0fb5d70a89fb /libs | |
parent | 995f3f80bbe963437d0b6365e1a6dee032a454b9 (diff) |
push2: add a little meat to the bones of the TrackMix layout (just a name, for now)
Diffstat (limited to 'libs')
-rw-r--r-- | libs/surfaces/push2/buttons.cc | 16 | ||||
-rw-r--r-- | libs/surfaces/push2/push2.cc | 2 | ||||
-rw-r--r-- | libs/surfaces/push2/push2.h | 2 | ||||
-rw-r--r-- | libs/surfaces/push2/track_mix.cc | 36 | ||||
-rw-r--r-- | libs/surfaces/push2/track_mix.h | 6 |
5 files changed, 60 insertions, 2 deletions
diff --git a/libs/surfaces/push2/buttons.cc b/libs/surfaces/push2/buttons.cc index 19fbfcb513..c33ef8807f 100644 --- a/libs/surfaces/push2/buttons.cc +++ b/libs/surfaces/push2/buttons.cc @@ -25,6 +25,7 @@ #include "layout.h" #include "push2.h" +#include "track_mix.h" using namespace ArdourSurface; using namespace ARDOUR; @@ -176,7 +177,7 @@ Push2::build_maps () MAKE_WHITE_BUTTON (Delete, 118); MAKE_WHITE_BUTTON (AddDevice, 52); MAKE_WHITE_BUTTON (Device, 110); - MAKE_WHITE_BUTTON (Mix, 112); + MAKE_WHITE_BUTTON_PRESS (Mix, 112, &Push2::button_mix_press); MAKE_WHITE_BUTTON_PRESS (Undo, 119, &Push2::button_undo); MAKE_WHITE_BUTTON_PRESS (AddTrack, 53, &Push2::button_add_track); MAKE_WHITE_BUTTON_PRESS (Browse, 111, &Push2::button_browse); @@ -547,3 +548,16 @@ Push2::button_scale_press () _current_layout = mix_layout; } } + +void +Push2::button_mix_press () +{ + if (_current_layout == track_mix_layout) { + _current_layout = mix_layout; + } else { + if (ControlProtocol::first_selected_stripable()) { + dynamic_cast<TrackMixLayout*> (track_mix_layout)->set_stripable (ControlProtocol::first_selected_stripable()); + _current_layout = track_mix_layout; + } + } +} diff --git a/libs/surfaces/push2/push2.cc b/libs/surfaces/push2/push2.cc index 16cd0a6f82..aea91ddc38 100644 --- a/libs/surfaces/push2/push2.cc +++ b/libs/surfaces/push2/push2.cc @@ -267,6 +267,8 @@ Push2::open () mix_layout = new MixLayout (*this, *session, context); scale_layout = new ScaleLayout (*this, *session, context); + track_mix_layout = new TrackMixLayout (*this, *session, context); + _current_layout = mix_layout; return 0; diff --git a/libs/surfaces/push2/push2.h b/libs/surfaces/push2/push2.h index 1132435318..b94126867d 100644 --- a/libs/surfaces/push2/push2.h +++ b/libs/surfaces/push2/push2.h @@ -446,6 +446,7 @@ class Push2 : public ARDOUR::ControlProtocol void button_octave_down (); void button_layout_press (); void button_scale_press (); + void button_mix_press (); void button_upper (uint32_t n); void button_lower (uint32_t n); @@ -494,6 +495,7 @@ class Push2 : public ARDOUR::ControlProtocol Push2Layout* drawn_layout; Push2Layout* mix_layout; Push2Layout* scale_layout; + Push2Layout* track_mix_layout; bool pad_filter (ARDOUR::MidiBuffer& in, ARDOUR::MidiBuffer& out) const; diff --git a/libs/surfaces/push2/track_mix.cc b/libs/surfaces/push2/track_mix.cc index 36af9dbf34..181f374c8e 100644 --- a/libs/surfaces/push2/track_mix.cc +++ b/libs/surfaces/push2/track_mix.cc @@ -56,6 +56,10 @@ TrackMixLayout::TrackMixLayout (Push2& p, Session& s, Cairo::RefPtr<Cairo::Conte : Push2Layout (p, s) , _dirty (false) { + name_layout = Pango::Layout::create (context); + + Pango::FontDescription fd ("Sans Bold 24"); + name_layout->set_font_description (fd); } TrackMixLayout::~TrackMixLayout () @@ -65,11 +69,20 @@ TrackMixLayout::~TrackMixLayout () bool TrackMixLayout::redraw (Cairo::RefPtr<Cairo::Context> context) const { + if (!_dirty) { + return false; + } + context->set_source_rgb (0.764, 0.882, 0.882); context->rectangle (0, 0, 960, 160); context->fill (); - return false; + context->set_source_rgb (0.23, 0.0, 0.349); + context->move_to (10, 2); + name_layout->update_from_cairo_context (context); + name_layout->show_in_cairo_context (context); + + return true; } void @@ -96,5 +109,26 @@ void TrackMixLayout::set_stripable (boost::shared_ptr<Stripable> s) { stripable = s; + + if (stripable) { + stripable->DropReferences.connect (stripable_connections, MISSING_INVALIDATOR, boost::bind (&TrackMixLayout::drop_stripable, this), &p2); + name_changed (); + } + + _dirty = true; +} + +void +TrackMixLayout::drop_stripable () +{ + stripable_connections.drop_connections (); + stripable.reset (); + _dirty = true; +} + +void +TrackMixLayout::name_changed () +{ + name_layout->set_text (stripable->name()); _dirty = true; } diff --git a/libs/surfaces/push2/track_mix.h b/libs/surfaces/push2/track_mix.h index bbcdc0210a..54081c115c 100644 --- a/libs/surfaces/push2/track_mix.h +++ b/libs/surfaces/push2/track_mix.h @@ -45,7 +45,13 @@ class TrackMixLayout : public Push2Layout private: boost::shared_ptr<ARDOUR::Stripable> stripable; + PBD::ScopedConnectionList stripable_connections; bool _dirty; + + Glib::RefPtr<Pango::Layout> name_layout; + + void drop_stripable (); + void name_changed (); }; } /* namespace */ |