Make ContourdesignControlProtocol::_button_actions private again ...
... and add proper bounds checks.
This commit is contained in:
parent
81dbb977c5
commit
16d6791566
@ -498,6 +498,25 @@ ContourDesignControlProtocol::setup_default_button_actions ()
|
||||
_button_actions.push_back (make_button_action ("Transport/GotoEnd"));
|
||||
}
|
||||
|
||||
const boost::shared_ptr<ButtonBase>
|
||||
ContourDesignControlProtocol::get_button_action (unsigned int index) const
|
||||
{
|
||||
if (index >= _button_actions.size()) {
|
||||
return boost::shared_ptr<ButtonBase>();
|
||||
}
|
||||
return _button_actions[index];
|
||||
}
|
||||
|
||||
void
|
||||
ContourDesignControlProtocol::set_button_action (unsigned int index, const boost::shared_ptr<ButtonBase> btn_act)
|
||||
{
|
||||
if (index >= _button_actions.size()) {
|
||||
return;
|
||||
}
|
||||
_button_actions[index] = btn_act;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ContourDesignControlProtocol::handle_button_press (unsigned short btn)
|
||||
{
|
||||
|
@ -107,6 +107,10 @@ public:
|
||||
bool test_mode () const { return _test_mode; }
|
||||
void set_test_mode (bool tm) { _test_mode = tm; }
|
||||
|
||||
int get_button_count() const { return _button_actions.size(); }
|
||||
const boost::shared_ptr<ButtonBase> get_button_action (unsigned int index) const;
|
||||
void set_button_action (unsigned int index, const boost::shared_ptr<ButtonBase> btn_act);
|
||||
|
||||
JumpDistance jog_distance () const { return _jog_distance; }
|
||||
void set_jog_distance (JumpDistance jd) { _jog_distance = jd; }
|
||||
|
||||
@ -118,8 +122,6 @@ public:
|
||||
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 ();
|
||||
@ -170,6 +172,8 @@ private:
|
||||
std::vector<double> _shuttle_speeds;
|
||||
JumpDistance _jog_distance;
|
||||
|
||||
std::vector<boost::shared_ptr<ButtonBase> > _button_actions;
|
||||
|
||||
mutable ContourDesignGUI* _gui;
|
||||
void build_gui ();
|
||||
|
||||
|
@ -164,9 +164,7 @@ ContourDesignGUI::ContourDesignGUI (ContourDesignControlProtocol& ccp)
|
||||
table->set_row_spacings (6);
|
||||
table->set_col_spacings (6);;
|
||||
|
||||
vector<boost::shared_ptr<ButtonBase> >::const_iterator it;
|
||||
unsigned int btn_idx = 0;
|
||||
for (it = _ccp._button_actions.begin(); it != _ccp._button_actions.end(); ++it) {
|
||||
for (int btn_idx=0; btn_idx < _ccp.get_button_count(); ++btn_idx) {
|
||||
boost::shared_ptr<ArdourButton> b (new ArdourButton (string_compose (_("Setting for button %1"), btn_idx+1),
|
||||
ArdourButton::Element(ArdourButton::Indicator|ArdourButton::Text|ArdourButton::Inactive)));
|
||||
table->attach (*b, 0, 2, btn_idx, btn_idx+1);
|
||||
@ -174,7 +172,10 @@ ContourDesignGUI::ContourDesignGUI (ContourDesignControlProtocol& ccp)
|
||||
|
||||
ButtonConfigWidget* bcw = manage (new ButtonConfigWidget);
|
||||
|
||||
bcw->set_current_config (*it);
|
||||
boost::shared_ptr<ButtonBase> btn_act = _ccp.get_button_action (btn_idx);
|
||||
assert (btn_act);
|
||||
bcw->set_current_config (btn_act);
|
||||
|
||||
bcw->Changed.connect (sigc::bind (sigc::mem_fun (*this, &ContourDesignGUI::update_action), btn_idx, bcw));
|
||||
table->attach (*bcw, 3, 5, btn_idx, btn_idx+1);
|
||||
|
||||
@ -185,7 +186,6 @@ ContourDesignGUI::ContourDesignGUI (ContourDesignControlProtocol& ccp)
|
||||
this->ProButtonsSensitive.connect (sigc::mem_fun (*b, &ArdourButton::set_sensitive));
|
||||
this->ProButtonsSensitive.connect (sigc::mem_fun (*bcw, &ButtonConfigWidget::set_sensitive));
|
||||
}
|
||||
++btn_idx;
|
||||
}
|
||||
|
||||
set_spacing (6);
|
||||
@ -226,12 +226,7 @@ ContourDesignGUI::update_jog_distance ()
|
||||
void
|
||||
ContourDesignGUI::update_action (unsigned int index, ButtonConfigWidget* sender)
|
||||
{
|
||||
if (index >= _ccp._button_actions.size()) {
|
||||
DEBUG_TRACE (DEBUG::ContourDesignControl, string_compose ("ContourDesignGUI::update_action() index out of bounds %1 / %2\n", index, _ccp._button_actions.size()));
|
||||
return;
|
||||
}
|
||||
_ccp._button_actions[index] = sender->get_current_config (_ccp);
|
||||
DEBUG_TRACE (DEBUG::ContourDesignControl, string_compose ("update_action () %1\n", index));
|
||||
_ccp.set_button_action (index, sender->get_current_config (_ccp));
|
||||
}
|
||||
|
||||
void
|
||||
|
Loading…
Reference in New Issue
Block a user