2005-09-25 18:42:24 +00:00
|
|
|
/*
|
2009-10-14 16:10:01 +00:00
|
|
|
Copyright (C) 2001 Paul Davis
|
2005-09-25 18:42:24 +00:00
|
|
|
|
|
|
|
|
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., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
2014-09-19 16:23:44 -04:00
|
|
|
#include <cmath>
|
2005-11-24 14:59:36 +00:00
|
|
|
#include <sigc++/bind.h>
|
2014-09-03 12:16:19 -04:00
|
|
|
#include <boost/scoped_ptr.hpp>
|
2014-09-03 10:28:10 -04:00
|
|
|
|
2009-02-25 18:26:51 +00:00
|
|
|
#include "ardour/tempo.h"
|
2014-09-03 10:28:10 -04:00
|
|
|
#include "ardour/profile.h"
|
2013-04-15 16:10:13 -04:00
|
|
|
|
2013-04-04 00:32:52 -04:00
|
|
|
#include "canvas/rectangle.h"
|
2014-06-22 11:41:05 -04:00
|
|
|
#include "canvas/container.h"
|
2013-04-04 00:32:52 -04:00
|
|
|
#include "canvas/line.h"
|
|
|
|
|
#include "canvas/polygon.h"
|
2013-04-06 16:39:11 -04:00
|
|
|
#include "canvas/text.h"
|
2013-04-15 16:10:13 -04:00
|
|
|
#include "canvas/canvas.h"
|
2014-06-21 11:44:22 -04:00
|
|
|
#include "canvas/scroll_group.h"
|
2014-09-03 14:45:53 -04:00
|
|
|
#include "canvas/utils.h"
|
2013-04-17 15:22:09 -04:00
|
|
|
#include "canvas/debug.h"
|
2005-09-25 18:42:24 +00:00
|
|
|
|
2009-08-08 22:36:32 +00:00
|
|
|
#include "ardour_ui.h"
|
|
|
|
|
/*
|
|
|
|
|
* ardour_ui.h include was moved to the top of the list
|
|
|
|
|
* due to a conflicting definition of 'Rect' between
|
|
|
|
|
* Apple's MacTypes.h and GTK.
|
|
|
|
|
*/
|
2014-09-21 17:38:35 -04:00
|
|
|
#include "gui_thread.h"
|
2005-09-25 18:42:24 +00:00
|
|
|
#include "marker.h"
|
|
|
|
|
#include "public_editor.h"
|
|
|
|
|
#include "utils.h"
|
2010-11-13 22:39:42 +00:00
|
|
|
#include "rgb_macros.h"
|
2005-09-25 18:42:24 +00:00
|
|
|
|
2009-05-21 17:30:45 +00:00
|
|
|
#include <gtkmm2ext/utils.h>
|
|
|
|
|
|
2005-09-25 18:42:24 +00:00
|
|
|
#include "i18n.h"
|
|
|
|
|
|
2009-05-12 17:03:42 +00:00
|
|
|
using namespace std;
|
2007-06-15 22:08:27 +00:00
|
|
|
using namespace ARDOUR;
|
2014-06-25 21:27:37 +02:00
|
|
|
using namespace ARDOUR_UI_UTILS;
|
2010-09-26 13:33:39 +00:00
|
|
|
using namespace Gtkmm2ext;
|
2007-06-15 22:08:27 +00:00
|
|
|
|
2009-12-22 20:21:43 +00:00
|
|
|
PBD::Signal1<void,Marker*> Marker::CatchDeletion;
|
|
|
|
|
|
2014-09-11 16:58:02 -04:00
|
|
|
const double Marker::_marker_height = 17.0;
|
2014-09-19 16:23:44 -04:00
|
|
|
const char * Marker::default_new_marker_prefix = N_("Marker");
|
2014-09-03 14:45:53 -04:00
|
|
|
|
2014-09-03 12:16:19 -04:00
|
|
|
static const double name_padding = 10.0;
|
2014-01-13 09:28:44 -05:00
|
|
|
|
2014-09-21 15:10:55 -04:00
|
|
|
RulerMarker::RulerMarker (ARDOUR::Location* l, PublicEditor& editor, ArdourCanvas::Container& parent, double height, guint32 rgba, const std::string& text,
|
2014-09-19 16:23:44 -04:00
|
|
|
framepos_t start, framepos_t end)
|
2014-09-21 15:10:55 -04:00
|
|
|
: RangeMarker (l, editor, parent, height, rgba, text, start, end)
|
2014-09-19 16:23:44 -04:00
|
|
|
{
|
|
|
|
|
/* make sure we call our own color stuff, since we look different */
|
|
|
|
|
|
2014-09-21 15:51:06 -04:00
|
|
|
use_color ();
|
2014-09-19 16:23:44 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
2014-09-21 15:51:06 -04:00
|
|
|
RulerMarker::use_color ()
|
2014-09-19 16:23:44 -04:00
|
|
|
{
|
2014-09-21 15:51:06 -04:00
|
|
|
Marker::use_color ();
|
2014-09-19 16:23:44 -04:00
|
|
|
|
2014-09-21 15:51:06 -04:00
|
|
|
/* unset the effects of RangeMarker::use_color () */
|
2014-09-19 16:23:44 -04:00
|
|
|
|
|
|
|
|
_name_background->set_pattern (Cairo::RefPtr<Cairo::SurfacePattern> ());
|
|
|
|
|
|
|
|
|
|
/* Create a linear gradient that goes from full opacity to totally transparent
|
|
|
|
|
across the height of the marker
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
ArdourCanvas::Color normal (_color);
|
|
|
|
|
int r, g, b;
|
2014-09-21 15:51:06 -04:00
|
|
|
UINT_TO_RGB(_color, &r, &g, &b);
|
2014-09-19 16:23:44 -04:00
|
|
|
ArdourCanvas::Color transparent = ArdourCanvas::rgba_to_color (r, g, b, 0.0);
|
|
|
|
|
|
|
|
|
|
ArdourCanvas::Fill::StopList stops;
|
|
|
|
|
stops.push_back (make_pair (0.0, normal));
|
|
|
|
|
stops.push_back (make_pair (1.0, transparent));
|
|
|
|
|
_name_background->set_gradient (stops, true);
|
|
|
|
|
|
|
|
|
|
/* set end line correctly, also */
|
|
|
|
|
|
|
|
|
|
if (_end_line) {
|
|
|
|
|
_end_line->set_outline_color (_color);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-09-21 15:10:55 -04:00
|
|
|
RangeMarker::RangeMarker (ARDOUR::Location* l, PublicEditor& editor, ArdourCanvas::Container& parent, double height, guint32 rgba, const std::string& text,
|
2014-09-19 16:23:44 -04:00
|
|
|
framepos_t start, framepos_t end)
|
2014-09-21 15:10:55 -04:00
|
|
|
: Marker (l, editor, parent, height, rgba, text, Range, start, true)
|
2014-09-19 16:23:44 -04:00
|
|
|
, _end_frame (end)
|
|
|
|
|
, _end_line (0)
|
|
|
|
|
{
|
|
|
|
|
assert (start < end);
|
|
|
|
|
|
|
|
|
|
/* Marker::Marker calls these but will not have used our versions since it is a constructor.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
set_position (frame_position);
|
|
|
|
|
setup_line ();
|
2014-09-21 15:51:06 -04:00
|
|
|
use_color ();
|
2014-09-19 16:23:44 -04:00
|
|
|
setup_name_display ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RangeMarker::~RangeMarker ()
|
|
|
|
|
{
|
|
|
|
|
delete _end_line;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
2014-09-21 15:51:06 -04:00
|
|
|
RangeMarker::use_color ()
|
2014-09-19 16:23:44 -04:00
|
|
|
{
|
2014-09-21 15:51:06 -04:00
|
|
|
Marker::use_color ();
|
2014-09-19 16:23:44 -04:00
|
|
|
|
|
|
|
|
double dimen = _height * 2.0;
|
|
|
|
|
|
|
|
|
|
Cairo::RefPtr<Cairo::Surface> surface = Cairo::ImageSurface::create (Cairo::FORMAT_ARGB32, dimen, dimen);
|
|
|
|
|
Cairo::RefPtr<Cairo::Context> context = Cairo::Context::create (surface);
|
|
|
|
|
|
|
|
|
|
/* make a darker version of the color */
|
|
|
|
|
|
|
|
|
|
double h, s, v;
|
|
|
|
|
ArdourCanvas::color_to_hsv (_color, h, s, v);
|
|
|
|
|
s *= 1.2;
|
|
|
|
|
v *= 1.2;
|
|
|
|
|
ArdourCanvas::Color darker = ArdourCanvas::hsv_to_color (h, s, v, 1.0);
|
|
|
|
|
|
|
|
|
|
/* fill background with transparent version of color */
|
|
|
|
|
ArdourCanvas::set_source_rgba (context, darker);
|
|
|
|
|
context->rectangle (0.0, 0.0, dimen, dimen);
|
|
|
|
|
context->fill ();
|
|
|
|
|
|
|
|
|
|
/* now draw lines */
|
|
|
|
|
|
|
|
|
|
ArdourCanvas::set_source_rgba (context, _color);
|
|
|
|
|
const double line_width = 2.0;
|
|
|
|
|
context->set_line_width (line_width);
|
|
|
|
|
|
|
|
|
|
const double d = line_width / (cos ((45.0 / 360.0) * (M_PI * 2.0)));
|
|
|
|
|
|
|
|
|
|
for (double p = d; p < (dimen * 3.0); p += (2.0 * d)) {
|
|
|
|
|
context->move_to (p, 0);
|
|
|
|
|
context->line_to (0, p);
|
|
|
|
|
context->stroke ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* and assign pattern to the background rect */
|
|
|
|
|
|
|
|
|
|
Cairo::RefPtr<Cairo::SurfacePattern> pattern = Cairo::SurfacePattern::create (surface);
|
|
|
|
|
pattern->set_extend (Cairo::EXTEND_REPEAT);
|
|
|
|
|
_name_background->set_pattern (pattern);
|
|
|
|
|
|
|
|
|
|
/* set end line correctly, also */
|
|
|
|
|
|
|
|
|
|
if (_end_line) {
|
|
|
|
|
_end_line->set_outline_color (_color);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (_name_item) {
|
|
|
|
|
/* black text */
|
|
|
|
|
_name_item->set_color (ArdourCanvas::rgba_to_color (0.0, 0.0, 0.0, 1.0));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
RangeMarker::set_position (framepos_t frame)
|
|
|
|
|
{
|
|
|
|
|
Marker::set_position (frame);
|
|
|
|
|
double pixel_width = editor.sample_to_pixel (_end_frame - frame_position);
|
|
|
|
|
_name_background->set_x1 (_name_background->x0() + pixel_width);
|
|
|
|
|
if (_name_item) {
|
|
|
|
|
_name_item->clamp_width (pixel_width - _label_offset);
|
|
|
|
|
}
|
|
|
|
|
setup_line ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
RangeMarker::setup_line ()
|
|
|
|
|
{
|
|
|
|
|
Marker::setup_line ();
|
|
|
|
|
|
|
|
|
|
if (!_end_line) {
|
|
|
|
|
_end_line = new ArdourCanvas::Line (editor.get_hscroll_group());
|
|
|
|
|
/* these never change - they cause the line to span from the bottom
|
|
|
|
|
edge of the marker rectangle to the absolute lowest possible
|
|
|
|
|
canvas coordinate.
|
|
|
|
|
*/
|
|
|
|
|
_end_line->set_y0 (_height);
|
|
|
|
|
_end_line->set_y1 (ArdourCanvas::COORD_MAX);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* line at the end (the start line is handled by Marker */
|
|
|
|
|
|
|
|
|
|
/* lines in a different canvas (scroll)group so we have to convert the position
|
|
|
|
|
into a different coordinate system.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
ArdourCanvas::Duple g = group->canvas_origin();
|
|
|
|
|
ArdourCanvas::Duple d = _end_line->canvas_to_item (ArdourCanvas::Duple (g.x + _shift + _name_background->x1(), 0));
|
|
|
|
|
|
|
|
|
|
_end_line->set_x0 (d.x);
|
|
|
|
|
_end_line->set_x1 (d.x);
|
|
|
|
|
_end_line->set_outline_color (_color);
|
|
|
|
|
_end_line->show ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
RangeMarker::setup_name_display ()
|
|
|
|
|
{
|
|
|
|
|
/* No need to adjust name background size here, since it is always the same */
|
|
|
|
|
|
|
|
|
|
if (_name.empty()) {
|
|
|
|
|
if (_name_item) {
|
|
|
|
|
_name_item->hide ();
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
if (!_name_item) {
|
|
|
|
|
_name_item = new ArdourCanvas::Text (group);
|
|
|
|
|
CANVAS_DEBUG_NAME (_name_item, string_compose ("Marker::_name_item for %1", _name));
|
|
|
|
|
_name_item->set_font_description (name_font);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_name_item->show ();
|
|
|
|
|
_name_item->set_x_position (_label_offset);
|
|
|
|
|
/* Limit text to width of background rect */
|
|
|
|
|
_name_item->clamp_width (_name_background->get().width());
|
|
|
|
|
_name_item->set (_name);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-09-21 15:10:55 -04:00
|
|
|
Marker::Marker (ARDOUR::Location* l, PublicEditor& ed, ArdourCanvas::Container& parent, double height, guint32 rgba, const string& annotation,
|
2014-09-19 16:23:44 -04:00
|
|
|
Type type, framepos_t start_pos, bool handle_events)
|
2005-09-25 18:42:24 +00:00
|
|
|
|
2010-11-11 13:36:38 +00:00
|
|
|
: editor (ed)
|
2014-09-21 15:10:55 -04:00
|
|
|
, _location (l)
|
2010-11-11 13:36:38 +00:00
|
|
|
, _parent (&parent)
|
2014-09-03 12:16:19 -04:00
|
|
|
, group (0)
|
|
|
|
|
, mark (0)
|
|
|
|
|
, _name_item (0)
|
2014-09-19 16:23:44 -04:00
|
|
|
, _start_line (0)
|
2014-09-03 14:45:53 -04:00
|
|
|
, _scene_change_rect (0)
|
|
|
|
|
, _scene_change_text (0)
|
2014-09-17 21:42:33 -04:00
|
|
|
, frame_position (start_pos)
|
2010-11-11 13:36:38 +00:00
|
|
|
, _type (type)
|
2014-09-19 16:23:44 -04:00
|
|
|
, _height (height)
|
2010-11-11 13:36:38 +00:00
|
|
|
, _shown (false)
|
|
|
|
|
, _color (rgba)
|
2010-11-12 22:51:54 +00:00
|
|
|
, _left_label_limit (DBL_MAX)
|
|
|
|
|
, _right_label_limit (DBL_MAX)
|
2010-11-13 22:39:42 +00:00
|
|
|
, _label_offset (0)
|
2014-09-03 14:45:53 -04:00
|
|
|
, _have_scene_change (false)
|
2005-09-25 18:42:24 +00:00
|
|
|
{
|
2014-09-17 21:42:33 -04:00
|
|
|
unit_position = editor.sample_to_pixel (frame_position);
|
2014-09-03 12:16:19 -04:00
|
|
|
unit_position -= _shift;
|
|
|
|
|
|
|
|
|
|
group = new ArdourCanvas::Container (&parent, ArdourCanvas::Duple (unit_position, 0));
|
|
|
|
|
CANVAS_DEBUG_NAME (group, string_compose ("Marker::group for %1", annotation));
|
|
|
|
|
|
|
|
|
|
_name_background = new ArdourCanvas::Rectangle (group);
|
|
|
|
|
CANVAS_DEBUG_NAME (_name_background, string_compose ("Marker::_name_background for %1", annotation));
|
2014-09-19 16:23:44 -04:00
|
|
|
/* x-coordinates will be set elsewhere */
|
|
|
|
|
_name_background->set_y0 (0.0);
|
|
|
|
|
_name_background->set_y1 (_height - 1.0);
|
2014-09-03 12:16:19 -04:00
|
|
|
|
2014-09-19 16:23:44 -04:00
|
|
|
_label_offset = name_padding;
|
2014-09-03 12:16:19 -04:00
|
|
|
|
|
|
|
|
/* setup name pixbuf sizes */
|
2014-09-19 16:23:44 -04:00
|
|
|
name_font = Pango::FontDescription (ARDOUR_UI::config()->get_canvasvar_SmallBoldFont());
|
2014-09-03 12:16:19 -04:00
|
|
|
Gtk::Label foo;
|
|
|
|
|
Glib::RefPtr<Pango::Layout> layout = foo.create_pango_layout (X_("Hg")); /* ascender + descender */
|
|
|
|
|
int width;
|
|
|
|
|
layout->set_font_description (name_font);
|
|
|
|
|
Gtkmm2ext::get_ink_pixel_size (layout, width, name_height);
|
|
|
|
|
|
|
|
|
|
editor.ZoomChanged.connect (sigc::mem_fun (*this, &Marker::reposition));
|
|
|
|
|
|
|
|
|
|
if (handle_events) {
|
2014-09-19 16:23:44 -04:00
|
|
|
/* events will be handled by both the group, make sure it can be used to lookup this object.
|
|
|
|
|
*/
|
|
|
|
|
group->set_data ("marker", this);
|
2014-09-03 12:16:19 -04:00
|
|
|
group->Event.connect (sigc::bind (sigc::mem_fun (editor, &PublicEditor::canvas_marker_event), group, this));
|
|
|
|
|
}
|
2014-09-19 16:23:44 -04:00
|
|
|
|
|
|
|
|
set_name (annotation);
|
2014-09-21 15:51:06 -04:00
|
|
|
pick_basic_color (rgba);
|
|
|
|
|
use_color ();
|
2014-09-21 17:38:35 -04:00
|
|
|
|
|
|
|
|
if (_location) {
|
|
|
|
|
_location->FlagsChanged.connect (flags_changed_connection, MISSING_INVALIDATOR, boost::bind (&Marker::flags_changed, this), gui_context());
|
|
|
|
|
}
|
2014-09-03 12:16:19 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Marker::~Marker ()
|
|
|
|
|
{
|
|
|
|
|
CatchDeletion (this); /* EMIT SIGNAL */
|
|
|
|
|
|
|
|
|
|
/* destroying the parent group destroys its contents, namely any polygons etc. that we added */
|
|
|
|
|
delete group;
|
2014-09-19 16:23:44 -04:00
|
|
|
delete _start_line;
|
2007-11-12 22:23:01 +00:00
|
|
|
}
|
|
|
|
|
|
2014-06-22 11:41:05 -04:00
|
|
|
void Marker::reparent(ArdourCanvas::Container & parent)
|
2008-01-10 21:20:59 +00:00
|
|
|
{
|
2013-04-04 00:32:52 -04:00
|
|
|
group->reparent (&parent);
|
2008-01-10 21:20:59 +00:00
|
|
|
_parent = &parent;
|
|
|
|
|
}
|
|
|
|
|
|
2014-09-21 17:38:35 -04:00
|
|
|
void
|
|
|
|
|
Marker::flags_changed ()
|
|
|
|
|
{
|
|
|
|
|
pick_basic_color (0);
|
|
|
|
|
}
|
|
|
|
|
|
2014-09-21 15:51:06 -04:00
|
|
|
void
|
|
|
|
|
Marker::set_color (ArdourCanvas::Color c)
|
|
|
|
|
{
|
|
|
|
|
_color = c;
|
|
|
|
|
use_color ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
Marker::reset_color ()
|
|
|
|
|
{
|
|
|
|
|
pick_basic_color (0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
Marker::pick_basic_color (ArdourCanvas::Color c)
|
|
|
|
|
{
|
|
|
|
|
ArdourCanvas::Color col;
|
|
|
|
|
|
|
|
|
|
if (_location) {
|
|
|
|
|
if (_location->is_cd_marker()) {
|
|
|
|
|
col = ARDOUR_UI::config()->get_canvasvar_LocationCDMarker();
|
|
|
|
|
} else if (_location->is_mark()) {
|
|
|
|
|
col = ARDOUR_UI::config()->get_canvasvar_LocationMarker();
|
|
|
|
|
} else if (_location->is_auto_loop()) {
|
|
|
|
|
col = ARDOUR_UI::config()->get_canvasvar_LocationLoop();
|
|
|
|
|
} else if (_location->is_auto_punch()) {
|
|
|
|
|
col = ARDOUR_UI::config()->get_canvasvar_LocationPunch();
|
|
|
|
|
} else if (_location->is_skip()) {
|
2014-09-21 17:38:35 -04:00
|
|
|
if (_location->is_skipping()) {
|
|
|
|
|
col = ARDOUR_UI::config()->get_canvasvar_LocationSkipping();
|
|
|
|
|
} else {
|
|
|
|
|
col = ARDOUR_UI::config()->get_canvasvar_LocationSkip();
|
|
|
|
|
}
|
2014-09-21 15:51:06 -04:00
|
|
|
} else {
|
|
|
|
|
col = ARDOUR_UI::config()->get_canvasvar_LocationRange();
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
col = c;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
set_color (col);
|
|
|
|
|
}
|
|
|
|
|
|
2007-11-12 22:23:01 +00:00
|
|
|
void
|
2010-11-11 13:36:38 +00:00
|
|
|
Marker::setup_line ()
|
2007-11-12 22:23:01 +00:00
|
|
|
{
|
2014-09-19 16:23:44 -04:00
|
|
|
if (_start_line == 0) {
|
|
|
|
|
_start_line = new ArdourCanvas::Line (editor.get_hscroll_group());
|
|
|
|
|
_start_line->Event.connect (sigc::bind (sigc::mem_fun (editor, &PublicEditor::canvas_marker_event), group, this));
|
|
|
|
|
_start_line->set_y0 (_height);
|
|
|
|
|
_start_line->set_y1 (ArdourCanvas::COORD_MAX);
|
|
|
|
|
}
|
2007-11-12 22:23:01 +00:00
|
|
|
|
2014-09-19 16:23:44 -04:00
|
|
|
/* lines in a different canvas (scroll)group so we have to convert the position
|
|
|
|
|
into a different coordinate system.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
ArdourCanvas::Duple g = group->canvas_origin();
|
|
|
|
|
ArdourCanvas::Duple d = _start_line->canvas_to_item (ArdourCanvas::Duple (g.x + _shift, _height));
|
|
|
|
|
|
|
|
|
|
_start_line->set_y0 (d.y);
|
|
|
|
|
_start_line->set_y1 (ArdourCanvas::COORD_MAX);
|
|
|
|
|
|
|
|
|
|
_start_line->set_x0 (d.x);
|
|
|
|
|
_start_line->set_x1 (d.x);
|
|
|
|
|
_start_line->set_outline_color (_color);
|
|
|
|
|
_start_line->show ();
|
2005-09-25 18:42:24 +00:00
|
|
|
}
|
|
|
|
|
|
2005-11-24 14:59:36 +00:00
|
|
|
ArdourCanvas::Item&
|
|
|
|
|
Marker::the_item() const
|
|
|
|
|
{
|
2013-04-10 10:53:21 -04:00
|
|
|
return *group;
|
2005-11-24 14:59:36 +00:00
|
|
|
}
|
|
|
|
|
|
2005-09-25 18:42:24 +00:00
|
|
|
void
|
2009-05-21 17:30:45 +00:00
|
|
|
Marker::set_name (const string& new_name)
|
2005-09-25 18:42:24 +00:00
|
|
|
{
|
2010-11-12 22:51:54 +00:00
|
|
|
_name = new_name;
|
|
|
|
|
|
2010-11-13 22:39:42 +00:00
|
|
|
setup_name_display ();
|
2010-11-12 22:51:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** @return true if our label is on the left of the mark, otherwise false */
|
|
|
|
|
bool
|
|
|
|
|
Marker::label_on_left () const
|
|
|
|
|
{
|
|
|
|
|
return (_type == SessionEnd || _type == RangeEnd || _type == LoopEnd || _type == PunchOut);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
2010-11-13 22:39:42 +00:00
|
|
|
Marker::setup_name_display ()
|
2010-11-12 22:51:54 +00:00
|
|
|
{
|
2014-09-19 16:23:44 -04:00
|
|
|
double limit = _left_label_limit;
|
|
|
|
|
|
|
|
|
|
if (_name.empty()) {
|
2014-09-11 16:58:02 -04:00
|
|
|
|
2014-09-19 16:23:44 -04:00
|
|
|
if (_name_item) {
|
|
|
|
|
_name_item->hide ();
|
2014-09-03 14:45:53 -04:00
|
|
|
}
|
|
|
|
|
|
2014-09-19 16:23:44 -04:00
|
|
|
_name_background->set_x0 (0);
|
|
|
|
|
_name_background->set_x1 (10);
|
2014-09-11 16:58:02 -04:00
|
|
|
|
2014-09-19 16:23:44 -04:00
|
|
|
return;
|
2013-04-06 16:39:11 -04:00
|
|
|
|
2010-11-13 22:39:42 +00:00
|
|
|
} else {
|
2014-01-13 09:49:09 -05:00
|
|
|
|
2014-09-19 16:23:44 -04:00
|
|
|
int name_width;
|
|
|
|
|
int scene_change_width = 0;
|
|
|
|
|
|
|
|
|
|
if (!_name_item) {
|
|
|
|
|
_name_item = new ArdourCanvas::Text (group);
|
|
|
|
|
CANVAS_DEBUG_NAME (_name_item, string_compose ("Marker::_name_item for %1", _name));
|
|
|
|
|
_name_item->set_font_description (name_font);
|
|
|
|
|
/* white with 95% opacity */
|
|
|
|
|
_name_item->set_color (ArdourCanvas::rgba_to_color (1.0,1.0,1.0,0.95));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (_have_scene_change) {
|
|
|
|
|
|
|
|
|
|
/* coordinates of rect that will surround "MIDI" */
|
|
|
|
|
|
|
|
|
|
ArdourCanvas::Rect r;
|
|
|
|
|
int midi_height;
|
|
|
|
|
|
|
|
|
|
pixel_size (X_("MIDI"), name_font, name_width, midi_height);
|
|
|
|
|
|
|
|
|
|
r.x0 = 2.0;
|
|
|
|
|
r.x1 = r.x1 + name_width + 7.0;
|
|
|
|
|
|
|
|
|
|
if (_scene_change_text == 0) {
|
|
|
|
|
_scene_change_rect = new ArdourCanvas::Rectangle (group);
|
|
|
|
|
_scene_change_text = new ArdourCanvas::Text (group);
|
|
|
|
|
/* move name label over */
|
|
|
|
|
_label_offset += r.x1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* white with 95% opacity */
|
|
|
|
|
_scene_change_rect->set_outline_color (ArdourCanvas::rgba_to_color (1.0, 1.0, 1.0, 0.95));
|
|
|
|
|
_scene_change_rect->set_fill (false);
|
|
|
|
|
|
|
|
|
|
_scene_change_text->set_font_description (name_font);
|
|
|
|
|
_scene_change_text->set_color (ArdourCanvas::rgba_to_color (1.0, 1.0, 1.0, 0.95));
|
|
|
|
|
_scene_change_text->set (X_("MIDI"));
|
|
|
|
|
|
|
|
|
|
/* 4 pixels left margin, place it in the vertical middle.
|
|
|
|
|
*/
|
|
|
|
|
_scene_change_text->set_position (ArdourCanvas::Duple (4.0, (_height / 2.0) - (name_height / 2.0)));
|
|
|
|
|
|
|
|
|
|
r.y0 = _scene_change_text->position().y - 2.0;
|
|
|
|
|
r.y1 = r.y0 + name_height + 4.0;
|
|
|
|
|
|
|
|
|
|
_scene_change_rect->set (r);
|
|
|
|
|
scene_change_width = r.x1;
|
|
|
|
|
|
2014-09-03 12:16:19 -04:00
|
|
|
} else {
|
2014-09-19 16:23:44 -04:00
|
|
|
if (_scene_change_text) {
|
|
|
|
|
delete _scene_change_text;
|
|
|
|
|
delete _scene_change_rect;
|
|
|
|
|
_scene_change_text = 0;
|
|
|
|
|
_scene_change_rect = 0;
|
2014-09-03 12:16:19 -04:00
|
|
|
}
|
|
|
|
|
}
|
2014-09-19 16:23:44 -04:00
|
|
|
|
|
|
|
|
double name_text_width = pixel_width (_name, name_font);
|
|
|
|
|
|
|
|
|
|
name_width = min ((name_text_width + (2.0 * name_padding)), limit);
|
|
|
|
|
_name_item->show ();
|
|
|
|
|
_name_item->set_position (ArdourCanvas::Duple (_label_offset, (_height / 2.0) - (name_height / 2.0)));
|
2014-01-13 09:49:09 -05:00
|
|
|
_name_item->clamp_width (name_width);
|
|
|
|
|
_name_item->set (_name);
|
2014-09-17 21:42:33 -04:00
|
|
|
|
2014-09-19 16:23:44 -04:00
|
|
|
_name_background->set_x0 (_name_item->position().x - _label_offset);
|
|
|
|
|
_name_background->set_x1 (_name_background->x0() + name_width + scene_change_width);
|
2014-09-17 21:42:33 -04:00
|
|
|
}
|
2005-09-25 18:42:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
2010-09-17 18:20:37 +00:00
|
|
|
Marker::set_position (framepos_t frame)
|
2005-09-25 18:42:24 +00:00
|
|
|
{
|
2014-09-19 16:23:44 -04:00
|
|
|
frame_position = frame;
|
|
|
|
|
unit_position = editor.sample_to_pixel (frame_position) - _shift;
|
2013-04-04 00:32:52 -04:00
|
|
|
group->set_x_position (unit_position);
|
2013-04-15 16:10:13 -04:00
|
|
|
setup_line ();
|
2005-09-25 18:42:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
Marker::reposition ()
|
|
|
|
|
{
|
|
|
|
|
set_position (frame_position);
|
2009-10-14 16:10:01 +00:00
|
|
|
}
|
2005-09-25 18:42:24 +00:00
|
|
|
|
|
|
|
|
void
|
|
|
|
|
Marker::show ()
|
|
|
|
|
{
|
2010-11-11 15:21:37 +00:00
|
|
|
_shown = true;
|
2011-06-01 17:00:29 +00:00
|
|
|
|
2010-11-11 15:21:37 +00:00
|
|
|
group->show ();
|
|
|
|
|
setup_line ();
|
2005-09-25 18:42:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
Marker::hide ()
|
|
|
|
|
{
|
2010-11-11 15:21:37 +00:00
|
|
|
_shown = false;
|
2011-06-01 17:00:29 +00:00
|
|
|
|
2010-11-11 15:21:37 +00:00
|
|
|
group->hide ();
|
|
|
|
|
setup_line ();
|
2005-09-25 18:42:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
2014-09-21 15:51:06 -04:00
|
|
|
Marker::use_color ()
|
2005-09-25 18:42:24 +00:00
|
|
|
{
|
2014-09-21 15:51:06 -04:00
|
|
|
if (mark) {
|
2014-09-03 12:16:19 -04:00
|
|
|
mark->set_fill_color (_color);
|
|
|
|
|
mark->set_outline_color (_color);
|
|
|
|
|
}
|
2010-11-13 22:39:42 +00:00
|
|
|
|
2014-09-19 16:23:44 -04:00
|
|
|
if (_start_line) {
|
|
|
|
|
_start_line->set_outline_color (_color);
|
2010-11-11 13:36:38 +00:00
|
|
|
}
|
2010-11-13 22:39:42 +00:00
|
|
|
|
2014-09-19 16:23:44 -04:00
|
|
|
if (_name_background) {
|
|
|
|
|
_name_background->set_fill (true);
|
|
|
|
|
_name_background->set_fill_color (_color);
|
|
|
|
|
/* white with 20% opacity */
|
|
|
|
|
_name_background->set_outline_color (ArdourCanvas::rgba_to_color (1.0, 1.0, 1.0, 0.20));
|
|
|
|
|
|
2014-09-03 14:45:53 -04:00
|
|
|
_name_background->set_outline_what (ArdourCanvas::Rectangle::What (ArdourCanvas::Rectangle::TOP|
|
|
|
|
|
ArdourCanvas::Rectangle::LEFT|
|
|
|
|
|
ArdourCanvas::Rectangle::RIGHT));
|
|
|
|
|
}
|
2005-09-25 18:42:24 +00:00
|
|
|
}
|
|
|
|
|
|
2010-11-12 22:51:54 +00:00
|
|
|
/** Set the number of pixels that are available for a label to the left of the centre of this marker */
|
|
|
|
|
void
|
|
|
|
|
Marker::set_left_label_limit (double p)
|
|
|
|
|
{
|
2014-09-19 16:23:44 -04:00
|
|
|
_left_label_limit = p;
|
|
|
|
|
|
2010-11-12 22:51:54 +00:00
|
|
|
if (_left_label_limit < 0) {
|
|
|
|
|
_left_label_limit = 0;
|
|
|
|
|
}
|
2011-06-01 17:00:29 +00:00
|
|
|
|
2010-11-12 22:51:54 +00:00
|
|
|
if (label_on_left ()) {
|
2010-11-13 22:39:42 +00:00
|
|
|
setup_name_display ();
|
2010-11-12 22:51:54 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** Set the number of pixels that are available for a label to the right of the centre of this marker */
|
|
|
|
|
void
|
|
|
|
|
Marker::set_right_label_limit (double p)
|
|
|
|
|
{
|
2014-09-19 16:23:44 -04:00
|
|
|
_right_label_limit = p;
|
|
|
|
|
|
2010-11-12 22:51:54 +00:00
|
|
|
if (_right_label_limit < 0) {
|
|
|
|
|
_right_label_limit = 0;
|
|
|
|
|
}
|
2011-06-01 17:00:29 +00:00
|
|
|
|
2010-11-12 22:51:54 +00:00
|
|
|
if (!label_on_left ()) {
|
2010-11-13 22:39:42 +00:00
|
|
|
setup_name_display ();
|
2010-11-12 22:51:54 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-09-03 14:45:53 -04:00
|
|
|
void
|
|
|
|
|
Marker::set_has_scene_change (bool yn)
|
|
|
|
|
{
|
|
|
|
|
_have_scene_change = yn;
|
|
|
|
|
setup_name_display ();
|
|
|
|
|
}
|
|
|
|
|
|
2005-09-25 18:42:24 +00:00
|
|
|
/***********************************************************************/
|
|
|
|
|
|
2014-06-22 11:41:05 -04:00
|
|
|
TempoMarker::TempoMarker (PublicEditor& editor, ArdourCanvas::Container& parent, guint32 rgba, const string& text,
|
2005-11-24 14:59:36 +00:00
|
|
|
ARDOUR::TempoSection& temp)
|
2014-09-21 15:10:55 -04:00
|
|
|
: Marker (0, editor, parent, Marker::marker_height(), rgba, text, Tempo, 0, false),
|
2005-09-25 18:42:24 +00:00
|
|
|
_tempo (temp)
|
|
|
|
|
{
|
|
|
|
|
set_position (_tempo.frame());
|
2013-04-10 10:53:21 -04:00
|
|
|
group->Event.connect (sigc::bind (sigc::mem_fun (editor, &PublicEditor::canvas_tempo_marker_event), group, this));
|
2005-09-25 18:42:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TempoMarker::~TempoMarker ()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***********************************************************************/
|
|
|
|
|
|
2014-06-22 11:41:05 -04:00
|
|
|
MeterMarker::MeterMarker (PublicEditor& editor, ArdourCanvas::Container& parent, guint32 rgba, const string& text,
|
2009-10-14 16:10:01 +00:00
|
|
|
ARDOUR::MeterSection& m)
|
2014-09-21 15:10:55 -04:00
|
|
|
: Marker (0, editor, parent, Marker::marker_height(), rgba, text, Meter, 0, false),
|
2005-09-25 18:42:24 +00:00
|
|
|
_meter (m)
|
|
|
|
|
{
|
|
|
|
|
set_position (_meter.frame());
|
2013-04-10 10:53:21 -04:00
|
|
|
group->Event.connect (sigc::bind (sigc::mem_fun (editor, &PublicEditor::canvas_meter_marker_event), group, this));
|
2005-09-25 18:42:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MeterMarker::~MeterMarker ()
|
|
|
|
|
{
|
|
|
|
|
}
|
2005-11-24 14:59:36 +00:00
|
|
|
|