trigger_ui: TriggerEntry is-a TriggerUI

This commit is contained in:
Ben Loftis 2021-12-30 12:10:50 -06:00
parent f35020fc59
commit c5b6d7f9d2
7 changed files with 51 additions and 50 deletions

View File

@ -716,7 +716,7 @@ Editor::Editor ()
VBox* summary_arrows_right = manage (new VBox);
summary_arrows_right->pack_start (*summary_arrow_right);
Frame* summary_frame = manage (new Frame);
Gtk::Frame* summary_frame = manage (new Gtk::Frame);
summary_frame->set_shadow_type (Gtk::SHADOW_ETCHED_IN);
summary_frame->add (*_summary);

View File

@ -347,7 +347,7 @@ SlotPropertyTable::set_follow_action (Trigger::FollowAction fa, uint64_t idx)
}
void
SlotPropertyTable::on_trigger_changed (PropertyChange pc)
SlotPropertyTable::on_trigger_changed (PropertyChange const& pc)
{
if (pc.contains (Properties::name)) {
_name_label.set_text (trigger()->name());

View File

@ -90,7 +90,7 @@ class SlotPropertyTable : public TriggerUI, public Gtk::Table
void set_launch_style (ARDOUR::Trigger::LaunchStyle);
void set_follow_action (ARDOUR::Trigger::FollowAction, uint64_t);
void on_trigger_changed (PBD::PropertyChange);
void on_trigger_changed (PBD::PropertyChange const& );
bool follow_action_button_event (GdkEvent*);
bool legato_button_event (GdkEvent*);

View File

@ -97,8 +97,23 @@ TriggerUI::TriggerUI ()
TriggerUI::~TriggerUI()
{
trigger_swap_connection.disconnect ();
trigger_connections.disconnect ();
}
void
TriggerUI::trigger_swap (uint32_t n)
{
if (n != tref.slot) {
/* some other slot in the same box got swapped. we don't care */
return;
}
trigger_connections.disconnect ();
trigger()->PropertyChanged.connect (trigger_connections, MISSING_INVALIDATOR, boost::bind (&TriggerEntry::trigger_changed, this, _1), gui_context ());
trigger_changed (Properties::name);
}
void
TriggerUI::setup_actions_and_bindings ()
{
@ -458,7 +473,7 @@ TriggerUI::trigger() const
}
void
TriggerUI::trigger_changed (PropertyChange what)
TriggerUI::trigger_changed (PropertyChange const& what)
{
on_trigger_changed(what);
}
@ -467,6 +482,9 @@ TriggerUI::trigger_changed (PropertyChange what)
void
TriggerUI::set_trigger (ARDOUR::TriggerReference tr)
{
// trigger_connections.clear();
// trigger_swap_connection.clear();
tref = tr;
PropertyChange pc;
@ -486,4 +504,6 @@ TriggerUI::set_trigger (ARDOUR::TriggerReference tr)
trigger_changed (pc);
trigger()->PropertyChanged.connect (trigger_connections, MISSING_INVALIDATOR, boost::bind (&TriggerUI::trigger_changed, this, _1), gui_context());
tref.box->TriggerSwapped.connect (trigger_swap_connection, MISSING_INVALIDATOR, boost::bind (&TriggerUI::trigger_swap, this, _1), gui_context ());
}

View File

@ -29,6 +29,12 @@
#include "widgets/slider_controller.h"
#include "widgets/frame.h"
namespace Gtk
{
class FileChooserDialog;
class Menu;
}
class TriggerUI
{
public:
@ -37,7 +43,7 @@ public:
void set_trigger (ARDOUR::TriggerReference);
virtual void on_trigger_changed (PBD::PropertyChange) = 0;
virtual void on_trigger_changed (PBD::PropertyChange const& ) = 0;
static std::string follow_action_to_string (ARDOUR::Trigger::FollowAction);
static ARDOUR::Trigger::FollowAction string_to_follow_action (std::string const &);
@ -53,8 +59,11 @@ public:
static void setup_actions_and_bindings ();
ARDOUR::TriggerReference trigger_reference() const { return tref; }
ARDOUR::TriggerPtr trigger() const;
private:
void trigger_changed (PBD::PropertyChange); //calls on_trigger_changed to subclasses
void trigger_changed (PBD::PropertyChange const& ); //calls on_trigger_changed to subclasses
/* Actions for Triggers: accessed via ardour_ui and shortcuts and lua */
static Glib::RefPtr<Gtk::ActionGroup> trigger_actions;
@ -92,9 +101,11 @@ protected:
sigc::connection _file_chooser_connection;
Gtk::FileChooserDialog* _file_chooser;
void trigger_swap (uint32_t);
PBD::ScopedConnection trigger_swap_connection;
ARDOUR::TriggerReference tref;
ARDOUR::TriggerPtr trigger() const;
PBD::ScopedConnectionList trigger_connections;
PBD::ScopedConnection trigger_connections;
};

View File

@ -66,18 +66,17 @@ using namespace PBD;
TriggerEntry::TriggerEntry (Item* item, TriggerReference tr)
: ArdourCanvas::Rectangle (item)
, tref (tr)
{
set_layout_sensitive (true); // why???
name = string_compose ("trigger %1", tref.slot);
name = string_compose ("trigger %1", tr.slot);
set_outline (false);
play_button = new ArdourCanvas::Rectangle (this);
play_button->set_outline (false);
play_button->set_fill (true);
play_button->name = string_compose ("playbutton %1", tref.slot);
play_button->name = string_compose ("playbutton %1", tr.slot);
play_button->show ();
follow_button = new ArdourCanvas::Rectangle (this);
@ -96,19 +95,15 @@ TriggerEntry::TriggerEntry (Item* item, TriggerReference tr)
name_text->set_ignore_events (false);
name_text->show ();
/* this will trigger a call to on_trigger_changed() */
set_trigger(tr);
/* watch for change in theme */
UIConfiguration::instance ().ParameterChanged.connect (sigc::mem_fun (*this, &TriggerEntry::ui_parameter_changed));
set_default_colors ();
trigger()->PropertyChanged.connect (trigger_prop_connection, MISSING_INVALIDATOR, boost::bind (&TriggerEntry::prop_change, this, _1), gui_context ());
tref.box->TriggerSwapped.connect (trigger_swap_connection, MISSING_INVALIDATOR, boost::bind (&TriggerEntry::trigger_swap, this, _1), gui_context ());
dynamic_cast<Stripable*> (tref.box->owner ())->presentation_info ().Change.connect (owner_prop_connection, MISSING_INVALIDATOR, boost::bind (&TriggerEntry::owner_prop_change, this, _1), gui_context ());
PropertyChange changed;
changed.add (ARDOUR::Properties::name);
changed.add (ARDOUR::Properties::running);
prop_change (changed);
selection_change ();
}
@ -116,18 +111,6 @@ TriggerEntry::~TriggerEntry ()
{
}
void
TriggerEntry::trigger_swap (uint32_t n)
{
if (n != tref.slot) {
/* some other slot in the same box got swapped. we don't care */
return;
}
trigger_prop_connection.disconnect ();
trigger()->PropertyChanged.connect (trigger_prop_connection, MISSING_INVALIDATOR, boost::bind (&TriggerEntry::prop_change, this, _1), gui_context ());
prop_change (Properties::name);
}
void
TriggerEntry::owner_prop_change (PropertyChange const& pc)
{
@ -420,7 +403,7 @@ TriggerEntry::render (ArdourCanvas::Rect const& area, Cairo::RefPtr<Cairo::Conte
}
void
TriggerEntry::prop_change (PropertyChange const& change)
TriggerEntry::on_trigger_changed (PropertyChange const& change)
{
if (change.contains (ARDOUR::Properties::name)) {
if (trigger()->region ()) {
@ -1175,6 +1158,8 @@ TriggerBoxUI::rapid_update ()
}
}
/* ********************************************** */
TriggerBoxWidget::TriggerBoxWidget (float w, float h)
: FittedCanvasWidget (w, h)
, ui (0)

View File

@ -30,11 +30,7 @@
#include "fitted_canvas_widget.h"
namespace Gtk
{
class FileChooserDialog;
class Menu;
}
#include "trigger_ui.h"
namespace Temporal
{
@ -47,18 +43,12 @@ namespace ArdourCanvas
class Polygon;
}
class TriggerEntry : public ArdourCanvas::Rectangle
class TriggerEntry : public ArdourCanvas::Rectangle, public TriggerUI
{
public:
TriggerEntry (ArdourCanvas::Item* item, ARDOUR::TriggerReference rf);
~TriggerEntry ();
boost::shared_ptr<ARDOUR::Trigger> trigger () const
{
return tref.trigger();
}
ARDOUR::TriggerReference trigger_reference() const { return tref; }
ArdourCanvas::Rectangle* play_button;
ArdourCanvas::Rectangle* name_button;
ArdourCanvas::Rectangle* follow_button;
@ -72,21 +62,16 @@ public:
void _size_allocate (ArdourCanvas::Rect const&);
void maybe_update ();
void on_trigger_changed (PBD::PropertyChange const& change);
void selection_change ();
void set_default_colors ();
private:
ARDOUR::TriggerReference tref;
double _poly_size;
double _poly_margin;
PBD::ScopedConnection trigger_prop_connection;
PBD::ScopedConnection trigger_swap_connection;
void prop_change (PBD::PropertyChange const& change);
void trigger_swap (uint32_t);
PBD::ScopedConnection owner_prop_connection;
void owner_prop_change (PBD::PropertyChange const&);
void owner_color_changed ();