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.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <algorithm>
|
|
|
|
|
2005-09-25 16:33:00 -04:00
|
|
|
#include <gtkmm.h>
|
|
|
|
#include <gtkmm2ext/gtk_ui.h>
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
#include "marker_time_axis_view.h"
|
|
|
|
#include "marker_time_axis.h"
|
|
|
|
#include "marker_view.h"
|
|
|
|
#include "imageframe_view.h"
|
|
|
|
#include "imageframe_time_axis.h"
|
|
|
|
#include "canvas-simplerect.h"
|
|
|
|
#include "public_editor.h"
|
|
|
|
#include "rgb_macros.h"
|
|
|
|
#include "gui_thread.h"
|
2007-06-29 13:13:09 -04:00
|
|
|
#include "ardour_ui.h"
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
#include "i18n.h"
|
|
|
|
|
|
|
|
using namespace ARDOUR ;
|
|
|
|
using namespace Editing;
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------//
|
|
|
|
// Constructor / Desctructor
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
/**
|
|
|
|
* Construct a new MarkerTimeAxisView helper time axis helper
|
|
|
|
*
|
|
|
|
* @param mta the TimeAxsiView that this objbect is the helper for
|
|
|
|
*/
|
|
|
|
MarkerTimeAxisView::MarkerTimeAxisView(MarkerTimeAxis& tv)
|
|
|
|
: _trackview (tv)
|
|
|
|
{
|
|
|
|
region_color = _trackview.color();
|
2007-06-29 13:13:09 -04:00
|
|
|
stream_base_color = ARDOUR_UI::config()->canvasvar_MarkerTrack.get();
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2005-11-23 12:21:12 -05:00
|
|
|
canvas_group = new ArdourCanvas::Group (*_trackview.canvas_display);
|
2005-11-12 22:53:51 -05:00
|
|
|
|
2005-11-23 12:21:12 -05:00
|
|
|
canvas_rect = new ArdourCanvas::SimpleRect (*canvas_group);
|
2005-11-27 17:35:04 -05:00
|
|
|
canvas_rect->property_x1() = 0.0;
|
|
|
|
canvas_rect->property_y1() = 0.0;
|
2006-11-16 13:42:48 -05:00
|
|
|
canvas_rect->property_x2() = max_frames;
|
2005-11-27 17:35:04 -05:00
|
|
|
canvas_rect->property_y2() = (double)20;
|
2007-06-29 13:13:09 -04:00
|
|
|
canvas_rect->property_outline_color_rgba() = ARDOUR_UI::config()->canvasvar_MarkerTrack.get();
|
2005-11-27 17:35:04 -05:00
|
|
|
canvas_rect->property_fill_color_rgba() = stream_base_color;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-12-11 18:29:48 -05:00
|
|
|
canvas_rect->signal_event().connect (sigc::bind (sigc::mem_fun (_trackview.editor, &PublicEditor::canvas_marker_time_axis_view_event), canvas_rect, &_trackview));
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
_samples_per_unit = _trackview.editor.get_current_zoom() ;
|
|
|
|
|
2009-12-11 18:29:48 -05:00
|
|
|
_trackview.editor.ZoomChanged.connect (sigc::mem_fun(*this, &MarkerTimeAxisView::reset_samples_per_unit));
|
2009-12-25 16:06:52 -05:00
|
|
|
MarkerView::CatchDeletion.connect (*this, ui_bind (&MarkerTimeAxisView::remove_marker_view, this, _1), gui_context());
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Destructor
|
|
|
|
* Reposinsibly for destroying all marker items that may have been added to this time axis view
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
MarkerTimeAxisView::~MarkerTimeAxisView()
|
|
|
|
{
|
|
|
|
// destroy everything upon this view
|
|
|
|
for(MarkerViewList::iterator iter = marker_view_list.begin(); iter != marker_view_list.end(); ++iter)
|
|
|
|
{
|
|
|
|
MarkerView* mv = (*iter) ;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
MarkerViewList::iterator next = iter ;
|
|
|
|
next++ ;
|
|
|
|
marker_view_list.erase(iter) ;
|
|
|
|
|
|
|
|
delete mv ;
|
|
|
|
mv = 0 ;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
iter = next ;
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-12-18 14:31:00 -05:00
|
|
|
delete canvas_rect;
|
|
|
|
canvas_rect = 0 ;
|
|
|
|
|
|
|
|
delete canvas_group;
|
|
|
|
canvas_group = 0 ;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------//
|
|
|
|
// ui methods & data
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the height of the time axis view and the item upon it
|
|
|
|
*
|
|
|
|
* @param height the new height
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
MarkerTimeAxisView::set_height(gdouble h)
|
|
|
|
{
|
2007-05-17 06:41:14 -04:00
|
|
|
if (h < 10.0 || h > 1000.0) {
|
|
|
|
return -1;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-11-28 17:36:26 -05:00
|
|
|
canvas_rect->property_y2() = h;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2007-05-17 06:41:14 -04:00
|
|
|
for (MarkerViewList::iterator i = marker_view_list.begin(); i != marker_view_list.end(); ++i) {
|
|
|
|
(*i)->set_y_position_and_height(0, h);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the position of this view helper on the canvas
|
|
|
|
*
|
|
|
|
* @param x the x position upon the canvas
|
|
|
|
* @param y the y position upon the canvas
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
MarkerTimeAxisView::set_position(gdouble x, gdouble y)
|
|
|
|
{
|
2005-11-27 17:35:04 -05:00
|
|
|
canvas_group->property_x() = x;
|
|
|
|
canvas_group->property_y() = y;
|
2005-09-25 14:42:24 -04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the current samples per unit.
|
|
|
|
* this method tells each item upon the time axis of the change
|
2009-10-14 12:10:01 -04:00
|
|
|
*
|
2005-09-25 14:42:24 -04:00
|
|
|
* @param spu the new samples per canvas unit value
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
MarkerTimeAxisView::set_samples_per_unit(gdouble spp)
|
|
|
|
{
|
|
|
|
if(spp < 1.0) {
|
|
|
|
return -1 ;
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
_samples_per_unit = spp ;
|
|
|
|
|
|
|
|
for(MarkerViewList::iterator i = marker_view_list.begin(); i != marker_view_list.end(); ++i)
|
|
|
|
{
|
|
|
|
(*i)->set_samples_per_unit(spp) ;
|
|
|
|
}
|
|
|
|
return(0) ;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the color of the items contained upon this view helper
|
|
|
|
*
|
|
|
|
* @param color the new base color
|
|
|
|
*/
|
|
|
|
void
|
2005-10-05 09:48:09 -04:00
|
|
|
MarkerTimeAxisView::apply_color(Gdk::Color& color)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
region_color = color;
|
|
|
|
|
|
|
|
for (MarkerViewList::iterator i = marker_view_list.begin(); i != marker_view_list.end(); i++)
|
|
|
|
{
|
|
|
|
(*i)->set_color (region_color) ;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------//
|
|
|
|
// Child MarkerView Accessors/Mutators
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
/**
|
|
|
|
* Adds a marker view to the list of items upon this time axis view helper
|
|
|
|
* the new MarkerView is returned
|
|
|
|
*
|
|
|
|
* @param ifv the ImageFrameView that the new item is marking up
|
|
|
|
* @param mark_text the text to be displayed uopn the new marker item
|
|
|
|
* @param mark_id the unique id of the new item
|
|
|
|
* @param start the position the new item should be placed upon the time line
|
|
|
|
* @param duration the duration the new item should be placed upon the timeline
|
|
|
|
* @param src the identity of the object that initiated the change
|
2009-10-14 12:10:01 -04:00
|
|
|
*/
|
2005-09-25 14:42:24 -04:00
|
|
|
MarkerView*
|
2006-09-28 13:23:52 -04:00
|
|
|
MarkerTimeAxisView::add_marker_view(ImageFrameView* ifv, std::string mark_type, std::string mark_id, nframes_t start, nframes_t dur, void* src)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
if(ifv->has_marker_view_item(mark_id))
|
|
|
|
{
|
|
|
|
return(0) ;
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-11-12 22:53:51 -05:00
|
|
|
MarkerView* mv = new MarkerView(canvas_group,
|
2005-09-25 14:42:24 -04:00
|
|
|
&_trackview,
|
|
|
|
ifv,
|
|
|
|
_trackview.editor.get_current_zoom(),
|
|
|
|
region_color,
|
|
|
|
mark_type,
|
|
|
|
mark_id,
|
|
|
|
start,
|
|
|
|
dur) ;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
ifv->add_marker_view_item(mv, src) ;
|
|
|
|
marker_view_list.push_front(mv) ;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-12-22 15:21:43 -05:00
|
|
|
MarkerViewAdded(mv,src) ; /* EMIT_SIGNAL */
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
return(mv) ;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the named MarkerView or 0 if the named marker does not exist
|
|
|
|
*
|
|
|
|
* @param item_id the unique id of the item to search for
|
|
|
|
* @return the named MarkerView, or 0 if it is not held upon this view
|
|
|
|
*/
|
|
|
|
MarkerView*
|
|
|
|
MarkerTimeAxisView::get_named_marker_view(std::string item_id)
|
|
|
|
{
|
|
|
|
MarkerView* mv = 0 ;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
for(MarkerViewList::iterator i = marker_view_list.begin(); i != marker_view_list.end(); ++i)
|
|
|
|
{
|
|
|
|
if(((MarkerView*)*i)->get_item_name() == item_id)
|
|
|
|
{
|
|
|
|
mv = ((MarkerView*)*i) ;
|
|
|
|
break ;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return(mv) ;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Removes the currently selected MarverView
|
|
|
|
* Note that this method actually destroys the MarkerView too.
|
|
|
|
* We assume that since we own the object, we are allowed to do this
|
|
|
|
*
|
|
|
|
* @param src the identity of the object that initiated the change
|
|
|
|
* @see add_marker_view
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
MarkerTimeAxisView::remove_selected_marker_view(void* src)
|
|
|
|
{
|
|
|
|
std::string removed ;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
if (selected_time_axis_item)
|
|
|
|
{
|
|
|
|
MarkerViewList::iterator i ;
|
|
|
|
if((i = find (marker_view_list.begin(), marker_view_list.end(), selected_time_axis_item)) != marker_view_list.end())
|
|
|
|
{
|
|
|
|
marker_view_list.erase(i) ;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
MarkerViewRemoved(selected_time_axis_item->get_item_name(),src) ; /* EMIT_SIGNAL */
|
|
|
|
|
|
|
|
delete(selected_time_axis_item) ;
|
|
|
|
selected_time_axis_item = 0 ;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
//No selected marker view
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Removes and returns the named MarkerView from the list of MarkerView held by this view helper
|
|
|
|
*
|
|
|
|
* @param item_id the MarkerView unique id to remove
|
|
|
|
* @param src the identity of the object that initiated the change
|
|
|
|
* @see add_marker_view
|
|
|
|
*/
|
|
|
|
MarkerView*
|
|
|
|
MarkerTimeAxisView::remove_named_marker_view(std::string item_id, void* src)
|
|
|
|
{
|
|
|
|
MarkerView* mv = 0 ;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
MarkerViewList::iterator i = marker_view_list.begin() ;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
for(MarkerViewList::iterator iter = marker_view_list.begin(); iter != marker_view_list.end(); ++iter)
|
|
|
|
{
|
|
|
|
if(((MarkerView*)*i)->get_item_name() == item_id)
|
|
|
|
{
|
|
|
|
mv = ((MarkerView*)*i) ;
|
|
|
|
marker_view_list.erase(i) ;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
MarkerViewRemoved(mv->get_item_name(), src) ; /* EMIT_SIGNAL */
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
// break from the for loop
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
i++ ;
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
return(mv) ;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Removes mv from the list of MarkerView upon this TimeAxis
|
|
|
|
*
|
|
|
|
* @param mv the MarkerView to remove
|
|
|
|
* @param src the identity of the object that initiated the change
|
|
|
|
*/
|
|
|
|
void
|
2009-12-25 16:06:52 -05:00
|
|
|
MarkerTimeAxisView::remove_marker_view (MarkerView* mv)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2009-12-11 18:29:48 -05:00
|
|
|
ENSURE_GUI_THREAD (*this, &MarkerTimeAxisView::remove_marker_view, mv, src)
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
MarkerViewList::iterator i;
|
|
|
|
|
|
|
|
if((i = find (marker_view_list.begin(), marker_view_list.end(), mv)) != marker_view_list.end()) {
|
|
|
|
marker_view_list.erase(i) ;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
// Assume this remove happened locally, else use remove_named_marker_time_axis
|
|
|
|
// let listeners know that the named MarkerTimeAxis has been removed
|
|
|
|
MarkerViewRemoved(mv->get_item_name(), src) ; /* EMIT_SIGNAL */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the duration of the selected MarkerView to the specified number of seconds
|
|
|
|
*
|
|
|
|
* @param sec the duration to set the MArkerView to, in seconds
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
MarkerTimeAxisView::set_marker_duration_sec(double sec)
|
|
|
|
{
|
|
|
|
if(get_selected_time_axis_item() != 0)
|
|
|
|
{
|
2009-12-17 13:24:23 -05:00
|
|
|
get_selected_time_axis_item()->set_duration((nframes_t) (sec * _trackview.editor.session()->frame_rate()), this) ;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------//
|
|
|
|
// Selected item methods
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the currently selected item upon this time axis
|
|
|
|
*
|
|
|
|
* @param mv the item to set selected
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
MarkerTimeAxisView::set_selected_time_axis_item(MarkerView* mv)
|
|
|
|
{
|
|
|
|
selected_time_axis_item = mv ;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Clears any selected item upon this time axis
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
MarkerTimeAxisView::clear_selected_time_axis_item()
|
|
|
|
{
|
|
|
|
selected_time_axis_item = 0 ;
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
/**
|
|
|
|
* Returnsthe currently selected item upon this time axis
|
|
|
|
*
|
|
|
|
* @return the currently selected item pon this time axis
|
|
|
|
*/
|
|
|
|
MarkerView*
|
|
|
|
MarkerTimeAxisView::get_selected_time_axis_item()
|
|
|
|
{
|
|
|
|
return(selected_time_axis_item) ;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* convenience method to re-get the samples per unit and tell items upon this view
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
MarkerTimeAxisView::reset_samples_per_unit ()
|
|
|
|
{
|
|
|
|
set_samples_per_unit(_trackview.editor.get_current_zoom()) ;
|
|
|
|
}
|