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
Signed by: rgareus
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,39 +50,39 @@ 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 ();
play_shape = new ArdourCanvas::Polygon (play_button);
play_shape = new ArdourCanvas::Polygon (play_button);
play_shape->name = string_compose ("playshape %1", _cue_idx);
play_shape->show ();
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 ()
@ -93,98 +93,98 @@ bool
CueEntry::event_handler (GdkEvent* ev)
{
switch (ev->type) {
case GDK_BUTTON_PRESS:
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 ());
}
break;
case GDK_LEAVE_NOTIFY:
if (ev->crossing.detail != GDK_NOTIFY_INFERIOR) {
set_default_colors();
}
break;
default:
break;
case GDK_BUTTON_PRESS:
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 ());
}
break;
case GDK_LEAVE_NOTIFY:
if (ev->crossing.detail != GDK_NOTIFY_INFERIOR) {
set_default_colors ();
}
break;
default:
break;
}
return false;
}
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()
*/
ArdourCanvas::Rect self (item_to_window (_rect));
* part of item_to_canvas()
*/
ArdourCanvas::Rect self (item_to_window (_rect));
const ArdourCanvas::Rect draw = self.intersection (area);
if (!draw) {
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);
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);
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;
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;
}
@ -344,27 +342,25 @@ bool
CueBoxUI::event (GdkEvent* ev, uint64_t n)
{
switch (ev->type) {
case GDK_BUTTON_PRESS:
trigger_scene(n);
break;
case GDK_2BUTTON_PRESS:
break;
case GDK_BUTTON_RELEASE:
break;
default:
break;
case GDK_BUTTON_PRESS:
trigger_scene (n);
break;
case GDK_2BUTTON_PRESS:
break;
case GDK_BUTTON_RELEASE:
break;
default:
break;
}
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,93 +26,81 @@
#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;
ArdourCanvas::Polygon* play_shape;
ArdourCanvas::Polygon* play_shape;
ArdourCanvas::Rectangle* name_button;
ArdourCanvas::Text* name_text;
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 ();
void trigger_scene (uint64_t n);
static Glib::RefPtr<Gtk::ActionGroup> trigger_actions;
static void setup_actions_and_bindings ();
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_pattern->add_color_stop_rgba (0, 0, 0, 0, 0.7);
drop_shadow_pattern->add_color_stop_rgba (1, 0, 0, 0, 0.0);
/* 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,23 +306,23 @@ 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;
case GDK_BUTTON_RELEASE:
switch (ev->button.button) {
case 3:
context_menu ();
return true;
case 3:
context_menu ();
return true;
}
default:
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_pattern->add_color_stop_rgba (0, 0, 0, 0, 0.7);
drop_shadow_pattern->add_color_stop_rgba (1, 0, 0, 0, 0.0);
/* 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

File diff suppressed because it is too large Load Diff

View File

@ -16,79 +16,80 @@
* 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;
ArdourCanvas::Polygon* play_shape;
ArdourCanvas::Rectangle* name_button;
ArdourCanvas::Text* name_text;
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 shape_play_button ();
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_color_changed ();
void owner_prop_change (PBD::PropertyChange const&);
void owner_color_changed ();
void ui_parameter_changed (std::string const& p);
};
class TriggerBoxUI : public ArdourCanvas::Rectangle
{
public:
public:
TriggerBoxUI (ArdourCanvas::Item* parent, ARDOUR::TriggerBox&);
~TriggerBoxUI ();
@ -97,23 +98,24 @@ class TriggerBoxUI : public ArdourCanvas::Rectangle
void stop_updating ();
static Glib::RefPtr<Gtk::ActionGroup> trigger_actions;
static void setup_actions_and_bindings ();
static void setup_actions_and_bindings ();
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;
Slots _slots;
Gtk::FileChooserDialog* file_chooser;
sigc::connection file_chooser_connection;
Gtk::Menu* _context_menu;
ARDOUR::TriggerBox& _triggerbox;
Slots _slots;
Gtk::FileChooserDialog* _file_chooser;
sigc::connection _file_chooser_connection;
Gtk::Menu* _context_menu;
static Gtkmm2ext::Bindings* bindings;
static void load_bindings ();
static void register_actions ();
static void load_bindings ();
static void register_actions ();
bool play_button_event (GdkEvent*, uint64_t);
bool text_button_event (GdkEvent*, uint64_t);
@ -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