Shuttle Surface: Fix C++ style: use accessor/setter methods

This also fixes C++ compat: no forward declaration of friend classes
(OSX compilation) and C++98 compat (enums are not classes e.g. ActiveState)
This commit is contained in:
Robin Gareus 2019-05-25 16:45:53 +02:00
parent 4cd379f89b
commit 3546a7291b
No known key found for this signature in database
GPG key ID: A090BCE02CF57F04
3 changed files with 47 additions and 21 deletions

View file

@ -570,6 +570,15 @@ void ContourDesignControlProtocol::jump_backward (JumpDistance dist)
jump_forward(bw);
}
void
ContourDesignControlProtocol::set_shuttle_speed (int index, double speed)
{
/* called from GUI thread */
// XXX this may race with ContourDesignControlProtocol::shuttle_event()
// TODO: add bounds check
_shuttle_speeds[index] = speed;
}
void
ContourDesignControlProtocol::shuttle_event(int position)
{

View file

@ -65,7 +65,6 @@ class ContourDesignControlProtocol
: public ARDOUR::ControlProtocol
, public AbstractUI<ContourDesignControlUIRequest>
{
friend ContourDesignGUI;
public:
ContourDesignControlProtocol (ARDOUR::Session &);
virtual ~ContourDesignControlProtocol ();
@ -99,6 +98,27 @@ public:
boost::shared_ptr<ButtonBase> make_button_action (std::string action_string);
int usb_errorcode () const { return _error; }
bool keep_rolling () const { return _keep_rolling; }
void set_keep_rolling (bool kr) { _keep_rolling = kr; }
bool test_mode () const { return _test_mode; }
void set_test_mode (bool tm) { _test_mode = tm; }
JumpDistance jog_distance () const { return _jog_distance; }
void set_jog_distance (JumpDistance jd) { _jog_distance = jd; }
void set_shuttle_speed (int index, double speed);
double shuttle_speed (int index) const {
return _shuttle_speeds[index];
}
PBD::Signal1<void, unsigned short> ButtonPress;
PBD::Signal1<void, unsigned short> ButtonRelease;
std::vector<boost::shared_ptr<ButtonBase> > _button_actions; // XXX TODO: use accessor/setter methods
private:
void do_request (ContourDesignControlUIRequest*);
void start ();
@ -113,6 +133,7 @@ private:
int acquire_device ();
void release_device ();
void setup_default_button_actions ();
void handle_button_press (unsigned short btn);
void handle_button_release (unsigned short btn);
@ -141,8 +162,6 @@ private:
State _state;
bool _test_mode;
PBD::Signal1<void, unsigned short> ButtonPress;
PBD::Signal1<void, unsigned short> ButtonRelease;
// Config stuff
@ -150,9 +169,6 @@ private:
std::vector<double> _shuttle_speeds;
JumpDistance _jog_distance;
std::vector<boost::shared_ptr<ButtonBase> > _button_actions;
void setup_default_button_actions ();
mutable ContourDesignGUI* _gui;
void build_gui ();

View file

@ -100,7 +100,7 @@ ContourDesignGUI::ContourDesignGUI (ContourDesignControlProtocol& ccp)
: _ccp (ccp)
, _test_button (_("Button Test"), ArdourButton::led_default_elements)
, _keep_rolling (_("Keep rolling after jumps"))
, _jog_distance (ccp._jog_distance)
, _jog_distance (ccp.jog_distance ())
, _device_state_lbl ()
{
Frame* dg_sample = manage (new Frame (_("Device")));
@ -123,7 +123,7 @@ ContourDesignGUI::ContourDesignGUI (ContourDesignControlProtocol& ccp)
HBox* speed_box = manage (new HBox);
for (int i=0; i != ContourDesignControlProtocol::num_shuttle_speeds; ++i) {
double speed = ccp._shuttle_speeds[i];
double speed = ccp.shuttle_speed (i);
boost::shared_ptr<Gtk::Adjustment> adj (new Gtk::Adjustment (speed, 0.0, 100.0, 0.25));
_shuttle_speed_adjustments.push_back (adj);
SpinButton* sb = manage (new SpinButton (*adj, 0.25, 2));
@ -140,7 +140,7 @@ ContourDesignGUI::ContourDesignGUI (ContourDesignControlProtocol& ccp)
_keep_rolling.set_tooltip_text (_("If checked Ardour keeps rolling after jog or shuttle events. If unchecked it stops."));
_keep_rolling.signal_toggled().connect (sigc::mem_fun (*this, &ContourDesignGUI::toggle_keep_rolling));
_keep_rolling.set_active (_ccp._keep_rolling);
_keep_rolling.set_active (_ccp.keep_rolling ());
sj_table->attach (_keep_rolling, 0,1, 2,3);
@ -207,20 +207,20 @@ ContourDesignGUI::ContourDesignGUI (ContourDesignControlProtocol& ccp)
void
ContourDesignGUI::toggle_keep_rolling ()
{
_ccp._keep_rolling = _keep_rolling.get_active();
_ccp.set_keep_rolling (_keep_rolling.get_active ());
}
void
ContourDesignGUI::set_shuttle_speed (int index)
{
double speed = _shuttle_speed_adjustments[index]->get_value ();
_ccp._shuttle_speeds[index] = speed;
_ccp.set_shuttle_speed (index, speed);
}
void
ContourDesignGUI::update_jog_distance ()
{
_ccp._jog_distance = _jog_distance.get_distance ();
_ccp.set_jog_distance (_jog_distance.get_distance ());
}
void
@ -237,9 +237,10 @@ ContourDesignGUI::update_action (unsigned int index, ButtonConfigWidget* sender)
void
ContourDesignGUI::toggle_test_mode ()
{
_ccp._test_mode = !_ccp._test_mode;
if (_ccp._test_mode) {
_test_button.set_active_state (ActiveState::ExplicitActive);
bool testmode = ! _ccp.test_mode(); // toggle
_ccp.set_test_mode (testmode);
if (testmode) {
_test_button.set_active_state (Gtkmm2ext::ExplicitActive);
} else {
reset_test_state ();
}
@ -257,11 +258,11 @@ ContourDesignGUI::init_on_show ()
bool
ContourDesignGUI::reset_test_state (GdkEventAny*)
{
_ccp._test_mode = false;
_test_button.set_active (ActiveState::Off);
_ccp.set_test_mode (false);
_test_button.set_active (Gtkmm2ext::Off);
vector<boost::shared_ptr<ArdourButton> >::const_iterator it;
for (it = _btn_leds.begin(); it != _btn_leds.end(); ++it) {
(*it)->set_active_state (ActiveState::Off);
(*it)->set_active_state (Gtkmm2ext::Off);
}
return false;
@ -270,13 +271,13 @@ ContourDesignGUI::reset_test_state (GdkEventAny*)
void
ContourDesignGUI::test_button_press (unsigned short btn)
{
_btn_leds[btn]->set_active_state (ActiveState::ExplicitActive);
_btn_leds[btn]->set_active_state (Gtkmm2ext::ExplicitActive);
}
void
ContourDesignGUI::test_button_release (unsigned short btn)
{
_btn_leds[btn]->set_active_state (ActiveState::Off);
_btn_leds[btn]->set_active_state (Gtkmm2ext::Off);
}
bool
@ -297,7 +298,7 @@ ContourDesignGUI::update_device_state ()
XpressButtonsSensitive (false);
ProButtonsSensitive (false);
_device_state_lbl.set_markup (string_compose ("<span weight=\"bold\" foreground=\"red\">Device not working:</span> %1",
libusb_strerror ((libusb_error)_ccp._error)));
libusb_strerror ((libusb_error)_ccp.usb_errorcode ())));
}
return false;