2005-09-25 14:42:24 -04:00
|
|
|
/*
|
|
|
|
Copyright (C) 2003 Paul Davis
|
|
|
|
|
|
|
|
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.
|
|
|
|
|
|
|
|
$Id$
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __gtk_ardour_time_axis_view_item_h__
|
|
|
|
#define __gtk_ardour_time_axis_view_item_h__
|
|
|
|
|
2005-09-25 16:33:00 -04:00
|
|
|
#include <sigc++/signal.h>
|
2005-11-12 22:53:51 -05:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
#include <jack/jack.h>
|
|
|
|
#include <string>
|
|
|
|
|
2005-11-12 17:07:07 -05:00
|
|
|
#include <libgnomecanvasmm/text.h>
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
#include "selectable.h"
|
2005-11-12 17:07:07 -05:00
|
|
|
#include "simplerect.h"
|
2005-11-23 12:21:12 -05:00
|
|
|
#include "canvas.h"
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
class TimeAxisView;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A base class for 'items' that may appear upon a TimeAxisView
|
|
|
|
*
|
|
|
|
*/
|
2005-09-25 16:33:00 -04:00
|
|
|
class TimeAxisViewItem : public sigc::trackable, public Selectable
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual ~TimeAxisViewItem() ;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the position of this item upon the timeline to the specified value
|
|
|
|
*
|
|
|
|
* @param pos the new position
|
|
|
|
* @param src the identity of the object that initiated the change
|
2006-05-26 18:30:54 -04:00
|
|
|
* @param delta ignored
|
2005-09-25 14:42:24 -04:00
|
|
|
* @return true if the position change was a success, false otherwise
|
|
|
|
*/
|
|
|
|
virtual bool set_position(jack_nframes_t pos, void* src, double* delta = 0) ;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the position of this item upon the timeline
|
|
|
|
*
|
|
|
|
* @return the position of this item
|
|
|
|
*/
|
|
|
|
jack_nframes_t get_position() const ;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the duration of this item
|
|
|
|
*
|
|
|
|
* @param dur the new duration of this item
|
|
|
|
* @param src the identity of the object that initiated the change
|
|
|
|
* @return true if the duration change was succesful, false otherwise
|
|
|
|
*/
|
|
|
|
virtual bool set_duration(jack_nframes_t dur, void* src) ;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the duration of this item
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
jack_nframes_t get_duration() const ;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the maximum duration that this item make have.
|
|
|
|
*
|
|
|
|
* @param dur the new maximum duration
|
|
|
|
* @param src the identity of the object that initiated the change
|
|
|
|
*/
|
|
|
|
virtual void set_max_duration(jack_nframes_t dur, void* src) ;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the maxmimum duration that this item may be set to
|
|
|
|
*
|
|
|
|
* @return the maximum duration that this item may be set to
|
|
|
|
*/
|
|
|
|
jack_nframes_t get_max_duration() const ;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the minimu duration that this item may be set to
|
|
|
|
*
|
2006-05-26 18:30:54 -04:00
|
|
|
* @param dur the minimum duration that this item may be set to
|
2005-09-25 14:42:24 -04:00
|
|
|
* @param src the identity of the object that initiated the change
|
|
|
|
*/
|
|
|
|
virtual void set_min_duration(jack_nframes_t dur, void* src) ;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the minimum duration that this item mey be set to
|
|
|
|
*
|
|
|
|
* @return the nimum duration that this item mey be set to
|
|
|
|
*/
|
|
|
|
jack_nframes_t get_min_duration() const ;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets whether the position of this Item is locked to its current position
|
|
|
|
* Locked items cannot be moved until the item is unlocked again.
|
|
|
|
*
|
|
|
|
* @param yn set to true to lock this item to its current position
|
|
|
|
* @param src the identity of the object that initiated the change
|
|
|
|
*/
|
|
|
|
virtual void set_position_locked(bool yn, void* src) ;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns whether this item is locked to its current position
|
|
|
|
*
|
|
|
|
* @return true if this item is locked to its current posotion
|
|
|
|
* false otherwise
|
|
|
|
*/
|
|
|
|
bool get_position_locked() const ;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets whether the Maximum Duration constraint is active and should be enforced
|
|
|
|
*
|
|
|
|
* @param active set true to enforce the max duration constraint
|
|
|
|
* @param src the identity of the object that initiated the change
|
|
|
|
*/
|
|
|
|
void set_max_duration_active(bool active, void* src) ;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns whether the Maximum Duration constraint is active and should be enforced
|
|
|
|
*
|
|
|
|
* @return true if the maximum duration constraint is active, false otherwise
|
|
|
|
*/
|
|
|
|
bool get_max_duration_active() const ;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets whether the Minimum Duration constraint is active and should be enforced
|
|
|
|
*
|
|
|
|
* @param active set true to enforce the min duration constraint
|
|
|
|
* @param src the identity of the object that initiated the change
|
|
|
|
*/
|
|
|
|
void set_min_duration_active(bool active, void* src) ;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns whether the Maximum Duration constraint is active and should be enforced
|
|
|
|
*
|
|
|
|
* @return true if the maximum duration constraint is active, false otherwise
|
|
|
|
*/
|
|
|
|
bool get_min_duration_active() const ;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the name/Id of this item.
|
|
|
|
*
|
|
|
|
* @param new_name the new name of this item
|
|
|
|
* @param src the identity of the object that initiated the change
|
|
|
|
*/
|
|
|
|
void set_item_name(std::string new_name, void* src) ;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the name/id of this item
|
|
|
|
*
|
|
|
|
* @return the name/id of this item
|
|
|
|
*/
|
|
|
|
virtual std::string get_item_name() const ;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set to true to indicate that this item is currently selected
|
|
|
|
*
|
|
|
|
* @param yn true if this item is currently selected
|
|
|
|
* @param src the identity of the object that initiated the change
|
|
|
|
*/
|
|
|
|
virtual void set_selected(bool yn, void* src) ;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set to true to indicate that this item should show its selection status
|
|
|
|
*
|
|
|
|
* @param yn true if this item should show its selected status
|
|
|
|
*/
|
|
|
|
virtual void set_should_show_selection (bool yn) ;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns whether this item is currently selected.
|
|
|
|
*
|
|
|
|
* @return true if this item is currently selected, false otherwise
|
|
|
|
*/
|
|
|
|
bool get_selected() const ;
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------//
|
|
|
|
// Parent Component Methods
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the TimeAxisView that this item is upon
|
|
|
|
*
|
|
|
|
* @return the timeAxisView that this item is placed upon
|
|
|
|
*/
|
|
|
|
TimeAxisView& get_time_axis_view() ;
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------//
|
|
|
|
// ui methods & data
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets 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
|
|
|
|
*
|
|
|
|
* @param new_name the new name text to display
|
|
|
|
*/
|
|
|
|
void set_name_text(std::string new_name) ;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the height of this item
|
|
|
|
*
|
|
|
|
* @param h the new height
|
|
|
|
*/
|
|
|
|
virtual void set_height(double h) ;
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
2005-10-05 09:48:09 -04:00
|
|
|
void set_color(Gdk::Color& color) ;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
2005-11-23 12:21:12 -05:00
|
|
|
ArdourCanvas::Item* get_canvas_frame() ;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
2005-11-23 12:21:12 -05:00
|
|
|
ArdourCanvas::Item* get_canvas_group();
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
2005-11-23 12:21:12 -05:00
|
|
|
ArdourCanvas::Item* get_name_highlight();
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
2005-11-23 12:21:12 -05:00
|
|
|
ArdourCanvas::Text* get_name_text();
|
2005-11-12 22:53:51 -05:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the samples per unit of this item.
|
|
|
|
* this item is used to determine the relative visual size and position of this item
|
|
|
|
* based upon its duration and start value.
|
|
|
|
*
|
|
|
|
* @param spu the new samples per unit value
|
|
|
|
*/
|
|
|
|
virtual void set_samples_per_unit(double spu) ;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the current samples per unit of this item
|
|
|
|
*
|
|
|
|
* @return the samples per unit of this item
|
|
|
|
*/
|
|
|
|
double get_samples_per_unit() ;
|
|
|
|
|
|
|
|
virtual void raise () { return; }
|
|
|
|
virtual void raise_to_top () { return; }
|
|
|
|
virtual void lower () { return; }
|
|
|
|
virtual void lower_to_bottom () { return; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* returns true if the name area should respond to events.
|
|
|
|
*/
|
|
|
|
bool name_active() const { return name_connected; }
|
|
|
|
|
|
|
|
// Default sizes, font and spacing
|
2005-10-09 08:51:04 -04:00
|
|
|
static Pango::FontDescription NAME_FONT ;
|
|
|
|
static bool have_name_font;
|
2005-09-25 14:42:24 -04:00
|
|
|
static const double NAME_X_OFFSET ;
|
|
|
|
static const double GRAB_HANDLE_LENGTH ;
|
2006-04-27 05:04:24 -04:00
|
|
|
/* these are not constant, but vary with the pixel size
|
|
|
|
of the font used to display the item name.
|
|
|
|
*/
|
|
|
|
static double NAME_Y_OFFSET ;
|
|
|
|
static double NAME_HIGHLIGHT_SIZE ;
|
|
|
|
static double NAME_HIGHLIGHT_THRESH ;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Handles the Removal of this time axis item
|
|
|
|
* This _needs_ to be called to alert others of the removal properly, ie where the source
|
|
|
|
* of the removal came from.
|
|
|
|
*
|
|
|
|
* XXX Although im not too happy about this method of doing things, I cant think of a cleaner method
|
|
|
|
* just now to capture the source of the removal
|
|
|
|
*
|
|
|
|
* @param src the identity of the object that initiated the change
|
|
|
|
*/
|
|
|
|
virtual void remove_this_item(void* src) ;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Emitted when this Group has been removed
|
|
|
|
* This is different to the GoingAway signal in that this signal
|
|
|
|
* is emitted during the deletion of this Time Axis, and not during
|
|
|
|
* the destructor, this allows us to capture the source of the deletion
|
|
|
|
* event
|
|
|
|
*/
|
2005-09-25 16:33:00 -04:00
|
|
|
sigc::signal<void,std::string,void*> ItemRemoved ;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
/** Emitted when the name/Id of this item is changed */
|
2005-09-25 16:33:00 -04:00
|
|
|
sigc::signal<void,std::string,std::string,void*> NameChanged ;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
/** Emiited when the position of this item changes */
|
2005-09-25 16:33:00 -04:00
|
|
|
sigc::signal<void,jack_nframes_t,void*> PositionChanged ;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
/** Emitted when the position lock of this item is changed */
|
2005-09-25 16:33:00 -04:00
|
|
|
sigc::signal<void,bool,void*> PositionLockChanged ;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
/** Emitted when the duration of this item changes */
|
2005-09-25 16:33:00 -04:00
|
|
|
sigc::signal<void,jack_nframes_t,void*> DurationChanged ;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
/** Emitted when the maximum item duration is changed */
|
2005-09-25 16:33:00 -04:00
|
|
|
sigc::signal<void,jack_nframes_t,void*> MaxDurationChanged ;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
/** Emitted when the mionimum item duration is changed */
|
2005-09-25 16:33:00 -04:00
|
|
|
sigc::signal<void,jack_nframes_t,void*> MinDurationChanged ;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
/** Emitted when the selected status of this item changes */
|
2005-09-25 16:33:00 -04:00
|
|
|
sigc::signal<void, bool> Selected ;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
enum Visibility {
|
|
|
|
ShowFrame = 0x1,
|
|
|
|
ShowNameHighlight = 0x2,
|
|
|
|
ShowNameText = 0x4,
|
2006-02-10 21:34:03 -05:00
|
|
|
ShowHandles = 0x8,
|
|
|
|
HideFrameLR = 0x10,
|
|
|
|
HideFrameTB = 0x20,
|
|
|
|
FullWidthNameHighlight = 0x40
|
2005-09-25 14:42:24 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Constructs a new TimeAxisViewItem.
|
|
|
|
*
|
|
|
|
* @param it_name the unique name/Id of this item
|
|
|
|
* @param parent the parent canvas group
|
|
|
|
* @param tv the TimeAxisView we are going to be added to
|
|
|
|
* @param spu samples per unit
|
2006-05-26 18:30:54 -04:00
|
|
|
* @param base_color base color
|
2005-09-25 14:42:24 -04:00
|
|
|
* @param start the start point of this item
|
|
|
|
* @param duration the duration of this item
|
2006-05-26 18:30:54 -04:00
|
|
|
* @param v visibility
|
2005-09-25 14:42:24 -04:00
|
|
|
*/
|
2006-05-26 18:30:54 -04:00
|
|
|
TimeAxisViewItem(const std::string & it_name, ArdourCanvas::Group& parent, TimeAxisView& tv, double spu,
|
|
|
|
Gdk::Color& base_color, jack_nframes_t start, jack_nframes_t duration, Visibility v = Visibility (0));
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Calculates some contrasting color for displaying various parts of this item, based upon the base color
|
|
|
|
*
|
|
|
|
* @param color the base color of the item
|
|
|
|
*/
|
2005-10-09 01:03:29 -04:00
|
|
|
virtual void compute_colors(Gdk::Color& color) ;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* convenience method to set the various canvas item colors
|
|
|
|
*/
|
|
|
|
virtual void set_colors() ;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the frame color depending on whether this item is selected
|
|
|
|
*/
|
|
|
|
void set_frame_color() ;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the colors of the start and end trim handle depending on object state
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
void set_trim_handle_colors() ;
|
|
|
|
|
|
|
|
virtual void reset_width_dependent_items (double pixel_width);
|
|
|
|
void reset_name_width (double pixel_width);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Callback used to remove this item during the gtk idle loop
|
|
|
|
* This is used to avoid deleting the obejct while inside the remove_this_group
|
|
|
|
* method
|
|
|
|
*
|
|
|
|
* @param item the time axis item to remove
|
|
|
|
* @param src the identity of the object that initiated the change
|
|
|
|
*/
|
|
|
|
static gint idle_remove_this_item(TimeAxisViewItem* item, void* src) ;
|
|
|
|
|
|
|
|
/** The time axis that this item is upon */
|
|
|
|
TimeAxisView& trackview ;
|
|
|
|
|
|
|
|
/** indicates whether this item is locked to its current position */
|
|
|
|
bool position_locked ;
|
|
|
|
|
|
|
|
/** The posotion of this item on the timeline */
|
|
|
|
jack_nframes_t frame_position ;
|
|
|
|
|
|
|
|
/** the duration of this item upon the timeline */
|
|
|
|
jack_nframes_t item_duration ;
|
|
|
|
|
|
|
|
/** the maximum duration that we allow this item to take */
|
|
|
|
jack_nframes_t max_item_duration ;
|
|
|
|
|
|
|
|
/** the minimu duration that we allow this item to take */
|
|
|
|
jack_nframes_t min_item_duration ;
|
|
|
|
|
|
|
|
/** indicates whether this Max Duration constraint is active */
|
|
|
|
bool max_duration_active ;
|
|
|
|
|
|
|
|
/** indicates whether this Min Duration constraint is active */
|
|
|
|
bool min_duration_active ;
|
|
|
|
|
|
|
|
/** the curretn samples per canvas unit */
|
|
|
|
double samples_per_unit ;
|
|
|
|
|
|
|
|
/** indicates if this item is currently selected */
|
|
|
|
bool selected ;
|
|
|
|
|
|
|
|
/** should the item show its selected status */
|
|
|
|
bool should_show_selection;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The unique item name of this Item
|
|
|
|
* Each item upon a time axis must have a unique id
|
|
|
|
*/
|
|
|
|
std::string item_name ;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* true if the name should respond to events
|
|
|
|
*/
|
|
|
|
bool name_connected;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* true if a small vestigial rect should be shown when the item gets very narrow
|
|
|
|
*/
|
|
|
|
|
|
|
|
bool show_vestigial;
|
|
|
|
|
|
|
|
uint32_t fill_opacity;
|
|
|
|
uint32_t fill_color ;
|
|
|
|
uint32_t frame_color_r ;
|
|
|
|
uint32_t frame_color_g ;
|
|
|
|
uint32_t frame_color_b ;
|
|
|
|
uint32_t selected_frame_color_r ;
|
|
|
|
uint32_t selected_frame_color_g ;
|
|
|
|
uint32_t selected_frame_color_b ;
|
|
|
|
uint32_t label_color ;
|
|
|
|
|
|
|
|
uint32_t handle_color_r ;
|
|
|
|
uint32_t handle_color_g ;
|
|
|
|
uint32_t handle_color_b ;
|
|
|
|
uint32_t lock_handle_color_r ;
|
|
|
|
uint32_t lock_handle_color_g ;
|
|
|
|
uint32_t lock_handle_color_b ;
|
|
|
|
|
2005-11-23 12:21:12 -05:00
|
|
|
ArdourCanvas::Group* group;
|
|
|
|
ArdourCanvas::SimpleRect* vestigial_frame;
|
|
|
|
ArdourCanvas::SimpleRect* frame;
|
|
|
|
ArdourCanvas::Text* name_text;
|
|
|
|
ArdourCanvas::SimpleRect* name_highlight;
|
|
|
|
ArdourCanvas::SimpleRect* frame_handle_start;
|
|
|
|
ArdourCanvas::SimpleRect* frame_handle_end;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2006-02-10 21:34:03 -05:00
|
|
|
Visibility visibility;
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
}; /* class TimeAxisViewItem */
|
|
|
|
|
|
|
|
#endif /* __gtk_ardour_time_axis_view_item_h__ */
|