Trigger_UI: De-Canvas the trigger_ui widget so it can be reused in other places
This commit is contained in:
parent
d7116c985e
commit
cdce9e120e
@ -27,11 +27,8 @@
|
|||||||
#include "ardour/region.h"
|
#include "ardour/region.h"
|
||||||
#include "ardour/triggerbox.h"
|
#include "ardour/triggerbox.h"
|
||||||
|
|
||||||
#include "canvas/polygon.h"
|
|
||||||
#include "canvas/text.h"
|
|
||||||
#include "canvas/widget.h"
|
|
||||||
|
|
||||||
#include "widgets/ardour_button.h"
|
#include "widgets/ardour_button.h"
|
||||||
|
#include "widgets/slider_controller.h"
|
||||||
|
|
||||||
#include "gtkmm2ext/utils.h"
|
#include "gtkmm2ext/utils.h"
|
||||||
|
|
||||||
@ -45,7 +42,6 @@
|
|||||||
#include "pbd/i18n.h"
|
#include "pbd/i18n.h"
|
||||||
|
|
||||||
using namespace ARDOUR;
|
using namespace ARDOUR;
|
||||||
using namespace ArdourCanvas;
|
|
||||||
using namespace ArdourWidgets;
|
using namespace ArdourWidgets;
|
||||||
using namespace Gtkmm2ext;
|
using namespace Gtkmm2ext;
|
||||||
using namespace PBD;
|
using namespace PBD;
|
||||||
@ -58,10 +54,11 @@ static std::string longest_quantize;
|
|||||||
static std::vector<std::string> launch_strings;
|
static std::vector<std::string> launch_strings;
|
||||||
static std::string longest_launch;
|
static std::string longest_launch;
|
||||||
|
|
||||||
TriggerUI::TriggerUI (Item* parent)
|
TriggerUI::TriggerUI () :
|
||||||
: Table (parent)
|
_follow_percent_adjustment(0,100,1)
|
||||||
, trigger(NULL)
|
|
||||||
{
|
{
|
||||||
|
trigger = NULL;
|
||||||
|
|
||||||
using namespace Gtk::Menu_Helpers;
|
using namespace Gtk::Menu_Helpers;
|
||||||
|
|
||||||
if (follow_strings.empty()) {
|
if (follow_strings.empty()) {
|
||||||
@ -93,72 +90,60 @@ TriggerUI::TriggerUI (Item* parent)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
set_fill_color (UIConfiguration::instance().color (X_("theme:bg")));
|
// set_fill_color (UIConfiguration::instance().color (X_("theme:bg")));
|
||||||
name = "triggerUI-table";
|
// name = "triggerUI-table";
|
||||||
set_row_spacing (10);
|
// set_row_spacing (2);
|
||||||
set_col_spacing (10);
|
set_spacings (2);
|
||||||
set_padding ({10});
|
// set_padding (2);
|
||||||
set_homogenous (false);
|
set_homogeneous (false);
|
||||||
|
|
||||||
_follow_action_button = new ArdourButton ();
|
_follow_action_button = new ArdourButton (ArdourButton::led_default_elements);
|
||||||
|
_follow_action_button->set_name("FollowAction");
|
||||||
_follow_action_button->set_text (_("Follow Action"));
|
_follow_action_button->set_text (_("Follow Action"));
|
||||||
_follow_action_button->set_active_color (UIConfiguration::instance().color ("alert:greenish"));
|
// _follow_action_button->set_active_color (UIConfiguration::instance().color ("alert:greenish"));
|
||||||
|
|
||||||
follow_action_button = new ArdourCanvas::Widget (canvas(), *_follow_action_button);
|
|
||||||
follow_action_button->name = "FollowAction";
|
|
||||||
_follow_action_button->signal_event().connect (sigc::mem_fun (*this, (&TriggerUI::follow_action_button_event)));
|
_follow_action_button->signal_event().connect (sigc::mem_fun (*this, (&TriggerUI::follow_action_button_event)));
|
||||||
|
|
||||||
|
_follow_percent_adjustment.set_lower (0.0);
|
||||||
|
_follow_percent_adjustment.set_upper (100.0);
|
||||||
|
_follow_percent_adjustment.set_step_increment (1.0);
|
||||||
|
_follow_percent_adjustment.set_page_increment (5.0);
|
||||||
|
|
||||||
|
_follow_percent_slider = new HSliderController (&_follow_percent_adjustment, boost::shared_ptr<PBD::Controllable>(), 24/*length*/, 12/*girth*/ );
|
||||||
|
_follow_percent_slider->set_name("FollowAction");
|
||||||
|
_follow_percent_slider->set_text (_("100% Left"));
|
||||||
|
// _follow_percent_slider->set_active_color (UIConfiguration::instance().color ("alert:greenish"));
|
||||||
|
// _follow_percent_slider->signal_event().connect (sigc::mem_fun (*this, (&TriggerUI::follow_action_button_event)));
|
||||||
|
|
||||||
_follow_left = new ArdourDropdown;
|
_follow_left = new ArdourDropdown;
|
||||||
|
_follow_left->set_name("FollowAction");
|
||||||
_follow_left->append_text_item (_("None"));
|
_follow_left->append_text_item (_("None"));
|
||||||
_follow_left->append_text_item (_("Repeat"));
|
_follow_left->append_text_item (_("Repeat"));
|
||||||
_follow_left->append_text_item (_("Next"));
|
_follow_left->append_text_item (_("Next"));
|
||||||
_follow_left->append_text_item (_("Previous"));
|
_follow_left->append_text_item (_("Previous"));
|
||||||
_follow_left->set_sizing_text (longest_follow);
|
_follow_left->set_sizing_text (longest_follow);
|
||||||
|
|
||||||
follow_left = new Widget (canvas(), *_follow_left);
|
|
||||||
follow_left->name = "FollowLeft";
|
|
||||||
|
|
||||||
_follow_right = new ArdourDropdown;
|
_follow_right = new ArdourDropdown;
|
||||||
|
_follow_right->set_name("FollowAction");
|
||||||
_follow_right->append_text_item (_("None"));
|
_follow_right->append_text_item (_("None"));
|
||||||
_follow_right->append_text_item (_("Repeat"));
|
_follow_right->append_text_item (_("Repeat"));
|
||||||
_follow_right->append_text_item (_("Next"));
|
_follow_right->append_text_item (_("Next"));
|
||||||
_follow_right->append_text_item (_("Previous"));
|
_follow_right->append_text_item (_("Previous"));
|
||||||
_follow_right->set_sizing_text (longest_follow);
|
_follow_right->set_sizing_text (longest_follow);
|
||||||
|
|
||||||
follow_right = new Widget (canvas(), *_follow_right);
|
|
||||||
follow_right->name = "FollowRight";
|
|
||||||
|
|
||||||
launch_text = new Text (canvas());
|
|
||||||
launch_text->set (_("Launch"));
|
|
||||||
launch_text->name = "LaunchText";
|
|
||||||
launch_text->set_color (Gtkmm2ext::contrasting_text_color (UIConfiguration::instance().color (X_("theme:bg"))));
|
|
||||||
launch_text->set_font_description (UIConfiguration::instance ().get_NormalBoldFont ());
|
|
||||||
|
|
||||||
_launch_style_button = new ArdourDropdown();
|
_launch_style_button = new ArdourDropdown();
|
||||||
|
_launch_style_button->set_name("FollowAction");
|
||||||
_launch_style_button->set_sizing_text (longest_launch);
|
_launch_style_button->set_sizing_text (longest_launch);
|
||||||
|
|
||||||
_launch_style_button->AddMenuElem (MenuElem (launch_style_to_string (Trigger::OneShot), sigc::bind (sigc::mem_fun (*this, &TriggerUI::set_launch_style), Trigger::OneShot)));
|
_launch_style_button->AddMenuElem (MenuElem (launch_style_to_string (Trigger::OneShot), sigc::bind (sigc::mem_fun (*this, &TriggerUI::set_launch_style), Trigger::OneShot)));
|
||||||
_launch_style_button->AddMenuElem (MenuElem (launch_style_to_string (Trigger::Gate), sigc::bind (sigc::mem_fun (*this, &TriggerUI::set_launch_style), Trigger::Gate)));
|
_launch_style_button->AddMenuElem (MenuElem (launch_style_to_string (Trigger::Gate), sigc::bind (sigc::mem_fun (*this, &TriggerUI::set_launch_style), Trigger::Gate)));
|
||||||
_launch_style_button->AddMenuElem (MenuElem (launch_style_to_string (Trigger::Toggle), sigc::bind (sigc::mem_fun (*this, &TriggerUI::set_launch_style), Trigger::Toggle)));
|
_launch_style_button->AddMenuElem (MenuElem (launch_style_to_string (Trigger::Toggle), sigc::bind (sigc::mem_fun (*this, &TriggerUI::set_launch_style), Trigger::Toggle)));
|
||||||
_launch_style_button->AddMenuElem (MenuElem (launch_style_to_string (Trigger::Repeat), sigc::bind (sigc::mem_fun (*this, &TriggerUI::set_launch_style), Trigger::Repeat)));
|
_launch_style_button->AddMenuElem (MenuElem (launch_style_to_string (Trigger::Repeat), sigc::bind (sigc::mem_fun (*this, &TriggerUI::set_launch_style), Trigger::Repeat)));
|
||||||
|
|
||||||
launch_style_button = new Widget (canvas(), *_launch_style_button);
|
_legato_button = new ArdourButton(ArdourButton::led_default_elements);
|
||||||
launch_style_button->name = "LaunchButton";
|
_launch_style_button->set_name("FollowAction");
|
||||||
|
|
||||||
_legato_button = new ArdourButton();
|
|
||||||
_legato_button->set_text (_("Legato"));
|
_legato_button->set_text (_("Legato"));
|
||||||
_legato_button->set_active_color (UIConfiguration::instance().color ("alert:greenish"));
|
_legato_button->set_active_color (UIConfiguration::instance().color ("alert:greenish"));
|
||||||
_legato_button->signal_event().connect (sigc::mem_fun (*this, (&TriggerUI::legato_button_event)));
|
_legato_button->signal_event().connect (sigc::mem_fun (*this, (&TriggerUI::legato_button_event)));
|
||||||
|
|
||||||
legato_button = new ArdourCanvas::Widget (canvas(), *_legato_button);
|
|
||||||
legato_button->name = "Legato";
|
|
||||||
|
|
||||||
quantize_text = new Text (canvas());
|
|
||||||
quantize_text->set (_("Quantize"));
|
|
||||||
quantize_text->name = "QuantizeText";
|
|
||||||
quantize_text->set_color (launch_text->color());
|
|
||||||
quantize_text->set_font_description (UIConfiguration::instance ().get_NormalBoldFont ());
|
|
||||||
|
|
||||||
_quantize_button = new ArdourDropdown;
|
_quantize_button = new ArdourDropdown;
|
||||||
|
|
||||||
#define quantize_item(b) _quantize_button->AddMenuElem (MenuElem (quantize_length_to_string (b), sigc::bind (sigc::mem_fun (*this, &TriggerUI::set_quantize), b)));
|
#define quantize_item(b) _quantize_button->AddMenuElem (MenuElem (quantize_length_to_string (b), sigc::bind (sigc::mem_fun (*this, &TriggerUI::set_quantize), b)));
|
||||||
@ -178,56 +163,34 @@ TriggerUI::TriggerUI (Item* parent)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
_quantize_button->set_sizing_text (longest_quantize);
|
_quantize_button->set_sizing_text (longest_quantize);
|
||||||
|
_quantize_button->set_name("FollowAction");
|
||||||
|
|
||||||
#undef quantize_item
|
#undef quantize_item
|
||||||
|
|
||||||
quantize_button = new Widget (canvas(), *_quantize_button);
|
int row=0;
|
||||||
quantize_button->name = "quantize";
|
Gtk::Label *label;
|
||||||
|
|
||||||
velocity = new Rectangle (canvas());
|
label = manage(new Gtk::Label(_("Velocity Sense:"))); label->set_alignment(1.0, 0.5);
|
||||||
velocity->name = "VelocityRect";
|
attach(*label, 0, 1, row, row+1, Gtk::FILL, Gtk::SHRINK );
|
||||||
velocity->set_fill_color (UIConfiguration::instance().color (X_("theme:bg")));
|
label = manage(new Gtk::Label(_("100%"))); label->set_alignment(0.0, 0.5);
|
||||||
velocity->set_outline_color (UIConfiguration::instance().color (X_("neutral:foreground")));
|
attach(*label, 1, 2, row, row+1, Gtk::FILL, Gtk::SHRINK ); row++;
|
||||||
|
|
||||||
velocity_text = new Text (velocity);
|
label = manage(new Gtk::Label(_("Launch Style:"))); label->set_alignment(1.0, 0.5);
|
||||||
velocity_text->set (_("100 %"));
|
attach(*label, 0, 1, row, row+1, Gtk::FILL, Gtk::SHRINK );
|
||||||
velocity_text->name = "VelocityText";
|
attach(*_launch_style_button, 1, 2, row, row+1, Gtk::FILL, Gtk::SHRINK ); row++;
|
||||||
velocity_text->set_color (quantize_text->color());
|
|
||||||
velocity_text->set_font_description (UIConfiguration::instance ().get_NormalFont ());
|
|
||||||
|
|
||||||
velocity_label = new Text (canvas());
|
label = manage(new Gtk::Label(_("Launch Quantize:"))); label->set_alignment(1.0, 0.5);
|
||||||
velocity_label->set (_("Velocity"));
|
attach(*label, 0, 1, row, row+1, Gtk::FILL, Gtk::SHRINK );
|
||||||
velocity_label->name = "VelocityLabel";
|
attach(*_quantize_button, 1, 2, row, row+1, Gtk::FILL, Gtk::SHRINK ); row++;
|
||||||
velocity_label->set_color (quantize_text->color());
|
|
||||||
velocity_label->set_font_description (UIConfiguration::instance ().get_NormalBoldFont ());
|
|
||||||
|
|
||||||
/* Row 0 */
|
label = manage(new Gtk::Label(_("Legato Mode:"))); label->set_alignment(1.0, 0.5);
|
||||||
|
attach(*label, 0, 1, row, row+1, Gtk::FILL, Gtk::SHRINK );
|
||||||
|
attach(*_legato_button, 1, 2, row, row+1, Gtk::FILL, Gtk::SHRINK ); row++;
|
||||||
|
|
||||||
attach_with_span (follow_action_button, 0, 0, 2, 1, PackExpand, PackExpand);
|
attach(*_follow_action_button, 0, 2, row, row+1, Gtk::FILL, Gtk::SHRINK ); row++;
|
||||||
|
attach(*_follow_percent_slider, 0, 2, row, row+1, Gtk::FILL, Gtk::SHRINK ); row++;
|
||||||
/* Row 1 */
|
attach(*_follow_left, 0, 1, row, row+1, Gtk::FILL, Gtk::SHRINK );
|
||||||
|
attach(*_follow_right, 1, 2, row, row+1, Gtk::FILL, Gtk::SHRINK ); row++;
|
||||||
attach (follow_left, 0, 1, PackExpand, PackExpand);
|
|
||||||
attach (follow_right, 1, 1, PackExpand, PackExpand);
|
|
||||||
|
|
||||||
/* Row 2 */
|
|
||||||
|
|
||||||
attach (launch_text, 0, 2);
|
|
||||||
|
|
||||||
/* Row 3 */
|
|
||||||
|
|
||||||
attach (launch_style_button, 0, 3, PackExpand, PackExpand);
|
|
||||||
attach (legato_button, 1, 3, PackExpand, PackExpand);
|
|
||||||
|
|
||||||
/* Row 4 */
|
|
||||||
|
|
||||||
attach (quantize_text, 0, 4);
|
|
||||||
attach (velocity_label, 1, 4);
|
|
||||||
|
|
||||||
/* Row 5 */
|
|
||||||
|
|
||||||
attach (quantize_button, 0, 5, PackExpand, PackExpand);
|
|
||||||
attach (velocity, 1, 5, PackExpand, PackExpand);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TriggerUI::~TriggerUI ()
|
TriggerUI::~TriggerUI ()
|
||||||
@ -403,32 +366,21 @@ TriggerUI::trigger_changed (PropertyChange pc)
|
|||||||
|
|
||||||
TriggerWidget::TriggerWidget ()
|
TriggerWidget::TriggerWidget ()
|
||||||
{
|
{
|
||||||
ui = new TriggerUI (root());
|
ui = new TriggerUI ();
|
||||||
set_background_color (UIConfiguration::instance().color (X_("theme:bg")));
|
pack_start(*ui);
|
||||||
}
|
ui->show();
|
||||||
|
// set_background_color (UIConfiguration::instance().color (X_("theme:bg")));
|
||||||
void
|
|
||||||
TriggerWidget::size_request (double& w, double& h) const
|
|
||||||
{
|
|
||||||
ui->size_request (w, h);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------ */
|
/* ------------ */
|
||||||
|
|
||||||
TriggerWindow::TriggerWindow (Trigger* t)
|
TriggerWindow::TriggerWindow (Trigger* slot)
|
||||||
{
|
{
|
||||||
TriggerWidget* tw = manage (new TriggerWidget ());
|
set_title (string_compose (_("Trigger: %1"), slot->name()));
|
||||||
tw->set_trigger(t);
|
|
||||||
set_title (string_compose (_("Trigger: %1"), t->name()));
|
|
||||||
|
|
||||||
double w;
|
TriggerWidget *triggerwidget = manage (new TriggerWidget ());
|
||||||
double h;
|
add (*triggerwidget);
|
||||||
|
triggerwidget->show_all();
|
||||||
tw->show ();
|
|
||||||
tw->size_request (w, h);
|
|
||||||
set_default_size (w, h);
|
|
||||||
std::cerr << "TW: set default win size to " << w << " x " << h << std::endl;
|
|
||||||
add (*tw);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
@ -21,25 +21,15 @@
|
|||||||
|
|
||||||
#include "ardour/triggerbox.h"
|
#include "ardour/triggerbox.h"
|
||||||
|
|
||||||
#include "canvas/box.h"
|
|
||||||
#include "canvas/canvas.h"
|
|
||||||
#include "canvas/table.h"
|
|
||||||
|
|
||||||
namespace ArdourWidgets {
|
namespace ArdourWidgets {
|
||||||
class ArdourButton;
|
class ArdourButton;
|
||||||
|
class HSliderController;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace ArdourCanvas {
|
class TriggerUI : public Gtk::Table //, public sigc::trackable
|
||||||
class Text;
|
|
||||||
class Polygon;
|
|
||||||
class Widget;
|
|
||||||
class Rectangle;
|
|
||||||
};
|
|
||||||
|
|
||||||
class TriggerUI : public ArdourCanvas::Table, public sigc::trackable
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
TriggerUI (ArdourCanvas::Item* parent);
|
TriggerUI ();
|
||||||
~TriggerUI ();
|
~TriggerUI ();
|
||||||
|
|
||||||
void set_trigger (ARDOUR::Trigger*);
|
void set_trigger (ARDOUR::Trigger*);
|
||||||
@ -48,38 +38,16 @@ class TriggerUI : public ArdourCanvas::Table, public sigc::trackable
|
|||||||
ARDOUR::Trigger* trigger;
|
ARDOUR::Trigger* trigger;
|
||||||
|
|
||||||
ArdourWidgets::ArdourButton* _follow_action_button;
|
ArdourWidgets::ArdourButton* _follow_action_button;
|
||||||
ArdourCanvas::Widget* follow_action_button;
|
Gtk::Adjustment _follow_percent_adjustment;
|
||||||
|
ArdourWidgets::HSliderController* _follow_percent_slider;
|
||||||
|
|
||||||
ArdourWidgets::ArdourDropdown* _follow_left;
|
ArdourWidgets::ArdourDropdown* _follow_left;
|
||||||
ArdourCanvas::Widget* follow_left;
|
|
||||||
ArdourWidgets::ArdourButton* _follow_left_percentage;
|
|
||||||
ArdourCanvas::Widget* follow_left_percentage;
|
|
||||||
|
|
||||||
ArdourWidgets::ArdourDropdown* _follow_right;
|
ArdourWidgets::ArdourDropdown* _follow_right;
|
||||||
ArdourCanvas::Widget* follow_right;
|
|
||||||
ArdourWidgets::ArdourButton* _follow_right_percentage;
|
|
||||||
ArdourCanvas::Widget* follow_right_percentage;
|
|
||||||
|
|
||||||
ArdourCanvas::Rectangle* percentage_slider;
|
|
||||||
|
|
||||||
ArdourCanvas::Rectangle* follow_count;
|
|
||||||
ArdourCanvas::Text* follow_count_text;
|
|
||||||
|
|
||||||
ArdourWidgets::ArdourButton* _legato_button;
|
ArdourWidgets::ArdourButton* _legato_button;
|
||||||
ArdourCanvas::Widget* legato_button;
|
|
||||||
|
|
||||||
ArdourWidgets::ArdourDropdown* _quantize_button;
|
ArdourWidgets::ArdourDropdown* _quantize_button;
|
||||||
ArdourCanvas::Widget* quantize_button;
|
|
||||||
ArdourCanvas::Text* quantize_text;
|
|
||||||
|
|
||||||
ArdourWidgets::ArdourDropdown* _launch_style_button;
|
ArdourWidgets::ArdourDropdown* _launch_style_button;
|
||||||
ArdourCanvas::Widget* launch_style_button;
|
|
||||||
ArdourCanvas::Text* launch_text;
|
|
||||||
|
|
||||||
ArdourCanvas::Rectangle* velocity;
|
|
||||||
ArdourCanvas::Text* velocity_text;
|
|
||||||
ArdourCanvas::Text* velocity_label;
|
|
||||||
|
|
||||||
void set_quantize (Temporal::BBT_Offset);
|
void set_quantize (Temporal::BBT_Offset);
|
||||||
void set_launch_style (ARDOUR::Trigger::LaunchStyle);
|
void set_launch_style (ARDOUR::Trigger::LaunchStyle);
|
||||||
@ -97,11 +65,10 @@ class TriggerUI : public ArdourCanvas::Table, public sigc::trackable
|
|||||||
static std::string launch_style_to_string (ARDOUR::Trigger::LaunchStyle);
|
static std::string launch_style_to_string (ARDOUR::Trigger::LaunchStyle);
|
||||||
};
|
};
|
||||||
|
|
||||||
class TriggerWidget : public ArdourCanvas::GtkCanvas
|
class TriggerWidget : public Gtk::VBox
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
TriggerWidget ();
|
TriggerWidget ();
|
||||||
void size_request (double& w, double& h) const;
|
|
||||||
void set_trigger (ARDOUR::Trigger* t) const {ui->set_trigger(t);}
|
void set_trigger (ARDOUR::Trigger* t) const {ui->set_trigger(t);}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Loading…
Reference in New Issue
Block a user