diff --git a/gtk2_ardour/fitted_canvas_widget.cc b/gtk2_ardour/fitted_canvas_widget.cc index ae6505a1b0..a81bd3f8af 100644 --- a/gtk2_ardour/fitted_canvas_widget.cc +++ b/gtk2_ardour/fitted_canvas_widget.cc @@ -33,8 +33,8 @@ #include "actions.h" #include "gui_thread.h" -#include "utils.h" #include "timers.h" +#include "utils.h" #include "fitted_canvas_widget.h" @@ -44,48 +44,48 @@ using namespace Gtk; using namespace Gtkmm2ext; using namespace ARDOUR_UI_UTILS; - -//a gtk widget with fixed-size semantics +/** a gtk widget with fixed-size semantics */ FittedCanvasWidget::FittedCanvasWidget (float w, float h, bool follow_scale) { - _nominal_width = w; + _nominal_width = w; _nominal_height = h; - _follow_scale = follow_scale; + _follow_scale = follow_scale; - //our rendering speed suffers if we re-render knobs simply because they are in-between 2 meters that got invalidated (for example) -// set_single_exposure(false); -//#ifdef __APPLE__ -// use_intermediate_surface (false); -//#endif + /* our rendering speed suffers if we re-render knobs simply because + * they are in-between 2 meters that got invalidated (for example) + */ + // set_single_exposure(false); +#ifdef __APPLE__ + // use_intermediate_surface (false); +#endif } void FittedCanvasWidget::on_size_request (Gtk::Requisition* req) { - const double scale = _follow_scale ? UIConfiguration::instance().get_ui_scale() : 1; - if (_nominal_width>0) { - req->width = _nominal_width*scale; + const double scale = _follow_scale ? UIConfiguration::instance ().get_ui_scale () : 1; + if (_nominal_width > 0) { + req->width = _nominal_width * scale; } - if (_nominal_height>0) { - req->height = _nominal_height*scale; + if (_nominal_height > 0) { + req->height = _nominal_height * scale; } } - void FittedCanvasWidget::on_size_allocate (Gtk::Allocation& alloc) { - GtkCanvas::on_size_allocate(alloc); + GtkCanvas::on_size_allocate (alloc); repeat_size_allocation (); } void FittedCanvasWidget::repeat_size_allocation () { - if (!_root.items().empty()) { - ArdourCanvas::Item *fitted = *_root.items().begin(); - Gtk::Allocation a = get_allocation (); - fitted->size_allocate (ArdourCanvas::Rect (0, 0, a.get_width(), a.get_height())); + if (_root.items ().empty ()) { + return; } -} + Gtk::Allocation a = get_allocation (); + _root.items ().front ()->size_allocate (ArdourCanvas::Rect (0, 0, a.get_width (), a.get_height ())); +} diff --git a/gtk2_ardour/fitted_canvas_widget.h b/gtk2_ardour/fitted_canvas_widget.h index 2de7a4fc52..82ef09d59f 100644 --- a/gtk2_ardour/fitted_canvas_widget.h +++ b/gtk2_ardour/fitted_canvas_widget.h @@ -17,55 +17,40 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#ifndef __fitted_canvas_widget__ -#define __fitted_canvas_widget__ - -#include -#include - -#include +#ifndef _gtk_ardour_fitted_canvas_widget_h_ +#define _gtk_ardour_fitted_canvas_widget_h_ #include -#include -#include -#include -#include -#include #include -#include -#include -#include -#include - -#include "route_ui.h" - /* FittedCanvasWidget has these properties: * it is provided a 'nominal size' on construction, which it will request of gtk * if asked, will resize itself when the user gui/font scale changes * it 'fits' the Item that was first attached to Root (presumably the top-level widget or container) * the fitted Item will be explicitly resized to fit when the canvas size is allocated * the fitted Item may be a container; it should allocate child positions during size_allocate() - * */ - + */ class FittedCanvasWidget : public ArdourCanvas::GtkCanvas { public: /* per gtk convention you may use -1 for width OR height if you don't care about that dimension */ - FittedCanvasWidget(float nominal_width, float nominal_height, bool follow_scale=true); + FittedCanvasWidget (float nominal_width, float nominal_height, bool follow_scale = true); /* call if the root item's first child is changed, to force a size-allocate on it */ void repeat_size_allocation (); - void on_size_request (Gtk::Requisition* req); //always returns the nominal size, regardless of children - void on_size_allocate (Gtk::Allocation& alloc); + /* always returns the nominal size, regardless of children */ + void on_size_request (Gtk::Requisition*); + + void on_size_allocate (Gtk::Allocation&); private: ArdourCanvas::Rect _allocation; + float _nominal_width; float _nominal_height; bool _follow_scale; }; -#endif //__fitted_canvas_widget__ +#endif // _gtk_ardour_fitted_canvas_widget_h_ diff --git a/gtk2_ardour/trigger_master.cc b/gtk2_ardour/trigger_master.cc index 5070ba6c4c..817d1949a3 100644 --- a/gtk2_ardour/trigger_master.cc +++ b/gtk2_ardour/trigger_master.cc @@ -25,7 +25,6 @@ #include "pbd/convert.h" #include "ardour/region.h" -#include "ardour/triggerbox.h" #include "canvas/polygon.h" #include "canvas/text.h" @@ -36,12 +35,12 @@ #include "ardour_ui.h" #include "gui_thread.h" -#include "trigger_master.h" -#include "trigger_ui.h" #include "public_editor.h" #include "region_view.h" #include "selection.h" #include "timers.h" +#include "trigger_master.h" +#include "trigger_ui.h" #include "ui_config.h" #include "utils.h" @@ -52,85 +51,84 @@ using namespace ArdourCanvas; using namespace Gtkmm2ext; using namespace PBD; -static const int nslices = 8; //in 8 pie slices .. ToDo .. maybe make this meter-senstive ... triplets and such... ? +static const int nslices = 8; // in 8 pie slices .. TODO .. maybe make this meter-senstive ... triplets and such... ? Loopster::Loopster (Item* parent) : ArdourCanvas::Rectangle (parent) - , _fraction(0) + , _fraction (0) { } void Loopster::set_fraction (float f) { - f = std::max(0.f, f); - f = std::min(1.f, f); + f = std::max (0.f, f); + f = std::min (1.f, f); - float prior_slice = floor(_fraction * nslices); - float new_slice = floor(f*nslices); + float prior_slice = floor (_fraction * nslices); + float new_slice = floor (f * nslices); if (new_slice != prior_slice) { _fraction = f; - redraw(); + redraw (); } } void -Loopster::render (Rect const & area, Cairo::RefPtr context) const +Loopster::render (Rect const& area, Cairo::RefPtr context) const { /* Note that item_to_window() already takes _position into account (as - part of item_to_canvas() - */ - Rect self (item_to_window (_rect)); + * part of item_to_canvas() + */ + Rect self (item_to_window (_rect)); const Rect draw = self.intersection (area); if (!draw) { return; } - context->set_identity_matrix(); - context->translate (self.x0, self.y0-0.5); + context->set_identity_matrix (); + context->translate (self.x0, self.y0 - 0.5); - float size = _rect.height(); + float size = _rect.height (); - const double scale = UIConfiguration::instance().get_ui_scale(); + const double scale = UIConfiguration::instance ().get_ui_scale (); - //white area - set_source_rgba (context, rgba_to_color (1,1,1,1)); - context->arc ( size/2, size/2, size/2 - 4*scale, 0, 2*M_PI ); - context->fill(); + /* white area */ + set_source_rgba (context, rgba_to_color (1, 1, 1, 1)); + context->arc (size / 2, size / 2, size / 2 - 4 * scale, 0, 2 * M_PI); + context->fill (); - //arc fill - context->set_line_width(5*scale); - float slices = floor(_fraction * nslices); - float deg_per_slice = 360/nslices; - float degrees = slices * deg_per_slice; - float radians = (degrees/180)*M_PI; - set_source_rgba (context, rgba_to_color (0,0,0,1)); - context->arc ( size/2, size/2, size/2 - 5*scale, 1.5*M_PI+radians, 1.5*M_PI+2*M_PI ); - context->stroke(); + /* arc fill */ + context->set_line_width (5 * scale); + float slices = floor (_fraction * nslices); + float deg_per_slice = 360 / nslices; + float degrees = slices * deg_per_slice; + float radians = (degrees / 180) * M_PI; + set_source_rgba (context, rgba_to_color (0, 0, 0, 1)); + context->arc (size / 2, size / 2, size / 2 - 5 * scale, 1.5 * M_PI + radians, 1.5 * M_PI + 2 * M_PI); + context->stroke (); - context->set_line_width(1); - context->set_identity_matrix(); + context->set_line_width (1); + context->set_identity_matrix (); } -/* ======================== */ - class PassThru : public ArdourCanvas::Rectangle { - public: +public: PassThru (ArdourCanvas::Item* canvas); - void render (ArdourCanvas::Rect const & area, Cairo::RefPtr context) const; + void render (ArdourCanvas::Rect const& area, Cairo::RefPtr context) const; void set_enabled (bool e); - private: + +private: bool _enabled; }; PassThru::PassThru (Item* parent) : ArdourCanvas::Rectangle (parent) { - set_enabled(false); + set_enabled (false); } void @@ -138,144 +136,139 @@ PassThru::set_enabled (bool e) { if (e != _enabled) { _enabled = e; - redraw(); + redraw (); } } void -PassThru::render (Rect const & area, Cairo::RefPtr context) const +PassThru::render (Rect const& area, Cairo::RefPtr context) const { /* Note that item_to_window() already takes _position into account (as - part of item_to_canvas() - */ - Rect self (item_to_window (_rect)); + * part of item_to_canvas() + */ + Rect self (item_to_window (_rect)); const Rect draw = self.intersection (area); if (!draw) { return; } - context->set_identity_matrix(); - context->translate (self.x0, self.y0-0.5); + context->set_identity_matrix (); + context->translate (self.x0, self.y0 - 0.5); - float size = _rect.height(); + float size = _rect.height (); - const double scale = UIConfiguration::instance().get_ui_scale(); + 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 (); } } -/* ======================== */ - - TriggerMaster::TriggerMaster (Item* parent) : ArdourCanvas::Rectangle (parent) , _context_menu (0) { - set_layout_sensitive(true); //why??? + set_layout_sensitive (true); // why??? name = X_("trigger stopper"); Event.connect (sigc::mem_fun (*this, &TriggerMaster::event_handler)); name_text = new Text (this); - name_text->set(""); + name_text->set (""); name_text->set_ignore_events (false); - _loopster = new Loopster(this); - _passthru = new PassThru(this); + _loopster = new Loopster (this); + _passthru = new PassThru (this); - /* trigger changes - _triggerbox->PropertyChanged.connect (trigger_prop_connection, MISSING_INVALIDATOR, boost::bind (&TriggerMaster::prop_change, this, _1), gui_context()); +#if 0 /* XXX trigger changes */ + _triggerbox->PropertyChanged.connect (_trigger_prop_connection, MISSING_INVALIDATOR, boost::bind (&TriggerMaster::prop_change, this, _1), gui_context()); PropertyChange changed; changed.add (ARDOUR::Properties::name); changed.add (ARDOUR::Properties::running); prop_change (changed); - */ +#endif - /* route changes - dynamic_cast (_triggerbox->owner())->presentation_info().Change.connect (owner_prop_connection, MISSING_INVALIDATOR, boost::bind (&TriggerMaster::owner_prop_change, this, _1), gui_context()); - */ +#if 0 /* XXX route changes */ + dynamic_cast (_triggerbox->owner())->presentation_info().Change.connect (_owner_prop_connection, MISSING_INVALIDATOR, boost::bind (&TriggerMaster::owner_prop_change, this, _1), gui_context()); +#endif - update_connection = Timers::rapid_connect (sigc::mem_fun (*this, &TriggerMaster::maybe_update)); + _update_connection = Timers::rapid_connect (sigc::mem_fun (*this, &TriggerMaster::maybe_update)); /* prefs (theme colors) */ - UIConfiguration::instance().ParameterChanged.connect (sigc::mem_fun (*this, &TriggerMaster::ui_parameter_changed)); - set_default_colors(); + UIConfiguration::instance ().ParameterChanged.connect (sigc::mem_fun (*this, &TriggerMaster::ui_parameter_changed)); + set_default_colors (); } TriggerMaster::~TriggerMaster () { - update_connection.disconnect(); } -void TriggerMaster::set_trigger (boost::shared_ptr t) +void +TriggerMaster::set_trigger (boost::shared_ptr t) { _triggerbox = t; } void -TriggerMaster::render (Rect const & area, Cairo::RefPtr context) const +TriggerMaster::render (Rect const& area, Cairo::RefPtr context) const { /* Note that item_to_window() already takes _position into account (as - part of item_to_canvas() - */ - Rect self (item_to_window (_rect)); + * part of item_to_canvas() + */ + Rect self (item_to_window (_rect)); const 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); - { - //line at right - 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(width-1, 0, width, height); - context->fill (); - context->set_identity_matrix(); - } - - //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 right */ + 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 (width - 1, 0, width, height); context->fill (); - context->set_identity_matrix(); + context->set_identity_matrix (); + + /* 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 (); } void -TriggerMaster::owner_prop_change (PropertyChange const & pc) +TriggerMaster::owner_prop_change (PropertyChange const& pc) { if (pc.contains (Properties::color)) { } @@ -294,36 +287,36 @@ TriggerMaster::event_handler (GdkEvent* ev) } switch (ev->type) { - case GDK_BUTTON_PRESS: - if (ev->button.button == 1) { - _triggerbox->request_stop_all (); - return true; - } - break; - case GDK_ENTER_NOTIFY: - if (ev->crossing.detail != GDK_NOTIFY_INFERIOR) { - name_text->set_color (UIConfiguration::instance().color("neutral:foregroundest")); - 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(); - } - redraw (); - break; - case GDK_BUTTON_RELEASE: - switch (ev->button.button) { - case 3: - context_menu (); - return true; + case GDK_BUTTON_PRESS: + if (ev->button.button == 1) { + _triggerbox->request_stop_all (); + return true; + } + break; + case GDK_ENTER_NOTIFY: + if (ev->crossing.detail != GDK_NOTIFY_INFERIOR) { + name_text->set_color (UIConfiguration::instance ().color ("neutral:foregroundest")); + 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 (); + } + redraw (); + break; + case GDK_BUTTON_RELEASE: + switch (ev->button.button) { + case 3: + context_menu (); + return true; + default: + break; + } + break; default: break; - } - break; - default: - break; } return false; @@ -338,12 +331,12 @@ TriggerMaster::context_menu () delete _context_menu; - _context_menu = new Menu; - MenuList& items = _context_menu->items(); + _context_menu = new Menu; + MenuList& items = _context_menu->items (); _context_menu->set_name ("ArdourContextMenu"); - Menu* follow_menu = manage (new Menu); - MenuList& fitems = follow_menu->items(); + Menu* follow_menu = manage (new Menu); + MenuList& fitems = follow_menu->items (); fitems.push_back (MenuElem (_("Stop"), sigc::bind (sigc::mem_fun (*this, &TriggerMaster::set_all_follow_action), Trigger::Stop))); fitems.push_back (MenuElem (_("Again"), sigc::bind (sigc::mem_fun (*this, &TriggerMaster::set_all_follow_action), Trigger::Again))); @@ -352,21 +345,21 @@ TriggerMaster::context_menu () fitems.push_back (MenuElem (_("Any"), sigc::bind (sigc::mem_fun (*this, &TriggerMaster::set_all_follow_action), Trigger::AnyTrigger))); fitems.push_back (MenuElem (_("Other"), sigc::bind (sigc::mem_fun (*this, &TriggerMaster::set_all_follow_action), Trigger::OtherTrigger))); - Menu* launch_menu = manage (new Menu); - MenuList& litems = launch_menu->items(); + Menu* launch_menu = manage (new Menu); + MenuList& litems = launch_menu->items (); litems.push_back (MenuElem (_("One Shot"), sigc::bind (sigc::mem_fun (*this, &TriggerMaster::set_all_launch_style), Trigger::OneShot))); litems.push_back (MenuElem (_("Gate"), sigc::bind (sigc::mem_fun (*this, &TriggerMaster::set_all_launch_style), Trigger::Gate))); litems.push_back (MenuElem (_("Toggle"), sigc::bind (sigc::mem_fun (*this, &TriggerMaster::set_all_launch_style), Trigger::Toggle))); litems.push_back (MenuElem (_("Repeat"), sigc::bind (sigc::mem_fun (*this, &TriggerMaster::set_all_launch_style), Trigger::Repeat))); - Menu* quant_menu = manage (new Menu); - MenuList& qitems = quant_menu->items(); + Menu* quant_menu = manage (new Menu); + MenuList& qitems = quant_menu->items (); BBT_Offset b; b = BBT_Offset (1, 0, 0); - qitems.push_back (MenuElem (_("Global"), sigc::bind (sigc::mem_fun (*this, &TriggerMaster::set_all_quantization), b))); //ToDo + qitems.push_back (MenuElem (_("Global"), sigc::bind (sigc::mem_fun (*this, &TriggerMaster::set_all_quantization), b))); // TODO b = BBT_Offset (1, 0, 0); qitems.push_back (MenuElem (_("Bars"), sigc::bind (sigc::mem_fun (*this, &TriggerMaster::set_all_quantization), b))); @@ -376,54 +369,54 @@ TriggerMaster::context_menu () qitems.push_back (MenuElem (_("Half"), sigc::bind (sigc::mem_fun (*this, &TriggerMaster::set_all_quantization), b))); b = BBT_Offset (0, 1, 0); qitems.push_back (MenuElem (_("Quarters"), sigc::bind (sigc::mem_fun (*this, &TriggerMaster::set_all_quantization), b))); - b = BBT_Offset (0, 0, ticks_per_beat/2); + b = BBT_Offset (0, 0, ticks_per_beat / 2); qitems.push_back (MenuElem (_("Eighths"), sigc::bind (sigc::mem_fun (*this, &TriggerMaster::set_all_quantization), b))); - b = BBT_Offset (0, 0, ticks_per_beat/4); - qitems.push_back (MenuElem ( _("Sixteenths"), sigc::bind (sigc::mem_fun (*this, &TriggerMaster::set_all_quantization), b))); - b = BBT_Offset (0, 0, ticks_per_beat/8); + b = BBT_Offset (0, 0, ticks_per_beat / 4); + qitems.push_back (MenuElem (_("Sixteenths"), sigc::bind (sigc::mem_fun (*this, &TriggerMaster::set_all_quantization), b))); + b = BBT_Offset (0, 0, ticks_per_beat / 8); qitems.push_back (MenuElem (_("Thirty-Seconds"), sigc::bind (sigc::mem_fun (*this, &TriggerMaster::set_all_quantization), b))); - b = BBT_Offset (0, 0, ticks_per_beat/16); + b = BBT_Offset (0, 0, ticks_per_beat / 16); qitems.push_back (MenuElem (_("Sixty-Fourths"), sigc::bind (sigc::mem_fun (*this, &TriggerMaster::set_all_quantization), b))); - Menu* load_menu = manage (new Menu); - MenuList& loitems (load_menu->items()); + Menu* load_menu = manage (new Menu); + MenuList& loitems (load_menu->items ()); items.push_back (CheckMenuElem (_("Toggle Monitor Thru"), sigc::mem_fun (*this, &TriggerMaster::toggle_thru))); - if (_triggerbox->pass_thru()) { + if (_triggerbox->pass_thru ()) { dynamic_cast (&items.back ())->set_active (true); } - items.push_back (MenuElem (_("Enable/Disable..."), sigc::mem_fun (*this, &TriggerMaster::maybe_update))); //ToDo + items.push_back (MenuElem (_("Enable/Disable..."), sigc::mem_fun (*this, &TriggerMaster::maybe_update))); // TODO items.push_back (MenuElem (_("Follow Action..."), *follow_menu)); items.push_back (MenuElem (_("Launch Style..."), *launch_menu)); items.push_back (MenuElem (_("Quantization..."), *quant_menu)); - items.push_back (MenuElem (_("Clear All..."), sigc::mem_fun (*this, &TriggerMaster::maybe_update))); //ToDo + items.push_back (MenuElem (_("Clear All..."), sigc::mem_fun (*this, &TriggerMaster::maybe_update))); // TODO - _context_menu->popup (1, gtk_get_current_event_time()); + _context_menu->popup (1, gtk_get_current_event_time ()); } void TriggerMaster::toggle_thru () { - _triggerbox->set_pass_thru(!_triggerbox->pass_thru()); + _triggerbox->set_pass_thru (!_triggerbox->pass_thru ()); } void TriggerMaster::set_all_follow_action (Trigger::FollowAction fa) { - //ToDo + // TODO } void TriggerMaster::set_all_launch_style (Trigger::LaunchStyle ls) { - //ToDo + // TODO } void -TriggerMaster::set_all_quantization (Temporal::BBT_Offset const & q) +TriggerMaster::set_all_quantization (Temporal::BBT_Offset const& q) { - //ToDo + // TODO } void @@ -432,96 +425,91 @@ TriggerMaster::maybe_update () PropertyChange changed; changed.add (ARDOUR::Properties::name); changed.add (ARDOUR::Properties::running); - prop_change(changed); + prop_change (changed); } void -TriggerMaster::_size_allocate (ArdourCanvas::Rect const & alloc) +TriggerMaster::_size_allocate (ArdourCanvas::Rect const& alloc) { Rectangle::_size_allocate (alloc); - const double scale = UIConfiguration::instance().get_ui_scale(); - poly_margin = 2. * scale; + const double scale = UIConfiguration::instance ().get_ui_scale (); + _poly_margin = 2. * scale; - const Distance width = _rect.width(); - const Distance height = _rect.height(); + const Distance width = _rect.width (); + const Distance height = _rect.height (); - poly_size = height - (poly_margin*2); + _poly_size = height - (_poly_margin * 2); - float tleft = poly_size + (poly_margin*3); - float twidth = width-poly_size-(poly_margin*3); + float tleft = _poly_size + (_poly_margin * 3); + float twidth = width - _poly_size - (_poly_margin * 3); 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->set_position (Duple (tleft, 1. * scale)); name_text->clamp_width (twidth); - _loopster->set(ArdourCanvas::Rect(0, 0, height, height)); - _passthru->set(ArdourCanvas::Rect(width-height, 0, width, height)); + _loopster->set (ArdourCanvas::Rect (0, 0, height, height)); + _passthru->set (ArdourCanvas::Rect (width - height, 0, 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 -TriggerMaster::prop_change (PropertyChange const & change) +TriggerMaster::prop_change (PropertyChange const& change) { if (!_triggerbox) { return; } - _passthru->set_enabled(_triggerbox->pass_thru ()); + _passthru->set_enabled (_triggerbox->pass_thru ()); std::string text; - ARDOUR::Trigger *trigger = _triggerbox->currently_playing(); + ARDOUR::Trigger* trigger = _triggerbox->currently_playing (); if (!trigger) { - name_text->set(text); - _loopster->hide(); + name_text->set (text); + _loopster->hide (); return; } - text = string_compose ("%1", (char) ('A'+ trigger->index())); + text = string_compose ("%1", (char)('A' + trigger->index ())); - if (trigger->follow_count() > 1) { - text.append(string_compose(X_(" %1/%2"), trigger->loop_count(), trigger->follow_count())); + if (trigger->follow_count () > 1) { + text.append (string_compose (X_(" %1/%2"), trigger->loop_count (), trigger->follow_count ())); } - - name_text->set(text); - if (trigger->active()) { + name_text->set (text); + + if (trigger->active ()) { double f = trigger->position_as_fraction (); - _loopster->set_fraction(f); - _loopster->show(); + _loopster->set_fraction (f); + _loopster->show (); } else { - _loopster->hide(); + _loopster->hide (); } } 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")); + set_fill_color (HSV (UIConfiguration::instance ().color ("theme:bg")).darker (0.25).color ()); + name_text->set_color (UIConfiguration::instance ().color ("neutral:foreground")); } - void TriggerMaster::ui_parameter_changed (std::string const& p) { if (p == "color-file") { - set_default_colors(); + set_default_colors (); } } - - -//==================================== - CueMaster::CueMaster (Item* parent) : ArdourCanvas::Rectangle (parent) { - set_layout_sensitive(true); //why??? + set_layout_sensitive (true); //why??? name = X_("trigger stopper"); @@ -535,12 +523,12 @@ CueMaster::CueMaster (Item* parent) stop_shape->show (); name_text = new Text (this); - name_text->set(""); + name_text->set (""); name_text->set_ignore_events (false); /* prefs (theme colors) */ - UIConfiguration::instance().ParameterChanged.connect (sigc::mem_fun (*this, &CueMaster::ui_parameter_changed)); - set_default_colors(); + UIConfiguration::instance ().ParameterChanged.connect (sigc::mem_fun (*this, &CueMaster::ui_parameter_changed)); + set_default_colors (); } CueMaster::~CueMaster () @@ -548,26 +536,26 @@ CueMaster::~CueMaster () } void -CueMaster::render (Rect const & area, Cairo::RefPtr context) const +CueMaster::render (Rect const& area, Cairo::RefPtr context) const { /* Note that item_to_window() already takes _position into account (as part of item_to_canvas() */ - Rect self (item_to_window (_rect)); + Rect self (item_to_window (_rect)); const 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 (); } @@ -575,47 +563,47 @@ CueMaster::render (Rect const & area, Cairo::RefPtr context) con { //line at right - 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(width-1, 0, width, height); + 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 (width - 1, 0, width, height); context->fill (); - context->set_identity_matrix(); + context->set_identity_matrix (); } //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->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 (); } bool CueMaster::event_handler (GdkEvent* ev) { switch (ev->type) { - case GDK_BUTTON_PRESS: - if (ev->button.button == 1) { - _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_fill_color (UIConfiguration::instance().color("neutral:foregroundest")); - 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: + if (ev->button.button == 1) { + _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_fill_color (UIConfiguration::instance ().color ("neutral:foregroundest")); + 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; @@ -624,54 +612,52 @@ CueMaster::event_handler (GdkEvent* ev) void CueMaster::maybe_update () { - } void -CueMaster::_size_allocate (ArdourCanvas::Rect const & alloc) +CueMaster::_size_allocate (ArdourCanvas::Rect const& alloc) { Rectangle::_size_allocate (alloc); - const double scale = UIConfiguration::instance().get_ui_scale(); - poly_margin = 2. * scale; + const double scale = UIConfiguration::instance ().get_ui_scale (); + _poly_margin = 2. * scale; - const Distance width = _rect.width(); - const Distance height = _rect.height(); + const Distance width = _rect.width (); + const Distance height = _rect.height (); - poly_size = height - (poly_margin*2); + _poly_size = height - (_poly_margin * 2); Points p; - 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)); stop_shape->set (p); - float tleft = poly_size + (poly_margin*3); - float twidth = width-poly_size-(poly_margin*3); + float tleft = _poly_size + (_poly_margin * 3); + float twidth = width - _poly_size - (_poly_margin * 3); 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->set_position (Duple (tleft, 1. * scale)); name_text->clamp_width (twidth); - //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 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_fill_color (UIConfiguration::instance().color("neutral:foreground")); + 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_fill_color (UIConfiguration::instance ().color ("neutral:foreground")); } void CueMaster::ui_parameter_changed (std::string const& p) { if (p == "color-file") { - set_default_colors(); + set_default_colors (); } } - diff --git a/gtk2_ardour/trigger_master.h b/gtk2_ardour/trigger_master.h index 5edf5b71d3..e55d77ff4a 100644 --- a/gtk2_ardour/trigger_master.h +++ b/gtk2_ardour/trigger_master.h @@ -17,107 +17,103 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#ifndef __ardour_trigger_master_h__ -#define __ardour_trigger_master_h__ - -#include - -#include +#ifndef _gtk_ardour_trigger_master_h_ +#define _gtk_ardour_ardour_trigger_master_h_ #include "pbd/properties.h" #include "ardour/triggerbox.h" -#include "canvas/table.h" #include "canvas/canvas.h" #include "canvas/rectangle.h" +#include "canvas/table.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 Loopster : public ArdourCanvas::Rectangle -{ - public: - Loopster (ArdourCanvas::Item* canvas); - - void render (ArdourCanvas::Rect const & area, Cairo::RefPtr context) const; - void set_fraction (float); - private: - float _fraction; -}; +} class PassThru; +class Loopster : public ArdourCanvas::Rectangle +{ +public: + Loopster (ArdourCanvas::Item* canvas); + + void render (ArdourCanvas::Rect const& area, Cairo::RefPtr context) const; + void set_fraction (float); + +private: + float _fraction; +}; + class TriggerMaster : public ArdourCanvas::Rectangle { - public: +public: TriggerMaster (ArdourCanvas::Item* canvas); ~TriggerMaster (); - void set_trigger(boost::shared_ptr); + void set_trigger (boost::shared_ptr); - void render (ArdourCanvas::Rect const & area, Cairo::RefPtr context) const; + void render (ArdourCanvas::Rect const&, Cairo::RefPtr) const; - void _size_allocate (ArdourCanvas::Rect const & alloc); + void _size_allocate (ArdourCanvas::Rect const&); - ArdourCanvas::Text* name_text; + ArdourCanvas::Text* name_text; void toggle_thru (); void maybe_update (); bool event_handler (GdkEvent*); void selection_change (); - private: +private: + void context_menu (); + void set_all_follow_action (ARDOUR::Trigger::FollowAction); + void set_all_launch_style (ARDOUR::Trigger::LaunchStyle); + void set_all_quantization (Temporal::BBT_Offset const&); + + void prop_change (PBD::PropertyChange const& change); + void owner_prop_change (PBD::PropertyChange const&); + void ui_parameter_changed (std::string const& p); + void set_default_colors (); + void shape_stop_button (); + + boost::shared_ptr _triggerbox; + Loopster* _loopster; PassThru* _passthru; Gtk::Menu* _context_menu; - void context_menu (); - void set_all_follow_action (ARDOUR::Trigger::FollowAction); - void set_all_launch_style (ARDOUR::Trigger::LaunchStyle); - void set_all_quantization (Temporal::BBT_Offset const &); + double _poly_size; + double _poly_margin; - boost::shared_ptr _triggerbox; - double poly_size; - double poly_margin; - - PBD::ScopedConnection trigger_prop_connection; - void prop_change (PBD::PropertyChange const & change); - void shape_stop_button (); - - PBD::ScopedConnection owner_prop_connection; - void owner_prop_change (PBD::PropertyChange const &); - - void ui_parameter_changed (std::string const& p); - void set_default_colors(); - - sigc::connection update_connection; + PBD::ScopedConnection _trigger_prop_connection; + PBD::ScopedConnection _owner_prop_connection; + sigc::connection _update_connection; }; - class CueMaster : public ArdourCanvas::Rectangle, public ARDOUR::SessionHandlePtr { - public: +public: CueMaster (ArdourCanvas::Item* canvas); ~CueMaster (); - void render (ArdourCanvas::Rect const & area, Cairo::RefPtr context) const; + void render (ArdourCanvas::Rect const& area, Cairo::RefPtr context) const; - void _size_allocate (ArdourCanvas::Rect const & alloc); + void _size_allocate (ArdourCanvas::Rect const& alloc); ArdourCanvas::Polygon* stop_shape; ArdourCanvas::Text* name_text; @@ -125,13 +121,13 @@ class CueMaster : public ArdourCanvas::Rectangle, public ARDOUR::SessionHandlePt void maybe_update (); bool event_handler (GdkEvent*); - private: - double poly_size; - double poly_margin; - +private: + void ui_parameter_changed (std::string const& p); + void set_default_colors (); void shape_stop_button (); - void ui_parameter_changed (std::string const& p); - void set_default_colors(); + double _poly_size; + double _poly_margin; }; -#endif /* __ardour_trigger_master_h__ */ + +#endif diff --git a/gtk2_ardour/trigger_page.cc b/gtk2_ardour/trigger_page.cc index 90e1b693b6..66462aed5b 100644 --- a/gtk2_ardour/trigger_page.cc +++ b/gtk2_ardour/trigger_page.cc @@ -87,11 +87,11 @@ TriggerPage::TriggerPage () /* Last item of strip packer, "+" background */ _strip_packer.pack_end (_no_strips, true, true); _no_strips.set_flags (Gtk::CAN_FOCUS); - _no_strips.add_events (Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK); + _no_strips.add_events (Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK); _no_strips.set_size_request (PX_SCALE (20), -1); _no_strips.signal_expose_event ().connect (sigc::bind (sigc::ptr_fun (&ArdourWidgets::ArdourIcon::expose), &_no_strips, ArdourWidgets::ArdourIcon::ShadedPlusSign)); - _no_strips.signal_button_press_event().connect (sigc::mem_fun(*this, &TriggerPage::no_strip_button_event)); - _no_strips.signal_button_release_event().connect (sigc::mem_fun(*this, &TriggerPage::no_strip_button_event)); + _no_strips.signal_button_press_event ().connect (sigc::mem_fun (*this, &TriggerPage::no_strip_button_event)); + _no_strips.signal_button_release_event ().connect (sigc::mem_fun (*this, &TriggerPage::no_strip_button_event)); _strip_group_box.pack_start (_cue_area_frame, false, false); _strip_group_box.pack_start (_strip_scroller, true, true); @@ -231,7 +231,7 @@ TriggerPage::set_session (Session* s) SessionHandlePtr::set_session (s); _trigger_clip_picker.set_session (s); - _master.set_session(s); + _master.set_session (s); if (!_session) { return; @@ -482,7 +482,7 @@ bool TriggerPage::no_strip_button_event (GdkEventButton* ev) { if ((ev->type == GDK_2BUTTON_PRESS && ev->button == 1) || (ev->type == GDK_BUTTON_RELEASE && Keyboard::is_context_menu_event (ev))) { - ARDOUR_UI::instance()->add_route (); + ARDOUR_UI::instance ()->add_route (); return true; } return false; diff --git a/gtk2_ardour/trigger_page.h b/gtk2_ardour/trigger_page.h index 96e367b03b..4626126a1b 100644 --- a/gtk2_ardour/trigger_page.h +++ b/gtk2_ardour/trigger_page.h @@ -103,12 +103,12 @@ private: SlotPropertiesBox _slot_prop_box; AudioTriggerPropertiesBox _audio_trig_box; - AudioRegionOperationsBox _audio_ops_box; - AudioClipEditorBox _audio_trim_box; + AudioRegionOperationsBox _audio_ops_box; + AudioClipEditorBox _audio_trim_box; MidiTriggerPropertiesBox _midi_trig_box; - MidiRegionOperationsBox _midi_ops_box; - MidiClipEditorBox _midi_trim_box; + MidiRegionOperationsBox _midi_ops_box; + MidiClipEditorBox _midi_trim_box; std::list _strips; sigc::connection _fast_screen_update_connection;