fix design and implementation of (GUI) transport controllables to make them usable with MIDI CC control
The old code meant that their current value was always zero, and that they would do nothing unless the new value exceeded 0.5
This commit is contained in:
parent
1983f56592
commit
38c61b6dab
|
@ -163,6 +163,14 @@ ARDOUR_UI::set_session (Session *s)
|
|||
transport_masters_window->set_session (s);
|
||||
rc_option_editor->set_session (s);
|
||||
|
||||
roll_controllable->set_session (s);
|
||||
stop_controllable->set_session (s);
|
||||
goto_start_controllable->set_session (s);
|
||||
goto_end_controllable->set_session (s);
|
||||
auto_loop_controllable->set_session (s);
|
||||
play_selection_controllable->set_session (s);
|
||||
rec_controllable->set_session (s);
|
||||
|
||||
/* allow wastebasket flush again */
|
||||
|
||||
Glib::RefPtr<Action> act = ActionManager::get_action (X_("Main"), X_("FlushWastebasket"));
|
||||
|
|
|
@ -16,12 +16,15 @@
|
|||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#include "pbd/i18n.h"
|
||||
|
||||
#include "ardour/location.h"
|
||||
#include "ardour/session.h"
|
||||
|
||||
#include "actions.h"
|
||||
#include "ardour_ui.h"
|
||||
#include "transport_control.h"
|
||||
|
||||
#include "pbd/i18n.h"
|
||||
|
||||
using namespace Gtk;
|
||||
|
||||
TransportControlProvider::TransportControlProvider ()
|
||||
|
@ -43,7 +46,7 @@ TransportControlProvider::TransportControllable::TransportControllable (std::str
|
|||
void
|
||||
TransportControlProvider::TransportControllable::set_value (double val, PBD::Controllable::GroupControlDisposition /*group_override*/)
|
||||
{
|
||||
if (val < 0.5) {
|
||||
if (val == 0.0) {
|
||||
/* do nothing: these are radio-style actions */
|
||||
return;
|
||||
}
|
||||
|
@ -86,3 +89,40 @@ TransportControlProvider::TransportControllable::set_value (double val, PBD::Con
|
|||
act->activate ();
|
||||
}
|
||||
}
|
||||
|
||||
double
|
||||
TransportControlProvider::TransportControllable::get_value () const
|
||||
{
|
||||
if (!_session) {
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
ARDOUR::Location* rloc;
|
||||
|
||||
switch (type) {
|
||||
case Roll:
|
||||
return (_session->transport_rolling() ? 1.0 : 0.0);
|
||||
case Stop:
|
||||
return (!_session->transport_rolling() ? 1.0 : 0.0);
|
||||
case GotoStart:
|
||||
if ((rloc = _session->locations()->session_range_location()) != 0) {
|
||||
return (_session->transport_sample() == rloc->start() ? 1.0 : 0.0);
|
||||
}
|
||||
return 0.0;
|
||||
case GotoEnd:
|
||||
if ((rloc = _session->locations()->session_range_location()) != 0) {
|
||||
return (_session->transport_sample() == rloc->end() ? 1.0 : 0.0);
|
||||
}
|
||||
return 0.0;
|
||||
case AutoLoop:
|
||||
return ((_session->get_play_loop() && _session->transport_rolling())? 1.0 : 0.0);
|
||||
case PlaySelection:
|
||||
return ((_session->transport_rolling() && _session->get_play_range()) ? 1.0 : 0.0);
|
||||
case RecordEnable:
|
||||
return (_session->actively_recording() ? 1.0 : 0.0);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return 0.0;
|
||||
}
|
||||
|
|
|
@ -22,6 +22,8 @@
|
|||
#include <gtkmm/widget.h>
|
||||
#include "pbd/controllable.h"
|
||||
|
||||
#include "ardour/session_handle.h"
|
||||
|
||||
/* This is an API implemenetd by AROUR_UI,
|
||||
* and made available to transport-control-UIs
|
||||
*/
|
||||
|
@ -34,7 +36,7 @@ public:
|
|||
/* show metronome preferences */
|
||||
virtual bool click_button_clicked (GdkEventButton *) = 0;
|
||||
|
||||
struct TransportControllable : public PBD::Controllable {
|
||||
struct TransportControllable : public PBD::Controllable, public ARDOUR::SessionHandlePtr {
|
||||
enum ToggleType {
|
||||
Roll = 0,
|
||||
Stop,
|
||||
|
@ -47,7 +49,7 @@ public:
|
|||
|
||||
TransportControllable (std::string name, ToggleType);
|
||||
void set_value (double, PBD::Controllable::GroupControlDisposition group_override);
|
||||
double get_value (void) const { return 0; }
|
||||
double get_value (void) const;
|
||||
|
||||
ToggleType type;
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue
Block a user