initial extensions for TriggerBox UI

This commit is contained in:
Paul Davis 2021-07-21 17:22:09 -06:00
parent a63ec8afa2
commit e68c60b407
3 changed files with 72 additions and 3 deletions

View File

@ -16,26 +16,79 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "ardour/triggerbox.h"
#include "gtkmm2ext/utils.h"
#include "triggerbox_ui.h"
using namespace ARDOUR;
using namespace ArdourCanvas;
using namespace Gtkmm2ext;
TriggerEntry::TriggerEntry (Item* parent, ARDOUR::Trigger& t)
: Rectangle (parent)
, _trigger (t)
{
Rect r (0, 0, 25, 12);
set (r);
set_outline_all ();
}
TriggerEntry::~TriggerEntry ()
{
}
TriggerBoxUI::TriggerBoxUI (ArdourCanvas::Item* parent)
: Box (parent, Box::Vertical)
void
TriggerEntry::render (Rect const & area, Cairo::RefPtr<Cairo::Context> context) const
{
/* convert expose area back to item coordinate space */
setup_outline_context (context);
rounded_rectangle (context, x0(), y0(), x1(), y1());
context->stroke_preserve ();
setup_fill_context (context);
context->fill ();
}
/* ---------------------------- */
TriggerBoxUI::TriggerBoxUI (ArdourCanvas::Item* parent, TriggerBox& tb)
: Box (parent, Box::Vertical)
, _triggerbox (tb)
{
set_homogenous (true);
set_spacing (6);
set_padding (6);
build ();
}
TriggerBoxUI::~TriggerBoxUI ()
{
}
void
TriggerBoxUI::build ()
{
Trigger* t;
size_t n = 0;
clear_items (true);
while (true) {
t = _triggerbox.trigger (n);
if (!t) {
break;
}
(void) new TriggerEntry (this, *t);
}
}
/* ------------ */
TriggerBoxWidget::TriggerBoxWidget (TriggerBox& tb)
{
ui = new TriggerBoxUI (root(), tb);
}

View File

@ -22,10 +22,12 @@
#include <map>
#include "canvas/box.h"
#include "canvas/canvas.h"
#include "canvas/rectangle.h"
namespace ARDOUR {
class Trigger;
class TriggerBox;
}
class TriggerEntry : public ArdourCanvas::Rectangle
@ -35,6 +37,7 @@ class TriggerEntry : public ArdourCanvas::Rectangle
~TriggerEntry ();
ARDOUR::Trigger& trigger() const { return _trigger; }
void render (ArdourCanvas::Rect const &, Cairo::RefPtr<Cairo::Context>) const;
private:
ARDOUR::Trigger& _trigger;
@ -43,11 +46,23 @@ class TriggerEntry : public ArdourCanvas::Rectangle
class TriggerBoxUI : public ArdourCanvas::Box
{
public:
TriggerBoxUI (ArdourCanvas::Item* parent);
TriggerBoxUI (ArdourCanvas::Item* parent, ARDOUR::TriggerBox&);
~TriggerBoxUI ();
private:
ARDOUR::TriggerBox& _triggerbox;
void build ();
};
class TriggerBoxWidget : public ArdourCanvas::GtkCanvas
{
public:
TriggerBoxWidget (ARDOUR::TriggerBox& tb);
private:
TriggerBoxUI* ui;
};
#endif /* __ardour_gtk_triggerbox_ui_h__ */

View File

@ -297,6 +297,7 @@ gtk2_ardour_sources = [
'transport_control_ui.cc',
'transport_masters_dialog.cc',
'transpose_dialog.cc',
'triggerbox_ui.cc',
'ui_config.cc',
'utils.cc',
'varispeed_dialog.cc',