push2: add a little meat to the bones of the TrackMix layout (just a name, for now)

This commit is contained in:
Paul Davis 2016-07-10 13:02:42 -04:00
parent 995f3f80bb
commit a4324d79a7
5 changed files with 60 additions and 2 deletions

View file

@ -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;
}
}
}

View file

@ -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;

View file

@ -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;

View file

@ -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;
}

View file

@ -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 */