ardour/gtk2_ardour/triggerbox_ui.cc

95 lines
2.0 KiB
C++
Raw Normal View History

2021-07-21 18:44:41 -04:00
/*
* Copyright (C) 2021 Paul Davis <paul@linuxaudiosystems.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
2021-07-21 19:22:09 -04:00
#include "ardour/triggerbox.h"
#include "gtkmm2ext/utils.h"
2021-07-21 18:44:41 -04:00
#include "triggerbox_ui.h"
using namespace ARDOUR;
using namespace ArdourCanvas;
2021-07-21 19:22:09 -04:00
using namespace Gtkmm2ext;
2021-07-21 18:44:41 -04:00
TriggerEntry::TriggerEntry (Item* parent, ARDOUR::Trigger& t)
: Rectangle (parent)
, _trigger (t)
{
2021-07-21 19:22:09 -04:00
Rect r (0, 0, 25, 12);
set (r);
set_outline_all ();
2021-07-21 18:44:41 -04:00
}
TriggerEntry::~TriggerEntry ()
{
}
2021-07-21 19:22:09 -04:00
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)
2021-07-21 18:44:41 -04:00
: Box (parent, Box::Vertical)
2021-07-21 19:22:09 -04:00
, _triggerbox (tb)
2021-07-21 18:44:41 -04:00
{
2021-07-21 19:22:09 -04:00
set_homogenous (true);
set_spacing (6);
set_padding (6);
build ();
2021-07-21 18:44:41 -04:00
}
TriggerBoxUI::~TriggerBoxUI ()
{
}
2021-07-21 19:22:09 -04:00
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);
}