13
0

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
This commit is contained in:
Robin Gareus 2018-08-24 16:53:06 +02:00
parent c46cd91d0e
commit 3136b20847
4 changed files with 22 additions and 18 deletions

View File

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

View File

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

View File

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

View File

@ -63,7 +63,8 @@ class LCXLGUI;
class LaunchControlMenu;
class LaunchControlXL : public ARDOUR::ControlProtocol,
public AbstractUI<LaunchControlRequest> {
public AbstractUI<LaunchControlRequest>
{
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