2008-12-11 08:06:27 +00:00
|
|
|
#include <iostream>
|
2012-06-11 22:58:55 +00:00
|
|
|
|
2012-06-12 17:16:43 +00:00
|
|
|
#include "gtkmm2ext/utils.h"
|
|
|
|
|
#include "gtkmm2ext/rgb_macros.h"
|
|
|
|
|
|
2008-12-11 08:06:27 +00:00
|
|
|
#include "ardour_ui.h"
|
2012-06-11 22:58:55 +00:00
|
|
|
#include "canvas-flag.h"
|
|
|
|
|
#include "time_axis_view_item.h"
|
2012-06-12 17:16:43 +00:00
|
|
|
#include "utils.h"
|
2008-12-11 08:06:27 +00:00
|
|
|
|
|
|
|
|
using namespace Gnome::Canvas;
|
|
|
|
|
using namespace std;
|
|
|
|
|
|
2010-05-28 16:37:04 +00:00
|
|
|
CanvasFlag::CanvasFlag (MidiRegionView& region,
|
|
|
|
|
Group& parent,
|
|
|
|
|
double height,
|
|
|
|
|
guint outline_color_rgba,
|
|
|
|
|
guint fill_color_rgba,
|
|
|
|
|
double x,
|
|
|
|
|
double y)
|
2010-11-25 20:37:39 +00:00
|
|
|
: Group(parent, x, y)
|
2012-06-12 17:16:43 +00:00
|
|
|
, _name_pixbuf(0)
|
2010-11-25 20:37:39 +00:00
|
|
|
, _height(height)
|
|
|
|
|
, _outline_color_rgba(outline_color_rgba)
|
|
|
|
|
, _fill_color_rgba(fill_color_rgba)
|
|
|
|
|
, _region(region)
|
2012-06-12 17:16:43 +00:00
|
|
|
, name_pixbuf_width (0)
|
2010-11-25 20:37:39 +00:00
|
|
|
, _line(0)
|
|
|
|
|
, _rect(0)
|
2010-05-28 16:37:04 +00:00
|
|
|
{
|
2010-11-25 20:37:39 +00:00
|
|
|
signal_event().connect (sigc::mem_fun (*this, &CanvasFlag::on_event));
|
2010-05-28 16:37:04 +00:00
|
|
|
}
|
|
|
|
|
|
2009-10-14 16:10:01 +00:00
|
|
|
void
|
2008-12-12 06:57:38 +00:00
|
|
|
CanvasFlag::delete_allocated_objects()
|
2008-12-11 08:06:27 +00:00
|
|
|
{
|
2012-06-12 17:16:43 +00:00
|
|
|
delete _name_pixbuf;
|
|
|
|
|
_name_pixbuf = 0;
|
2008-12-18 19:31:00 +00:00
|
|
|
|
|
|
|
|
delete _line;
|
|
|
|
|
_line = 0;
|
|
|
|
|
|
|
|
|
|
delete _rect;
|
|
|
|
|
_rect = 0;
|
2008-12-12 06:57:38 +00:00
|
|
|
}
|
|
|
|
|
|
2009-10-14 16:10:01 +00:00
|
|
|
void
|
2012-06-12 17:16:43 +00:00
|
|
|
CanvasFlag::set_text (const string& text)
|
2008-12-12 06:57:38 +00:00
|
|
|
{
|
|
|
|
|
delete_allocated_objects();
|
2009-10-14 16:10:01 +00:00
|
|
|
|
2012-06-12 17:16:43 +00:00
|
|
|
_name_pixbuf = new ArdourCanvas::Pixbuf (*this);
|
|
|
|
|
name_pixbuf_width = Gtkmm2ext::pixel_width (text, TimeAxisViewItem::NAME_FONT) + 2;
|
|
|
|
|
Gdk::Color c;
|
|
|
|
|
set_color (c, _outline_color_rgba);
|
|
|
|
|
_name_pixbuf->property_pixbuf() = Gtkmm2ext::pixbuf_from_string (text, TimeAxisViewItem::NAME_FONT, name_pixbuf_width,
|
|
|
|
|
TimeAxisViewItem::NAME_HEIGHT, c);
|
|
|
|
|
_name_pixbuf->property_x() = 10.0;
|
|
|
|
|
_name_pixbuf->property_y() = 2.0;
|
|
|
|
|
_name_pixbuf->show();
|
|
|
|
|
|
|
|
|
|
double flagwidth = name_pixbuf_width + 8.0;
|
|
|
|
|
double flagheight = TimeAxisViewItem::NAME_HEIGHT + 3.0;
|
2008-12-11 08:06:27 +00:00
|
|
|
_line = new SimpleLine(*this, 0.0, 0.0, 0.0, _height);
|
|
|
|
|
_line->property_color_rgba() = _outline_color_rgba;
|
2010-05-28 16:37:04 +00:00
|
|
|
_rect = new SimpleRect(*this, 0.0, 0.0, flagwidth, flagheight);
|
2008-12-11 08:06:27 +00:00
|
|
|
_rect->property_outline_color_rgba() = _outline_color_rgba;
|
|
|
|
|
_rect->property_fill_color_rgba() = _fill_color_rgba;
|
2010-05-28 16:37:04 +00:00
|
|
|
|
2012-06-12 17:16:43 +00:00
|
|
|
_name_pixbuf->raise_to_top();
|
2008-12-11 08:06:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CanvasFlag::~CanvasFlag()
|
|
|
|
|
{
|
2008-12-12 06:57:38 +00:00
|
|
|
delete_allocated_objects();
|
2008-12-11 08:06:27 +00:00
|
|
|
}
|
|
|
|
|
|
2008-12-12 22:04:22 +00:00
|
|
|
bool
|
2009-07-21 15:55:17 +00:00
|
|
|
CanvasFlag::on_event(GdkEvent* /*ev*/)
|
2008-12-12 22:04:22 +00:00
|
|
|
{
|
2010-11-25 20:37:39 +00:00
|
|
|
/* XXX if you change this function to actually do anything, be sure
|
|
|
|
|
to fix the connections commented out elsewhere in this file.
|
|
|
|
|
*/
|
2008-12-12 22:04:22 +00:00
|
|
|
return false;
|
|
|
|
|
}
|
2010-08-11 18:21:37 +00:00
|
|
|
|
|
|
|
|
void
|
|
|
|
|
CanvasFlag::set_height (double h)
|
|
|
|
|
{
|
2010-11-25 20:37:39 +00:00
|
|
|
_height = h;
|
2010-08-11 18:21:37 +00:00
|
|
|
|
2010-11-25 20:37:39 +00:00
|
|
|
if (_line) {
|
|
|
|
|
_line->property_y2() = _height;
|
|
|
|
|
}
|
2010-08-11 18:21:37 +00:00
|
|
|
}
|