Cleanup and clang-format source

This commit is contained in:
Robin Gareus 2021-12-17 15:30:14 +01:00
parent 6e3ed7f822
commit 27ba2c7ea6
No known key found for this signature in database
GPG key ID: A090BCE02CF57F04
6 changed files with 338 additions and 371 deletions

View file

@ -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,19 +44,20 @@ 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_height = h;
_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)
/* 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__
#ifdef __APPLE__
// use_intermediate_surface (false);
//#endif
#endif
}
void
@ -71,7 +72,6 @@ FittedCanvasWidget::on_size_request (Gtk::Requisition* req)
}
}
void
FittedCanvasWidget::on_size_allocate (Gtk::Allocation& alloc)
{
@ -82,10 +82,10 @@ FittedCanvasWidget::on_size_allocate (Gtk::Allocation& alloc)
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 ()));
}

View file

@ -17,38 +17,20 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef __fitted_canvas_widget__
#define __fitted_canvas_widget__
#include <string>
#include <vector>
#include <pangomm/fontdescription.h>
#ifndef _gtk_ardour_fitted_canvas_widget_h_
#define _gtk_ardour_fitted_canvas_widget_h_
#include <canvas/canvas.h>
#include <canvas/container.h>
#include <canvas/item.h>
#include <canvas/fill.h>
#include <canvas/outline.h>
#include <canvas/rectangle.h>
#include <gtkmm/layout.h>
#include <ardour/route.h>
#include <ardour/plugin.h>
#include <ardour/plugin_insert.h>
#include <ardour/automation_control.h>
#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:
@ -58,14 +40,17 @@ public:
/* 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_

View file

@ -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,7 +51,7 @@ 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)
@ -79,7 +78,7 @@ void
Loopster::render (Rect const& area, Cairo::RefPtr<Cairo::Context> context) const
{
/* Note that item_to_window() already takes _position into account (as
part of item_to_canvas()
* part of item_to_canvas()
*/
Rect self (item_to_window (_rect));
const Rect draw = self.intersection (area);
@ -95,12 +94,12 @@ Loopster::render (Rect const & area, Cairo::RefPtr<Cairo::Context> context) cons
const double scale = UIConfiguration::instance ().get_ui_scale ();
//white area
/* 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
/* arc fill */
context->set_line_width (5 * scale);
float slices = floor (_fraction * nslices);
float deg_per_slice = 360 / nslices;
@ -114,8 +113,6 @@ Loopster::render (Rect const & area, Cairo::RefPtr<Cairo::Context> context) cons
context->set_identity_matrix ();
}
/* ======================== */
class PassThru : public ArdourCanvas::Rectangle
{
public:
@ -123,6 +120,7 @@ class PassThru : public ArdourCanvas::Rectangle
void render (ArdourCanvas::Rect const& area, Cairo::RefPtr<Cairo::Context> context) const;
void set_enabled (bool e);
private:
bool _enabled;
};
@ -146,7 +144,7 @@ void
PassThru::render (Rect const& area, Cairo::RefPtr<Cairo::Context> context) const
{
/* Note that item_to_window() already takes _position into account (as
part of item_to_canvas()
* part of item_to_canvas()
*/
Rect self (item_to_window (_rect));
const Rect draw = self.intersection (area);
@ -163,26 +161,23 @@ PassThru::render (Rect const & area, Cairo::RefPtr<Cairo::Context> context) cons
const double scale = UIConfiguration::instance ().get_ui_scale ();
if (_enabled) {
//outer white circle
/* 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
/* 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
/* 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)
@ -200,19 +195,19 @@ TriggerMaster::TriggerMaster (Item* parent)
_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<Stripable*> (_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<Stripable*> (_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));
@ -221,10 +216,10 @@ TriggerMaster::TriggerMaster (Item* parent)
TriggerMaster::~TriggerMaster ()
{
update_connection.disconnect();
}
void TriggerMaster::set_trigger (boost::shared_ptr<ARDOUR::TriggerBox> t)
void
TriggerMaster::set_trigger (boost::shared_ptr<ARDOUR::TriggerBox> t)
{
_triggerbox = t;
}
@ -233,7 +228,7 @@ void
TriggerMaster::render (Rect const& area, Cairo::RefPtr<Cairo::Context> context) const
{
/* Note that item_to_window() already takes _position into account (as
part of item_to_canvas()
* part of item_to_canvas()
*/
Rect self (item_to_window (_rect));
const Rect draw = self.intersection (area);
@ -255,17 +250,15 @@ TriggerMaster::render (Rect const & area, Cairo::RefPtr<Cairo::Context> context)
render_children (area, context);
{
//line at right
/* 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
/* 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));
@ -366,7 +359,7 @@ TriggerMaster::context_menu ()
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)));
@ -393,11 +386,11 @@ TriggerMaster::context_menu ()
dynamic_cast<Gtk::CheckMenuItem*> (&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 ());
}
@ -411,19 +404,19 @@ TriggerMaster::toggle_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)
{
//ToDo
// TODO
}
void
@ -441,15 +434,15 @@ TriggerMaster::_size_allocate (ArdourCanvas::Rect const & alloc)
Rectangle::_size_allocate (alloc);
const double scale = UIConfiguration::instance ().get_ui_scale ();
poly_margin = 2. * scale;
_poly_margin = 2. * scale;
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);
@ -459,7 +452,7 @@ TriggerMaster::_size_allocate (ArdourCanvas::Rect const & alloc)
_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
/* font scale may have changed. uiconfig 'embeds' the ui-scale in the font */
name_text->set_font_description (UIConfiguration::instance ().get_NormalFont ());
}
@ -505,7 +498,6 @@ TriggerMaster::set_default_colors ()
name_text->set_color (UIConfiguration::instance ().color ("neutral:foreground"));
}
void
TriggerMaster::ui_parameter_changed (std::string const& p)
{
@ -514,10 +506,6 @@ TriggerMaster::ui_parameter_changed (std::string const& p)
}
}
//====================================
CueMaster::CueMaster (Item* parent)
: ArdourCanvas::Rectangle (parent)
{
@ -624,7 +612,6 @@ CueMaster::event_handler (GdkEvent* ev)
void
CueMaster::maybe_update ()
{
}
void
@ -633,29 +620,29 @@ CueMaster::_size_allocate (ArdourCanvas::Rect const & alloc)
Rectangle::_size_allocate (alloc);
const double scale = UIConfiguration::instance ().get_ui_scale ();
poly_margin = 2. * scale;
_poly_margin = 2. * scale;
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->clamp_width (twidth);
//font scale may have changed. uiconfig 'embeds' the ui-scale in the font
/* font scale may have changed. uiconfig 'embeds' the ui-scale in the font */
name_text->set_font_description (UIConfiguration::instance ().get_NormalFont ());
}
@ -674,4 +661,3 @@ CueMaster::ui_parameter_changed (std::string const& p)
set_default_colors ();
}
}

