triggerbox: (slowly) evolving the launch settings dialog

This commit is contained in:
Paul Davis 2021-09-10 13:05:19 -06:00
parent e777acb7f9
commit 2e4502763c
3 changed files with 148 additions and 25 deletions

View File

@ -28,8 +28,12 @@
#include "ardour/region.h"
#include "ardour/triggerbox.h"
#include "canvas/constrained_item.h"
#include "canvas/polygon.h"
#include "canvas/text.h"
#include "canvas/widget.h"
#include "widgets/ardour_button.h"
#include "gtkmm2ext/utils.h"
@ -42,29 +46,128 @@
using namespace ARDOUR;
using namespace ArdourCanvas;
using namespace ArdourWidgets;
using namespace Gtkmm2ext;
using namespace PBD;
static std::vector<std::string> follow_strings;
static std::string longest_follow;
TriggerUI::TriggerUI (Item* parent, Trigger& t)
: Box (parent, Box::Vertical)
: ConstraintPacker (parent)
, trigger (t)
{
follow_label = new Box (canvas(), Horizontal);
follow_label->set_fill_color (UIConfiguration::instance().color (X_("theme:bg")));
follow_label->set_outline_color (UIConfiguration::instance().color (X_("neutral:foreground")));
if (follow_strings.empty()) {
follow_strings.push_back (follow_action_to_string (Trigger::Stop));
follow_strings.push_back (follow_action_to_string (Trigger::Again));
follow_strings.push_back (follow_action_to_string (Trigger::QueuedTrigger));
follow_strings.push_back (follow_action_to_string (Trigger::NextTrigger));
follow_strings.push_back (follow_action_to_string (Trigger::PrevTrigger));
follow_strings.push_back (follow_action_to_string (Trigger::FirstTrigger));
follow_strings.push_back (follow_action_to_string (Trigger::LastTrigger));
follow_strings.push_back (follow_action_to_string (Trigger::AnyTrigger));
follow_strings.push_back (follow_action_to_string (Trigger::OtherTrigger));
follow_text = new Text (canvas());
follow_text->set (X_("Follow Action"));
follow_text->set_color (Gtkmm2ext::contrasting_text_color (follow_label->fill_color()));
for (std::vector<std::string>::const_iterator i = follow_strings.begin(); i != follow_strings.end(); ++i) {
if (i->length() > longest_follow.length()) {
longest_follow = *i;
}
}
}
follow_label->add (follow_text);
add (follow_label);
name = "TriggerUI-CP";
_follow_action_button = new ArdourButton ();
_follow_action_button->set_text (_("Follow Action"));
follow_action_button = new ArdourCanvas::Widget (canvas(), *_follow_action_button);
follow_action_button->name = "FollowAction";
_follow_left = new ArdourDropdown;
_follow_left->append_text_item (_("None"));
_follow_left->append_text_item (_("Repeat"));
_follow_left->append_text_item (_("Next"));
_follow_left->append_text_item (_("Previous"));
_follow_left->set_sizing_text (longest_follow);
follow_left = new Widget (canvas(), *_follow_left);
follow_left->name = "FollowLeft";
_follow_right = new ArdourDropdown;
_follow_right->append_text_item (_("None"));
_follow_right->append_text_item (_("Repeat"));
_follow_right->append_text_item (_("Next"));
_follow_right->append_text_item (_("Previous"));
_follow_right->set_sizing_text (longest_follow);
follow_right = new Widget (canvas(), *_follow_right);
follow_right->name = "FollowRight";
ConstrainedItem* cfa = add_constrained (follow_action_button);
ConstrainedItem* cfl = add_constrained (follow_left);
ConstrainedItem* cfr = add_constrained (follow_right);
/* sizing */
const double scale = UIConfiguration::instance().get_ui_scale();
const Distance spacing = 12. * scale;
constrain (this->width == cfa->width() + (2. * spacing));
constrain (cfa->top() == spacing);
constrain (cfa->left() == spacing);
constrain (cfa->height() == 26); /* XXX fix me */
cfl->below (*cfa, spacing);
cfl->same_size_as (*cfr);
cfl->left_aligned_with (*cfa);
cfl->same_height_as (*cfa);
cfl->top_aligned_with (*cfr);
cfr->below (*cfa, spacing);
cfr->right_aligned_with (*cfa);
cfr->right_of (*cfl, spacing);
trigger_changed ();
}
TriggerUI::~TriggerUI ()
{
}
std::string
TriggerUI::follow_action_to_string (Trigger::FollowAction fa)
{
switch (fa) {
case Trigger::Stop:
return _("Stop");
case Trigger::Again:
return _("Again");
case Trigger::QueuedTrigger:
return _("Queued");
case Trigger::NextTrigger:
return _("Next");
case Trigger::PrevTrigger:
return _("Prev");
case Trigger::FirstTrigger:
return _("First");
case Trigger::LastTrigger:
return _("Last");
case Trigger::AnyTrigger:
return _("Any");
case Trigger::OtherTrigger:
return _("Other");
}
/*NOTREACHED*/
return std::string();
}
void
TriggerUI::trigger_changed ()
{
_follow_right->set_text (follow_action_to_string (trigger.follow_action (0)));
_follow_left->set_text (follow_action_to_string (trigger.follow_action (1)));
}
/* ------------ */
TriggerWidget::TriggerWidget (Trigger& t)
@ -84,16 +187,15 @@ TriggerWidget::size_request (double& w, double& h) const
TriggerWindow::TriggerWindow (Trigger& t)
{
TriggerWidget* tw = manage (new TriggerWidget (t));
set_title (_("Trigger XXXX"));
set_title (string_compose (_("Trigger: %1"), t.name()));
double w;
double h;
tw->show ();
tw->size_request (w, h);
set_default_size (w, h);
add (*tw);
tw->show ();
}
bool

