2005-09-25 14:42:24 -04:00
|
|
|
/*
|
2009-10-14 12:10:01 -04:00
|
|
|
Copyright (C) 2003 Paul Davis
|
2005-09-25 14:42:24 -04: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.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
2009-02-25 13:26:51 -05:00
|
|
|
#include "pbd/error.h"
|
|
|
|
#include "pbd/stacktrace.h"
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2009-02-25 13:26:51 -05:00
|
|
|
#include "ardour/types.h"
|
|
|
|
#include "ardour/ardour.h"
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2011-02-08 15:01:55 -05:00
|
|
|
#include "gtkmm2ext/utils.h"
|
|
|
|
#include "gtkmm2ext/gui_thread.h"
|
2006-04-27 05:04:24 -04:00
|
|
|
|
2009-08-08 18:36:32 -04:00
|
|
|
#include "ardour_ui.h"
|
|
|
|
/*
|
|
|
|
* ardour_ui.h was moved up in the include list
|
|
|
|
* due to a conflicting definition of 'Rect' between
|
|
|
|
* Apple's MacTypes.h file and GTK
|
|
|
|
*/
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
#include "public_editor.h"
|
|
|
|
#include "time_axis_view_item.h"
|
|
|
|
#include "time_axis_view.h"
|
2005-11-12 17:07:07 -05:00
|
|
|
#include "simplerect.h"
|
2005-09-25 14:42:24 -04:00
|
|
|
#include "utils.h"
|
2005-11-25 19:06:46 -05:00
|
|
|
#include "canvas_impl.h"
|
2005-09-25 14:42:24 -04:00
|
|
|
#include "rgb_macros.h"
|
|
|
|
|
|
|
|
#include "i18n.h"
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
using namespace Editing;
|
2005-11-13 13:13:50 -05:00
|
|
|
using namespace Glib;
|
2006-06-21 19:01:03 -04:00
|
|
|
using namespace PBD;
|
2007-06-15 18:08:27 -04:00
|
|
|
using namespace ARDOUR;
|
2010-09-26 09:33:39 -04:00
|
|
|
using namespace Gtkmm2ext;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2011-06-02 13:50:37 -04:00
|
|
|
Pango::FontDescription TimeAxisViewItem::NAME_FONT;
|
2005-09-25 14:42:24 -04:00
|
|
|
const double TimeAxisViewItem::NAME_X_OFFSET = 15.0;
|
2012-04-30 19:00:15 -04:00
|
|
|
const double TimeAxisViewItem::GRAB_HANDLE_TOP = 6;
|
|
|
|
const double TimeAxisViewItem::GRAB_HANDLE_WIDTH = 5;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2009-11-12 15:39:53 -05:00
|
|
|
int TimeAxisViewItem::NAME_HEIGHT;
|
2006-04-27 05:04:24 -04:00
|
|
|
double TimeAxisViewItem::NAME_Y_OFFSET;
|
|
|
|
double TimeAxisViewItem::NAME_HIGHLIGHT_SIZE;
|
|
|
|
double TimeAxisViewItem::NAME_HIGHLIGHT_THRESH;
|
|
|
|
|
2010-06-03 11:57:31 -04:00
|
|
|
void
|
|
|
|
TimeAxisViewItem::set_constant_heights ()
|
|
|
|
{
|
|
|
|
NAME_FONT = get_font_for_style (X_("TimeAxisViewItemName"));
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-06-03 11:57:31 -04:00
|
|
|
Gtk::Window win;
|
|
|
|
Gtk::Label foo;
|
|
|
|
win.add (foo);
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-06-03 11:57:31 -04:00
|
|
|
Glib::RefPtr<Pango::Layout> layout = foo.create_pango_layout (X_("Hg")); /* ascender + descender */
|
|
|
|
int width = 0;
|
|
|
|
int height = 0;
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2011-06-02 13:50:37 -04:00
|
|
|
layout->set_font_description (NAME_FONT);
|
2010-06-03 11:57:31 -04:00
|
|
|
Gtkmm2ext::get_ink_pixel_size (layout, width, height);
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-06-03 11:57:31 -04:00
|
|
|
NAME_HEIGHT = height;
|
|
|
|
NAME_Y_OFFSET = height + 3;
|
|
|
|
NAME_HIGHLIGHT_SIZE = height + 2;
|
|
|
|
NAME_HIGHLIGHT_THRESH = NAME_HIGHLIGHT_SIZE * 3;
|
|
|
|
}
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
/**
|
2010-04-07 07:03:00 -04:00
|
|
|
* Construct a new TimeAxisViewItem.
|
2005-09-25 14:42:24 -04:00
|
|
|
*
|
2010-04-07 07:03:00 -04:00
|
|
|
* @param it_name the unique name of this item
|
2010-09-01 18:35:46 -04:00
|
|
|
* @param parent the parent canvas group
|
2005-09-25 14:42:24 -04:00
|
|
|
* @param tv the TimeAxisView we are going to be added to
|
|
|
|
* @param spu samples per unit
|
|
|
|
* @param base_color
|
|
|
|
* @param start the start point of this item
|
|
|
|
* @param duration the duration of this item
|
2010-09-01 18:35:46 -04:00
|
|
|
* @param recording true if this is a recording region view
|
|
|
|
* @param automation true if this is an automation region view
|
2005-09-25 14:42:24 -04:00
|
|
|
*/
|
2010-09-01 18:35:46 -04:00
|
|
|
TimeAxisViewItem::TimeAxisViewItem(
|
|
|
|
const string & it_name, ArdourCanvas::Group& parent, TimeAxisView& tv, double spu, Gdk::Color const & base_color,
|
2010-09-17 14:20:37 -04:00
|
|
|
framepos_t start, framecnt_t duration, bool recording, bool automation, Visibility vis
|
2010-09-01 18:35:46 -04:00
|
|
|
)
|
2010-04-07 07:03:00 -04:00
|
|
|
: trackview (tv)
|
|
|
|
, _height (1.0)
|
|
|
|
, _recregion (recording)
|
2010-09-01 18:35:46 -04:00
|
|
|
, _automation (automation)
|
2012-05-07 18:02:17 -04:00
|
|
|
, _dragging (false)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2007-04-11 09:07:51 -04:00
|
|
|
group = new ArdourCanvas::Group (parent);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-12-02 21:22:36 -05:00
|
|
|
init (it_name, spu, base_color, start, duration, vis, true, true);
|
2007-04-11 09:07:51 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
TimeAxisViewItem::TimeAxisViewItem (const TimeAxisViewItem& other)
|
2011-10-18 09:18:47 -04:00
|
|
|
: trackable (other)
|
|
|
|
, Selectable (other)
|
2009-12-20 11:50:41 -05:00
|
|
|
, PBD::ScopedConnectionList()
|
2009-02-25 19:58:35 -05:00
|
|
|
, trackview (other.trackview)
|
2010-01-07 20:28:15 -05:00
|
|
|
, _recregion (other._recregion)
|
2010-09-01 18:35:46 -04:00
|
|
|
, _automation (other._automation)
|
2012-05-07 18:02:17 -04:00
|
|
|
, _dragging (other._dragging)
|
2007-04-11 09:07:51 -04:00
|
|
|
{
|
|
|
|
|
|
|
|
Gdk::Color c;
|
|
|
|
int r,g,b,a;
|
|
|
|
|
|
|
|
UINT_TO_RGBA (other.fill_color, &r, &g, &b, &a);
|
|
|
|
c.set_rgb_p (r/255.0, g/255.0, b/255.0);
|
|
|
|
|
|
|
|
/* share the other's parent, but still create a new group */
|
|
|
|
|
|
|
|
Gnome::Canvas::Group* parent = other.group->property_parent();
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2007-04-11 09:07:51 -04:00
|
|
|
group = new ArdourCanvas::Group (*parent);
|
|
|
|
|
2009-12-11 07:13:59 -05:00
|
|
|
_selected = other._selected;
|
|
|
|
|
2012-05-07 18:02:17 -04:00
|
|
|
init (other.item_name, other.samples_per_unit, c, other.frame_position,
|
|
|
|
other.item_duration, other.visibility, other.wide_enough_for_name, other.high_enough_for_name);
|
2007-04-11 09:07:51 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-12-02 21:22:36 -05:00
|
|
|
TimeAxisViewItem::init (
|
2010-09-17 14:20:37 -04:00
|
|
|
const string& it_name, double spu, Gdk::Color const & base_color, framepos_t start, framepos_t duration, Visibility vis, bool wide, bool high)
|
2007-04-11 09:07:51 -04:00
|
|
|
{
|
2010-04-07 07:03:00 -04:00
|
|
|
item_name = it_name;
|
|
|
|
samples_per_unit = spu;
|
|
|
|
frame_position = start;
|
|
|
|
item_duration = duration;
|
2005-09-25 14:42:24 -04:00
|
|
|
name_connected = false;
|
2009-05-01 16:30:57 -04:00
|
|
|
fill_opacity = 60;
|
2010-04-07 07:03:00 -04:00
|
|
|
position_locked = false;
|
2010-09-17 12:24:22 -04:00
|
|
|
max_item_duration = ARDOUR::max_framepos;
|
2010-04-07 07:03:00 -04:00
|
|
|
min_item_duration = 0;
|
2005-09-25 14:42:24 -04:00
|
|
|
show_vestigial = true;
|
2006-02-10 21:34:03 -05:00
|
|
|
visibility = vis;
|
2007-04-11 09:07:51 -04:00
|
|
|
_sensitive = true;
|
2009-11-12 15:39:53 -05:00
|
|
|
name_pixbuf_width = 0;
|
|
|
|
last_item_width = 0;
|
2009-12-02 19:14:24 -05:00
|
|
|
wide_enough_for_name = wide;
|
2009-12-02 21:22:36 -05:00
|
|
|
high_enough_for_name = high;
|
2011-03-03 09:51:02 -05:00
|
|
|
rect_visible = true;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
if (duration == 0) {
|
2010-04-07 07:03:00 -04:00
|
|
|
warning << "Time Axis Item Duration == 0" << endl;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2009-07-09 13:58:13 -04:00
|
|
|
vestigial_frame = new ArdourCanvas::SimpleRect (*group, 0.0, 1.0, 2.0, trackview.current_height());
|
2009-05-13 11:33:41 -04:00
|
|
|
vestigial_frame->hide ();
|
2007-08-05 19:17:40 -04:00
|
|
|
vestigial_frame->property_outline_what() = 0xF;
|
2007-06-29 13:13:09 -04:00
|
|
|
vestigial_frame->property_outline_color_rgba() = ARDOUR_UI::config()->canvasvar_VestigialFrame.get();
|
|
|
|
vestigial_frame->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_VestigialFrame.get();
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
if (visibility & ShowFrame) {
|
2009-07-09 13:58:13 -04:00
|
|
|
frame = new ArdourCanvas::SimpleRect (*group, 0.0, 1.0, trackview.editor().frame_to_pixel(duration), trackview.current_height());
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2008-09-14 15:01:08 -04:00
|
|
|
frame->property_outline_pixels() = 1;
|
2007-08-05 19:17:40 -04:00
|
|
|
frame->property_outline_what() = 0xF;
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-09-01 18:35:46 -04:00
|
|
|
if (_recregion) {
|
2010-07-16 16:03:16 -04:00
|
|
|
frame->property_outline_color_rgba() = ARDOUR_UI::config()->canvasvar_RecordingRect.get();
|
2010-09-01 18:35:46 -04:00
|
|
|
} else {
|
2010-07-16 16:03:16 -04:00
|
|
|
frame->property_outline_color_rgba() = ARDOUR_UI::config()->canvasvar_TimeAxisFrame.get();
|
2006-02-10 21:34:03 -05:00
|
|
|
}
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-07-16 16:03:16 -04:00
|
|
|
frame->property_outline_what() = 0x1|0x2|0x4|0x8;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
} else {
|
|
|
|
frame = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (visibility & ShowNameHighlight) {
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2006-02-10 21:34:03 -05:00
|
|
|
if (visibility & FullWidthNameHighlight) {
|
2010-09-14 14:56:41 -04:00
|
|
|
name_highlight = new ArdourCanvas::SimpleRect (*group, 0.0, trackview.editor().frame_to_pixel(item_duration), trackview.current_height() - TimeAxisViewItem::NAME_HIGHLIGHT_SIZE, trackview.current_height());
|
2006-02-10 21:34:03 -05:00
|
|
|
} else {
|
2010-09-14 14:56:41 -04:00
|
|
|
name_highlight = new ArdourCanvas::SimpleRect (*group, 1.0, trackview.editor().frame_to_pixel(item_duration) - 1, trackview.current_height() - TimeAxisViewItem::NAME_HIGHLIGHT_SIZE, trackview.current_height());
|
2006-02-10 21:34:03 -05:00
|
|
|
}
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2005-11-12 17:07:07 -05:00
|
|
|
name_highlight->set_data ("timeaxisviewitem", this);
|
2010-09-14 14:56:41 -04:00
|
|
|
name_highlight->property_outline_what() = 0x4;
|
|
|
|
/* we should really use a canvas color property here */
|
|
|
|
name_highlight->property_outline_color_rgba() = RGBA_TO_UINT (0,0,0,255);
|
2005-11-12 17:07:07 -05:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
} else {
|
|
|
|
name_highlight = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (visibility & ShowNameText) {
|
2009-05-13 11:33:41 -04:00
|
|
|
name_pixbuf = new ArdourCanvas::Pixbuf(*group);
|
|
|
|
name_pixbuf->property_x() = NAME_X_OFFSET;
|
2009-12-02 21:34:24 -05:00
|
|
|
name_pixbuf->property_y() = trackview.current_height() + 1 - NAME_Y_OFFSET;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-05-22 07:58:46 -04:00
|
|
|
} else {
|
|
|
|
name_pixbuf = 0;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2009-10-14 12:10:01 -04:00
|
|
|
/* create our grab handles used for trimming/duration etc */
|
2010-09-01 18:35:46 -04:00
|
|
|
if (!_recregion && !_automation) {
|
2012-04-30 19:00:15 -04:00
|
|
|
double top = TimeAxisViewItem::GRAB_HANDLE_TOP;
|
|
|
|
double width = TimeAxisViewItem::GRAB_HANDLE_WIDTH;
|
|
|
|
|
|
|
|
frame_handle_start = new ArdourCanvas::SimpleRect (*group, 0.0, top, width, trackview.current_height());
|
2010-07-19 19:26:10 -04:00
|
|
|
frame_handle_start->property_outline_what() = 0x0;
|
2012-04-30 19:00:15 -04:00
|
|
|
frame_handle_end = new ArdourCanvas::SimpleRect (*group, 0.0, top, width, trackview.current_height());
|
2010-07-19 19:26:10 -04:00
|
|
|
frame_handle_end->property_outline_what() = 0x0;
|
|
|
|
} else {
|
|
|
|
frame_handle_start = frame_handle_end = 0;
|
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2010-04-07 07:03:00 -04:00
|
|
|
set_color (base_color);
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2010-04-07 07:03:00 -04:00
|
|
|
set_duration (item_duration, this);
|
|
|
|
set_position (start, this);
|
2011-02-08 15:01:55 -05:00
|
|
|
|
2012-04-25 08:58:19 -04:00
|
|
|
Config->ParameterChanged.connect (*this, invalidator (*this), boost::bind (&TimeAxisViewItem::parameter_changed, this, _1), gui_context ());
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
TimeAxisViewItem::~TimeAxisViewItem()
|
|
|
|
{
|
2005-11-12 17:07:07 -05:00
|
|
|
delete group;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2011-03-03 09:51:02 -05:00
|
|
|
void
|
|
|
|
TimeAxisViewItem::hide_rect ()
|
|
|
|
{
|
|
|
|
rect_visible = false;
|
|
|
|
set_frame_color ();
|
|
|
|
|
|
|
|
if (name_highlight) {
|
|
|
|
name_highlight->property_outline_what() = 0x0;
|
2011-03-04 10:16:21 -05:00
|
|
|
name_highlight->property_fill_color_rgba() = UINT_RGBA_CHANGE_A(fill_color,64);
|
2011-03-03 09:51:02 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
TimeAxisViewItem::show_rect ()
|
|
|
|
{
|
|
|
|
rect_visible = true;
|
|
|
|
set_frame_color ();
|
|
|
|
|
|
|
|
if (name_highlight) {
|
|
|
|
name_highlight->property_outline_what() = 0x4;
|
2011-03-04 10:16:21 -05:00
|
|
|
name_highlight->property_fill_color_rgba() = fill_color;
|
2011-03-03 09:51:02 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
/**
|
2010-04-07 07:03:00 -04:00
|
|
|
* Set the position of this item on the timeline.
|
2005-09-25 14:42:24 -04:00
|
|
|
*
|
|
|
|
* @param pos the new position
|
|
|
|
* @param src the identity of the object that initiated the change
|
2010-04-07 07:03:00 -04:00
|
|
|
* @return true on success
|
2005-09-25 14:42:24 -04:00
|
|
|
*/
|
2010-04-07 07:03:00 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
bool
|
2010-09-17 14:20:37 -04:00
|
|
|
TimeAxisViewItem::set_position(framepos_t pos, void* src, double* delta)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
if (position_locked) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
frame_position = pos;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-09-25 18:26:56 -04:00
|
|
|
/* This sucks. The GnomeCanvas version I am using
|
|
|
|
doesn't correctly implement gnome_canvas_group_set_arg(),
|
2005-09-25 14:42:24 -04:00
|
|
|
so that simply setting the "x" arg of the group
|
|
|
|
fails to move the group. Instead, we have to
|
2005-09-25 18:26:56 -04:00
|
|
|
use gnome_canvas_item_move(), which does the right
|
2005-09-25 14:42:24 -04:00
|
|
|
thing. I see that in GNOME CVS, the current (Sept 2001)
|
|
|
|
version of GNOME Canvas rectifies this issue cleanly.
|
|
|
|
*/
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2010-04-07 07:03:00 -04:00
|
|
|
double old_unit_pos;
|
|
|
|
double new_unit_pos = pos / samples_per_unit;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2005-11-13 13:13:50 -05:00
|
|
|
old_unit_pos = group->property_x();
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
if (new_unit_pos != old_unit_pos) {
|
2005-11-12 17:07:07 -05:00
|
|
|
group->move (new_unit_pos - old_unit_pos, 0.0);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
if (delta) {
|
|
|
|
(*delta) = new_unit_pos - old_unit_pos;
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2010-04-07 07:03:00 -04:00
|
|
|
PositionChanged (frame_position, src); /* EMIT_SIGNAL */
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-04-07 07:03:00 -04:00
|
|
|
/** @return position of this item on the timeline */
|
2010-09-17 14:20:37 -04:00
|
|
|
framepos_t
|
2005-09-25 14:42:24 -04:00
|
|
|
TimeAxisViewItem::get_position() const
|
|
|
|
{
|
|
|
|
return frame_position;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2010-04-07 07:03:00 -04:00
|
|
|
* Set the duration of this item.
|
2005-09-25 14:42:24 -04:00
|
|
|
*
|
|
|
|
* @param dur the new duration of this item
|
|
|
|
* @param src the identity of the object that initiated the change
|
2010-04-07 07:03:00 -04:00
|
|
|
* @return true on success
|
2005-09-25 14:42:24 -04:00
|
|
|
*/
|
2010-04-07 07:03:00 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
bool
|
2012-04-14 18:04:51 -04:00
|
|
|
TimeAxisViewItem::set_duration (framecnt_t dur, void* src)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
if ((dur > max_item_duration) || (dur < min_item_duration)) {
|
2013-01-05 08:07:57 -05:00
|
|
|
warning << string_compose (
|
2013-01-05 08:29:55 -05:00
|
|
|
P_("new duration %1 frame is out of bounds for %2", "new duration of %1 frames is out of bounds for %2", dur),
|
2013-01-05 08:07:57 -05:00
|
|
|
get_item_name(), dur)
|
2005-09-25 14:42:24 -04:00
|
|
|
<< endmsg;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (dur == 0) {
|
2005-11-12 17:07:07 -05:00
|
|
|
group->hide();
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
item_duration = dur;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-07-09 13:58:13 -04:00
|
|
|
reset_width_dependent_items (trackview.editor().frame_to_pixel (dur));
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2010-04-07 07:03:00 -04:00
|
|
|
DurationChanged (dur, src); /* EMIT_SIGNAL */
|
2005-09-25 14:42:24 -04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-04-07 07:03:00 -04:00
|
|
|
/** @return duration of this item */
|
2010-09-17 14:20:37 -04:00
|
|
|
framepos_t
|
2005-09-25 14:42:24 -04:00
|
|
|
TimeAxisViewItem::get_duration() const
|
|
|
|
{
|
2010-04-07 07:03:00 -04:00
|
|
|
return item_duration;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2010-04-07 07:03:00 -04:00
|
|
|
* Set the maximum duration that this item can have.
|
2005-09-25 14:42:24 -04:00
|
|
|
*
|
|
|
|
* @param dur the new maximum duration
|
|
|
|
* @param src the identity of the object that initiated the change
|
|
|
|
*/
|
|
|
|
void
|
2010-09-17 14:20:37 -04:00
|
|
|
TimeAxisViewItem::set_max_duration(framecnt_t dur, void* src)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2010-04-07 07:03:00 -04:00
|
|
|
max_item_duration = dur;
|
|
|
|
MaxDurationChanged(max_item_duration, src); /* EMIT_SIGNAL */
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2010-04-07 07:03:00 -04:00
|
|
|
/** @return the maximum duration that this item may have */
|
2010-09-17 14:20:37 -04:00
|
|
|
framecnt_t
|
2005-09-25 14:42:24 -04:00
|
|
|
TimeAxisViewItem::get_max_duration() const
|
|
|
|
{
|
2010-04-07 07:03:00 -04:00
|
|
|
return max_item_duration;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2010-04-07 07:03:00 -04:00
|
|
|
* Set the minimum duration that this item may have.
|
2005-09-25 14:42:24 -04:00
|
|
|
*
|
|
|
|
* @param the minimum duration that this item may be set to
|
|
|
|
* @param src the identity of the object that initiated the change
|
|
|
|
*/
|
|
|
|
void
|
2010-09-17 14:20:37 -04:00
|
|
|
TimeAxisViewItem::set_min_duration(framecnt_t dur, void* src)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2010-04-07 07:03:00 -04:00
|
|
|
min_item_duration = dur;
|
|
|
|
MinDurationChanged(max_item_duration, src); /* EMIT_SIGNAL */
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2010-04-07 07:03:00 -04:00
|
|
|
/** @return the minimum duration that this item mey have */
|
2010-09-17 14:20:37 -04:00
|
|
|
framecnt_t
|
2005-09-25 14:42:24 -04:00
|
|
|
TimeAxisViewItem::get_min_duration() const
|
|
|
|
{
|
2010-04-07 07:03:00 -04:00
|
|
|
return min_item_duration;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2010-04-07 07:03:00 -04:00
|
|
|
* Set whether this item is locked to its current position.
|
2005-09-25 14:42:24 -04:00
|
|
|
* Locked items cannot be moved until the item is unlocked again.
|
|
|
|
*
|
2010-04-07 07:03:00 -04:00
|
|
|
* @param yn true to lock this item to its current position
|
2005-09-25 14:42:24 -04:00
|
|
|
* @param src the identity of the object that initiated the change
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
TimeAxisViewItem::set_position_locked(bool yn, void* src)
|
|
|
|
{
|
2010-04-07 07:03:00 -04:00
|
|
|
position_locked = yn;
|
|
|
|
set_trim_handle_colors();
|
2005-09-25 14:42:24 -04:00
|
|
|
PositionLockChanged (position_locked, src); /* EMIT_SIGNAL */
|
|
|
|
}
|
|
|
|
|
2010-04-07 07:03:00 -04:00
|
|
|
/** @return true if this item is locked to its current position */
|
2005-09-25 14:42:24 -04:00
|
|
|
bool
|
|
|
|
TimeAxisViewItem::get_position_locked() const
|
|
|
|
{
|
2010-04-07 07:03:00 -04:00
|
|
|
return position_locked;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2010-04-07 07:03:00 -04:00
|
|
|
* Set whether the maximum duration constraint is active.
|
2005-09-25 14:42:24 -04:00
|
|
|
*
|
|
|
|
* @param active set true to enforce the max duration constraint
|
|
|
|
* @param src the identity of the object that initiated the change
|
|
|
|
*/
|
|
|
|
void
|
2009-07-21 11:55:17 -04:00
|
|
|
TimeAxisViewItem::set_max_duration_active (bool active, void* /*src*/)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2009-07-21 11:55:17 -04:00
|
|
|
max_duration_active = active;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2010-04-07 07:03:00 -04:00
|
|
|
/** @return true if the maximum duration constraint is active */
|
2005-09-25 14:42:24 -04:00
|
|
|
bool
|
|
|
|
TimeAxisViewItem::get_max_duration_active() const
|
|
|
|
{
|
2010-04-07 07:03:00 -04:00
|
|
|
return max_duration_active;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
/**
|
2010-04-07 07:03:00 -04:00
|
|
|
* Set whether the minimum duration constraint is active.
|
2005-09-25 14:42:24 -04:00
|
|
|
*
|
|
|
|
* @param active set true to enforce the min duration constraint
|
|
|
|
* @param src the identity of the object that initiated the change
|
|
|
|
*/
|
2010-04-07 07:03:00 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
void
|
2009-07-21 11:55:17 -04:00
|
|
|
TimeAxisViewItem::set_min_duration_active (bool active, void* /*src*/)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2010-04-07 07:03:00 -04:00
|
|
|
min_duration_active = active;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2010-04-07 07:03:00 -04:00
|
|
|
/** @return true if the maximum duration constraint is active */
|
2005-09-25 14:42:24 -04:00
|
|
|
bool
|
|
|
|
TimeAxisViewItem::get_min_duration_active() const
|
|
|
|
{
|
2010-04-07 07:03:00 -04:00
|
|
|
return min_duration_active;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2010-04-07 07:03:00 -04:00
|
|
|
* Set the name of this item.
|
2005-09-25 14:42:24 -04:00
|
|
|
*
|
|
|
|
* @param new_name the new name of this item
|
|
|
|
* @param src the identity of the object that initiated the change
|
|
|
|
*/
|
2010-04-07 07:03:00 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
void
|
|
|
|
TimeAxisViewItem::set_item_name(std::string new_name, void* src)
|
|
|
|
{
|
|
|
|
if (new_name != item_name) {
|
2010-04-07 07:03:00 -04:00
|
|
|
std::string temp_name = item_name;
|
|
|
|
item_name = new_name;
|
|
|
|
NameChanged (item_name, temp_name, src); /* EMIT_SIGNAL */
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-04-07 07:03:00 -04:00
|
|
|
/** @return the name of this item */
|
2005-09-25 14:42:24 -04:00
|
|
|
std::string
|
|
|
|
TimeAxisViewItem::get_item_name() const
|
|
|
|
{
|
2010-04-07 07:03:00 -04:00
|
|
|
return item_name;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2010-04-07 07:03:00 -04:00
|
|
|
* Set selection status.
|
2005-09-25 14:42:24 -04:00
|
|
|
*
|
|
|
|
* @param yn true if this item is currently selected
|
|
|
|
*/
|
|
|
|
void
|
2006-06-20 14:50:38 -04:00
|
|
|
TimeAxisViewItem::set_selected(bool yn)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
if (_selected != yn) {
|
2006-06-20 14:50:38 -04:00
|
|
|
Selectable::set_selected (yn);
|
2005-09-25 14:42:24 -04:00
|
|
|
set_frame_color ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-04-07 07:03:00 -04:00
|
|
|
/** @return the TimeAxisView that this item is on */
|
2009-07-09 13:58:13 -04:00
|
|
|
TimeAxisView&
|
2010-09-06 08:34:11 -04:00
|
|
|
TimeAxisViewItem::get_time_axis_view () const
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
return trackview;
|
2009-10-14 12:10:01 -04:00
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
/**
|
2010-04-07 07:03:00 -04:00
|
|
|
* Set the displayed item text.
|
|
|
|
* This item is the visual text name displayed on the canvas item, this can be different to the name of the item.
|
2005-09-25 14:42:24 -04:00
|
|
|
*
|
|
|
|
* @param new_name the new name text to display
|
|
|
|
*/
|
2010-04-07 07:03:00 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
void
|
2010-09-14 12:51:02 -04:00
|
|
|
TimeAxisViewItem::set_name_text(const string& new_name)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2009-11-12 15:39:53 -05:00
|
|
|
if (!name_pixbuf) {
|
2009-05-13 11:33:41 -04:00
|
|
|
return;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
2009-05-13 11:33:41 -04:00
|
|
|
|
2009-11-12 15:39:53 -05:00
|
|
|
last_item_width = trackview.editor().frame_to_pixel(item_duration);
|
2011-06-02 13:50:37 -04:00
|
|
|
name_pixbuf_width = pixel_width (new_name, NAME_FONT) + 2;
|
2010-09-14 12:51:02 -04:00
|
|
|
name_pixbuf->property_pixbuf() = pixbuf_from_string(new_name, NAME_FONT, name_pixbuf_width, NAME_HEIGHT, Gdk::Color ("#000000"));
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2009-11-12 15:39:53 -05:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
/**
|
2010-04-07 07:03:00 -04:00
|
|
|
* Set the height of this item.
|
2005-09-25 14:42:24 -04:00
|
|
|
*
|
2010-04-07 07:03:00 -04:00
|
|
|
* @param h new height
|
2009-10-14 12:10:01 -04:00
|
|
|
*/
|
2005-09-25 14:42:24 -04:00
|
|
|
void
|
2008-09-19 15:32:10 -04:00
|
|
|
TimeAxisViewItem::set_height (double height)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2010-03-16 11:33:04 -04:00
|
|
|
_height = height;
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
if (name_highlight) {
|
2008-09-19 15:32:10 -04:00
|
|
|
if (height < NAME_HIGHLIGHT_THRESH) {
|
2009-12-02 21:22:36 -05:00
|
|
|
name_highlight->hide ();
|
|
|
|
high_enough_for_name = false;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
} else {
|
2005-11-12 17:07:07 -05:00
|
|
|
name_highlight->show();
|
2009-12-02 21:22:36 -05:00
|
|
|
high_enough_for_name = true;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2008-09-19 15:32:10 -04:00
|
|
|
if (height > NAME_HIGHLIGHT_SIZE) {
|
2009-08-09 23:07:48 -04:00
|
|
|
name_highlight->property_y1() = (double) height - 1 - NAME_HIGHLIGHT_SIZE;
|
2010-09-14 14:56:41 -04:00
|
|
|
name_highlight->property_y2() = (double) height - 1;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* it gets hidden now anyway */
|
2008-09-19 15:32:10 -04:00
|
|
|
name_highlight->property_y1() = (double) 1.0;
|
|
|
|
name_highlight->property_y2() = (double) height;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-05-13 11:33:41 -04:00
|
|
|
if (visibility & ShowNameText) {
|
2009-12-02 21:34:24 -05:00
|
|
|
name_pixbuf->property_y() = height + 1 - NAME_Y_OFFSET;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (frame) {
|
2009-08-09 23:07:48 -04:00
|
|
|
frame->property_y2() = height - 1;
|
2010-07-19 19:26:10 -04:00
|
|
|
if (frame_handle_start) {
|
|
|
|
frame_handle_start->property_y2() = height - 1;
|
|
|
|
frame_handle_end->property_y2() = height - 1;
|
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2009-08-09 23:07:48 -04:00
|
|
|
vestigial_frame->property_y2() = height - 1;
|
2009-12-02 21:22:36 -05:00
|
|
|
|
|
|
|
update_name_pixbuf_visibility ();
|
2011-02-08 09:09:42 -05:00
|
|
|
set_colors ();
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-06-08 15:28:51 -04:00
|
|
|
TimeAxisViewItem::set_color (Gdk::Color const & base_color)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
compute_colors (base_color);
|
|
|
|
set_colors ();
|
|
|
|
}
|
|
|
|
|
2005-11-23 12:21:12 -05:00
|
|
|
ArdourCanvas::Item*
|
2005-09-25 14:42:24 -04:00
|
|
|
TimeAxisViewItem::get_canvas_frame()
|
|
|
|
{
|
2010-04-07 07:03:00 -04:00
|
|
|
return frame;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2008-09-10 17:27:39 -04:00
|
|
|
ArdourCanvas::Group*
|
2005-09-25 14:42:24 -04:00
|
|
|
TimeAxisViewItem::get_canvas_group()
|
|
|
|
{
|
2010-04-07 07:03:00 -04:00
|
|
|
return group;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2005-11-23 12:21:12 -05:00
|
|
|
ArdourCanvas::Item*
|
2005-09-25 14:42:24 -04:00
|
|
|
TimeAxisViewItem::get_name_highlight()
|
|
|
|
{
|
2010-04-07 07:03:00 -04:00
|
|
|
return name_highlight;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2009-05-13 11:33:41 -04:00
|
|
|
ArdourCanvas::Pixbuf*
|
|
|
|
TimeAxisViewItem::get_name_pixbuf()
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2010-04-07 07:03:00 -04:00
|
|
|
return name_pixbuf;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2010-04-07 07:03:00 -04:00
|
|
|
* Calculate some contrasting color for displaying various parts of this item, based upon the base color.
|
2005-09-25 14:42:24 -04:00
|
|
|
*
|
|
|
|
* @param color the base color of the item
|
|
|
|
*/
|
|
|
|
void
|
2009-06-08 15:28:51 -04:00
|
|
|
TimeAxisViewItem::compute_colors (Gdk::Color const & base_color)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2010-04-07 07:03:00 -04:00
|
|
|
unsigned char radius;
|
|
|
|
char minor_shift;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2010-04-07 07:03:00 -04:00
|
|
|
unsigned char r,g,b;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
/* FILL: this is simple */
|
2010-04-07 07:03:00 -04:00
|
|
|
r = base_color.get_red()/256;
|
|
|
|
g = base_color.get_green()/256;
|
|
|
|
b = base_color.get_blue()/256;
|
|
|
|
fill_color = RGBA_TO_UINT(r,g,b,160);
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
/* for minor colors:
|
|
|
|
if the overall saturation is strong, make the minor colors light.
|
|
|
|
if its weak, make them dark.
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
we do this by moving an equal distance to the other side of the
|
|
|
|
central circle in the color wheel from where we started.
|
|
|
|
*/
|
|
|
|
|
2010-04-07 07:03:00 -04:00
|
|
|
radius = (unsigned char) rint (floor (sqrt (static_cast<double>(r*r + g*g + b+b))/3.0f));
|
|
|
|
minor_shift = 125 - radius;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
/* LABEL: rotate around color wheel by 120 degrees anti-clockwise */
|
|
|
|
|
2005-10-10 16:38:53 -04:00
|
|
|
r = base_color.get_red()/256;
|
|
|
|
g = base_color.get_green()/256;
|
|
|
|
b = base_color.get_blue()/256;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
if (r > b)
|
|
|
|
{
|
|
|
|
if (r > g)
|
|
|
|
{
|
|
|
|
/* red sector => green */
|
|
|
|
swap (r,g);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* green sector => blue */
|
|
|
|
swap (g,b);
|
2009-10-14 12:10:01 -04:00
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (b > g)
|
|
|
|
{
|
|
|
|
/* blue sector => red */
|
|
|
|
swap (b,r);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* green sector => blue */
|
|
|
|
swap (g,b);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
r += minor_shift;
|
|
|
|
b += minor_shift;
|
|
|
|
g += minor_shift;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
label_color = RGBA_TO_UINT(r,g,b,255);
|
2010-04-07 07:03:00 -04:00
|
|
|
r = (base_color.get_red()/256) + 127;
|
|
|
|
g = (base_color.get_green()/256) + 127;
|
|
|
|
b = (base_color.get_blue()/256) + 127;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
label_color = RGBA_TO_UINT(r,g,b,255);
|
|
|
|
|
|
|
|
/* XXX can we do better than this ? */
|
2010-04-07 07:03:00 -04:00
|
|
|
/* We're trying;) */
|
2005-09-25 14:42:24 -04:00
|
|
|
/* NUKECOLORS */
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
//frame_color_r = 192;
|
|
|
|
//frame_color_g = 192;
|
|
|
|
//frame_color_b = 194;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
//selected_frame_color_r = 182;
|
|
|
|
//selected_frame_color_g = 145;
|
|
|
|
//selected_frame_color_b = 168;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2010-04-07 07:03:00 -04:00
|
|
|
//handle_color_r = 25;
|
|
|
|
//handle_color_g = 0;
|
|
|
|
//handle_color_b = 255;
|
|
|
|
//lock_handle_color_r = 235;
|
2005-09-25 14:42:24 -04:00
|
|
|
//lock_handle_color_g = 16;
|
|
|
|
//lock_handle_color_b = 16;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Convenience method to set the various canvas item colors
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
TimeAxisViewItem::set_colors()
|
|
|
|
{
|
2010-04-07 07:03:00 -04:00
|
|
|
set_frame_color();
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
if (name_highlight) {
|
2005-11-27 17:35:04 -05:00
|
|
|
name_highlight->property_fill_color_rgba() = fill_color;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
2010-04-07 07:03:00 -04:00
|
|
|
set_trim_handle_colors();
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the frame color depending on whether this item is selected
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
TimeAxisViewItem::set_frame_color()
|
|
|
|
{
|
2011-03-03 09:51:02 -05:00
|
|
|
uint32_t f = 0;
|
|
|
|
|
2011-02-08 09:06:58 -05:00
|
|
|
if (!frame) {
|
|
|
|
return;
|
|
|
|
}
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2011-02-08 09:08:05 -05:00
|
|
|
if (_selected) {
|
2011-03-03 09:51:02 -05:00
|
|
|
|
|
|
|
f = ARDOUR_UI::config()->canvasvar_SelectedFrameBase.get();
|
|
|
|
|
2011-02-08 09:09:20 -05:00
|
|
|
if (fill_opacity) {
|
2011-03-03 09:51:02 -05:00
|
|
|
f = UINT_RGBA_CHANGE_A (f, fill_opacity);
|
2011-06-01 13:00:29 -04:00
|
|
|
}
|
2011-03-03 09:51:02 -05:00
|
|
|
|
|
|
|
if (!rect_visible) {
|
|
|
|
f = UINT_RGBA_CHANGE_A (f, 0);
|
|
|
|
}
|
|
|
|
|
2011-02-08 09:06:58 -05:00
|
|
|
} else {
|
2011-03-03 09:51:02 -05:00
|
|
|
|
2011-02-08 09:06:58 -05:00
|
|
|
if (_recregion) {
|
2011-03-03 09:51:02 -05:00
|
|
|
f = ARDOUR_UI::config()->canvasvar_RecordingRect.get();
|
2011-02-08 15:01:55 -05:00
|
|
|
} else {
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2011-02-08 15:01:55 -05:00
|
|
|
if (high_enough_for_name && !Config->get_color_regions_using_track_color()) {
|
|
|
|
f = ARDOUR_UI::config()->canvasvar_FrameBase.get();
|
2008-09-10 11:03:30 -04:00
|
|
|
} else {
|
2011-02-08 15:01:55 -05:00
|
|
|
f = fill_color;
|
2008-09-10 11:03:30 -04:00
|
|
|
}
|
2011-02-08 15:01:55 -05:00
|
|
|
|
2011-02-08 09:09:42 -05:00
|
|
|
if (fill_opacity) {
|
2011-02-08 15:01:55 -05:00
|
|
|
f = UINT_RGBA_CHANGE_A (f, fill_opacity);
|
2011-02-08 09:09:42 -05:00
|
|
|
}
|
2011-02-08 15:01:55 -05:00
|
|
|
|
2011-03-03 09:51:02 -05:00
|
|
|
if (!rect_visible) {
|
|
|
|
f = UINT_RGBA_CHANGE_A (f, 0);
|
|
|
|
}
|
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
2011-03-03 09:51:02 -05:00
|
|
|
|
|
|
|
frame->property_fill_color_rgba() = f;
|
2011-03-03 13:32:06 -05:00
|
|
|
|
|
|
|
if (!_recregion) {
|
2011-03-14 15:36:41 -04:00
|
|
|
if (_selected) {
|
|
|
|
f = ARDOUR_UI::config()->canvasvar_SelectedTimeAxisFrame.get();
|
|
|
|
} else {
|
|
|
|
f = ARDOUR_UI::config()->canvasvar_TimeAxisFrame.get();
|
|
|
|
}
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2011-03-03 13:32:06 -05:00
|
|
|
if (!rect_visible) {
|
|
|
|
f = UINT_RGBA_CHANGE_A (f, 64);
|
|
|
|
}
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2011-03-03 13:32:06 -05:00
|
|
|
frame->property_outline_color_rgba() = f;
|
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2010-04-07 07:03:00 -04:00
|
|
|
* Set the colors of the start and end trim handle depending on object state
|
2005-09-25 14:42:24 -04:00
|
|
|
*/
|
|
|
|
void
|
|
|
|
TimeAxisViewItem::set_trim_handle_colors()
|
|
|
|
{
|
|
|
|
if (frame_handle_start) {
|
|
|
|
if (position_locked) {
|
2007-06-29 13:13:09 -04:00
|
|
|
frame_handle_start->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_TrimHandleLocked.get();
|
2009-08-09 23:07:48 -04:00
|
|
|
frame_handle_end->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_TrimHandleLocked.get();
|
2005-09-25 14:42:24 -04:00
|
|
|
} else {
|
2009-08-09 23:07:48 -04:00
|
|
|
frame_handle_start->property_fill_color_rgba() = RGBA_TO_UINT(1, 1, 1, 0); //ARDOUR_UI::config()->canvasvar_TrimHandle.get();
|
|
|
|
frame_handle_end->property_fill_color_rgba() = RGBA_TO_UINT(1, 1, 1, 0); //ARDOUR_UI::config()->canvasvar_TrimHandle.get();
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-04-07 07:03:00 -04:00
|
|
|
/** @return the samples per unit of this item */
|
2005-09-25 14:42:24 -04:00
|
|
|
double
|
|
|
|
TimeAxisViewItem::get_samples_per_unit()
|
|
|
|
{
|
2010-04-07 07:03:00 -04:00
|
|
|
return samples_per_unit;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2010-04-07 07:03:00 -04:00
|
|
|
/**
|
|
|
|
* Set the samples per unit of this item.
|
|
|
|
* This item is used to determine the relative visual size and position of this item
|
|
|
|
* based upon its duration and start value.
|
|
|
|
*
|
|
|
|
* @param spu the new samples per unit value
|
|
|
|
*/
|
2005-09-25 14:42:24 -04:00
|
|
|
void
|
|
|
|
TimeAxisViewItem::set_samples_per_unit (double spu)
|
|
|
|
{
|
2010-04-07 07:03:00 -04:00
|
|
|
samples_per_unit = spu;
|
2005-09-25 14:42:24 -04:00
|
|
|
set_position (this->get_position(), this);
|
|
|
|
reset_width_dependent_items ((double)get_duration() / samples_per_unit);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
TimeAxisViewItem::reset_width_dependent_items (double pixel_width)
|
|
|
|
{
|
2010-07-16 20:56:27 -04:00
|
|
|
|
|
|
|
if (pixel_width < 2.0) {
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
if (show_vestigial) {
|
2005-11-12 22:53:51 -05:00
|
|
|
vestigial_frame->show();
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (name_highlight) {
|
2005-11-12 17:07:07 -05:00
|
|
|
name_highlight->hide();
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (frame) {
|
2005-11-12 22:53:51 -05:00
|
|
|
frame->hide();
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (frame_handle_start) {
|
2005-11-12 17:07:07 -05:00
|
|
|
frame_handle_start->hide();
|
|
|
|
frame_handle_end->hide();
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-12-02 21:22:36 -05:00
|
|
|
wide_enough_for_name = false;
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
} else {
|
2005-11-12 17:07:07 -05:00
|
|
|
vestigial_frame->hide();
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
if (name_highlight) {
|
|
|
|
|
2010-03-16 11:33:04 -04:00
|
|
|
if (_height < NAME_HIGHLIGHT_THRESH) {
|
2005-11-12 17:07:07 -05:00
|
|
|
name_highlight->hide();
|
2009-12-02 21:22:36 -05:00
|
|
|
high_enough_for_name = false;
|
2005-09-25 14:42:24 -04:00
|
|
|
} else {
|
2005-11-12 17:07:07 -05:00
|
|
|
name_highlight->show();
|
2009-05-13 11:33:41 -04:00
|
|
|
if (!get_item_name().empty()) {
|
2006-02-10 21:34:03 -05:00
|
|
|
reset_name_width (pixel_width);
|
|
|
|
}
|
2009-12-02 21:22:36 -05:00
|
|
|
high_enough_for_name = true;
|
2006-02-10 21:34:03 -05:00
|
|
|
}
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-11-14 12:26:50 -05:00
|
|
|
name_highlight->property_x2() = pixel_width;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (frame) {
|
2005-11-12 17:07:07 -05:00
|
|
|
frame->show();
|
2005-11-27 17:35:04 -05:00
|
|
|
frame->property_x2() = pixel_width;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (frame_handle_start) {
|
2012-04-30 19:00:15 -04:00
|
|
|
if (pixel_width < (3 * TimeAxisViewItem::GRAB_HANDLE_WIDTH)) {
|
|
|
|
/*
|
|
|
|
* there's less than GRAB_HANDLE_WIDTH of the region between
|
|
|
|
* the right-hand end of frame_handle_start and the left-hand
|
|
|
|
* end of frame_handle_end, so disable the handles
|
|
|
|
*/
|
2005-11-12 17:07:07 -05:00
|
|
|
frame_handle_start->hide();
|
|
|
|
frame_handle_end->hide();
|
2012-04-30 19:00:15 -04:00
|
|
|
} else {
|
|
|
|
frame_handle_start->show();
|
|
|
|
frame_handle_end->property_x1() = pixel_width - (TimeAxisViewItem::GRAB_HANDLE_WIDTH);
|
|
|
|
frame_handle_end->property_x2() = pixel_width;
|
|
|
|
frame_handle_end->show();
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
}
|
2011-05-05 10:40:53 -04:00
|
|
|
|
|
|
|
wide_enough_for_name = true;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
2010-03-16 11:33:04 -04:00
|
|
|
|
|
|
|
update_name_pixbuf_visibility ();
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-07-21 11:55:17 -04:00
|
|
|
TimeAxisViewItem::reset_name_width (double /*pixel_width*/)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2009-11-12 15:39:53 -05:00
|
|
|
uint32_t it_width;
|
|
|
|
int pb_width;
|
|
|
|
bool pixbuf_holds_full_name;
|
|
|
|
|
|
|
|
if (!name_pixbuf) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
it_width = trackview.editor().frame_to_pixel(item_duration);
|
|
|
|
pb_width = name_pixbuf_width;
|
|
|
|
|
|
|
|
pixbuf_holds_full_name = last_item_width > pb_width + NAME_X_OFFSET;
|
|
|
|
last_item_width = it_width;
|
|
|
|
|
|
|
|
if (pixbuf_holds_full_name && (it_width >= pb_width + NAME_X_OFFSET)) {
|
|
|
|
/*
|
2011-06-01 13:00:29 -04:00
|
|
|
we've previously had the full name length showing
|
2009-11-12 15:39:53 -05:00
|
|
|
and its still showing.
|
|
|
|
*/
|
|
|
|
return;
|
|
|
|
}
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2009-11-12 15:39:53 -05:00
|
|
|
if (pb_width > it_width - NAME_X_OFFSET) {
|
|
|
|
pb_width = it_width - NAME_X_OFFSET;
|
|
|
|
}
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2009-12-02 21:22:36 -05:00
|
|
|
if (it_width <= NAME_X_OFFSET) {
|
2009-12-02 19:14:24 -05:00
|
|
|
wide_enough_for_name = false;
|
2009-11-12 15:39:53 -05:00
|
|
|
} else {
|
2009-12-02 19:14:24 -05:00
|
|
|
wide_enough_for_name = true;
|
2009-11-12 15:39:53 -05:00
|
|
|
}
|
|
|
|
|
2009-12-02 21:22:36 -05:00
|
|
|
update_name_pixbuf_visibility ();
|
2012-05-23 19:39:36 -04:00
|
|
|
|
|
|
|
if (pb_width < 1) {
|
|
|
|
pb_width = 1;
|
2009-12-02 21:22:36 -05:00
|
|
|
}
|
2012-05-23 19:39:36 -04:00
|
|
|
|
|
|
|
name_pixbuf->property_pixbuf() = pixbuf_from_string(item_name, NAME_FONT, pb_width, NAME_HEIGHT, Gdk::Color ("#000000"));
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2010-04-07 07:03:00 -04:00
|
|
|
* Callback used to remove this time axis item during the gtk idle loop.
|
2005-09-25 14:42:24 -04:00
|
|
|
* This is used to avoid deleting the obejct while inside the remove_this_item
|
2010-04-07 07:03:00 -04:00
|
|
|
* method.
|
2005-09-25 14:42:24 -04:00
|
|
|
*
|
2010-04-07 07:03:00 -04:00
|
|
|
* @param item the TimeAxisViewItem to remove.
|
|
|
|
* @param src the identity of the object that initiated the change.
|
2005-09-25 14:42:24 -04:00
|
|
|
*/
|
|
|
|
gint
|
|
|
|
TimeAxisViewItem::idle_remove_this_item(TimeAxisViewItem* item, void* src)
|
|
|
|
{
|
2010-04-07 07:03:00 -04:00
|
|
|
item->ItemRemoved (item->get_item_name(), src); /* EMIT_SIGNAL */
|
2006-04-27 05:04:24 -04:00
|
|
|
delete item;
|
|
|
|
item = 0;
|
|
|
|
return false;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
2008-09-10 11:03:30 -04:00
|
|
|
|
2008-12-22 23:11:24 -05:00
|
|
|
void
|
|
|
|
TimeAxisViewItem::set_y (double y)
|
|
|
|
{
|
|
|
|
double const old = group->property_y ();
|
|
|
|
if (y != old) {
|
|
|
|
group->move (0, y - old);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-12-02 21:22:36 -05:00
|
|
|
void
|
|
|
|
TimeAxisViewItem::update_name_pixbuf_visibility ()
|
|
|
|
{
|
2009-12-04 13:13:25 -05:00
|
|
|
if (!name_pixbuf) {
|
|
|
|
return;
|
|
|
|
}
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2009-12-02 21:22:36 -05:00
|
|
|
if (wide_enough_for_name && high_enough_for_name) {
|
|
|
|
name_pixbuf->show ();
|
|
|
|
} else {
|
|
|
|
name_pixbuf->hide ();
|
|
|
|
}
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2011-02-08 15:01:55 -05:00
|
|
|
void
|
|
|
|
TimeAxisViewItem::parameter_changed (string p)
|
|
|
|
{
|
|
|
|
if (p == "color-regions-using-track-color") {
|
|
|
|
set_frame_color ();
|
|
|
|
}
|
|
|
|
}
|