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.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
2013-04-16 23:46:22 -04:00
|
|
|
#include <utility>
|
|
|
|
|
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
|
|
|
|
2014-06-22 11:41:05 -04:00
|
|
|
#include "canvas/container.h"
|
2013-04-04 00:32:52 -04:00
|
|
|
#include "canvas/rectangle.h"
|
|
|
|
#include "canvas/debug.h"
|
2013-04-15 13:50:05 -04:00
|
|
|
#include "canvas/text.h"
|
2014-11-07 14:24:27 -05:00
|
|
|
#include "canvas/colors.h"
|
2013-04-04 00:32:52 -04:00
|
|
|
|
2014-04-16 06:35:24 -04:00
|
|
|
#include "ardour/profile.h"
|
|
|
|
|
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"
|
|
|
|
#include "utils.h"
|
|
|
|
#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;
|
2014-06-25 15:27:37 -04:00
|
|
|
using namespace ARDOUR_UI_UTILS;
|
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;
|
2014-02-25 13:37:57 -05:00
|
|
|
const double TimeAxisViewItem::GRAB_HANDLE_TOP = 0.0;
|
|
|
|
const double TimeAxisViewItem::GRAB_HANDLE_WIDTH = 10.0;
|
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 ()
|
|
|
|
{
|
2014-10-21 22:55:08 -04:00
|
|
|
NAME_FONT = Pango::FontDescription (ARDOUR_UI::config()->get_SmallFont());
|
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);
|
2014-01-02 14:29:07 -05:00
|
|
|
get_pixel_size (layout, width, height);
|
|
|
|
|
|
|
|
layout = foo.create_pango_layout (X_("H")); /* just the ascender */
|
|
|
|
|
2010-06-03 11:57:31 -04:00
|
|
|
NAME_HEIGHT = height;
|
2014-04-16 07:35:20 -04:00
|
|
|
|
|
|
|
/* Config->get_show_name_highlight) == true:
|
|
|
|
Y_OFFSET is measured from bottom of the time axis view item.
|
|
|
|
Config->get_show_name_highlight) == false:
|
|
|
|
Y_OFFSET is measured from the top of the time axis view item.
|
2014-04-16 06:35:24 -04:00
|
|
|
*/
|
2014-04-16 07:35:20 -04:00
|
|
|
|
2014-12-22 13:39:41 -05:00
|
|
|
if (ARDOUR_UI::config()->get_show_name_highlight()) {
|
2014-04-16 06:35:24 -04:00
|
|
|
NAME_Y_OFFSET = height + 1;
|
|
|
|
NAME_HIGHLIGHT_SIZE = height + 2;
|
2014-04-16 07:30:09 -04:00
|
|
|
} else {
|
|
|
|
NAME_Y_OFFSET = 3;
|
|
|
|
NAME_HIGHLIGHT_SIZE = 0;
|
2014-04-16 06:35:24 -04:00
|
|
|
}
|
2010-06-03 11:57:31 -04:00
|
|
|
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(
|
2014-06-21 11:44:22 -04:00
|
|
|
const string & it_name, ArdourCanvas::Item& parent, TimeAxisView& tv, double spu, uint32_t 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)
|
2014-02-13 18:16:10 -05:00
|
|
|
, frame_position (-1)
|
2013-10-25 13:30:01 -04:00
|
|
|
, item_name (it_name)
|
2014-11-05 19:45:17 -05:00
|
|
|
, selection_frame (0)
|
2010-04-07 07:03:00 -04:00
|
|
|
, _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)
|
2013-12-29 23:10:54 -05:00
|
|
|
, _width (0.0)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2013-10-25 13:30:01 -04:00
|
|
|
init (&parent, 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)
|
2014-02-13 18:16:10 -05:00
|
|
|
, frame_position (-1)
|
2013-10-25 13:30:01 -04:00
|
|
|
, item_name (other.item_name)
|
2014-11-05 19:45:17 -05:00
|
|
|
, selection_frame (0)
|
2013-12-29 23:10:54 -05:00
|
|
|
, _height (1.0)
|
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)
|
2013-12-29 23:10:54 -05:00
|
|
|
, _width (0.0)
|
2007-04-11 09:07:51 -04:00
|
|
|
{
|
|
|
|
/* share the other's parent, but still create a new group */
|
|
|
|
|
2014-06-21 11:44:22 -04:00
|
|
|
ArdourCanvas::Item* parent = other.group->parent();
|
2013-04-25 16:06:12 -04:00
|
|
|
|
2009-12-11 07:13:59 -05:00
|
|
|
_selected = other._selected;
|
2013-04-25 16:06:12 -04:00
|
|
|
|
2014-06-09 23:28:32 -04:00
|
|
|
init (parent, other.samples_per_pixel, other.fill_color, other.frame_position,
|
2012-05-07 18:02:17 -04:00
|
|
|
other.item_duration, other.visibility, other.wide_enough_for_name, other.high_enough_for_name);
|
2007-04-11 09:07:51 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2014-06-21 11:44:22 -04:00
|
|
|
TimeAxisViewItem::init (ArdourCanvas::Item* parent, double fpp, uint32_t base_color,
|
2013-04-24 18:31:00 -04:00
|
|
|
framepos_t start, framepos_t duration, Visibility vis,
|
|
|
|
bool wide, bool high)
|
2007-04-11 09:07:51 -04:00
|
|
|
{
|
2014-06-22 11:41:05 -04:00
|
|
|
group = new ArdourCanvas::Container (parent);
|
2013-04-25 16:06:12 -04:00
|
|
|
CANVAS_DEBUG_NAME (group, string_compose ("TAVI group for %1", get_item_name()));
|
|
|
|
group->Event.connect (sigc::mem_fun (*this, &TimeAxisViewItem::canvas_group_event));
|
|
|
|
|
2014-06-09 23:28:32 -04:00
|
|
|
fill_color = base_color;
|
2014-12-19 12:06:42 -05:00
|
|
|
fill_color_name = "time axis view item base";
|
2013-04-12 11:31:50 -04:00
|
|
|
samples_per_pixel = fpp;
|
2010-04-07 07:03:00 -04:00
|
|
|
frame_position = start;
|
|
|
|
item_duration = duration;
|
2005-09-25 14:42:24 -04:00
|
|
|
name_connected = false;
|
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;
|
2013-04-15 13:50:05 -04:00
|
|
|
name_text_width = 0;
|
2009-11-12 15:39:53 -05:00
|
|
|
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;
|
2014-11-07 08:35:26 -05:00
|
|
|
vestigial_frame = 0;
|
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
|
|
|
}
|
|
|
|
|
|
|
|
if (visibility & ShowFrame) {
|
2015-02-11 21:56:44 -05:00
|
|
|
frame = new ArdourCanvas::Rectangle (group,
|
2014-02-25 11:35:55 -05:00
|
|
|
ArdourCanvas::Rect (0.0, 0.0,
|
2014-11-07 12:58:46 -05:00
|
|
|
trackview.editor().sample_to_pixel(duration),
|
2014-11-05 19:45:17 -05:00
|
|
|
trackview.current_height()));
|
|
|
|
|
|
|
|
frame->set_outline_what (ArdourCanvas::Rectangle::What (ArdourCanvas::Rectangle::LEFT|ArdourCanvas::Rectangle::RIGHT));
|
2013-10-30 23:36:30 -04:00
|
|
|
|
2013-04-24 15:42:14 -04:00
|
|
|
CANVAS_DEBUG_NAME (frame, string_compose ("frame for %1", get_item_name()));
|
2014-08-31 17:36:38 -04:00
|
|
|
|
2010-09-01 18:35:46 -04:00
|
|
|
if (_recregion) {
|
2014-12-14 16:15:38 -05:00
|
|
|
frame->set_outline_color (ARDOUR_UI::config()->color ("recording rect"));
|
2010-09-01 18:35:46 -04:00
|
|
|
} else {
|
2014-12-14 16:15:38 -05:00
|
|
|
frame->set_outline_color (ARDOUR_UI::config()->color ("time axis frame"));
|
2006-02-10 21:34:03 -05:00
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
2014-02-25 11:35:55 -05:00
|
|
|
|
2014-12-22 13:39:41 -05:00
|
|
|
if (ARDOUR_UI::config()->get_show_name_highlight() && (visibility & ShowNameHighlight)) {
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2015-06-19 08:15:25 -04:00
|
|
|
/* rectangle size will be set in ::manage_name_highlight() */
|
|
|
|
name_highlight = new ArdourCanvas::Rectangle (group);
|
2014-01-10 11:56:55 -05:00
|
|
|
CANVAS_DEBUG_NAME (name_highlight, string_compose ("name highlight for %1", get_item_name()));
|
2005-11-12 17:07:07 -05:00
|
|
|
name_highlight->set_data ("timeaxisviewitem", this);
|
2013-04-15 13:50:05 -04:00
|
|
|
name_highlight->set_outline_what (ArdourCanvas::Rectangle::TOP);
|
2015-06-19 08:15:25 -04:00
|
|
|
name_highlight->set_outline_color (RGBA_TO_UINT (0,0,0,255)); // this should use a theme color
|
2005-11-12 17:07:07 -05:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
} else {
|
|
|
|
name_highlight = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (visibility & ShowNameText) {
|
2013-04-15 13:50:05 -04:00
|
|
|
name_text = new ArdourCanvas::Text (group);
|
2013-04-24 15:42:14 -04:00
|
|
|
CANVAS_DEBUG_NAME (name_text, string_compose ("name text for %1", get_item_name()));
|
2014-12-22 13:39:41 -05:00
|
|
|
if (ARDOUR_UI::config()->get_show_name_highlight()) {
|
2014-04-16 06:35:24 -04:00
|
|
|
name_text->set_position (ArdourCanvas::Duple (NAME_X_OFFSET, trackview.current_height() - NAME_Y_OFFSET));
|
2014-04-16 07:30:09 -04:00
|
|
|
} else {
|
|
|
|
name_text->set_position (ArdourCanvas::Duple (NAME_X_OFFSET, NAME_Y_OFFSET));
|
2014-04-16 06:35:24 -04:00
|
|
|
}
|
2013-04-15 13:50:05 -04:00
|
|
|
name_text->set_font_description (NAME_FONT);
|
2014-06-27 09:37:37 -04:00
|
|
|
name_text->set_ignore_events (true);
|
2009-05-22 07:58:46 -04:00
|
|
|
} else {
|
2013-04-15 13:50:05 -04:00
|
|
|
name_text = 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;
|
|
|
|
|
2014-06-12 14:51:51 -04:00
|
|
|
frame_handle_start = new ArdourCanvas::Rectangle (group, ArdourCanvas::Rect (0.0, top, width, trackview.current_height()));
|
2013-04-24 15:42:14 -04:00
|
|
|
CANVAS_DEBUG_NAME (frame_handle_start, "TAVI frame handle start");
|
|
|
|
frame_handle_start->set_outline (false);
|
|
|
|
frame_handle_start->set_fill (false);
|
|
|
|
frame_handle_start->Event.connect (sigc::bind (sigc::mem_fun (*this, &TimeAxisViewItem::frame_handle_crossing), frame_handle_start));
|
|
|
|
|
2014-06-12 14:51:51 -04:00
|
|
|
frame_handle_end = new ArdourCanvas::Rectangle (group, ArdourCanvas::Rect (0.0, top, width, trackview.current_height()));
|
2013-04-24 15:42:14 -04:00
|
|
|
CANVAS_DEBUG_NAME (frame_handle_end, "TAVI frame handle end");
|
|
|
|
frame_handle_end->set_outline (false);
|
|
|
|
frame_handle_end->set_fill (false);
|
|
|
|
frame_handle_end->Event.connect (sigc::bind (sigc::mem_fun (*this, &TimeAxisViewItem::frame_handle_crossing), frame_handle_end));
|
2010-07-19 19:26:10 -04:00
|
|
|
} 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 ());
|
2013-04-16 23:46:22 -04:00
|
|
|
ARDOUR_UI::config()->ParameterChanged.connect (sigc::mem_fun (*this, &TimeAxisViewItem::parameter_changed));
|
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
|
|
|
}
|
|
|
|
|
2013-04-25 16:06:12 -04:00
|
|
|
bool
|
2013-05-08 14:48:28 -04:00
|
|
|
TimeAxisViewItem::canvas_group_event (GdkEvent* /*ev*/)
|
2013-04-25 16:06:12 -04:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2014-02-13 18:16:10 -05:00
|
|
|
double new_unit_pos = trackview.editor().sample_to_pixel (pos);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
if (delta) {
|
2014-02-13 18:16:10 -05:00
|
|
|
(*delta) = new_unit_pos - group->position().x;
|
|
|
|
if (*delta == 0.0) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (new_unit_pos == group->position().x) {
|
|
|
|
return true;
|
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2014-02-13 18:16:10 -05:00
|
|
|
group->set_x_position (new_unit_pos);
|
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
|
|
|
|
2015-02-11 21:35:23 -05:00
|
|
|
double end_pixel = trackview.editor().sample_to_pixel (frame_position + dur);
|
|
|
|
double first_pixel = trackview.editor().sample_to_pixel (frame_position);
|
|
|
|
|
|
|
|
reset_width_dependent_items (end_pixel - first_pixel);
|
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
|
|
|
{
|
2014-11-05 19:45:17 -05:00
|
|
|
if (_selected == yn) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
Selectable::set_selected (yn);
|
|
|
|
set_frame_color ();
|
|
|
|
set_name_text_color ();
|
2014-08-31 17:36:38 -04:00
|
|
|
|
2014-11-05 19:45:17 -05:00
|
|
|
if (_selected && frame) {
|
|
|
|
if (!selection_frame) {
|
2015-02-11 21:56:44 -05:00
|
|
|
selection_frame = new ArdourCanvas::Rectangle (group);
|
2014-11-05 19:45:17 -05:00
|
|
|
selection_frame->set_fill (false);
|
2014-12-14 16:15:38 -05:00
|
|
|
selection_frame->set_outline_color (ARDOUR_UI::config()->color ("selected time axis frame"));
|
2014-11-05 19:45:17 -05:00
|
|
|
selection_frame->set_ignore_events (true);
|
|
|
|
}
|
|
|
|
selection_frame->set (frame->get().shrink (1.0));
|
|
|
|
selection_frame->show ();
|
|
|
|
} else {
|
|
|
|
if (selection_frame) {
|
|
|
|
selection_frame->hide ();
|
2014-08-31 17:36:38 -04:00
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
2013-04-15 13:50:05 -04:00
|
|
|
if (!name_text) {
|
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
|
|
|
|
2013-04-15 13:50:05 -04:00
|
|
|
name_text_width = pixel_width (new_name, NAME_FONT) + 2;
|
|
|
|
name_text->set (new_name);
|
2013-04-15 14:45:22 -04: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;
|
|
|
|
|
2013-12-29 23:10:54 -05:00
|
|
|
manage_name_highlight ();
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2009-05-13 11:33:41 -04:00
|
|
|
if (visibility & ShowNameText) {
|
2014-12-22 13:39:41 -05:00
|
|
|
if (ARDOUR_UI::config()->get_show_name_highlight()) {
|
2014-04-16 06:35:24 -04:00
|
|
|
name_text->set_y_position (height - NAME_Y_OFFSET);
|
2014-04-16 07:30:09 -04:00
|
|
|
} else {
|
|
|
|
name_text->set_y_position (NAME_Y_OFFSET);
|
2014-04-16 06:35:24 -04:00
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (frame) {
|
2014-11-05 19:45:17 -05:00
|
|
|
|
2015-06-19 08:15:25 -04:00
|
|
|
frame->set_y0 (0.0);
|
2014-11-05 19:45:17 -05:00
|
|
|
frame->set_y1 (height);
|
2014-08-31 17:36:38 -04:00
|
|
|
|
2010-07-19 19:26:10 -04:00
|
|
|
if (frame_handle_start) {
|
2014-01-10 11:56:55 -05:00
|
|
|
frame_handle_start->set_y1 (height);
|
|
|
|
frame_handle_end->set_y1 (height);
|
2010-07-19 19:26:10 -04:00
|
|
|
}
|
2014-11-05 19:45:17 -05:00
|
|
|
|
|
|
|
if (selection_frame) {
|
|
|
|
selection_frame->set (frame->get().shrink (1.0));
|
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2014-11-07 08:35:26 -05:00
|
|
|
if (vestigial_frame) {
|
2015-06-19 08:15:25 -04:00
|
|
|
vestigial_frame->set_y0 (0.0);
|
2014-11-07 08:35:26 -05:00
|
|
|
vestigial_frame->set_y1 (height);
|
|
|
|
}
|
2009-12-02 21:22:36 -05:00
|
|
|
|
2011-02-08 09:09:42 -05:00
|
|
|
set_colors ();
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2013-12-29 23:10:54 -05:00
|
|
|
void
|
|
|
|
TimeAxisViewItem::manage_name_highlight ()
|
|
|
|
{
|
2014-01-10 11:56:55 -05:00
|
|
|
if (!name_highlight) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-12-29 23:10:54 -05:00
|
|
|
if (_height < NAME_HIGHLIGHT_THRESH) {
|
|
|
|
high_enough_for_name = false;
|
|
|
|
} else {
|
|
|
|
high_enough_for_name = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_width < 2.0) {
|
|
|
|
wide_enough_for_name = false;
|
|
|
|
} else {
|
|
|
|
wide_enough_for_name = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (name_highlight && wide_enough_for_name && high_enough_for_name) {
|
|
|
|
|
|
|
|
name_highlight->show();
|
2015-06-19 08:15:25 -04:00
|
|
|
// name_highlight->set_x_position (1.0);
|
|
|
|
name_highlight->set (ArdourCanvas::Rect (0.0, (double) _height - NAME_HIGHLIGHT_SIZE, _width - 2.0, _height));
|
2013-12-29 23:10:54 -05:00
|
|
|
|
|
|
|
} else {
|
|
|
|
name_highlight->hide();
|
|
|
|
}
|
|
|
|
|
|
|
|
manage_name_text ();
|
|
|
|
}
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
void
|
2014-06-09 23:28:32 -04:00
|
|
|
TimeAxisViewItem::set_color (uint32_t base_color)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2014-06-09 23:28:32 -04:00
|
|
|
fill_color = base_color;
|
2005-09-25 14:42:24 -04:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2014-06-21 11:44:22 -04:00
|
|
|
ArdourCanvas::Item*
|
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
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Convenience method to set the various canvas item colors
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
TimeAxisViewItem::set_colors()
|
|
|
|
{
|
2014-06-13 10:56:46 -04:00
|
|
|
set_frame_color ();
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
if (name_highlight) {
|
2014-02-25 11:35:55 -05:00
|
|
|
name_highlight->set_fill_color (fill_color);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
2013-06-26 17:40:10 -04:00
|
|
|
|
2014-06-05 12:00:24 -04:00
|
|
|
set_name_text_color ();
|
|
|
|
set_trim_handle_colors();
|
|
|
|
}
|
2013-06-26 17:40:10 -04:00
|
|
|
|
2014-06-05 12:00:24 -04:00
|
|
|
void
|
|
|
|
TimeAxisViewItem::set_name_text_color ()
|
|
|
|
{
|
|
|
|
if (!name_text) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-06-26 17:40:10 -04:00
|
|
|
|
2014-06-05 12:00:24 -04:00
|
|
|
uint32_t f;
|
|
|
|
|
2014-12-22 13:39:41 -05:00
|
|
|
if (ARDOUR_UI::config()->get_show_name_highlight()) {
|
2014-06-05 12:00:24 -04:00
|
|
|
/* name text will always be on top of name highlight, which
|
|
|
|
will always use our fill color.
|
|
|
|
*/
|
|
|
|
f = fill_color;
|
|
|
|
} else {
|
|
|
|
/* name text will be on top of the item, whose color
|
|
|
|
may vary depending on various conditions.
|
|
|
|
*/
|
|
|
|
f = get_fill_color ();
|
|
|
|
}
|
2013-06-26 17:40:10 -04:00
|
|
|
|
2014-06-30 10:38:45 -04:00
|
|
|
name_text->set_color (ArdourCanvas::contrasting_text_color (f));
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2014-12-19 12:06:42 -05:00
|
|
|
ArdourCanvas::Color
|
2013-06-24 16:28:53 -04:00
|
|
|
TimeAxisViewItem::get_fill_color () const
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2014-12-19 12:06:42 -05:00
|
|
|
const std::string mod_name = (_dragging ? "dragging region" : fill_color_name);
|
2014-06-13 10:56:46 -04:00
|
|
|
|
2011-02-08 09:08:05 -05:00
|
|
|
if (_selected) {
|
2015-01-08 19:59:40 -05:00
|
|
|
return ARDOUR_UI::config()->color_mod ("selected region base", mod_name);
|
|
|
|
} else if (_recregion) {
|
|
|
|
return ARDOUR_UI::config()->color ("recording rect");
|
|
|
|
} else if ((!ARDOUR_UI::config()->get_show_name_highlight() || high_enough_for_name) &&
|
|
|
|
!ARDOUR_UI::config()->get_color_regions_using_track_color()) {
|
|
|
|
return ARDOUR_UI::config()->color_mod (fill_color_name, mod_name);
|
2013-06-24 16:28:53 -04:00
|
|
|
}
|
2015-01-08 19:59:40 -05:00
|
|
|
return ARDOUR_UI::config()->color_mod (fill_color, mod_name);
|
2013-06-24 16:28:53 -04:00
|
|
|
}
|
2011-02-08 15:01:55 -05:00
|
|
|
|
2013-06-24 16:28:53 -04:00
|
|
|
/**
|
|
|
|
* Sets the frame color depending on whether this item is selected
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
TimeAxisViewItem::set_frame_color()
|
|
|
|
{
|
|
|
|
if (!frame) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-11-13 23:33:11 -05:00
|
|
|
frame->set_fill_color (get_fill_color());
|
2013-04-16 23:46:22 -04:00
|
|
|
set_frame_gradient ();
|
2011-03-03 13:32:06 -05:00
|
|
|
|
2014-11-13 23:33:11 -05:00
|
|
|
if (!_recregion) {
|
2014-12-12 18:16:50 -05:00
|
|
|
frame->set_outline_color (ARDOUR_UI::config()->color ("time axis frame"));
|
2014-11-13 23:33:11 -05:00
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2014-06-09 23:28:32 -04:00
|
|
|
void
|
2013-04-16 23:46:22 -04:00
|
|
|
TimeAxisViewItem::set_frame_gradient ()
|
|
|
|
{
|
|
|
|
if (ARDOUR_UI::config()->get_timeline_item_gradient_depth() == 0.0) {
|
|
|
|
frame->set_gradient (ArdourCanvas::Fill::StopList (), 0);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ArdourCanvas::Fill::StopList stops;
|
|
|
|
double r, g, b, a;
|
|
|
|
double h, s, v;
|
2013-06-24 16:28:53 -04:00
|
|
|
ArdourCanvas::Color f (get_fill_color());
|
2013-04-16 23:46:22 -04:00
|
|
|
|
|
|
|
/* need to get alpha value */
|
|
|
|
ArdourCanvas::color_to_rgba (f, r, g, b, a);
|
|
|
|
|
|
|
|
stops.push_back (std::make_pair (0.0, f));
|
|
|
|
|
|
|
|
/* now a darker version */
|
|
|
|
|
|
|
|
ArdourCanvas::color_to_hsv (f, h, s, v);
|
2013-06-24 16:28:53 -04:00
|
|
|
|
|
|
|
v = min (1.0, v * (1.0 - ARDOUR_UI::config()->get_timeline_item_gradient_depth()));
|
2013-04-16 23:46:22 -04:00
|
|
|
|
2014-11-19 13:14:26 -05:00
|
|
|
ArdourCanvas::Color darker = ArdourCanvas::hsva_to_color (h, s, v, a);
|
2013-04-16 23:46:22 -04:00
|
|
|
stops.push_back (std::make_pair (1.0, darker));
|
|
|
|
|
2013-06-27 10:41:00 -04:00
|
|
|
frame->set_gradient (stops, true);
|
2013-04-16 23:46:22 -04:00
|
|
|
}
|
|
|
|
|
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()
|
|
|
|
{
|
2014-04-14 04:46:24 -04:00
|
|
|
#if 1
|
|
|
|
/* Leave them transparent for now */
|
|
|
|
if (frame_handle_start) {
|
|
|
|
frame_handle_start->set_fill_color (0x00000000);
|
|
|
|
frame_handle_end->set_fill_color (0x00000000);
|
|
|
|
}
|
|
|
|
#else
|
2005-09-25 14:42:24 -04:00
|
|
|
if (frame_handle_start) {
|
|
|
|
if (position_locked) {
|
2014-10-21 22:55:08 -04:00
|
|
|
frame_handle_start->set_fill_color (ARDOUR_UI::config()->get_TrimHandleLocked());
|
|
|
|
frame_handle_end->set_fill_color (ARDOUR_UI::config()->get_TrimHandleLocked());
|
2005-09-25 14:42:24 -04:00
|
|
|
} else {
|
2014-10-21 22:55:08 -04:00
|
|
|
frame_handle_start->set_fill_color (ARDOUR_UI::config()->get_TrimHandle());
|
|
|
|
frame_handle_end->set_fill_color (ARDOUR_UI::config()->get_TrimHandle());
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
}
|
2014-04-14 04:46:24 -04:00
|
|
|
#endif
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2013-04-24 15:42:14 -04:00
|
|
|
bool
|
|
|
|
TimeAxisViewItem::frame_handle_crossing (GdkEvent* ev, ArdourCanvas::Rectangle* item)
|
|
|
|
{
|
2014-03-10 12:14:37 -04:00
|
|
|
switch (ev->type) {
|
|
|
|
case GDK_LEAVE_NOTIFY:
|
|
|
|
/* always hide the handle whenever we leave, no matter what mode */
|
|
|
|
item->set_fill (false);
|
|
|
|
break;
|
|
|
|
case GDK_ENTER_NOTIFY:
|
2014-12-08 23:00:00 -05:00
|
|
|
if (trackview.editor().effective_mouse_mode() == Editing::MouseObject) {
|
|
|
|
/* Never set this to be visible in other modes. Note, however,
|
|
|
|
that we do need to undo visibility (LEAVE_NOTIFY case above) no
|
|
|
|
matter what the mode is. */
|
2014-03-05 14:33:27 -05:00
|
|
|
item->set_fill (true);
|
|
|
|
}
|
2014-03-10 12:14:37 -04:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2013-04-24 15:42:14 -04:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-04-04 00:32:52 -04:00
|
|
|
/** @return the frames per pixel */
|
2005-09-25 14:42:24 -04:00
|
|
|
double
|
2013-04-12 11:31:50 -04:00
|
|
|
TimeAxisViewItem::get_samples_per_pixel () const
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2013-04-12 11:31:50 -04:00
|
|
|
return samples_per_pixel;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2013-04-04 00:32:52 -04:00
|
|
|
/** Set the frames per pixel 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.
|
2010-04-07 07:03:00 -04:00
|
|
|
*
|
2013-04-04 00:32:52 -04:00
|
|
|
* @param fpp the new frames per pixel
|
2010-04-07 07:03:00 -04:00
|
|
|
*/
|
2005-09-25 14:42:24 -04:00
|
|
|
void
|
2013-04-12 11:31:50 -04:00
|
|
|
TimeAxisViewItem::set_samples_per_pixel (double fpp)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2013-04-12 11:31:50 -04:00
|
|
|
samples_per_pixel = fpp;
|
2005-09-25 14:42:24 -04:00
|
|
|
set_position (this->get_position(), this);
|
2015-02-11 21:35:23 -05:00
|
|
|
|
|
|
|
double end_pixel = trackview.editor().sample_to_pixel (frame_position + get_duration());
|
|
|
|
double first_pixel = trackview.editor().sample_to_pixel (frame_position);
|
|
|
|
|
|
|
|
reset_width_dependent_items (end_pixel - first_pixel);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
TimeAxisViewItem::reset_width_dependent_items (double pixel_width)
|
|
|
|
{
|
2013-12-29 23:10:54 -05:00
|
|
|
_width = pixel_width;
|
|
|
|
|
|
|
|
manage_name_highlight ();
|
2014-06-07 11:47:38 -04:00
|
|
|
manage_name_text ();
|
2013-12-29 23:10:54 -05:00
|
|
|
|
2010-07-16 20:56:27 -04:00
|
|
|
if (pixel_width < 2.0) {
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
if (show_vestigial) {
|
2014-11-07 08:35:26 -05:00
|
|
|
|
|
|
|
if (!vestigial_frame) {
|
2015-02-11 21:56:44 -05:00
|
|
|
vestigial_frame = new ArdourCanvas::Rectangle (group, ArdourCanvas::Rect (0.0, 0.0, 2.0, trackview.current_height()));
|
2014-11-07 08:35:26 -05:00
|
|
|
CANVAS_DEBUG_NAME (vestigial_frame, string_compose ("vestigial frame for %1", get_item_name()));
|
2014-12-14 16:15:38 -05:00
|
|
|
vestigial_frame->set_outline_color (ARDOUR_UI::config()->color ("vestigial frame"));
|
|
|
|
vestigial_frame->set_fill_color (ARDOUR_UI::config()->color ("vestigial frame"));
|
2014-11-07 12:58:46 -05:00
|
|
|
vestigial_frame->set_outline_what (ArdourCanvas::Rectangle::What (ArdourCanvas::Rectangle::LEFT|ArdourCanvas::Rectangle::RIGHT));
|
2014-11-07 08:35:26 -05:00
|
|
|
}
|
|
|
|
|
2005-11-12 22:53:51 -05:00
|
|
|
vestigial_frame->show();
|
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
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
} else {
|
2014-11-07 08:35:26 -05:00
|
|
|
if (vestigial_frame) {
|
|
|
|
vestigial_frame->hide();
|
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
if (frame) {
|
2005-11-12 17:07:07 -05:00
|
|
|
frame->show();
|
2015-02-11 21:35:23 -05:00
|
|
|
/* Note: x0 is always zero - the position is defined by
|
|
|
|
* the position of the group, not the frame.
|
|
|
|
*/
|
2014-11-07 12:58:46 -05:00
|
|
|
frame->set_x1 (pixel_width);
|
2014-11-05 19:45:17 -05:00
|
|
|
|
|
|
|
if (selection_frame) {
|
|
|
|
selection_frame->set (frame->get().shrink (1.0));
|
|
|
|
}
|
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
|
|
|
|
*/
|
2013-04-24 15:42:14 -04:00
|
|
|
|
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();
|
2014-11-07 12:58:46 -05:00
|
|
|
frame_handle_end->set_x0 (pixel_width - (TimeAxisViewItem::GRAB_HANDLE_WIDTH));
|
|
|
|
frame_handle_end->set_x1 (pixel_width);
|
2012-04-30 19:00:15 -04:00
|
|
|
frame_handle_end->show();
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2013-12-29 23:10:54 -05:00
|
|
|
TimeAxisViewItem::manage_name_text ()
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2013-12-29 23:10:54 -05:00
|
|
|
int visible_name_width;
|
2009-11-12 15:39:53 -05:00
|
|
|
|
2013-04-15 13:50:05 -04:00
|
|
|
if (!name_text) {
|
2009-11-12 15:39:53 -05:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-12-29 23:10:54 -05:00
|
|
|
if (!wide_enough_for_name || !high_enough_for_name) {
|
|
|
|
name_text->hide ();
|
2009-11-12 15:39:53 -05:00
|
|
|
return;
|
|
|
|
}
|
2013-12-29 23:10:54 -05:00
|
|
|
|
|
|
|
if (name_text->text().empty()) {
|
|
|
|
name_text->hide ();
|
2009-11-12 15:39:53 -05:00
|
|
|
}
|
|
|
|
|
2013-12-29 23:10:54 -05:00
|
|
|
visible_name_width = name_text_width;
|
2012-05-23 19:39:36 -04:00
|
|
|
|
2013-12-29 23:10:54 -05:00
|
|
|
if (visible_name_width > _width - NAME_X_OFFSET) {
|
|
|
|
visible_name_width = _width - NAME_X_OFFSET;
|
2009-12-02 21:22:36 -05:00
|
|
|
}
|
2012-05-23 19:39:36 -04:00
|
|
|
|
2013-12-29 23:10:54 -05:00
|
|
|
if (visible_name_width < 1) {
|
|
|
|
name_text->hide ();
|
|
|
|
} else {
|
|
|
|
name_text->clamp_width (visible_name_width);
|
|
|
|
name_text->show ();
|
|
|
|
}
|
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)
|
|
|
|
{
|
2014-09-04 10:14:01 -04:00
|
|
|
group->set_y_position (y);
|
2008-12-22 23:11:24 -05:00
|
|
|
}
|
|
|
|
|
2011-02-08 15:01:55 -05:00
|
|
|
void
|
|
|
|
TimeAxisViewItem::parameter_changed (string p)
|
|
|
|
{
|
|
|
|
if (p == "color-regions-using-track-color") {
|
2013-06-28 11:31:26 -04:00
|
|
|
set_colors ();
|
2013-04-16 23:46:22 -04:00
|
|
|
} else if (p == "timeline-item-gradient-depth") {
|
|
|
|
set_frame_gradient ();
|
2011-02-08 15:01:55 -05:00
|
|
|
}
|
|
|
|
}
|
2014-06-13 10:56:46 -04:00
|
|
|
|
|
|
|
void
|
|
|
|
TimeAxisViewItem::drag_start ()
|
|
|
|
{
|
|
|
|
_dragging = true;
|
|
|
|
set_frame_color ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
TimeAxisViewItem::drag_end ()
|
|
|
|
{
|
|
|
|
_dragging = false;
|
|
|
|
set_frame_color ();
|
|
|
|
}
|