Re-do source-code cleanup and formatting

Some of this was lost in 26df9ccdf8
This also removes some excess code
This commit is contained in:
Robin Gareus 2021-12-17 16:32:52 +01:00
parent 49b1eb401d
commit 422ad6656d
No known key found for this signature in database
GPG key ID: A090BCE02CF57F04
5 changed files with 575 additions and 592 deletions

View file

@ -30,8 +30,8 @@
#include "gtkmm2ext/utils.h"
#include "ardour_ui.h"
#include "gui_thread.h"
#include "cuebox_ui.h"
#include "gui_thread.h"
#include "public_editor.h"
#include "region_view.h"
#include "selection.h"
@ -50,18 +50,18 @@ CueEntry::CueEntry (Item* item, uint64_t cue_index)
: ArdourCanvas::Rectangle (item)
, _cue_idx (cue_index)
{
set_layout_sensitive(true); //why???
set_layout_sensitive (true); // why???
name = string_compose ("cue %1", _cue_idx);
Event.connect (sigc::mem_fun (*this, &CueEntry::event_handler));
set_outline (false);
set_fill_color (UIConfiguration::instance().color ("theme:bg"));
set_fill_color (UIConfiguration::instance ().color ("theme:bg"));
play_button = new ArdourCanvas::Rectangle (this);
play_button->set_outline (false);
play_button->set_fill(true);
play_button->set_fill (true);
play_button->name = string_compose ("playbutton %1", _cue_idx);
play_button->show ();
@ -71,18 +71,18 @@ CueEntry::CueEntry (Item* item, uint64_t cue_index)
name_button = new ArdourCanvas::Rectangle (this);
name_button->set_outline (true);
name_button->set_fill(false);
name_button->set_fill (false);
name_button->name = ("slot_selector_button");
name_button->show ();
name_text = new Text (name_button);
name_text->set (string_compose ("%1", (char) ('A'+ _cue_idx) ));
name_text->set (string_compose ("%1", (char)('A' + _cue_idx)));
name_text->set_ignore_events (false);
name_text->show();
name_text->show ();
/* watch for change in theme */
UIConfiguration::instance().ParameterChanged.connect (sigc::mem_fun (*this, &CueEntry::ui_parameter_changed));
set_default_colors();
UIConfiguration::instance ().ParameterChanged.connect (sigc::mem_fun (*this, &CueEntry::ui_parameter_changed));
set_default_colors ();
}
CueEntry::~CueEntry ()
@ -97,15 +97,15 @@ CueEntry::event_handler (GdkEvent* ev)
break;
case GDK_ENTER_NOTIFY:
if (ev->crossing.detail != GDK_NOTIFY_INFERIOR) {
name_text->set_color (UIConfiguration::instance().color("neutral:foregroundest"));
play_shape->set_outline_color (UIConfiguration::instance().color("neutral:foregroundest"));
play_button->set_fill_color (HSV (fill_color()).lighter(0.15).color ());
set_fill_color (HSV (fill_color()).lighter(0.15).color ());
name_text->set_color (UIConfiguration::instance ().color ("neutral:foregroundest"));
play_shape->set_outline_color (UIConfiguration::instance ().color ("neutral:foregroundest"));
play_button->set_fill_color (HSV (fill_color ()).lighter (0.15).color ());
set_fill_color (HSV (fill_color ()).lighter (0.15).color ());
}
break;
case GDK_LEAVE_NOTIFY:
if (ev->crossing.detail != GDK_NOTIFY_INFERIOR) {
set_default_colors();
set_default_colors ();
}
break;
default:
@ -116,39 +116,39 @@ CueEntry::event_handler (GdkEvent* ev)
}
void
CueEntry::_size_allocate (ArdourCanvas::Rect const & alloc)
CueEntry::_size_allocate (ArdourCanvas::Rect const& alloc)
{
ArdourCanvas::Rectangle::_size_allocate (alloc);
const Distance width = _rect.width();
const Distance height = _rect.height();
const Distance width = _rect.width ();
const Distance height = _rect.height ();
play_button->set (ArdourCanvas::Rect (0, 0, height, height));
name_button->set (ArdourCanvas::Rect (height, 0, width, height));
const double scale = UIConfiguration::instance().get_ui_scale();
poly_margin = 2. * scale;
poly_size = height - 2*poly_margin;
const double scale = UIConfiguration::instance ().get_ui_scale ();
_poly_margin = 2. * scale;
_poly_size = height - 2 * _poly_margin;
shape_play_button ();
float tleft = height; //make room for the play button
float twidth = name_button->width() - poly_margin*2;
float tleft = height; // make room for the play button
float twidth = name_button->width () - _poly_margin * 2;
name_text->size_allocate (ArdourCanvas::Rect (0, 0, width, height));
name_text->set_position (Duple (tleft + poly_margin, poly_margin -0.5));
name_text->clamp_width ( width - height );
name_text->set_position (Duple (tleft + _poly_margin, _poly_margin - 0.5));
name_text->clamp_width (width - height);
//font scale may have changed. uiconfig 'embeds' the ui-scale in the font
name_text->set_font_description (UIConfiguration::instance().get_NormalFont());
/* font scale may have changed. uiconfig 'embeds' the ui-scale in the font */
name_text->set_font_description (UIConfiguration::instance ().get_NormalFont ());
}
void
CueEntry::render (ArdourCanvas::Rect const & area, Cairo::RefPtr<Cairo::Context> context) const
CueEntry::render (ArdourCanvas::Rect const& area, Cairo::RefPtr<Cairo::Context> context) const
{
ArdourCanvas::Rectangle::render(area, context);
ArdourCanvas::Rectangle::render (area, context);
/* Note that item_to_window() already takes _position into account (as
part of item_to_canvas()
* part of item_to_canvas()
*/
ArdourCanvas::Rect self (item_to_window (_rect));
const ArdourCanvas::Rect draw = self.intersection (area);
@ -157,34 +157,34 @@ CueEntry::render (ArdourCanvas::Rect const & area, Cairo::RefPtr<Cairo::Context>
return;
}
float width = _rect.width();
float height = _rect.height();
float width = _rect.width ();
float height = _rect.height ();
const double scale = UIConfiguration::instance().get_ui_scale();
const double scale = UIConfiguration::instance ().get_ui_scale ();
if (_fill && !_transparent) {
setup_fill_context (context);
context->rectangle (draw.x0, draw.y0, draw.width(), draw.height());
context->rectangle (draw.x0, draw.y0, draw.width (), draw.height ());
context->fill ();
}
render_children (area, context);
if (_cue_idx==0) {
Cairo::RefPtr<Cairo::LinearGradient> drop_shadow_pattern = Cairo::LinearGradient::create (0.0, 0.0, 0.0, 6*scale);
if (_cue_idx == 0) {
Cairo::RefPtr<Cairo::LinearGradient> drop_shadow_pattern = Cairo::LinearGradient::create (0.0, 0.0, 0.0, 6 * scale);
drop_shadow_pattern->add_color_stop_rgba (0, 0, 0, 0, 0.7);
drop_shadow_pattern->add_color_stop_rgba (1, 0, 0, 0, 0.0);
context->set_source (drop_shadow_pattern);
context->rectangle(0, 0, width, 6*scale );
context->rectangle (0, 0, width, 6 * scale);
context->fill ();
} else if (_cue_idx%2==0) {
//line at top
context->set_identity_matrix();
context->translate (self.x0, self.y0-0.5);
set_source_rgba (context, rgba_to_color (0,0,0,1));
context->rectangle(0, 0, width, 1.);
} else if (_cue_idx % 2 == 0) {
/* line at top */
context->set_identity_matrix ();
context->translate (self.x0, self.y0 - 0.5);
set_source_rgba (context, rgba_to_color (0, 0, 0, 1));
context->rectangle (0, 0, width, 1.);
context->fill ();
context->set_identity_matrix();
context->set_identity_matrix ();
}
}
@ -193,13 +193,13 @@ CueEntry::shape_play_button ()
{
Points p;
p.push_back (Duple (poly_margin, poly_margin));
p.push_back (Duple (poly_margin, poly_size));
p.push_back (Duple (poly_size, 0.5+poly_size / 2.));
p.push_back (Duple (_poly_margin, _poly_margin));
p.push_back (Duple (_poly_margin, _poly_size));
p.push_back (Duple (_poly_size, 0.5 + _poly_size / 2.));
play_shape->set (p);
if (false /*ToDo*/) {
if (false /*TODO*/) {
play_shape->set_outline (false);
play_shape->set_fill (true);
} else {
@ -211,25 +211,26 @@ CueEntry::shape_play_button ()
void
CueEntry::set_default_colors ()
{
set_fill_color (UIConfiguration::instance().color ("theme:bg"));
play_button->set_fill_color (UIConfiguration::instance().color("theme:bg"));
play_button->set_outline_color (UIConfiguration::instance().color("theme:bg"));
name_button->set_fill_color (UIConfiguration::instance().color("theme:bg"));
name_text->set_fill_color (UIConfiguration::instance().color("theme:bg"));
name_button->set_outline_color (UIConfiguration::instance().color("theme:bg"));
if ((_cue_idx/2)%2==0) {
set_fill_color (HSV (fill_color()).darker(0.15).color ());
play_button->set_fill_color (HSV (fill_color()).darker(0.15).color ());
play_button->set_outline_color (HSV (fill_color()).darker(0.15).color ());
name_button->set_fill_color (HSV (fill_color()).darker(0.15).color ());
name_text->set_fill_color (HSV (fill_color()).darker(0.15).color ());
name_button->set_outline_color (HSV (fill_color()).darker(0.15).color ());
set_fill_color (UIConfiguration::instance ().color ("theme:bg"));
play_button->set_fill_color (UIConfiguration::instance ().color ("theme:bg"));
play_button->set_outline_color (UIConfiguration::instance ().color ("theme:bg"));
name_button->set_fill_color (UIConfiguration::instance ().color ("theme:bg"));
name_text->set_fill_color (UIConfiguration::instance ().color ("theme:bg"));
name_button->set_outline_color (UIConfiguration::instance ().color ("theme:bg"));
if ((_cue_idx / 2) % 2 == 0) {
set_fill_color (HSV (fill_color ()).darker (0.15).color ());
play_button->set_fill_color (HSV (fill_color ()).darker (0.15).color ());
play_button->set_outline_color (HSV (fill_color ()).darker (0.15).color ());
name_button->set_fill_color (HSV (fill_color ()).darker (0.15).color ());
name_text->set_fill_color (HSV (fill_color ()).darker (0.15).color ());
name_button->set_outline_color (HSV (fill_color ()).darker (0.15).color ());
}
name_text->set_color (UIConfiguration::instance().color("neutral:foreground"));
name_text->set_color (UIConfiguration::instance ().color ("neutral:foreground"));
play_shape->set_outline_color (UIConfiguration::instance().color("neutral:foreground"));
play_shape->set_fill_color (UIConfiguration::instance().color("neutral:foreground"));
play_shape->set_outline_color (UIConfiguration::instance ().color ("neutral:foreground"));
play_shape->set_fill_color (UIConfiguration::instance ().color ("neutral:foreground"));
}
void
@ -240,19 +241,15 @@ CueEntry::ui_parameter_changed (std::string const& p)
}
}
/* ---------------------------- */
Gtkmm2ext::Bindings* CueBoxUI::bindings = 0;
Glib::RefPtr<Gtk::ActionGroup> CueBoxUI::trigger_actions;
CueBoxUI::CueBoxUI (ArdourCanvas::Item* parent)
: ArdourCanvas::Rectangle (parent)
{
set_layout_sensitive(true); //why???
set_layout_sensitive (true); // why???
set_fill_color (UIConfiguration::instance().color(X_("theme:bg")));
set_fill_color (UIConfiguration::instance ().color (X_("theme:bg")));
set_fill (true);
build ();
@ -303,39 +300,40 @@ CueBoxUI::build ()
_slots.clear ();
for (int32_t n = 0; n < TriggerBox::default_triggers_per_box; ++n) { //ToDo
for (int32_t n = 0; n < TriggerBox::default_triggers_per_box; ++n) { // TODO
CueEntry* te = new CueEntry (this, n);
_slots.push_back (te);
// te->play_button->Event.connect (sigc::bind (sigc::mem_fun (*this, &CueBoxUI::trigger_scene), n));
// te->name_text->Event.connect (sigc::bind (sigc::mem_fun (*this, &CueBoxUI::text_event), n));
#if 0
te->play_button->Event.connect (sigc::bind (sigc::mem_fun (*this, &CueBoxUI::trigger_scene), n));
te->name_text->Event.connect (sigc::bind (sigc::mem_fun (*this, &CueBoxUI::text_event), n));
#endif
te->Event.connect (sigc::bind (sigc::mem_fun (*this, &CueBoxUI::event), n));
}
}
void
CueBoxUI::_size_allocate (ArdourCanvas::Rect const & alloc)
CueBoxUI::_size_allocate (ArdourCanvas::Rect const& alloc)
{
ArdourCanvas::Rectangle::_size_allocate (alloc);
const float width = alloc.width();
const float height = alloc.height();
const float width = alloc.width ();
const float height = alloc.height ();
const float slot_h = height / TriggerBox::default_triggers_per_box; //ToDo
const float slot_h = height / TriggerBox::default_triggers_per_box; // TODO
float ypos = 0;
for (auto & slot : _slots) {
for (auto& slot : _slots) {
slot->size_allocate (ArdourCanvas::Rect (0, 0, width, slot_h));
slot->set_position (Duple (0, ypos));
ypos += slot_h;
slot->show();
slot->show ();
}
}
bool
CueBoxUI::text_event (GdkEvent *ev, uint64_t n)
CueBoxUI::text_event (GdkEvent* ev, uint64_t n)
{
return false;
}
@ -345,7 +343,7 @@ CueBoxUI::event (GdkEvent* ev, uint64_t n)
{
switch (ev->type) {
case GDK_BUTTON_PRESS:
trigger_scene(n);
trigger_scene (n);
break;
case GDK_2BUTTON_PRESS:
break;
@ -358,13 +356,11 @@ CueBoxUI::event (GdkEvent* ev, uint64_t n)
return false;
}
/* ------------ */
CueBoxWidget::CueBoxWidget (float w, float h) : FittedCanvasWidget(w,h)
CueBoxWidget::CueBoxWidget (float w, float h)
: FittedCanvasWidget (w, h)
{
ui = new CueBoxUI (root());
set_background_color (UIConfiguration::instance().color (X_("theme:bg")));
ui = new CueBoxUI (root ());
set_background_color (UIConfiguration::instance ().color (X_("theme:bg")));
}
void
@ -379,15 +375,12 @@ CueBoxWidget::on_unmap ()
FittedCanvasWidget::on_unmap ();
}
/* ------------ */
CueBoxWindow::CueBoxWindow ()
{
CueBoxWidget* tbw = manage (new CueBoxWidget (-1., TriggerBox::default_triggers_per_box*16.));
CueBoxWidget* tbw = manage (new CueBoxWidget (-1., TriggerBox::default_triggers_per_box * 16.));
set_title (_("CueBox for XXXX"));
set_default_size (-1., TriggerBox::default_triggers_per_box*16.);
set_default_size (-1., TriggerBox::default_triggers_per_box * 16.);
add (*tbw);
tbw->show ();
}
@ -395,13 +388,13 @@ CueBoxWindow::CueBoxWindow ()
bool
CueBoxWindow::on_key_press_event (GdkEventKey* ev)
{
Gtk::Window& main_window (ARDOUR_UI::instance()->main_window());
Gtk::Window& main_window (ARDOUR_UI::instance ()->main_window ());
return ARDOUR_UI_UTILS::relay_key_press (ev, &main_window);
}
bool
CueBoxWindow::on_key_release_event (GdkEventKey* ev)
{
Gtk::Window& main_window (ARDOUR_UI::instance()->main_window());
Gtk::Window& main_window (ARDOUR_UI::instance ()->main_window ());
return ARDOUR_UI_UTILS::relay_key_press (ev, &main_window);
}

View file

@ -17,10 +17,8 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef __cuebox_ui_h__
#define __cuebox_ui_h__
#include <map>
#ifndef _gtk_ardour_cuebox_ui_h_
#define _gtk_ardour_cuebox_ui_h_
#include <gtkmm/window.h>
@ -28,30 +26,21 @@
#include "ardour/triggerbox.h"
#include "canvas/table.h"
#include "canvas/canvas.h"
#include "canvas/rectangle.h"
#include "fitted_canvas_widget.h"
namespace Gtk {
class FileChooserDialog;
class Menu;
}
namespace Temporal {
struct BBT_Offset;
}
namespace ArdourCanvas {
namespace ArdourCanvas
{
class Text;
class Polygon;
};
}
class CueEntry : public ArdourCanvas::Rectangle
{
public:
CueEntry (ArdourCanvas::Item* item, uint64_t cue_index );
public:
CueEntry (ArdourCanvas::Item* item, uint64_t cue_index);
~CueEntry ();
ArdourCanvas::Rectangle* play_button;
@ -60,27 +49,24 @@ class CueEntry : public ArdourCanvas::Rectangle
ArdourCanvas::Rectangle* name_button;
ArdourCanvas::Text* name_text;
void render (ArdourCanvas::Rect const & area, Cairo::RefPtr<Cairo::Context> context) const;
void render (ArdourCanvas::Rect const& area, Cairo::RefPtr<Cairo::Context> context) const;
void _size_allocate (ArdourCanvas::Rect const &);
void _size_allocate (ArdourCanvas::Rect const&);
bool event_handler (GdkEvent*);
private:
uint64_t _cue_idx;
double poly_size;
double poly_margin;
private:
void shape_play_button ();
void ui_parameter_changed (std::string const& p);
void set_default_colors ();
};
uint64_t _cue_idx;
double _poly_size;
double _poly_margin;
};
class CueBoxUI : public ArdourCanvas::Rectangle
{
public:
public:
CueBoxUI (ArdourCanvas::Item* parent);
~CueBoxUI ();
@ -89,32 +75,32 @@ class CueBoxUI : public ArdourCanvas::Rectangle
static Glib::RefPtr<Gtk::ActionGroup> trigger_actions;
static void setup_actions_and_bindings ();
void _size_allocate (ArdourCanvas::Rect const &);
private:
void _size_allocate (ArdourCanvas::Rect const&);
private:
bool event (GdkEvent*, uint64_t);
bool text_event (GdkEvent*, uint64_t);
typedef std::vector<ArdourCanvas::Rectangle*> Slots;
Slots _slots;
void build ();
static Gtkmm2ext::Bindings* bindings;
static void load_bindings ();
static void register_actions ();
void build ();
typedef std::vector<ArdourCanvas::Rectangle*> Slots;
Slots _slots;
};
class CueBoxWidget : public FittedCanvasWidget
{
public:
public:
CueBoxWidget (float w, float h);
void on_map ();
void on_unmap ();
private:
private:
CueBoxUI* ui;
};
@ -122,11 +108,11 @@ class CueBoxWidget : public FittedCanvasWidget
class CueBoxWindow : public Gtk::Window
{
public:
public:
CueBoxWindow ();
bool on_key_press_event (GdkEventKey*);
bool on_key_release_event (GdkEventKey*);
};
#endif /* __cuebox_ui_h__ */
#endif

View file

@ -161,23 +161,23 @@ PassThru::render (Rect const& area, Cairo::RefPtr<Cairo::Context> context) const
const double scale = UIConfiguration::instance ().get_ui_scale ();
if (_enabled) {
//outer white circle
set_source_rgba (context, rgba_to_color (1,1,1,1));
context->arc ( size/2, size/2, size/2 - 3*scale, 0, 2*M_PI );
context->fill();
/* outer white circle */
set_source_rgba (context, rgba_to_color (1, 1, 1, 1));
context->arc (size / 2, size / 2, size / 2 - 3 * scale, 0, 2 * M_PI);
context->fill ();
//black circle
set_source_rgba (context, rgba_to_color (0,0,0,1));
context->arc ( size/2, size/2, size/2 - 5*scale, 0, 2*M_PI );
context->fill();
/* black circle */
set_source_rgba (context, rgba_to_color (0, 0, 0, 1));
context->arc (size / 2, size / 2, size / 2 - 5 * scale, 0, 2 * M_PI);
context->fill ();
//inner white circle
set_source_rgba (context, rgba_to_color (1,1,1,1));
context->arc ( size/2, size/2, size/2 - 7*scale, 0, 2*M_PI );
context->fill();
/* inner white circle */
set_source_rgba (context, rgba_to_color (1, 1, 1, 1));
context->arc (size / 2, size / 2, size / 2 - 7 * scale, 0, 2 * M_PI);
context->fill ();
}
context->set_identity_matrix();
context->set_identity_matrix ();
}
TriggerMaster::TriggerMaster (Item* parent)
@ -259,22 +259,22 @@ TriggerMaster::render (Rect const& area, Cairo::RefPtr<Cairo::Context> context)
render_children (area, context);
//drop-shadow at top
if (true) {
Cairo::RefPtr<Cairo::LinearGradient> drop_shadow_pattern = Cairo::LinearGradient::create (0.0, 0.0, 0.0, 6*scale);
/* drop-shadow at top */
Cairo::RefPtr<Cairo::LinearGradient> drop_shadow_pattern = Cairo::LinearGradient::create (0.0, 0.0, 0.0, 6 * scale);
drop_shadow_pattern->add_color_stop_rgba (0, 0, 0, 0, 0.7);
drop_shadow_pattern->add_color_stop_rgba (1, 0, 0, 0, 0.0);
context->set_source (drop_shadow_pattern);
context->rectangle(0, 0, width, 6*scale );
context->rectangle (0, 0, width, 6 * scale);
context->fill ();
} else {
//line at top
context->set_identity_matrix();
context->translate (self.x0, self.y0-0.5);
set_source_rgba (context, rgba_to_color (0,0,0,1));
context->rectangle(0, 0, width, 1.);
/* line at top */
context->set_identity_matrix ();
context->translate (self.x0, self.y0 - 0.5);
set_source_rgba (context, rgba_to_color (0, 0, 0, 1));
context->rectangle (0, 0, width, 1.);
context->fill ();
context->set_identity_matrix();
context->set_identity_matrix ();
}
}
@ -306,15 +306,15 @@ TriggerMaster::event_handler (GdkEvent* ev)
break;
case GDK_ENTER_NOTIFY:
if (ev->crossing.detail != GDK_NOTIFY_INFERIOR) {
name_text->set_color (UIConfiguration::instance().color("neutral:foregroundest"));
stop_shape->set_outline_color (UIConfiguration::instance().color("neutral:foreground"));
set_fill_color (HSV (fill_color()).lighter(0.15).color ());
name_text->set_color (UIConfiguration::instance ().color ("neutral:foregroundest"));
stop_shape->set_outline_color (UIConfiguration::instance ().color ("neutral:foreground"));
set_fill_color (HSV (fill_color ()).lighter (0.15).color ());
}
redraw ();
break;
case GDK_LEAVE_NOTIFY:
if (ev->crossing.detail != GDK_NOTIFY_INFERIOR) {
set_default_colors();
set_default_colors ();
}
redraw ();
break;
@ -460,7 +460,7 @@ TriggerMaster::_size_allocate (ArdourCanvas::Rect const& alloc)
float tleft = _poly_size + (_poly_margin * 3);
float twidth = width - _poly_size - (_poly_margin * 3);
ArdourCanvas::Rect text_alloc (tleft, 0, twidth, height); //testing
ArdourCanvas::Rect text_alloc (tleft, 0, twidth, height); // testing
name_text->size_allocate (text_alloc);
name_text->set_position (Duple (tleft, 1. * scale));
name_text->clamp_width (twidth);
@ -486,8 +486,8 @@ TriggerMaster::prop_change (PropertyChange const& change)
ARDOUR::Trigger* trigger = _triggerbox->currently_playing ();
if (!trigger) {
name_text->set (text);
_loopster->hide();
stop_shape->show();
_loopster->hide ();
stop_shape->show ();
return;
}
@ -501,21 +501,21 @@ TriggerMaster::prop_change (PropertyChange const& change)
if (trigger->active ()) {
double f = trigger->position_as_fraction ();
_loopster->set_fraction(f);
_loopster->show();
stop_shape->hide();
_loopster->set_fraction (f);
_loopster->show ();
stop_shape->hide ();
} else {
_loopster->hide();
stop_shape->show();
_loopster->hide ();
stop_shape->show ();
}
}
void
TriggerMaster::set_default_colors ()
{
set_fill_color (HSV (UIConfiguration::instance().color("theme:bg")).darker(0.25).color ());
name_text->set_color (UIConfiguration::instance().color("neutral:foreground"));
stop_shape->set_outline_color (UIConfiguration::instance().color("neutral:midground"));
set_fill_color (HSV (UIConfiguration::instance ().color ("theme:bg")).darker (0.25).color ());
name_text->set_color (UIConfiguration::instance ().color ("neutral:foreground"));
stop_shape->set_outline_color (UIConfiguration::instance ().color ("neutral:midground"));
}
void
@ -529,7 +529,7 @@ TriggerMaster::ui_parameter_changed (std::string const& p)
CueMaster::CueMaster (Item* parent)
: ArdourCanvas::Rectangle (parent)
{
set_layout_sensitive (true); //why???
set_layout_sensitive (true); // why???
name = X_("trigger stopper");
@ -581,20 +581,20 @@ CueMaster::render (Rect const& area, Cairo::RefPtr<Cairo::Context> context) cons
render_children (area, context);
//drop-shadow at top
if (true) {
Cairo::RefPtr<Cairo::LinearGradient> drop_shadow_pattern = Cairo::LinearGradient::create (0.0, 0.0, 0.0, 6*scale);
/* drop-shadow at top */
Cairo::RefPtr<Cairo::LinearGradient> drop_shadow_pattern = Cairo::LinearGradient::create (0.0, 0.0, 0.0, 6 * scale);
drop_shadow_pattern->add_color_stop_rgba (0, 0, 0, 0, 0.7);
drop_shadow_pattern->add_color_stop_rgba (1, 0, 0, 0, 0.0);
context->set_source (drop_shadow_pattern);
context->rectangle(0, 0, width, 6*scale );
context->rectangle (0, 0, width, 6 * scale);
context->fill ();
} else {
//line at top
context->set_identity_matrix();
context->translate (self.x0, self.y0-0.5);
set_source_rgba (context, rgba_to_color (0,0,0,1));
context->rectangle(0, 0, width, 1.);
/* line at top */
context->set_identity_matrix ();
context->translate (self.x0, self.y0 - 0.5);
set_source_rgba (context, rgba_to_color (0, 0, 0, 1));
context->rectangle (0, 0, width, 1.);
context->fill ();
context->set_identity_matrix ();
}
@ -606,20 +606,20 @@ CueMaster::event_handler (GdkEvent* ev)
switch (ev->type) {
case GDK_BUTTON_PRESS:
if (ev->button.button == 1) {
_session->stop_all_triggers();
_session->stop_all_triggers ();
return true;
}
break;
case GDK_ENTER_NOTIFY:
if (ev->crossing.detail != GDK_NOTIFY_INFERIOR) {
name_text->set_color (UIConfiguration::instance().color("neutral:foregroundest"));
stop_shape->set_outline_color (UIConfiguration::instance().color("neutral:foreground"));
set_fill_color (HSV (fill_color()).lighter(0.15).color ());
name_text->set_color (UIConfiguration::instance ().color ("neutral:foregroundest"));
stop_shape->set_outline_color (UIConfiguration::instance ().color ("neutral:foreground"));
set_fill_color (HSV (fill_color ()).lighter (0.15).color ());
}
break;
case GDK_LEAVE_NOTIFY:
if (ev->crossing.detail != GDK_NOTIFY_INFERIOR) {
set_default_colors();
set_default_colors ();
}
break;
default:
@ -647,19 +647,19 @@ CueMaster::_size_allocate (ArdourCanvas::Rect const& alloc)
_poly_size = height - (_poly_margin * 2);
float centering_offset = (width/2)-_poly_margin-_poly_size/2;
float centering_offset = (width / 2) - _poly_margin - _poly_size / 2;
Points p;
p.push_back (Duple (centering_offset+ _poly_margin, _poly_margin));
p.push_back (Duple (centering_offset+ _poly_margin, _poly_size));
p.push_back (Duple (centering_offset+ _poly_size, _poly_size));
p.push_back (Duple (centering_offset+ _poly_size, _poly_margin));
p.push_back (Duple (centering_offset + _poly_margin, _poly_margin));
p.push_back (Duple (centering_offset + _poly_margin, _poly_size));
p.push_back (Duple (centering_offset + _poly_size, _poly_size));
p.push_back (Duple (centering_offset + _poly_size, _poly_margin));
stop_shape->set (p);
float tleft = _poly_size + (_poly_margin * 3);
float twidth = width - _poly_size - (_poly_margin * 3);
ArdourCanvas::Rect text_alloc (tleft, 0, twidth, height); //testing
ArdourCanvas::Rect text_alloc (tleft, 0, twidth, height); // testing
name_text->size_allocate (text_alloc);
name_text->set_position (Duple (tleft, 1. * scale));
name_text->clamp_width (twidth);
@ -671,9 +671,9 @@ CueMaster::_size_allocate (ArdourCanvas::Rect const& alloc)
void
CueMaster::set_default_colors ()
{
set_fill_color (HSV (UIConfiguration::instance().color("theme:bg")).darker(0.25).color ());
name_text->set_color (UIConfiguration::instance().color("neutral:foreground"));
stop_shape->set_outline_color (UIConfiguration::instance().color("neutral:midground"));
set_fill_color (HSV (UIConfiguration::instance ().color ("theme:bg")).darker (0.25).color ());
name_text->set_color (UIConfiguration::instance ().color ("neutral:foreground"));
stop_shape->set_outline_color (UIConfiguration::instance ().color ("neutral:midground"));
}
void

View file

@ -38,12 +38,12 @@
#include "ardour_ui.h"
#include "gui_thread.h"
#include "triggerbox_ui.h"
#include "trigger_ui.h"
#include "public_editor.h"
#include "region_view.h"
#include "selection.h"
#include "timers.h"
#include "trigger_ui.h"
#include "triggerbox_ui.h"
#include "ui_config.h"
#include "utils.h"
@ -58,45 +58,45 @@ TriggerEntry::TriggerEntry (Item* item, ARDOUR::Trigger& t)
: ArdourCanvas::Rectangle (item)
, _trigger (t)
{
set_layout_sensitive(true); //why???
set_layout_sensitive (true); // why???
name = string_compose ("trigger %1", _trigger.index());
name = string_compose ("trigger %1", _trigger.index ());
set_outline (false);
play_button = new ArdourCanvas::Rectangle (this);
play_button->set_outline (true);
play_button->set_fill(true);
play_button->name = string_compose ("playbutton %1", _trigger.index());
play_button->set_fill (true);
play_button->name = string_compose ("playbutton %1", _trigger.index ());
play_button->show ();
play_shape = new ArdourCanvas::Polygon (play_button);
play_shape->name = string_compose ("playshape %1", _trigger.index());
play_shape->name = string_compose ("playshape %1", _trigger.index ());
play_shape->show ();
name_button = new ArdourCanvas::Rectangle (this);
name_button->set_outline (true);
name_button->set_fill(true);
name_button->set_fill (true);
name_button->name = ("slot_selector_button");
name_button->show ();
name_text = new Text (name_button);
name_text->set_ignore_events (false);
name_text->show();
name_text->show ();
/* watch for change in theme */
UIConfiguration::instance().ParameterChanged.connect (sigc::mem_fun (*this, &TriggerEntry::ui_parameter_changed));
set_default_colors();
UIConfiguration::instance ().ParameterChanged.connect (sigc::mem_fun (*this, &TriggerEntry::ui_parameter_changed));
set_default_colors ();
_trigger.PropertyChanged.connect (trigger_prop_connection, MISSING_INVALIDATOR, boost::bind (&TriggerEntry::prop_change, this, _1), gui_context());
dynamic_cast<Stripable*> (_trigger.box().owner())->presentation_info().Change.connect (owner_prop_connection, MISSING_INVALIDATOR, boost::bind (&TriggerEntry::owner_prop_change, this, _1), gui_context());
_trigger.PropertyChanged.connect (trigger_prop_connection, MISSING_INVALIDATOR, boost::bind (&TriggerEntry::prop_change, this, _1), gui_context ());
dynamic_cast<Stripable*> (_trigger.box ().owner ())->presentation_info ().Change.connect (owner_prop_connection, MISSING_INVALIDATOR, boost::bind (&TriggerEntry::owner_prop_change, this, _1), gui_context ());
PropertyChange changed;
changed.add (ARDOUR::Properties::name);
changed.add (ARDOUR::Properties::running);
prop_change (changed);
selection_change();
selection_change ();
}
TriggerEntry::~TriggerEntry ()
@ -104,7 +104,7 @@ TriggerEntry::~TriggerEntry ()
}
void
TriggerEntry::owner_prop_change (PropertyChange const & pc)
TriggerEntry::owner_prop_change (PropertyChange const& pc)
{
if (pc.contains (Properties::color)) {
owner_color_changed ();
@ -114,112 +114,114 @@ TriggerEntry::owner_prop_change (PropertyChange const & pc)
void
TriggerEntry::owner_color_changed ()
{
//ToDo
// TODO
}
void
TriggerEntry::selection_change ()
{
if (PublicEditor::instance().get_selection().selected (this)) {
name_button->set_outline_color (UIConfiguration::instance().color ("alert:red"));
if (PublicEditor::instance ().get_selection ().selected (this)) {
name_button->set_outline_color (UIConfiguration::instance ().color ("alert:red"));
} else {
set_default_colors();
set_default_colors ();
}
}
void
TriggerEntry::maybe_update ()
{
//what here?
// what here?
}
void
TriggerEntry::_size_allocate (ArdourCanvas::Rect const & alloc)
TriggerEntry::_size_allocate (ArdourCanvas::Rect const& alloc)
{
Rectangle::_size_allocate (alloc);
const Distance width = _rect.width();
const Distance height = _rect.height();
const Distance width = _rect.width ();
const Distance height = _rect.height ();
play_button->set (ArdourCanvas::Rect (0, 0, height, height));
name_button->set (ArdourCanvas::Rect (height, 0, width, height));
const double scale = UIConfiguration::instance().get_ui_scale();
poly_margin = 2. * scale;
poly_size = height - 2*poly_margin;
const double scale = UIConfiguration::instance ().get_ui_scale ();
_poly_margin = 2. * scale;
_poly_size = height - 2 * _poly_margin;
shape_play_button ();
float tleft = height; //make room for the play button
float tleft = height; // make room for the play button
name_text->size_allocate (ArdourCanvas::Rect(0, 0, width, height));
name_text->set_position (Duple (tleft + poly_margin, poly_margin -0.5));
name_text->clamp_width ( width - height - height );
name_text->size_allocate (ArdourCanvas::Rect (0, 0, width, height));
name_text->set_position (Duple (tleft + _poly_margin, _poly_margin - 0.5));
name_text->clamp_width (width - height - height);
//font scale may have changed. uiconfig 'embeds' the ui-scale in the font
name_text->set_font_description (UIConfiguration::instance().get_NormalFont());
/* font scale may have changed. uiconfig 'embeds' the ui-scale in the font */
name_text->set_font_description (UIConfiguration::instance ().get_NormalFont ());
}
void draw_follow_icon( Cairo::RefPtr<Cairo::Context> context, Trigger::FollowAction icon, float size, float scale ) {
context->set_line_width ( 1*scale );
void
draw_follow_icon (Cairo::RefPtr<Cairo::Context> context, Trigger::FollowAction icon, float size, float scale)
{
context->set_line_width (1 * scale);
switch (icon) {
case Trigger::Stop:
context->rectangle ( 6*scale, 6*scale, size-12*scale, size-12*scale );
context->stroke();
context->rectangle (6 * scale, 6 * scale, size - 12 * scale, size - 12 * scale);
context->stroke ();
break;
case Trigger::Again:
context->arc ( size/2, size/2, size*0.20, 60.*(M_PI/180.0), 2*M_PI );
context->stroke();
context->arc ( size/2+size*0.2, size/2, 1.5*scale, 0, 2*M_PI ); //arrow head
context->fill();
context->arc (size / 2, size / 2, size * 0.20, 60. * (M_PI / 180.0), 2 * M_PI);
context->stroke ();
context->arc (size / 2 + size * 0.2, size / 2, 1.5 * scale, 0, 2 * M_PI); // arrow head
context->fill ();
break;
case Trigger::NextTrigger:
context->move_to ( size/2, 3*scale );
context->line_to ( size/2, size-5*scale );
context->stroke();
context->arc ( size/2, size-5*scale, 1.5*scale, 0, 2*M_PI ); //arrow head
context->fill();
context->move_to (size / 2, 3 * scale);
context->line_to (size / 2, size - 5 * scale);
context->stroke ();
context->arc (size / 2, size - 5 * scale, 1.5 * scale, 0, 2 * M_PI); // arrow head
context->fill ();
break;
case Trigger::PrevTrigger:
context->move_to ( size/2, 5*scale );
context->line_to ( size/2, size-3*scale );
context->stroke();
context->arc ( size/2, 5*scale, 1.5*scale, 0, 2*M_PI ); //arrow head
context->fill();
context->move_to (size / 2, 5 * scale);
context->line_to (size / 2, size - 3 * scale);
context->stroke ();
context->arc (size / 2, 5 * scale, 1.5 * scale, 0, 2 * M_PI); // arrow head
context->fill ();
break;
case Trigger::QueuedTrigger: {
Glib::RefPtr<Pango::Layout> layout = Pango::Layout::create (context);
layout->set_font_description ( UIConfiguration::instance().get_SmallMonospaceFont() );
layout->set_font_description (UIConfiguration::instance ().get_SmallMonospaceFont ());
layout->set_text (icon == Trigger::AnyTrigger ? "&" : "@");
int tw, th; layout->get_pixel_size (tw, th);
context->move_to ( size/2, size/2 );
context->rel_move_to ( -tw/2, -th/2 );
int tw, th;
layout->get_pixel_size (tw, th);
context->move_to (size / 2, size / 2);
context->rel_move_to (-tw / 2, -th / 2);
layout->show_in_cairo_context (context);
} break;
case Trigger::AnyTrigger: {
context->move_to ( size/2, 3*scale );
context->line_to ( size/2, size-3*scale );
context->move_to ( size/2, size/2 );
context->line_to ( size/2-3*scale, size/2 );
context->stroke();
context->arc ( size/2, 4*scale, 1.5*scale, 0, 2*M_PI ); //arrow head
context->fill();
context->arc ( size/2, size-3*scale, 1.5*scale, 0, 2*M_PI ); //arrow head
context->fill();
context->arc ( size/2-3*scale, size/2, 1.5*scale, 0, 2*M_PI ); //arrow head
context->fill();
context->move_to (size / 2, 3 * scale);
context->line_to (size / 2, size - 3 * scale);
context->move_to (size / 2, size / 2);
context->line_to (size / 2 - 3 * scale, size / 2);
context->stroke ();
context->arc (size / 2, 4 * scale, 1.5 * scale, 0, 2 * M_PI); // arrow head
context->fill ();
context->arc (size / 2, size - 3 * scale, 1.5 * scale, 0, 2 * M_PI); // arrow head
context->fill ();
context->arc (size / 2 - 3 * scale, size / 2, 1.5 * scale, 0, 2 * M_PI); // arrow head
context->fill ();
} break;
case Trigger::OtherTrigger: {
context->move_to ( size/2, 3*scale );
context->line_to ( size/2, 7*scale );
context->move_to ( size/2, size-7*scale );
context->line_to ( size/2, size-3*scale );
context->stroke();
context->arc ( size/2, 3*scale, 1.5*scale, 0, 2*M_PI ); //arrow head
context->fill();
context->arc ( size/2, size-3*scale, 1.5*scale, 0, 2*M_PI ); //arrow head
context->fill();
context->move_to (size / 2, 3 * scale);
context->line_to (size / 2, 7 * scale);
context->move_to (size / 2, size - 7 * scale);
context->line_to (size / 2, size - 3 * scale);
context->stroke ();
context->arc (size / 2, 3 * scale, 1.5 * scale, 0, 2 * M_PI); // arrow head
context->fill ();
context->arc (size / 2, size - 3 * scale, 1.5 * scale, 0, 2 * M_PI); // arrow head
context->fill ();
} break;
default:
break;
@ -227,9 +229,9 @@ void draw_follow_icon( Cairo::RefPtr<Cairo::Context> context, Trigger::FollowAct
}
void
TriggerEntry::render (ArdourCanvas::Rect const & area, Cairo::RefPtr<Cairo::Context> context) const
TriggerEntry::render (ArdourCanvas::Rect const& area, Cairo::RefPtr<Cairo::Context> context) const
{
Rectangle::render(area, context);
Rectangle::render (area, context);
/* Note that item_to_window() already takes _position into account (as
part of item_to_canvas()
@ -241,47 +243,46 @@ TriggerEntry::render (ArdourCanvas::Rect const & area, Cairo::RefPtr<Cairo::Cont
return;
}
float width = _rect.width();
float height = _rect.height();
float width = _rect.width ();
float height = _rect.height ();
const double scale = UIConfiguration::instance().get_ui_scale();
const double scale = UIConfiguration::instance ().get_ui_scale ();
if (_fill && !_transparent) {
setup_fill_context (context);
context->rectangle (draw.x0, draw.y0, draw.width(), draw.height());
context->rectangle (draw.x0, draw.y0, draw.width (), draw.height ());
context->fill ();
}
render_children (area, context);
if (_trigger.index()==1) {
//drop-shadow at top
Cairo::RefPtr<Cairo::LinearGradient> drop_shadow_pattern = Cairo::LinearGradient::create (0.0, 0.0, 0.0, 6*scale);
if (_trigger.index () == 1) {
/* drop-shadow at top */
Cairo::RefPtr<Cairo::LinearGradient> drop_shadow_pattern = Cairo::LinearGradient::create (0.0, 0.0, 0.0, 6 * scale);
drop_shadow_pattern->add_color_stop_rgba (0, 0, 0, 0, 0.7);
drop_shadow_pattern->add_color_stop_rgba (1, 0, 0, 0, 0.0);
context->set_source (drop_shadow_pattern);
context->rectangle(0, 0, width, 6*scale );
context->rectangle (0, 0, width, 6 * scale);
context->fill ();
} else if (_trigger.index()%2==0) {
//line at top
context->set_identity_matrix();
context->translate (self.x0, self.y0-0.5);
set_source_rgba (context, rgba_to_color (0,0,0,1));
context->rectangle(0, 0, width, 1);
} else if (_trigger.index () % 2 == 0) {
/* line at top */
context->set_identity_matrix ();
context->translate (self.x0, self.y0 - 0.5);
set_source_rgba (context, rgba_to_color (0, 0, 0, 1));
context->rectangle (0, 0, width, 1);
context->fill ();
context->set_identity_matrix();
context->set_identity_matrix ();
}
//follow-action icon
if (_trigger.region()) {
context->set_identity_matrix();
context->translate (self.x0, self.y0-0.5);
context->translate ( width - height, 0); //right side of the widget
set_source_rgba (context, UIConfiguration::instance().color("neutral:midground"));
draw_follow_icon( context, _trigger.follow_action(0), height, scale );
context->set_identity_matrix();
/* follow-action icon */
if (_trigger.region ()) {
context->set_identity_matrix ();
context->translate (self.x0, self.y0 - 0.5);
context->translate (width - height, 0); // right side of the widget
set_source_rgba (context, UIConfiguration::instance ().color ("neutral:midground"));
draw_follow_icon (context, _trigger.follow_action (0), height, scale);
context->set_identity_matrix ();
}
}
void
@ -289,22 +290,22 @@ TriggerEntry::shape_play_button ()
{
Points p;
if (!_trigger.region()) {
if (!_trigger.region ()) {
/* no region, so must be a stop button, drawn as a square */
p.push_back (Duple (poly_margin, poly_margin));
p.push_back (Duple (poly_margin, poly_size));
p.push_back (Duple (poly_size, poly_size));
p.push_back (Duple (poly_size, poly_margin));
p.push_back (Duple (_poly_margin, _poly_margin));
p.push_back (Duple (_poly_margin, _poly_size));
p.push_back (Duple (_poly_size, _poly_size));
p.push_back (Duple (_poly_size, _poly_margin));
} else {
/* region exists; draw triangle to show that we can trigger */
p.push_back (Duple (poly_margin, poly_margin));
p.push_back (Duple (poly_margin, poly_size));
p.push_back (Duple (poly_size, 0.5+poly_size / 2.));
p.push_back (Duple (_poly_margin, _poly_margin));
p.push_back (Duple (_poly_margin, _poly_size));
p.push_back (Duple (_poly_size, 0.5 + _poly_size / 2.));
}
play_shape->set (p);
if (_trigger.active()) {
if (_trigger.active ()) {
play_shape->set_outline (false);
play_shape->set_fill (true);
} else {
@ -314,13 +315,13 @@ TriggerEntry::shape_play_button ()
}
void
TriggerEntry::prop_change (PropertyChange const & change)
TriggerEntry::prop_change (PropertyChange const& change)
{
bool need_pb = false;
if (change.contains (ARDOUR::Properties::name)) {
if (_trigger.region()) {
name_text->set (short_version (_trigger.name(), 16));
if (_trigger.region ()) {
name_text->set (short_version (_trigger.name (), 16));
} else {
name_text->set ("");
}
@ -333,7 +334,7 @@ TriggerEntry::prop_change (PropertyChange const & change)
}
if (change.contains (ARDOUR::Properties::follow_action0)) {
redraw();
redraw ();
}
if (need_pb) {
@ -344,33 +345,33 @@ TriggerEntry::prop_change (PropertyChange const & change)
void
TriggerEntry::set_default_colors ()
{
set_fill_color (UIConfiguration::instance().color ("theme:bg"));
play_button->set_fill_color (UIConfiguration::instance().color("theme:bg"));
play_button->set_outline_color (UIConfiguration::instance().color("theme:bg"));
name_button->set_fill_color (UIConfiguration::instance().color("theme:bg"));
name_button->set_outline_color (UIConfiguration::instance().color("theme:bg"));
if ((_trigger.index()/2)%2==0) {
set_fill_color (HSV (fill_color()).darker(0.15).color ());
play_button->set_fill_color (HSV (fill_color()).darker(0.15).color ());
play_button->set_outline_color (HSV (fill_color()).darker(0.15).color ());
name_button->set_fill_color (HSV (fill_color()).darker(0.15).color ());
name_button->set_outline_color (HSV (fill_color()).darker(0.15).color ());
set_fill_color (UIConfiguration::instance ().color ("theme:bg"));
play_button->set_fill_color (UIConfiguration::instance ().color ("theme:bg"));
play_button->set_outline_color (UIConfiguration::instance ().color ("theme:bg"));
name_button->set_fill_color (UIConfiguration::instance ().color ("theme:bg"));
name_button->set_outline_color (UIConfiguration::instance ().color ("theme:bg"));
if ((_trigger.index () / 2) % 2 == 0) {
set_fill_color (HSV (fill_color ()).darker (0.15).color ());
play_button->set_fill_color (HSV (fill_color ()).darker (0.15).color ());
play_button->set_outline_color (HSV (fill_color ()).darker (0.15).color ());
name_button->set_fill_color (HSV (fill_color ()).darker (0.15).color ());
name_button->set_outline_color (HSV (fill_color ()).darker (0.15).color ());
}
name_text->set_color (UIConfiguration::instance().color("neutral:foreground"));
name_text->set_fill_color (UIConfiguration::instance().color("neutral:midground"));
name_text->set_color (UIConfiguration::instance ().color ("neutral:foreground"));
name_text->set_fill_color (UIConfiguration::instance ().color ("neutral:midground"));
if (_trigger.region()) {
play_shape->set_outline_color (UIConfiguration::instance().color("neutral:foreground"));
play_shape->set_fill_color (UIConfiguration::instance().color("neutral:foreground"));
if (_trigger.region ()) {
play_shape->set_outline_color (UIConfiguration::instance ().color ("neutral:foreground"));
play_shape->set_fill_color (UIConfiguration::instance ().color ("neutral:foreground"));
} else {
play_shape->set_outline_color (UIConfiguration::instance().color("neutral:midground"));
play_shape->set_fill_color (UIConfiguration::instance().color("neutral:midground"));
play_shape->set_outline_color (UIConfiguration::instance ().color ("neutral:midground"));
play_shape->set_fill_color (UIConfiguration::instance ().color ("neutral:midground"));
}
/*preserve selection border*/
if (PublicEditor::instance().get_selection().selected (this)) {
name_button->set_outline_color (UIConfiguration::instance().color ("alert:red"));
if (PublicEditor::instance ().get_selection ().selected (this)) {
name_button->set_outline_color (UIConfiguration::instance ().color ("alert:red"));
}
}
@ -378,7 +379,7 @@ void
TriggerEntry::ui_parameter_changed (std::string const& p)
{
if (p == "color-file") {
set_default_colors();
set_default_colors ();
}
}
@ -388,17 +389,17 @@ Glib::RefPtr<Gtk::ActionGroup> TriggerBoxUI::trigger_actions;
TriggerBoxUI::TriggerBoxUI (ArdourCanvas::Item* parent, TriggerBox& tb)
: Rectangle (parent)
, _triggerbox (tb)
, file_chooser (0)
, _file_chooser (0)
, _context_menu (0)
{
set_layout_sensitive(true); //why???
set_layout_sensitive (true); // why???
set_fill_color (UIConfiguration::instance().color(X_("theme:bg")));
set_fill_color (UIConfiguration::instance ().color (X_("theme:bg")));
set_fill (true);
build ();
selection_connection = PublicEditor::instance().get_selection().TriggersChanged.connect (sigc::mem_fun (*this, &TriggerBoxUI::selection_changed));
_selection_connection = PublicEditor::instance ().get_selection ().TriggersChanged.connect (sigc::mem_fun (*this, &TriggerBoxUI::selection_changed));
std::vector<Gtk::TargetEntry> target_table;
target_table.push_back (Gtk::TargetEntry ("regions"));
@ -406,24 +407,22 @@ TriggerBoxUI::TriggerBoxUI (ArdourCanvas::Item* parent, TriggerBox& tb)
target_table.push_back (Gtk::TargetEntry ("text/plain"));
target_table.push_back (Gtk::TargetEntry ("application/x-rootwin-drop"));
GtkCanvas* gtkcanvas = static_cast<GtkCanvas*> (canvas());
GtkCanvas* gtkcanvas = static_cast<GtkCanvas*> (canvas ());
assert (gtkcanvas);
gtkcanvas->drag_dest_set (target_table);
gtkcanvas->signal_drag_motion().connect (sigc::mem_fun(*this, &TriggerBoxUI::drag_motion));
gtkcanvas->signal_drag_leave().connect (sigc::mem_fun(*this, &TriggerBoxUI::drag_leave));
gtkcanvas->signal_drag_data_received().connect (sigc::mem_fun(*this, &TriggerBoxUI::drag_data_received));
gtkcanvas->signal_drag_motion ().connect (sigc::mem_fun (*this, &TriggerBoxUI::drag_motion));
gtkcanvas->signal_drag_leave ().connect (sigc::mem_fun (*this, &TriggerBoxUI::drag_leave));
gtkcanvas->signal_drag_data_received ().connect (sigc::mem_fun (*this, &TriggerBoxUI::drag_data_received));
}
TriggerBoxUI::~TriggerBoxUI ()
{
update_connection.disconnect ();
selection_connection.disconnect ();
}
void
TriggerBoxUI::selection_changed ()
{
for (auto & slot : _slots) {
for (auto& slot : _slots) {
slot->selection_change ();
}
}
@ -450,7 +449,7 @@ TriggerBoxUI::register_actions ()
const std::string action_name = string_compose ("trigger-scene-%1", n);
const std::string display_name = string_compose (_("Scene %1"), n);
ActionManager::register_toggle_action (trigger_actions, action_name.c_str(), display_name.c_str(), sigc::bind (sigc::ptr_fun (TriggerBoxUI::trigger_scene), n));
ActionManager::register_toggle_action (trigger_actions, action_name.c_str (), display_name.c_str (), sigc::bind (sigc::ptr_fun (TriggerBoxUI::trigger_scene), n));
}
}
@ -481,30 +480,31 @@ TriggerBoxUI::build ()
te->play_button->Event.connect (sigc::bind (sigc::mem_fun (*this, &TriggerBoxUI::play_button_event), n));
te->name_button->Event.connect (sigc::bind (sigc::mem_fun (*this, &TriggerBoxUI::text_button_event), n));
// te->Event.connect (sigc::bind (sigc::mem_fun (*this, &TriggerBoxUI::event), n));
#if 0
te->Event.connect (sigc::bind (sigc::mem_fun (*this, &TriggerBoxUI::event), n));
#endif
++n;
}
}
void
TriggerBoxUI::_size_allocate (ArdourCanvas::Rect const & alloc)
TriggerBoxUI::_size_allocate (ArdourCanvas::Rect const& alloc)
{
Rectangle::_size_allocate (alloc);
const float width = alloc.width();
const float height = alloc.height();
const float width = alloc.width ();
const float height = alloc.height ();
const float slot_h = height / TriggerBox::default_triggers_per_box; //ToDo
const float slot_h = height / TriggerBox::default_triggers_per_box; // TODO
float ypos = 0;
for (auto & slot : _slots) {
slot->size_allocate (ArdourCanvas::Rect(0, 0, width, slot_h));
for (auto& slot : _slots) {
slot->size_allocate (ArdourCanvas::Rect (0, 0, width, slot_h));
slot->set_position (Duple (0, ypos));
ypos += slot_h;
slot->show();
slot->show ();
}
}
bool
@ -513,21 +513,21 @@ TriggerBoxUI::text_button_event (GdkEvent* ev, uint64_t n)
switch (ev->type) {
case GDK_ENTER_NOTIFY:
if (ev->crossing.detail != GDK_NOTIFY_INFERIOR) {
_slots[n]->name_text->set_color (UIConfiguration::instance().color ("neutral:foregroundest"));
_slots[n]->name_button->set_fill_color (HSV (fill_color()).lighter(0.15).color ());
_slots[n]->name_text->set_color (UIConfiguration::instance ().color ("neutral:foregroundest"));
_slots[n]->name_button->set_fill_color (HSV (fill_color ()).lighter (0.15).color ());
}
break;
case GDK_LEAVE_NOTIFY:
if (ev->crossing.detail != GDK_NOTIFY_INFERIOR) {
_slots[n]->set_default_colors();
_slots[n]->set_default_colors ();
}
break;
case GDK_BUTTON_PRESS:
if (_slots[n]->trigger().region()) {
PublicEditor::instance().get_selection().set (_slots[n]);
//a side-effect of selection-change is that the slot's color is reset. retain the "entered-color" here:
_slots[n]->name_text->set_color (UIConfiguration::instance().color ("neutral:foregroundest"));
_slots[n]->name_button->set_fill_color (HSV (fill_color()).lighter(0.15).color ());
if (_slots[n]->trigger ().region ()) {
PublicEditor::instance ().get_selection ().set (_slots[n]);
/* a side-effect of selection-change is that the slot's color is reset. retain the "entered-color" here: */
_slots[n]->name_text->set_color (UIConfiguration::instance ().color ("neutral:foregroundest"));
_slots[n]->name_button->set_fill_color (HSV (fill_color ()).lighter (0.15).color ());
}
break;
case GDK_2BUTTON_PRESS:
@ -550,9 +550,9 @@ TriggerBoxUI::text_button_event (GdkEvent* ev, uint64_t n)
}
bool
TriggerBoxUI::play_button_event (GdkEvent *ev, uint64_t n)
TriggerBoxUI::play_button_event (GdkEvent* ev, uint64_t n)
{
if (!_triggerbox.trigger (n)->region()) {
if (!_triggerbox.trigger (n)->region ()) {
/* this is a stop button */
switch (ev->type) {
case GDK_BUTTON_PRESS:
@ -571,7 +571,7 @@ TriggerBoxUI::play_button_event (GdkEvent *ev, uint64_t n)
case GDK_BUTTON_PRESS:
switch (ev->button.button) {
case 1:
_slots[n]->trigger().bang ();
_slots[n]->trigger ().bang ();
return true;
default:
break;
@ -580,9 +580,9 @@ TriggerBoxUI::play_button_event (GdkEvent *ev, uint64_t n)
case GDK_BUTTON_RELEASE:
switch (ev->button.button) {
case 1:
if (_slots[n]->trigger().launch_style() == Trigger::Gate ||
_slots[n]->trigger().launch_style() == Trigger::Repeat) {
_slots[n]->trigger().unbang ();
if (_slots[n]->trigger ().launch_style () == Trigger::Gate ||
_slots[n]->trigger ().launch_style () == Trigger::Repeat) {
_slots[n]->trigger ().unbang ();
}
break;
default:
@ -591,14 +591,14 @@ TriggerBoxUI::play_button_event (GdkEvent *ev, uint64_t n)
break;
case GDK_ENTER_NOTIFY:
if (ev->crossing.detail != GDK_NOTIFY_INFERIOR) {
_slots[n]->play_button->set_fill_color (HSV (fill_color()).lighter(0.15).color ());
_slots[n]->play_shape->set_fill_color (UIConfiguration::instance().color ("neutral:foregroundest"));
_slots[n]->play_shape->set_outline_color (UIConfiguration::instance().color ("neutral:foregroundest"));
_slots[n]->play_button->set_fill_color (HSV (fill_color ()).lighter (0.15).color ());
_slots[n]->play_shape->set_fill_color (UIConfiguration::instance ().color ("neutral:foregroundest"));
_slots[n]->play_shape->set_outline_color (UIConfiguration::instance ().color ("neutral:foregroundest"));
}
break;
case GDK_LEAVE_NOTIFY:
if (ev->crossing.detail != GDK_NOTIFY_INFERIOR) {
_slots[n]->set_default_colors();
_slots[n]->set_default_colors ();
}
break;
default:
@ -617,84 +617,84 @@ TriggerBoxUI::context_menu (uint64_t n)
delete _context_menu;
_context_menu = new Menu;
MenuList& items = _context_menu->items();
MenuList& items = _context_menu->items ();
_context_menu->set_name ("ArdourContextMenu");
Menu* follow_menu = manage (new Menu);
MenuList& fitems = follow_menu->items();
MenuList& fitems = follow_menu->items ();
RadioMenuItem::Group fagroup;
RadioMenuItem::Group lagroup;
RadioMenuItem::Group qgroup;
fitems.push_back (RadioMenuElem (fagroup, _("Stop"), sigc::bind (sigc::mem_fun (*this, &TriggerBoxUI::set_follow_action), n, Trigger::Stop)));
if (_triggerbox.trigger (n)->follow_action(0) == Trigger::Stop) {
if (_triggerbox.trigger (n)->follow_action (0) == Trigger::Stop) {
dynamic_cast<Gtk::CheckMenuItem*> (&fitems.back ())->set_active (true);
}
fitems.push_back (RadioMenuElem (fagroup, _("Again"), sigc::bind (sigc::mem_fun (*this, &TriggerBoxUI::set_follow_action), n, Trigger::Again)));
if (_triggerbox.trigger (n)->follow_action(0) == Trigger::Again) {
if (_triggerbox.trigger (n)->follow_action (0) == Trigger::Again) {
dynamic_cast<Gtk::CheckMenuItem*> (&fitems.back ())->set_active (true);
}
#if QUEUED_SLOTS_IMPLEMENTED
fitems.push_back (RadioMenuElem (fagroup, _("Queued"), sigc::bind (sigc::mem_fun (*this, &TriggerBoxUI::set_follow_action), n, Trigger::QueuedTrigger)));
if (_triggerbox.trigger (n)->follow_action(0) == Trigger::QueuedTrigger) {
if (_triggerbox.trigger (n)->follow_action (0) == Trigger::QueuedTrigger) {
dynamic_cast<Gtk::CheckMenuItem*> (&fitems.back ())->set_active (true);
}
#endif
fitems.push_back (RadioMenuElem (fagroup, _("Next"), sigc::bind (sigc::mem_fun (*this, &TriggerBoxUI::set_follow_action), n, Trigger::NextTrigger)));
if (_triggerbox.trigger (n)->follow_action(0) == Trigger::NextTrigger) {
if (_triggerbox.trigger (n)->follow_action (0) == Trigger::NextTrigger) {
dynamic_cast<Gtk::CheckMenuItem*> (&fitems.back ())->set_active (true);
}
fitems.push_back (RadioMenuElem (fagroup, _("Previous"), sigc::bind (sigc::mem_fun (*this, &TriggerBoxUI::set_follow_action), n, Trigger::PrevTrigger)));
if (_triggerbox.trigger (n)->follow_action(0) == Trigger::PrevTrigger) {
if (_triggerbox.trigger (n)->follow_action (0) == Trigger::PrevTrigger) {
dynamic_cast<Gtk::CheckMenuItem*> (&fitems.back ())->set_active (true);
}
fitems.push_back (RadioMenuElem (fagroup, _("First"), sigc::bind (sigc::mem_fun (*this, &TriggerBoxUI::set_follow_action), n, Trigger::FirstTrigger)));
if (_triggerbox.trigger (n)->follow_action(0) == Trigger::FirstTrigger) {
if (_triggerbox.trigger (n)->follow_action (0) == Trigger::FirstTrigger) {
dynamic_cast<Gtk::CheckMenuItem*> (&fitems.back ())->set_active (true);
}
fitems.push_back (RadioMenuElem (fagroup, _("Last"), sigc::bind (sigc::mem_fun (*this, &TriggerBoxUI::set_follow_action), n, Trigger::LastTrigger)));
if (_triggerbox.trigger (n)->follow_action(0) == Trigger::LastTrigger) {
if (_triggerbox.trigger (n)->follow_action (0) == Trigger::LastTrigger) {
dynamic_cast<Gtk::CheckMenuItem*> (&fitems.back ())->set_active (true);
}
fitems.push_back (RadioMenuElem (fagroup, _("Any"), sigc::bind (sigc::mem_fun (*this, &TriggerBoxUI::set_follow_action), n, Trigger::AnyTrigger)));
if (_triggerbox.trigger (n)->follow_action(0) == Trigger::AnyTrigger) {
if (_triggerbox.trigger (n)->follow_action (0) == Trigger::AnyTrigger) {
dynamic_cast<Gtk::CheckMenuItem*> (&fitems.back ())->set_active (true);
}
fitems.push_back (RadioMenuElem (fagroup, _("Other"), sigc::bind (sigc::mem_fun (*this, &TriggerBoxUI::set_follow_action), n, Trigger::OtherTrigger)));
if (_triggerbox.trigger (n)->follow_action(0) == Trigger::OtherTrigger) {
if (_triggerbox.trigger (n)->follow_action (0) == Trigger::OtherTrigger) {
dynamic_cast<Gtk::CheckMenuItem*> (&fitems.back ())->set_active (true);
}
Menu* launch_menu = manage (new Menu);
MenuList& litems = launch_menu->items();
MenuList& litems = launch_menu->items ();
litems.push_back (RadioMenuElem (lagroup, _("One Shot"), sigc::bind (sigc::mem_fun (*this, &TriggerBoxUI::set_launch_style), n, Trigger::OneShot)));
if (_triggerbox.trigger (n)->launch_style() == Trigger::OneShot) {
if (_triggerbox.trigger (n)->launch_style () == Trigger::OneShot) {
dynamic_cast<Gtk::CheckMenuItem*> (&litems.back ())->set_active (true);
}
litems.push_back (RadioMenuElem (lagroup, _("Gate"), sigc::bind (sigc::mem_fun (*this, &TriggerBoxUI::set_launch_style), n, Trigger::Gate)));
if (_triggerbox.trigger (n)->launch_style() == Trigger::Gate) {
if (_triggerbox.trigger (n)->launch_style () == Trigger::Gate) {
dynamic_cast<Gtk::CheckMenuItem*> (&litems.back ())->set_active (true);
}
litems.push_back (RadioMenuElem (lagroup, _("Toggle"), sigc::bind (sigc::mem_fun (*this, &TriggerBoxUI::set_launch_style), n, Trigger::Toggle)));
if (_triggerbox.trigger (n)->launch_style() == Trigger::Toggle) {
if (_triggerbox.trigger (n)->launch_style () == Trigger::Toggle) {
dynamic_cast<Gtk::CheckMenuItem*> (&litems.back ())->set_active (true);
}
litems.push_back (RadioMenuElem (lagroup, _("Repeat"), sigc::bind (sigc::mem_fun (*this, &TriggerBoxUI::set_launch_style), n, Trigger::Repeat)));
if (_triggerbox.trigger (n)->launch_style() == Trigger::Repeat) {
if (_triggerbox.trigger (n)->launch_style () == Trigger::Repeat) {
dynamic_cast<Gtk::CheckMenuItem*> (&litems.back ())->set_active (true);
}
Menu* quant_menu = manage (new Menu);
MenuList& qitems = quant_menu->items();
MenuList& qitems = quant_menu->items ();
bool success;
Beats grid_beats (PublicEditor::instance().get_grid_type_as_beats (success, timepos_t (0)));
Beats grid_beats (PublicEditor::instance ().get_grid_type_as_beats (success, timepos_t (0)));
BBT_Offset b;
if (success) {
b = BBT_Offset (0, grid_beats.get_beats(), grid_beats.get_ticks());
b = BBT_Offset (0, grid_beats.get_beats (), grid_beats.get_ticks ());
qitems.push_back (RadioMenuElem (fagroup, _("Main Grid"), sigc::bind (sigc::mem_fun (*this, &TriggerBoxUI::set_quantization), n, b)));
/* can't mark this active because the current trigger quant setting may just a specific setting below */
/* XXX HOW TO GET THIS TO FOLLOW GRID CHANGES (which are GUI only) */
@ -702,48 +702,48 @@ TriggerBoxUI::context_menu (uint64_t n)
b = BBT_Offset (1, 0, 0);
qitems.push_back (RadioMenuElem (qgroup, _("Bars"), sigc::bind (sigc::mem_fun (*this, &TriggerBoxUI::set_quantization), n, b)));
if (_triggerbox.trigger (n)->quantization() == b) {
if (_triggerbox.trigger (n)->quantization () == b) {
dynamic_cast<Gtk::CheckMenuItem*> (&qitems.back ())->set_active (true);
}
b = BBT_Offset (0, 4, 0);
qitems.push_back (RadioMenuElem (qgroup, _("Whole"), sigc::bind (sigc::mem_fun (*this, &TriggerBoxUI::set_quantization), n, b)));
if (_triggerbox.trigger (n)->quantization() == b) {
if (_triggerbox.trigger (n)->quantization () == b) {
dynamic_cast<Gtk::CheckMenuItem*> (&qitems.back ())->set_active (true);
}
b = BBT_Offset (0, 2, 0);
qitems.push_back (RadioMenuElem (qgroup, _("Half"), sigc::bind (sigc::mem_fun (*this, &TriggerBoxUI::set_quantization), n, b)));
if (_triggerbox.trigger (n)->quantization() == b) {
if (_triggerbox.trigger (n)->quantization () == b) {
dynamic_cast<Gtk::CheckMenuItem*> (&qitems.back ())->set_active (true);
}
b = BBT_Offset (0, 1, 0);
qitems.push_back (RadioMenuElem (qgroup, _("Quarters"), sigc::bind (sigc::mem_fun (*this, &TriggerBoxUI::set_quantization), n, b)));
if (_triggerbox.trigger (n)->quantization() == b) {
if (_triggerbox.trigger (n)->quantization () == b) {
dynamic_cast<Gtk::CheckMenuItem*> (&qitems.back ())->set_active (true);
}
b = BBT_Offset (0, 0, ticks_per_beat/2);
b = BBT_Offset (0, 0, ticks_per_beat / 2);
qitems.push_back (RadioMenuElem (qgroup, _("Eighths"), sigc::bind (sigc::mem_fun (*this, &TriggerBoxUI::set_quantization), n, b)));
if (_triggerbox.trigger (n)->quantization() == b) {
if (_triggerbox.trigger (n)->quantization () == b) {
dynamic_cast<Gtk::CheckMenuItem*> (&qitems.back ())->set_active (true);
}
b = BBT_Offset (0, 0, ticks_per_beat/4);
b = BBT_Offset (0, 0, ticks_per_beat / 4);
qitems.push_back (RadioMenuElem (qgroup, _("Sixteenths"), sigc::bind (sigc::mem_fun (*this, &TriggerBoxUI::set_quantization), n, b)));
if (_triggerbox.trigger (n)->quantization() == b) {
if (_triggerbox.trigger (n)->quantization () == b) {
dynamic_cast<Gtk::CheckMenuItem*> (&qitems.back ())->set_active (true);
}
b = BBT_Offset (0, 0, ticks_per_beat/8);
b = BBT_Offset (0, 0, ticks_per_beat / 8);
qitems.push_back (RadioMenuElem (qgroup, _("Thirty-Seconds"), sigc::bind (sigc::mem_fun (*this, &TriggerBoxUI::set_quantization), n, b)));
if (_triggerbox.trigger (n)->quantization() == b) {
if (_triggerbox.trigger (n)->quantization () == b) {
dynamic_cast<Gtk::CheckMenuItem*> (&qitems.back ())->set_active (true);
}
b = BBT_Offset (0, 0, ticks_per_beat/16);
b = BBT_Offset (0, 0, ticks_per_beat / 16);
qitems.push_back (RadioMenuElem (qgroup, _("Sixty-Fourths"), sigc::bind (sigc::mem_fun (*this, &TriggerBoxUI::set_quantization), n, b)));
if (_triggerbox.trigger (n)->quantization() == b) {
if (_triggerbox.trigger (n)->quantization () == b) {
dynamic_cast<Gtk::CheckMenuItem*> (&qitems.back ())->set_active (true);
}
Menu* load_menu = manage (new Menu);
MenuList& loitems (load_menu->items());
MenuList& loitems (load_menu->items ());
loitems.push_back (MenuElem (_("from file"), sigc::bind (sigc::mem_fun (*this, &TriggerBoxUI::choose_sample), n)));
loitems.push_back (MenuElem (_("from selection"), sigc::bind (sigc::mem_fun (*this, &TriggerBoxUI::set_from_selection), n)));
@ -754,14 +754,14 @@ TriggerBoxUI::context_menu (uint64_t n)
items.push_back (MenuElem (_("Launch Style..."), *launch_menu));
items.push_back (MenuElem (_("Quantization..."), *quant_menu));
_context_menu->popup (1, gtk_get_current_event_time());
_context_menu->popup (1, gtk_get_current_event_time ());
}
void
TriggerBoxUI::edit_trigger (uint64_t n)
{
Trigger* trigger = _triggerbox.trigger (n);
TriggerWindow* tw = static_cast<TriggerWindow*> (trigger->ui());
TriggerWindow* tw = static_cast<TriggerWindow*> (trigger->ui ());
if (!tw) {
tw = new TriggerWindow (_triggerbox.trigger (n));
@ -784,7 +784,7 @@ TriggerBoxUI::set_launch_style (uint64_t n, Trigger::LaunchStyle ls)
}
void
TriggerBoxUI::set_quantization (uint64_t n, Temporal::BBT_Offset const & q)
TriggerBoxUI::set_quantization (uint64_t n, Temporal::BBT_Offset const& q)
{
_triggerbox.trigger (n)->set_quantization (q);
}
@ -792,23 +792,23 @@ TriggerBoxUI::set_quantization (uint64_t n, Temporal::BBT_Offset const & q)
void
TriggerBoxUI::choose_sample (uint64_t n)
{
if (!file_chooser) {
file_chooser = new Gtk::FileChooserDialog (_("Select sample"), Gtk::FILE_CHOOSER_ACTION_OPEN);
file_chooser->add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
file_chooser->add_button(Gtk::Stock::OK, Gtk::RESPONSE_OK);
file_chooser->set_select_multiple (true);
if (!_file_chooser) {
_file_chooser = new Gtk::FileChooserDialog (_("Select sample"), Gtk::FILE_CHOOSER_ACTION_OPEN);
_file_chooser->add_button (Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
_file_chooser->add_button (Gtk::Stock::OK, Gtk::RESPONSE_OK);
_file_chooser->set_select_multiple (true);
}
file_chooser_connection.disconnect ();
file_chooser_connection = file_chooser->signal_response().connect (sigc::bind (sigc::mem_fun (*this, &TriggerBoxUI::sample_chosen), n));
_file_chooser_connection.disconnect ();
_file_chooser_connection = _file_chooser->signal_response ().connect (sigc::bind (sigc::mem_fun (*this, &TriggerBoxUI::sample_chosen), n));
file_chooser->present ();
_file_chooser->present ();
}
void
TriggerBoxUI::sample_chosen (int response, uint64_t n)
{
file_chooser->hide ();
_file_chooser->hide ();
switch (response) {
case Gtk::RESPONSE_OK:
@ -817,9 +817,9 @@ TriggerBoxUI::sample_chosen (int response, uint64_t n)
return;
}
std::list<std::string> paths = file_chooser->get_filenames ();
std::list<std::string> paths = _file_chooser->get_filenames ();
for (std::list<std::string>::iterator s = paths.begin(); s != paths.end(); ++s) {
for (std::list<std::string>::iterator s = paths.begin (); s != paths.end (); ++s) {
/* this will do nothing if n is too large */
_triggerbox.set_from_path (n, *s);
++n;
@ -840,7 +840,7 @@ TriggerBoxUI::slot_at_y (int y) const
}
bool
TriggerBoxUI::drag_motion (Glib::RefPtr<Gdk::DragContext>const& context, int, int y, guint time)
TriggerBoxUI::drag_motion (Glib::RefPtr<Gdk::DragContext> const& context, int, int y, guint time)
{
bool can_drop = true;
uint64_t n = slot_at_y (y);
@ -850,7 +850,7 @@ TriggerBoxUI::drag_motion (Glib::RefPtr<Gdk::DragContext>const& context, int, in
}
if (can_drop) {
context->drag_status(Gdk::ACTION_COPY, time);
context->drag_status (Gdk::ACTION_COPY, time);
/* prelight */
GdkEventCrossing ev;
ev.detail = GDK_NOTIFY_ANCESTOR;
@ -866,7 +866,7 @@ TriggerBoxUI::drag_motion (Glib::RefPtr<Gdk::DragContext>const& context, int, in
}
void
TriggerBoxUI::drag_leave (Glib::RefPtr<Gdk::DragContext>const&, guint)
TriggerBoxUI::drag_leave (Glib::RefPtr<Gdk::DragContext> const&, guint)
{
GdkEventCrossing ev;
ev.type = GDK_LEAVE_NOTIFY;
@ -884,8 +884,8 @@ TriggerBoxUI::drag_data_received (Glib::RefPtr<Gdk::DragContext> const& context,
context->drag_finish (false, false, time);
return;
}
if (data.get_target() == X_("regions")) {
boost::shared_ptr<Region> region = PublicEditor::instance().get_dragged_region_from_sidebar ();
if (data.get_target () == X_("regions")) {
boost::shared_ptr<Region> region = PublicEditor::instance ().get_dragged_region_from_sidebar ();
if (region) {
_triggerbox.set_from_selection (n, region);
context->drag_finish (true, false, time);
@ -909,16 +909,16 @@ TriggerBoxUI::drag_data_received (Glib::RefPtr<Gdk::DragContext> const& context,
void
TriggerBoxUI::set_from_selection (uint64_t n)
{
Selection& selection (PublicEditor::instance().get_selection());
Selection& selection (PublicEditor::instance ().get_selection ());
RegionSelection rselection (selection.regions);
if (rselection.empty()) {
if (rselection.empty ()) {
/* XXX possible message about no selection ? */
return;
}
for (RegionSelection::iterator r = rselection.begin(); r != rselection.end(); ++r) {
_triggerbox.set_from_selection (n, (*r)->region());
for (RegionSelection::iterator r = rselection.begin (); r != rselection.end (); ++r) {
_triggerbox.set_from_selection (n, (*r)->region ());
++n;
}
}
@ -926,33 +926,35 @@ TriggerBoxUI::set_from_selection (uint64_t n)
void
TriggerBoxUI::start_updating ()
{
update_connection = Timers::rapid_connect (sigc::mem_fun (*this, &TriggerBoxUI::rapid_update));
_update_connection = Timers::rapid_connect (sigc::mem_fun (*this, &TriggerBoxUI::rapid_update));
}
void
TriggerBoxUI::stop_updating ()
{
update_connection.disconnect ();
_update_connection.disconnect ();
}
void
TriggerBoxUI::rapid_update ()
{
for (auto & slot : _slots) {
for (auto& slot : _slots) {
slot->maybe_update ();
}
}
TriggerBoxWidget::TriggerBoxWidget (float w, float h) : FittedCanvasWidget(w,h), ui (0)
TriggerBoxWidget::TriggerBoxWidget (float w, float h)
: FittedCanvasWidget (w, h)
, ui (0)
{
set_background_color (UIConfiguration::instance().color (X_("theme:bg")));
set_background_color (UIConfiguration::instance ().color (X_("theme:bg")));
}
void
TriggerBoxWidget::set_triggerbox (TriggerBox* tb)
{
if (ui) {
root()->remove (ui);
root ()->remove (ui);
delete ui;
ui = 0;
}
@ -961,10 +963,10 @@ TriggerBoxWidget::set_triggerbox (TriggerBox* tb)
return;
}
ui = new TriggerBoxUI (root(), *tb);
ui = new TriggerBoxUI (root (), *tb);
repeat_size_allocation ();
if (is_mapped()) {
if (is_mapped ()) {
ui->start_updating ();
}
}

View file

@ -16,44 +16,45 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef __ardour_gtk_triggerbox_ui_h__
#define __ardour_gtk_triggerbox_ui_h__
#include <map>
#include <gtkmm/window.h>
#ifndef _gtk_ardour_triggerbox_ui_h_
#define _gtk_ardour_triggerbox_ui_h_
#include "pbd/properties.h"
#include "ardour/triggerbox.h"
#include "canvas/table.h"
#include "canvas/canvas.h"
#include "canvas/rectangle.h"
#include "fitted_canvas_widget.h"
namespace Gtk {
class FileChooserDialog;
class Menu;
namespace Gtk
{
class FileChooserDialog;
class Menu;
}
namespace Temporal {
namespace Temporal
{
struct BBT_Offset;
}
namespace ArdourCanvas {
namespace ArdourCanvas
{
class Text;
class Polygon;
};
}
class TriggerEntry : public ArdourCanvas::Rectangle
{
public:
public:
TriggerEntry (ArdourCanvas::Item* item, ARDOUR::Trigger&);
~TriggerEntry ();
ARDOUR::Trigger& trigger() const { return _trigger; }
ARDOUR::Trigger& trigger () const
{
return _trigger;
}
ArdourCanvas::Rectangle* play_button;
ArdourCanvas::Polygon* play_shape;
@ -61,26 +62,26 @@ class TriggerEntry : public ArdourCanvas::Rectangle
ArdourCanvas::Rectangle* name_button;
ArdourCanvas::Text* name_text;
void render (ArdourCanvas::Rect const & area, Cairo::RefPtr<Cairo::Context> context) const;
void render (ArdourCanvas::Rect const& area, Cairo::RefPtr<Cairo::Context> context) const;
void _size_allocate (ArdourCanvas::Rect const &);
void _size_allocate (ArdourCanvas::Rect const&);
void maybe_update ();
void selection_change ();
void set_default_colors();
void set_default_colors ();
private:
private:
ARDOUR::Trigger& _trigger;
double poly_size;
double poly_margin;
double _poly_size;
double _poly_margin;
PBD::ScopedConnection trigger_prop_connection;
void prop_change (PBD::PropertyChange const & change);
void prop_change (PBD::PropertyChange const& change);
void shape_play_button ();
PBD::ScopedConnection owner_prop_connection;
void owner_prop_change (PBD::PropertyChange const &);
void owner_prop_change (PBD::PropertyChange const&);
void owner_color_changed ();
void ui_parameter_changed (std::string const& p);
@ -88,7 +89,7 @@ class TriggerEntry : public ArdourCanvas::Rectangle
class TriggerBoxUI : public ArdourCanvas::Rectangle
{
public:
public:
TriggerBoxUI (ArdourCanvas::Item* parent, ARDOUR::TriggerBox&);
~TriggerBoxUI ();
@ -101,14 +102,15 @@ class TriggerBoxUI : public ArdourCanvas::Rectangle
static void trigger_scene (int32_t);
void _size_allocate (ArdourCanvas::Rect const &);
void _size_allocate (ArdourCanvas::Rect const&);
private:
ARDOUR::TriggerBox& _triggerbox;
typedef std::vector<TriggerEntry*> Slots;
ARDOUR::TriggerBox& _triggerbox;
Slots _slots;
Gtk::FileChooserDialog* file_chooser;
sigc::connection file_chooser_connection;
Gtk::FileChooserDialog* _file_chooser;
sigc::connection _file_chooser_connection;
Gtk::Menu* _context_menu;
static Gtkmm2ext::Bindings* bindings;
@ -123,7 +125,7 @@ private:
void context_menu (uint64_t n);
void set_follow_action (uint64_t slot, ARDOUR::Trigger::FollowAction);
void set_launch_style (uint64_t slot, ARDOUR::Trigger::LaunchStyle);
void set_quantization (uint64_t slot, Temporal::BBT_Offset const &);
void set_quantization (uint64_t slot, Temporal::BBT_Offset const&);
void set_from_selection (uint64_t slot);
void build ();
@ -131,19 +133,19 @@ private:
void selection_changed ();
bool drag_motion (Glib::RefPtr<Gdk::DragContext>const&, int, int, guint);
void drag_leave (Glib::RefPtr<Gdk::DragContext>const&, guint);
bool drag_motion (Glib::RefPtr<Gdk::DragContext> const&, int, int, guint);
void drag_leave (Glib::RefPtr<Gdk::DragContext> const&, guint);
void drag_data_received (Glib::RefPtr<Gdk::DragContext> const&, int, int, Gtk::SelectionData const&, guint, guint);
uint64_t slot_at_y (int) const;
sigc::connection update_connection;
sigc::connection selection_connection;
sigc::connection _update_connection;
sigc::connection _selection_connection;
};
class TriggerBoxWidget : public FittedCanvasWidget
{
public:
public:
TriggerBoxWidget (float w, float h);
void set_triggerbox (ARDOUR::TriggerBox* tb);
@ -151,8 +153,8 @@ class TriggerBoxWidget : public FittedCanvasWidget
void on_map ();
void on_unmap ();
private:
private:
TriggerBoxUI* ui;
};
#endif /* __ardour_gtk_triggerbox_ui_h__ */
#endif