some incredibly hasic functionality for the triggerbox UI
This commit is contained in:
parent
33fed0f689
commit
ccf1c4fb57
@ -17,8 +17,13 @@
|
||||
*/
|
||||
|
||||
#include "pbd/i18n.h"
|
||||
#include "pbd/compose.h"
|
||||
|
||||
#include "ardour/triggerbox.h"
|
||||
|
||||
#include "canvas/polygon.h"
|
||||
#include "canvas/text.h"
|
||||
|
||||
#include "gtkmm2ext/utils.h"
|
||||
|
||||
#include "triggerbox_ui.h"
|
||||
@ -36,26 +41,32 @@ TriggerEntry::TriggerEntry (Item* parent, ARDOUR::Trigger& t)
|
||||
set_outline_all ();
|
||||
set_fill_color (Gtkmm2ext::random_color());
|
||||
set_outline_color (Gtkmm2ext::random_color());
|
||||
name = string_compose ("trigger %1", _trigger.index());
|
||||
|
||||
play_button = new Polygon (this);
|
||||
|
||||
Points p;
|
||||
p.push_back (Duple (0, 0));
|
||||
p.push_back (Duple (0, 10));
|
||||
p.push_back (Duple (10, 5));
|
||||
|
||||
play_button->set (p);
|
||||
play_button->set_fill_color (Gtkmm2ext::random_color());
|
||||
play_button->set_outline (false);
|
||||
|
||||
play_button->set_position (Duple (10, 2));
|
||||
|
||||
name_text = new Text (this);
|
||||
name_text->set_font_description (Pango::FontDescription ("Sans 10"));
|
||||
name_text->set ("Bang Crash");
|
||||
name_text->set_color (Gtkmm2ext::random_color());
|
||||
name_text->set_position (Duple (50, name_text->height() / 2));
|
||||
}
|
||||
|
||||
TriggerEntry::~TriggerEntry ()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
TriggerEntry::render (Rect const & area, Cairo::RefPtr<Cairo::Context> context) const
|
||||
{
|
||||
/* convert expose area back to item coordinate space */
|
||||
|
||||
Rect self (item_to_window (get()));
|
||||
|
||||
setup_outline_context (context);
|
||||
rounded_rectangle (context, self.x0, self.y0, self.width(), self.height());
|
||||
context->stroke_preserve ();
|
||||
setup_fill_context (context);
|
||||
context->fill ();
|
||||
}
|
||||
|
||||
/* ---------------------------- */
|
||||
|
||||
TriggerBoxUI::TriggerBoxUI (ArdourCanvas::Item* parent, TriggerBox& tb)
|
||||
@ -82,17 +93,40 @@ TriggerBoxUI::build ()
|
||||
|
||||
// clear_items (true);
|
||||
|
||||
_slots.clear ();
|
||||
|
||||
while (true) {
|
||||
t = _triggerbox.trigger (n);
|
||||
if (!t) {
|
||||
break;
|
||||
}
|
||||
std::cerr << "NEW TE for trigger " << n << std::endl;
|
||||
(void) new TriggerEntry (this, *t);
|
||||
TriggerEntry* te = new TriggerEntry (this, *t);
|
||||
|
||||
_slots.push_back (te);
|
||||
|
||||
te->play_button->Event.connect (sigc::bind (sigc::mem_fun (*this, &TriggerBoxUI::bang), n));
|
||||
|
||||
++n;
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
TriggerBoxUI::bang (GdkEvent *ev, size_t n)
|
||||
{
|
||||
switch (ev->type) {
|
||||
case GDK_BUTTON_PRESS:
|
||||
if (ev->button.button == 1) {
|
||||
_triggerbox.queue_trigger (&_slots[n]->trigger());
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/* ------------ */
|
||||
|
||||
TriggerBoxWidget::TriggerBoxWidget (TriggerBox& tb)
|
||||
|
@ -32,6 +32,11 @@ namespace ARDOUR {
|
||||
class TriggerBox;
|
||||
}
|
||||
|
||||
namespace ArdourCanvas {
|
||||
class Text;
|
||||
class Polygon;
|
||||
};
|
||||
|
||||
class TriggerEntry : public ArdourCanvas::Rectangle
|
||||
{
|
||||
public:
|
||||
@ -39,7 +44,9 @@ class TriggerEntry : public ArdourCanvas::Rectangle
|
||||
~TriggerEntry ();
|
||||
|
||||
ARDOUR::Trigger& trigger() const { return _trigger; }
|
||||
void render (ArdourCanvas::Rect const &, Cairo::RefPtr<Cairo::Context>) const;
|
||||
|
||||
ArdourCanvas::Polygon* play_button;
|
||||
ArdourCanvas::Text* name_text;
|
||||
|
||||
private:
|
||||
ARDOUR::Trigger& _trigger;
|
||||
@ -53,7 +60,10 @@ class TriggerBoxUI : public ArdourCanvas::Box
|
||||
|
||||
private:
|
||||
ARDOUR::TriggerBox& _triggerbox;
|
||||
typedef std::vector<TriggerEntry*> Slots;
|
||||
Slots _slots;
|
||||
|
||||
bool bang (GdkEvent*, size_t);
|
||||
void build ();
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user