From 3136b20847ea2e2e12f707bdc82fa336f85f4801 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Fri, 24 Aug 2018 16:53:06 +0200 Subject: Cleanup various design patterns. * do not use implicit bool-to-int-cast * avoid C++11 member initialization in header * always use set and access methods, remove public variable --- libs/surfaces/launch_control_xl/controllers.cc | 4 ++-- libs/surfaces/launch_control_xl/gui.cc | 9 ++++----- libs/surfaces/launch_control_xl/launch_control_xl.cc | 16 +++++++++------- libs/surfaces/launch_control_xl/launch_control_xl.h | 11 +++++++---- 4 files changed, 22 insertions(+), 18 deletions(-) diff --git a/libs/surfaces/launch_control_xl/controllers.cc b/libs/surfaces/launch_control_xl/controllers.cc index 4bcfc32fbc..5749b58d48 100644 --- a/libs/surfaces/launch_control_xl/controllers.cc +++ b/libs/surfaces/launch_control_xl/controllers.cc @@ -528,13 +528,13 @@ LaunchControlXL::button_track_mode(TrackMode state) void LaunchControlXL::button_select_left() { - switch_bank (max (0, bank_start - (7 + (LaunchControlXL::use_fader8master)))); + switch_bank (max (0, bank_start - (7 + (fader8master() ? 1 : 0)))); } void LaunchControlXL::button_select_right() { - switch_bank (max (0, bank_start + 7 + (LaunchControlXL::use_fader8master))); + switch_bank (max (0, bank_start + 7 + (fader8master() ? 1 : 0))); } void diff --git a/libs/surfaces/launch_control_xl/gui.cc b/libs/surfaces/launch_control_xl/gui.cc index b4b5f95d36..ad12b9a6b6 100644 --- a/libs/surfaces/launch_control_xl/gui.cc +++ b/libs/surfaces/launch_control_xl/gui.cc @@ -134,7 +134,7 @@ LCXLGUI::LCXLGUI (LaunchControlXL& p) align->set (0.0, 0.5); align->add (fader8master_button); table.attach (*align, 1, 2, row, row+1, AttachOptions(FILL|EXPAND), AttachOptions (0),0,0); - fader8master_button.set_active(lcxl.use_fader8master); + fader8master_button.set_active (lcxl.fader8master()); fader8master_button.signal_toggled().connect (sigc::mem_fun (*this, &LCXLGUI::toggle_fader8master)); row++; @@ -285,8 +285,7 @@ LCXLGUI::active_port_changed (Gtk::ComboBox* combo, bool for_input) void LCXLGUI::toggle_fader8master () { - DEBUG_TRACE(DEBUG::LaunchControlXL, string_compose("use_fader8master WAS: %1\n", lcxl.use_fader8master)); - lcxl.use_fader8master = !(lcxl.use_fader8master); - DEBUG_TRACE(DEBUG::LaunchControlXL, string_compose("use_fader8master IS: %1\n", lcxl.use_fader8master)); - lcxl.set_fader8master(lcxl.use_fader8master); + DEBUG_TRACE(DEBUG::LaunchControlXL, string_compose("use_fader8master WAS: %1\n", lcxl.fader8master())); + lcxl.set_fader8master (!lcxl.fader8master()); + DEBUG_TRACE(DEBUG::LaunchControlXL, string_compose("use_fader8master IS: %1\n", lcxl.fader8master())); } diff --git a/libs/surfaces/launch_control_xl/launch_control_xl.cc b/libs/surfaces/launch_control_xl/launch_control_xl.cc index dc2cd2bfa1..fa402afd6c 100644 --- a/libs/surfaces/launch_control_xl/launch_control_xl.cc +++ b/libs/surfaces/launch_control_xl/launch_control_xl.cc @@ -69,6 +69,7 @@ LaunchControlXL::LaunchControlXL (ARDOUR::Session& s) , in_use (false) , _track_mode(TrackMute) , _template_number(8) // default template (factory 1) + , _fader8master (false) , bank_start (0) , connection_state (ConnectionState (0)) , gui (0) @@ -148,8 +149,8 @@ LaunchControlXL::begin_using_device () in_use = true; - DEBUG_TRACE (DEBUG::LaunchControlXL, string_compose("use_fader8master inital value '%1'\n", use_fader8master)); - set_fader8master(use_fader8master); + DEBUG_TRACE (DEBUG::LaunchControlXL, string_compose("fader8master inital value '%1'\n", fader8master())); + set_fader8master (fader8master()); return 0; } @@ -656,7 +657,7 @@ LaunchControlXL::get_state() node.add_child_nocopy (*child); child = new XMLNode (X_("Configuration")); - child->set_property ("fader8master", LaunchControlXL::use_fader8master); + child->set_property ("fader8master", fader8master()); node.add_child_nocopy (*child); return node; @@ -691,7 +692,7 @@ LaunchControlXL::set_state (const XMLNode & node, int version) if ((child = node.child (X_("Configuration"))) !=0) { /* this should propably become a for-loop at some point */ - child->get_property ("fader8master", use_fader8master); + child->get_property ("fader8master", _fader8master); } return retval; @@ -854,7 +855,7 @@ LaunchControlXL::switch_bank (uint32_t base) uint32_t different = 0; uint8_t stripable_counter; - if (LaunchControlXL::use_fader8master) { + if (fader8master ()) { stripable_counter = 7; } else { stripable_counter = 8; @@ -938,8 +939,9 @@ void LaunchControlXL::set_track_mode (TrackMode mode) { void LaunchControlXL::set_fader8master (bool yn) { - if (yn) { + _fader8master = yn; + if (_fader8master) { stripable[7] = master; } - switch_bank(bank_start); + switch_bank (bank_start); } diff --git a/libs/surfaces/launch_control_xl/launch_control_xl.h b/libs/surfaces/launch_control_xl/launch_control_xl.h index bfd0bafddc..16c3d50f0a 100644 --- a/libs/surfaces/launch_control_xl/launch_control_xl.h +++ b/libs/surfaces/launch_control_xl/launch_control_xl.h @@ -63,7 +63,8 @@ class LCXLGUI; class LaunchControlMenu; class LaunchControlXL : public ARDOUR::ControlProtocol, - public AbstractUI { + public AbstractUI +{ public: enum TrackMode { TrackMute, @@ -335,8 +336,6 @@ public: void *get_gui() const; void tear_down_gui(); - bool use_fader8master = false; - int set_active(bool yn); XMLNode &get_state(); int set_state(const XMLNode &node, int version); @@ -354,7 +353,9 @@ public: void write(const MidiByteArray &); void reset(uint8_t chan); + void set_fader8master (bool yn); + bool fader8master () const { return _fader8master; } TrackMode track_mode() const { return _track_mode; } void set_track_mode(TrackMode mode); @@ -366,6 +367,8 @@ private: TrackMode _track_mode; uint8_t _template_number; + bool _fader8master; + void do_request(LaunchControlRequest *); int begin_using_device(); @@ -538,7 +541,7 @@ private: void stripable_selection_changed(); bool in_range_select; - }; +}; } // namespace ArdourSurface -- cgit v1.2.3