View file

@ -17,36 +17,35 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef __ardour_trigger_master_h__
#define __ardour_trigger_master_h__
#include <map>
#include <gtkmm/window.h>
#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 {
namespace Gtk
{
class FileChooserDialog;
class Menu;
}
namespace Temporal {
namespace Temporal
{
struct BBT_Offset;
}
namespace ArdourCanvas {
namespace ArdourCanvas
{
class Text;
class Polygon;
};
}
class PassThru;
class Loopster : public ArdourCanvas::Rectangle
{
@ -55,12 +54,11 @@ class Loopster : public ArdourCanvas::Rectangle
void render (ArdourCanvas::Rect const& area, Cairo::RefPtr<Cairo::Context> context) const;
void set_fraction (float);
private:
float _fraction;
};
class PassThru;
class TriggerMaster : public ArdourCanvas::Rectangle
{
public:
@ -69,9 +67,9 @@ class TriggerMaster : public ArdourCanvas::Rectangle
void set_trigger (boost::shared_ptr<ARDOUR::TriggerBox>);
void render (ArdourCanvas::Rect const & area, Cairo::RefPtr<Cairo::Context> context) const;
void render (ArdourCanvas::Rect const&, Cairo::RefPtr<Cairo::Context>) const;
void _size_allocate (ArdourCanvas::Rect const & alloc);
void _size_allocate (ArdourCanvas::Rect const&);
ArdourCanvas::Text* name_text;
@ -81,34 +79,32 @@ class TriggerMaster : public ArdourCanvas::Rectangle
void selection_change ();
private:
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&);
boost::shared_ptr<ARDOUR::TriggerBox> _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 ();
void shape_stop_button ();
sigc::connection update_connection;
boost::shared_ptr<ARDOUR::TriggerBox> _triggerbox;
Loopster* _loopster;
PassThru* _passthru;
Gtk::Menu* _context_menu;
double _poly_size;
double _poly_margin;
PBD::ScopedConnection _trigger_prop_connection;
PBD::ScopedConnection _owner_prop_connection;
sigc::connection _update_connection;
};
class CueMaster : public ArdourCanvas::Rectangle, public ARDOUR::SessionHandlePtr
{
public:
@ -126,12 +122,12 @@ class CueMaster : public ArdourCanvas::Rectangle, public ARDOUR::SessionHandlePt
bool event_handler (GdkEvent*);
private:
double poly_size;
double poly_margin;
void shape_stop_button ();
void ui_parameter_changed (std::string const& p);
void set_default_colors ();
void shape_stop_button ();
double _poly_size;
double _poly_margin;
};
#endif /* __ardour_trigger_master_h__ */
#endif