2005-09-25 14:42:24 -04:00
|
|
|
/*
|
2019-08-02 17:26:43 -04:00
|
|
|
* Copyright (C) 2005-2019 Paul Davis <paul@linuxaudiosystems.com>
|
|
|
|
* Copyright (C) 2005 Karsten Wiese <fzuuzf@googlemail.com>
|
|
|
|
* Copyright (C) 2005 Taybin Rutkin <taybin@taybin.com>
|
|
|
|
* Copyright (C) 2007-2012 Carl Hetherington <carl@carlh.net>
|
|
|
|
* Copyright (C) 2007-2015 David Robillard <d@drobilla.net>
|
|
|
|
* Copyright (C) 2007 Doug McLain <doug@nostar.net>
|
|
|
|
* Copyright (C) 2013-2019 Robin Gareus <robin@gareus.org>
|
|
|
|
* Copyright (C) 2014-2016 Nick Mainsbridge <mainsbridge@gmail.com>
|
|
|
|
* Copyright (C) 2014 Ben Loftis <ben@harrisonconsoles.com>
|
|
|
|
* Copyright (C) 2015 Tim Mayberry <mojofunk@gmail.com>
|
|
|
|
*
|
|
|
|
* 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.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*/
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2013-04-16 23:46:22 -04:00
|
|
|
#include <utility>
|
|
|
|
|
2009-02-25 13:26:51 -05:00
|
|
|
#include "pbd/error.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"
|
2017-07-17 12:34:35 -04:00
|
|
|
#include "gtkmm2ext/colors.h"
|
2013-04-04 00:32:52 -04:00
|
|
|
|
2014-04-16 06:35:24 -04:00
|
|
|
#include "ardour/profile.h"
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
#include "public_editor.h"
|
|
|
|
#include "time_axis_view_item.h"
|
|
|
|
#include "time_axis_view.h"
|
2015-01-02 09:44:54 -05:00
|
|
|
#include "ui_config.h"
|
2005-09-25 14:42:24 -04:00
|
|
|
#include "utils.h"
|
|
|
|
#include "rgb_macros.h"
|
|
|
|
|
2016-07-14 14:44:52 -04:00
|
|
|
#include "pbd/i18n.h"
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
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 ()
|
|
|
|
{
|
2017-07-01 12:42:24 -04:00
|
|
|
NAME_FONT = Pango::FontDescription (UIConfiguration::instance().get_SmallFont());
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2017-07-01 12:42:24 -04:00
|
|
|
Gtk::Window win;
|
|
|
|
Gtk::Label foo;
|
|
|
|
win.add (foo);
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2017-07-01 12:42:24 -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
|
|
|
|
2017-07-01 12:42:24 -04:00
|
|
|
layout->set_font_description (NAME_FONT);
|
|
|
|
get_pixel_size (layout, width, height);
|
2014-01-02 14:29:07 -05:00
|
|
|
|
2017-07-01 12:42:24 -04:00
|
|
|
layout = foo.create_pango_layout (X_("H")); /* just the ascender */
|
2014-01-02 14:29:07 -05:00
|
|
|
|
2017-07-01 12:42:24 -04:00
|
|
|
NAME_HEIGHT = height;
|
2014-04-16 07:35:20 -04:00
|
|
|
|
2015-10-04 14:51:05 -04:00
|
|
|
/* Config->get_show_name_highlight) == true:
|
2014-04-16 07:35:20 -04:00
|
|
|
Y_OFFSET is measured from bottom of the time axis view item.
|
2015-10-04 14:51:05 -04:00
|
|
|
Config->get_show_name_highlight) == false:
|
2014-04-16 07:35:20 -04:00
|
|
|
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
|
|
|
|
2015-01-02 09:44:54 -05:00
|
|
|
if (UIConfiguration::instance().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
|
|
|
}
|
2017-07-01 12:42:24 -04:00
|
|
|
NAME_HIGHLIGHT_THRESH = NAME_HIGHLIGHT_SIZE * 3;
|
2010-06-03 11:57:31 -04:00
|
|
|
}
|
|
|
|
|
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,
|
2020-10-15 21:07:15 -04:00
|
|
|
timepos_t const & start, timecnt_t const & 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)
|
2013-10-25 13:30:01 -04:00
|
|
|
, item_name (it_name)
|
2019-04-08 14:00:02 -04: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)
|
2013-10-25 13:30:01 -04:00
|
|
|
, item_name (other.item_name)
|
2019-04-08 14:00:02 -04: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();
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2009-12-11 07:13:59 -05:00
|
|
|
_selected = other._selected;
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2020-10-15 21:07:15 -04:00
|
|
|
init (parent, other.samples_per_pixel, other.fill_color, other.time_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
|
2015-10-04 14:51:05 -04:00
|
|
|
TimeAxisViewItem::init (ArdourCanvas::Item* parent, double fpp, uint32_t base_color,
|
2020-10-15 21:07:15 -04:00
|
|
|
timepos_t const & start, timecnt_t const & duration, Visibility vis,
|
2013-04-24 18:31:00 -04:00
|
|
|
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()));
|
|
|
|
|
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;
|
2020-10-15 21:07:15 -04:00
|
|
|
time_position = start;
|
2010-04-07 07:03:00 -04:00
|
|
|
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;
|
2020-10-15 21:07:15 -04:00
|
|
|
max_item_duration = timecnt_t::max (item_duration.time_domain());
|
|
|
|
min_item_duration = timecnt_t::zero (item_duration.time_domain());
|
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;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2021-12-11 09:51:31 -05:00
|
|
|
if (duration.is_zero ()) {
|
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) {
|
2019-04-08 14:00:02 -04:00
|
|
|
frame = new ArdourCanvas::Rectangle (group,
|
|
|
|
ArdourCanvas::Rect (0.0, 0.0,
|
2020-10-19 14:37:54 -04:00
|
|
|
trackview.editor().duration_to_pixels (duration),
|
2019-04-08 14:00:02 -04:00
|
|
|
trackview.current_height()));
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2019-04-08 14:00:02 -04:00
|
|
|
frame->set_outline_what (ArdourCanvas::Rectangle::What (ArdourCanvas::Rectangle::LEFT|ArdourCanvas::Rectangle::RIGHT));
|
|
|
|
frame->show ();
|
2013-10-30 23:36:30 -04:00
|
|
|
|
2019-04-08 14:00:02 -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) {
|
2019-04-08 14:00:02 -04:00
|
|
|
frame->set_outline_color (UIConfiguration::instance().color ("recording rect"));
|
2010-09-01 18:35:46 -04:00
|
|
|
} else {
|
2019-04-08 14:00:02 -04:00
|
|
|
frame->set_outline_color (UIConfiguration::instance().color ("time axis frame"));
|
2006-02-10 21:34:03 -05:00
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2015-01-02 09:44:54 -05:00
|
|
|
if (UIConfiguration::instance().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);
|
2017-07-01 12:42:24 -04:00
|
|
|
name_highlight->set_outline_what (ArdourCanvas::Rectangle::TOP);
|
|
|
|
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()));
|
2015-01-02 09:44:54 -05:00
|
|
|
if (UIConfiguration::instance().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;
|
|
|
|
|
2019-04-08 14:25:05 -04:00
|
|
|
frame_handle_start = new ArdourCanvas::Rectangle (group, ArdourCanvas::Rect (0.0, top, width, trackview.current_height()));
|
|
|
|
CANVAS_DEBUG_NAME (frame_handle_start, "TAVI frame handle start");
|
|
|
|
frame_handle_start->set_outline (false);
|
|
|
|
frame_handle_start->set_fill (false);
|
2019-04-08 15:40:33 -04:00
|
|
|
frame_handle_start->Event.connect (sigc::bind (sigc::mem_fun (*this, &TimeAxisViewItem::frame_handle_crossing), frame_handle_start));
|
2019-04-08 14:25:05 -04:00
|
|
|
|
|
|
|
frame_handle_end = new ArdourCanvas::Rectangle (group, ArdourCanvas::Rect (0.0, top, width, trackview.current_height()));
|
|
|
|
CANVAS_DEBUG_NAME (frame_handle_end, "TAVI frame handle end");
|
|
|
|
frame_handle_end->set_outline (false);
|
|
|
|
frame_handle_end->set_fill (false);
|
2019-04-08 15:40:33 -04:00
|
|
|
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 {
|
2019-04-08 14:25:05 -04:00
|
|
|
frame_handle_start = frame_handle_end = 0;
|
2010-07-19 19:26:10 -04:00
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2016-04-12 15:38:31 -04:00
|
|
|
//set_color (base_color);
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2016-04-12 15:38:31 -04:00
|
|
|
//set_duration (item_duration, this);
|
|
|
|
//set_position (start, this);
|
2011-02-08 15:01:55 -05:00
|
|
|
|
2016-04-12 15:38:31 -04:00
|
|
|
group->Event.connect (sigc::mem_fun (*this, &TimeAxisViewItem::canvas_group_event));
|
|
|
|
//Config->ParameterChanged.connect (*this, invalidator (*this), boost::bind (&TimeAxisViewItem::parameter_changed, this, _1), gui_context ());
|
2016-12-29 17:05:08 -05:00
|
|
|
UIConfiguration::instance().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
|
2020-09-26 11:14:59 -04:00
|
|
|
TimeAxisViewItem::set_position(timepos_t const & pos, void* src, double* delta)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
if (position_locked) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2020-10-19 14:37:54 -04:00
|
|
|
time_position = pos;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2020-10-15 21:07:15 -04:00
|
|
|
double new_unit_pos = trackview.editor().time_to_pixel (time_position);
|
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);
|
2020-10-15 21:07:15 -04:00
|
|
|
PositionChanged (time_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 */
|
2020-10-15 21:07:15 -04:00
|
|
|
timepos_t
|
2005-09-25 14:42:24 -04:00
|
|
|
TimeAxisViewItem::get_position() const
|
|
|
|
{
|
2020-10-15 21:07:15 -04:00
|
|
|
return time_position;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
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
|
2020-10-15 21:07:15 -04:00
|
|
|
TimeAxisViewItem::set_duration (timecnt_t const & dur, void* src)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
if ((dur > max_item_duration) || (dur < min_item_duration)) {
|
2020-10-19 14:37:54 -04:00
|
|
|
// XXX NUTEMPO we do not have a plural i18n form that is type-safe (P_() requires integers)
|
|
|
|
//
|
|
|
|
//warning << string_compose (
|
|
|
|
//P_("new duration %1 is out of bounds for %2", "new duration of %1 samples is out of bounds for %2", dur),
|
|
|
|
// get_item_name(), dur)
|
|
|
|
//<< endmsg;
|
2005-09-25 14:42:24 -04:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2021-12-11 09:51:31 -05:00
|
|
|
if (dur.is_zero()) {
|
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
|
|
|
|
2020-10-15 21:07:15 -04:00
|
|
|
double end_pixel = trackview.editor().time_to_pixel (time_position + dur);
|
|
|
|
double first_pixel = trackview.editor().time_to_pixel (time_position);
|
2015-02-11 21:35:23 -05:00
|
|
|
|
|
|
|
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 */
|
2020-10-15 21:07:15 -04:00
|
|
|
timecnt_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
|
2020-10-19 14:37:54 -04:00
|
|
|
TimeAxisViewItem::set_max_duration(timecnt_t const & 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 */
|
2020-10-15 21:07:15 -04:00
|
|
|
timecnt_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
|
2020-10-19 14:37:54 -04:00
|
|
|
TimeAxisViewItem::set_min_duration(timecnt_t const & 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 */
|
2020-10-15 21:07:15 -04:00
|
|
|
timecnt_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;
|
|
|
|
}
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2014-11-05 19:45:17 -05:00
|
|
|
Selectable::set_selected (yn);
|
2019-04-08 14:00:02 -04:00
|
|
|
set_frame_color ();
|
2014-11-05 19:45:17 -05:00
|
|
|
set_name_text_color ();
|
2014-08-31 17:36:38 -04:00
|
|
|
|
2019-04-08 14:00:02 -04:00
|
|
|
if (_selected && frame) {
|
|
|
|
if (!selection_frame) {
|
|
|
|
selection_frame = new ArdourCanvas::Rectangle (group);
|
|
|
|
selection_frame->set_fill (false);
|
|
|
|
selection_frame->set_outline_color (UIConfiguration::instance().color ("selected time axis frame"));
|
|
|
|
selection_frame->set_ignore_events (true);
|
2014-11-05 19:45:17 -05:00
|
|
|
}
|
2019-04-08 14:00:02 -04:00
|
|
|
selection_frame->set (frame->get().shrink (1.0));
|
|
|
|
selection_frame->show ();
|
2014-11-05 19:45:17 -05:00
|
|
|
} else {
|
2019-04-08 14:00:02 -04:00
|
|
|
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);
|
2015-09-06 10:45:48 -04:00
|
|
|
manage_name_text ();
|
2016-04-12 15:38:31 -04:00
|
|
|
manage_name_highlight ();
|
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
|
|
|
{
|
2017-07-01 12:42:24 -04:00
|
|
|
_height = height;
|
2010-03-16 11:33:04 -04:00
|
|
|
|
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) {
|
2015-01-02 09:44:54 -05:00
|
|
|
if (UIConfiguration::instance().get_show_name_highlight()) {
|
2015-10-04 14:51:05 -04:00
|
|
|
name_text->set_y_position (height - NAME_Y_OFFSET);
|
2014-04-16 07:30:09 -04:00
|
|
|
} else {
|
2015-10-04 14:51:05 -04:00
|
|
|
name_text->set_y_position (NAME_Y_OFFSET);
|
2014-04-16 06:35:24 -04:00
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2019-04-08 14:00:02 -04:00
|
|
|
if (frame) {
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2019-04-08 14:00:02 -04:00
|
|
|
frame->set_y0 (0.0);
|
|
|
|
frame->set_y1 (height);
|
2014-08-31 17:36:38 -04:00
|
|
|
|
2019-04-08 14:25:05 -04:00
|
|
|
if (frame_handle_start) {
|
|
|
|
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
|
|
|
|
2019-04-08 14:00:02 -04:00
|
|
|
if (selection_frame) {
|
|
|
|
selection_frame->set (frame->get().shrink (1.0));
|
2014-11-05 19:45:17 -05:00
|
|
|
}
|
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));
|
2015-10-05 10:17:49 -04:00
|
|
|
|
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*
|
2019-04-08 15:40:33 -04:00
|
|
|
TimeAxisViewItem::get_canvas_frame()
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2019-04-08 14:00:02 -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()
|
|
|
|
{
|
2019-04-08 14:00:02 -04:00
|
|
|
set_frame_color ();
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
if (name_highlight) {
|
2017-07-01 12:42:24 -04: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;
|
|
|
|
}
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2013-06-26 17:40:10 -04:00
|
|
|
|
2014-06-05 12:00:24 -04:00
|
|
|
uint32_t f;
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2015-01-02 09:44:54 -05:00
|
|
|
if (UIConfiguration::instance().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
|
|
|
|
2017-07-17 12:34:35 -04:00
|
|
|
name_text->set_color (contrasting_text_color (f));
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2017-07-17 12:34:35 -04:00
|
|
|
Gtkmm2ext::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) {
|
2019-09-26 13:35:31 -04:00
|
|
|
return UIConfiguration::instance().color ("selected region base");
|
2015-01-08 19:59:40 -05:00
|
|
|
} else if (_recregion) {
|
2015-01-02 09:44:54 -05:00
|
|
|
return UIConfiguration::instance().color ("recording rect");
|
|
|
|
} else if ((!UIConfiguration::instance().get_show_name_highlight() || high_enough_for_name) &&
|
|
|
|
!UIConfiguration::instance().get_color_regions_using_track_color()) {
|
|
|
|
return UIConfiguration::instance().color_mod (fill_color_name, mod_name);
|
2013-06-24 16:28:53 -04:00
|
|
|
}
|
2015-01-02 09:44:54 -05:00
|
|
|
return UIConfiguration::instance().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
|
|
|
/**
|
2019-04-08 14:00:02 -04:00
|
|
|
* Sets the frame color depending on whether this item is selected
|
2013-06-24 16:28:53 -04:00
|
|
|
*/
|
|
|
|
void
|
2019-04-08 14:00:02 -04:00
|
|
|
TimeAxisViewItem::set_frame_color()
|
2013-06-24 16:28:53 -04:00
|
|
|
{
|
2019-04-08 14:00:02 -04:00
|
|
|
if (!frame) {
|
2013-06-24 16:28:53 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-04-08 14:00:02 -04:00
|
|
|
frame->set_fill_color (get_fill_color());
|
|
|
|
set_frame_gradient ();
|
2011-03-03 13:32:06 -05:00
|
|
|
|
2014-11-13 23:33:11 -05:00
|
|
|
if (!_recregion) {
|
2019-04-08 14:00:02 -04:00
|
|
|
frame->set_outline_color (UIConfiguration::instance().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
|
2019-04-08 14:00:02 -04:00
|
|
|
TimeAxisViewItem::set_frame_gradient ()
|
2013-04-16 23:46:22 -04:00
|
|
|
{
|
2015-01-02 09:44:54 -05:00
|
|
|
if (UIConfiguration::instance().get_timeline_item_gradient_depth() == 0.0) {
|
2019-04-08 14:00:02 -04:00
|
|
|
frame->set_gradient (ArdourCanvas::Fill::StopList (), 0);
|
2013-04-16 23:46:22 -04:00
|
|
|
return;
|
|
|
|
}
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2013-04-16 23:46:22 -04:00
|
|
|
ArdourCanvas::Fill::StopList stops;
|
|
|
|
double r, g, b, a;
|
|
|
|
double h, s, v;
|
2017-07-17 12:34:35 -04:00
|
|
|
Color f (get_fill_color());
|
2013-04-16 23:46:22 -04:00
|
|
|
|
|
|
|
/* need to get alpha value */
|
2017-07-17 12:34:35 -04:00
|
|
|
color_to_rgba (f, r, g, b, a);
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2013-04-16 23:46:22 -04:00
|
|
|
stops.push_back (std::make_pair (0.0, f));
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2013-04-16 23:46:22 -04:00
|
|
|
/* now a darker version */
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2017-07-17 12:34:35 -04:00
|
|
|
color_to_hsv (f, h, s, v);
|
2013-06-24 16:28:53 -04:00
|
|
|
|
2015-01-02 09:44:54 -05:00
|
|
|
v = min (1.0, v * (1.0 - UIConfiguration::instance().get_timeline_item_gradient_depth()));
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2017-07-17 12:34:35 -04:00
|
|
|
Color darker = hsva_to_color (h, s, v, a);
|
2013-04-16 23:46:22 -04:00
|
|
|
stops.push_back (std::make_pair (1.0, darker));
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2019-04-08 14:00:02 -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 */
|
2019-04-08 14:25:05 -04:00
|
|
|
if (frame_handle_start) {
|
|
|
|
frame_handle_start->set_fill_color (0x00000000);
|
|
|
|
frame_handle_end->set_fill_color (0x00000000);
|
2014-04-14 04:46:24 -04:00
|
|
|
}
|
|
|
|
#else
|
2019-04-08 14:25:05 -04:00
|
|
|
if (frame_handle_start) {
|
2005-09-25 14:42:24 -04:00
|
|
|
if (position_locked) {
|
2019-04-08 14:25:05 -04:00
|
|
|
frame_handle_start->set_fill_color (UIConfiguration::instance().get_TrimHandleLocked());
|
|
|
|
frame_handle_end->set_fill_color (UIConfiguration::instance().get_TrimHandleLocked());
|
2005-09-25 14:42:24 -04:00
|
|
|
} else {
|
2019-04-08 14:25:05 -04:00
|
|
|
frame_handle_start->set_fill_color (UIConfiguration::instance().get_TrimHandle());
|
|
|
|
frame_handle_end->set_fill_color (UIConfiguration::instance().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
|
2019-04-08 15:40:33 -04:00
|
|
|
TimeAxisViewItem::frame_handle_crossing (GdkEvent* ev, ArdourCanvas::Rectangle* item)
|
2013-04-24 15:42:14 -04:00
|
|
|
{
|
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;
|
|
|
|
}
|
|
|
|
|
2017-09-18 12:39:17 -04:00
|
|
|
/** @return the samples 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
|
|
|
}
|
|
|
|
|
2017-09-18 12:39:17 -04:00
|
|
|
/** Set the samples per pixel of this item.
|
2013-04-04 00:32:52 -04:00
|
|
|
* 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
|
|
|
*
|
2017-09-18 12:39:17 -04:00
|
|
|
* @param fpp the new samples 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
|
|
|
|
2020-10-19 14:37:54 -04:00
|
|
|
double end_pixel = trackview.editor().time_to_pixel (time_position + get_duration());
|
2020-10-15 21:07:15 -04:00
|
|
|
double first_pixel = trackview.editor().time_to_pixel (time_position);
|
2015-02-11 21:35:23 -05:00
|
|
|
|
|
|
|
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
|
|
|
|
2019-04-08 14:00:02 -04:00
|
|
|
if (frame) {
|
|
|
|
frame->set_outline (false);
|
|
|
|
frame->set_x1 (std::max(1.0, pixel_width));
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2019-04-08 14:25:05 -04:00
|
|
|
if (frame_handle_start) {
|
|
|
|
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 {
|
2019-04-08 14:00:02 -04:00
|
|
|
if (frame) {
|
|
|
|
frame->set_outline (true);
|
2015-02-11 21:35:23 -05:00
|
|
|
/* Note: x0 is always zero - the position is defined by
|
2019-04-08 14:00:02 -04:00
|
|
|
* the position of the group, not the frame.
|
2015-02-11 21:35:23 -05:00
|
|
|
*/
|
2019-04-08 14:00:02 -04:00
|
|
|
frame->set_x1 (pixel_width);
|
2014-11-05 19:45:17 -05:00
|
|
|
|
2019-04-08 14:00:02 -04:00
|
|
|
if (selection_frame) {
|
|
|
|
selection_frame->set (frame->get().shrink (1.0));
|
2014-11-05 19:45:17 -05:00
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2019-04-08 14:25:05 -04:00
|
|
|
if (frame_handle_start) {
|
2012-04-30 19:00:15 -04:00
|
|
|
if (pixel_width < (3 * TimeAxisViewItem::GRAB_HANDLE_WIDTH)) {
|
|
|
|
/*
|
2015-10-04 14:51:05 -04:00
|
|
|
* there's less than GRAB_HANDLE_WIDTH of the region between
|
2019-04-08 14:25:05 -04:00
|
|
|
* the right-hand end of frame_handle_start and the left-hand
|
|
|
|
* end of frame_handle_end, so disable the handles
|
2012-04-30 19:00:15 -04:00
|
|
|
*/
|
2013-04-24 15:42:14 -04:00
|
|
|
|
2019-04-08 14:25:05 -04:00
|
|
|
frame_handle_start->hide();
|
|
|
|
frame_handle_end->hide();
|
2012-04-30 19:00:15 -04:00
|
|
|
} else {
|
2019-04-08 14:25:05 -04:00
|
|
|
frame_handle_start->show();
|
|
|
|
frame_handle_end->set_x0 (pixel_width - (TimeAxisViewItem::GRAB_HANDLE_WIDTH));
|
|
|
|
frame_handle_end->set_x1 (pixel_width);
|
|
|
|
frame_handle_end->show();
|
2016-08-17 23:09:33 -04:00
|
|
|
|
2019-04-08 14:25:05 -04:00
|
|
|
frame_handle_start->raise_to_top ();
|
|
|
|
frame_handle_end->raise_to_top ();
|
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;
|
|
|
|
}
|
|
|
|
|
2019-05-29 17:16:00 -04:00
|
|
|
if (!(visibility & ShowNameText) || (!wide_enough_for_name || !high_enough_for_name)) {
|
2013-12-29 23:10:54 -05:00
|
|
|
name_text->hide ();
|
2009-11-12 15:39:53 -05:00
|
|
|
return;
|
|
|
|
}
|
2015-10-05 10:17:49 -04:00
|
|
|
|
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") {
|
2019-04-08 14:00:02 -04:00
|
|
|
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;
|
2019-04-08 14:00:02 -04:00
|
|
|
set_frame_color ();
|
2014-06-13 10:56:46 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
TimeAxisViewItem::drag_end ()
|
|
|
|
{
|
|
|
|
_dragging = false;
|
2019-04-08 14:00:02 -04:00
|
|
|
set_frame_color ();
|
2014-06-13 10:56:46 -04:00
|
|
|
}
|