View File

@ -23,14 +23,20 @@
#include "canvas/box.h"
#include "canvas/canvas.h"
#include "canvas/rectangle.h"
#include "canvas/constraint_packer.h"
namespace ArdourWidgets {
class ArdourButton;
}
namespace ArdourCanvas {
class Text;
class Polygon;
class Widget;
class Rectangle;
};
class TriggerUI : public ArdourCanvas::Box
class TriggerUI : public ArdourCanvas::ConstraintPacker
{
public:
TriggerUI (ArdourCanvas::Item* parent, ARDOUR::Trigger&);
@ -39,18 +45,21 @@ class TriggerUI : public ArdourCanvas::Box
private:
ARDOUR::Trigger& trigger;
ArdourCanvas::Box* follow_label;
ArdourCanvas::Text* follow_text;
ArdourWidgets::ArdourButton* _follow_action_button;
ArdourCanvas::Widget* follow_action_button;
ArdourCanvas::Rectangle* follow_left;
ArdourCanvas::Text* follow_left_text;
ArdourCanvas::Rectangle* follow_left_percentage;
ArdourCanvas::Text* follow_left_percentage_text;
ArdourCanvas::Rectangle* follow_right;
ArdourCanvas::Text* follow_right_text;
ArdourCanvas::Rectangle* follow_right_percentage;
ArdourCanvas::Text* follow_right_percentage_text;
ArdourWidgets::ArdourDropdown* _follow_left;
ArdourCanvas::Widget* follow_left;
ArdourWidgets::ArdourButton* _follow_left_percentage;
ArdourCanvas::Widget* follow_left_percentage;
ArdourWidgets::ArdourDropdown* _follow_right;
ArdourCanvas::Widget* follow_right;
ArdourWidgets::ArdourButton* _follow_right_percentage;
ArdourCanvas::Widget* follow_right_percentage;
ArdourCanvas::ConstraintPacker* follow_upper_box;
ArdourCanvas::Rectangle* percentage_slider;
@ -65,6 +74,11 @@ class TriggerUI : public ArdourCanvas::Box
ArdourCanvas::Rectangle* velocity;
ArdourCanvas::Rectangle* velocity_text;
void trigger_changed ();
static std::string follow_action_to_string (ARDOUR::Trigger::FollowAction);
static ARDOUR::Trigger::FollowAction string_to_follow_action (std::string const &);
};
class TriggerWidget : public ArdourCanvas::GtkCanvas

View File

@ -404,7 +404,14 @@ TriggerBoxUI::context_menu (size_t n)
void
TriggerBoxUI::edit_trigger (size_t n)
{
TriggerWindow* tw = new TriggerWindow (*_triggerbox.trigger (n));
Trigger* trigger = _triggerbox.trigger (n);
TriggerWindow* tw = static_cast<TriggerWindow*> (trigger->ui());
if (!tw) {
tw = new TriggerWindow (*_triggerbox.trigger (n));
trigger->set_ui (tw);
}
tw->present ();
}