X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;ds=sidebyside;f=gtk2_ardour%2Ftime_axis_view_item.h;h=ece4b0b21448bf108df1176a568c0f83c69f4e2c;hb=ccf58b8de23619db9983a45f696fd97e13a15cce;hp=c86564eb6217c1cca2b633fddfc68a71ca245cfc;hpb=1a3a77607768721f6834ddae09f532cdb6aec4a6;p=ardour.git diff --git a/gtk2_ardour/time_axis_view_item.h b/gtk2_ardour/time_axis_view_item.h index c86564eb62..ece4b0b214 100644 --- a/gtk2_ardour/time_axis_view_item.h +++ b/gtk2_ardour/time_axis_view_item.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2003 Paul Davis + 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 @@ -15,20 +15,19 @@ 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__ -#include #include #include -#include +#include #include "selectable.h" #include "simplerect.h" +#include "canvas.h" class TimeAxisView; @@ -36,11 +35,11 @@ class TimeAxisView; * A base class for 'items' that may appear upon a TimeAxisView * */ -class TimeAxisViewItem : public sigc::trackable, public Selectable +class TimeAxisViewItem : public Selectable { public: - virtual ~TimeAxisViewItem() ; - + virtual ~TimeAxisViewItem() ; + /** * Set the position of this item upon the timeline to the specified value * @@ -48,15 +47,15 @@ class TimeAxisViewItem : public sigc::trackable, public Selectable * @param src the identity of the object that initiated the change * @return true if the position change was a success, false otherwise */ - virtual bool set_position(jack_nframes_t pos, void* src, double* delta = 0) ; - + virtual bool set_position(nframes64_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 ; - + nframes64_t get_position() const ; + /** * Sets the duration of this item * @@ -64,44 +63,44 @@ class TimeAxisViewItem : public sigc::trackable, public Selectable * @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) ; - + virtual bool set_duration(nframes64_t dur, void* src) ; + /** * Returns the duration of this item * */ - jack_nframes_t get_duration() const ; - + nframes64_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) ; - + virtual void set_max_duration(nframes64_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 ; - + nframes64_t get_max_duration() const ; + /** * Sets the minimu duration that this item may be set to * * @param the minimum duration that this item may be set to * @param src the identity of the object that initiated the change */ - virtual void set_min_duration(jack_nframes_t dur, void* src) ; - + virtual void set_min_duration(nframes64_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 ; - + nframes64_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. @@ -110,7 +109,7 @@ class TimeAxisViewItem : public sigc::trackable, public Selectable * @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 * @@ -118,7 +117,7 @@ class TimeAxisViewItem : public sigc::trackable, public Selectable * false otherwise */ bool get_position_locked() const ; - + /** * Sets whether the Maximum Duration constraint is active and should be enforced * @@ -126,14 +125,14 @@ class TimeAxisViewItem : public sigc::trackable, public Selectable * @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 * @@ -141,14 +140,14 @@ class TimeAxisViewItem : public sigc::trackable, public Selectable * @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. * @@ -156,21 +155,20 @@ class TimeAxisViewItem : public sigc::trackable, public Selectable * @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) ; + virtual void set_selected(bool yn) ; /** * Set to true to indicate that this item should show its selection status @@ -178,66 +176,70 @@ class TimeAxisViewItem : public sigc::trackable, public Selectable * @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 ; - + + void set_sensitive (bool yn) { _sensitive = yn; } + bool sensitive () const { return _sensitive; } + //---------------------------------------------------------------------------------------// // 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) ; - + void set_name_text(const Glib::ustring& new_name) ; + /** * Set the height of this item * * @param h the new height */ virtual void set_height(double h) ; - + + void set_y (double); + /** - * + * */ - void set_color(Gdk::Color& color) ; - + void set_color (Gdk::Color const &); + /** - * + * */ - Gnome::Canvas::Item* get_canvas_frame() ; + ArdourCanvas::Item* get_canvas_frame() ; /** - * + * */ - Gnome::Canvas::Item* get_canvas_group(); + ArdourCanvas::Group* get_canvas_group(); /** - * + * */ - Gnome::Canvas::Item* get_name_highlight(); + ArdourCanvas::Item* get_name_highlight(); /** - * + * */ - Gnome::Canvas::Item* get_name_text(); + ArdourCanvas::Pixbuf* get_name_pixbuf(); + + + /** + * Returns the time axis that this item is upon + */ + TimeAxisView& get_trackview() const { return trackview; } /** * Sets the samples per unit of this item. @@ -247,7 +249,7 @@ class TimeAxisViewItem : public sigc::trackable, public Selectable * @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 * @@ -259,20 +261,24 @@ class TimeAxisViewItem : public sigc::trackable, public Selectable 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 - static Pango::FontDescription NAME_FONT ; + static Pango::FontDescription* NAME_FONT ; static bool have_name_font; static const double NAME_X_OFFSET ; - static const double NAME_Y_OFFSET ; - static const double NAME_HIGHLIGHT_SIZE ; - static const double NAME_HIGHLIGHT_THRESH ; static const double GRAB_HANDLE_LENGTH ; + /* these are not constant, but vary with the pixel size + of the font used to display the item name. + */ + static int NAME_HEIGHT; + static double NAME_Y_OFFSET ; + static double NAME_HIGHLIGHT_SIZE ; + static double NAME_HIGHLIGHT_THRESH ; /** * Handles the Removal of this time axis item @@ -285,7 +291,7 @@ class TimeAxisViewItem : public sigc::trackable, public Selectable * @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 @@ -293,39 +299,38 @@ class TimeAxisViewItem : public sigc::trackable, public Selectable * the destructor, this allows us to capture the source of the deletion * event */ + sigc::signal ItemRemoved ; - + /** Emitted when the name/Id of this item is changed */ sigc::signal NameChanged ; - + /** Emiited when the position of this item changes */ - sigc::signal PositionChanged ; - + sigc::signal PositionChanged ; + /** Emitted when the position lock of this item is changed */ sigc::signal PositionLockChanged ; - + /** Emitted when the duration of this item changes */ - sigc::signal DurationChanged ; - + sigc::signal DurationChanged ; + /** Emitted when the maximum item duration is changed */ - sigc::signal MaxDurationChanged ; - + sigc::signal MaxDurationChanged ; + /** Emitted when the mionimum item duration is changed */ - sigc::signal MinDurationChanged ; - - /** Emitted when the selected status of this item changes */ - sigc::signal Selected ; - + sigc::signal MinDurationChanged ; - protected: - enum Visibility { ShowFrame = 0x1, ShowNameHighlight = 0x2, ShowNameText = 0x4, - ShowHandles = 0x8 + ShowHandles = 0x8, + HideFrameLeft = 0x10, + HideFrameRight = 0x20, + HideFrameTB = 0x40, + FullWidthNameHighlight = 0x80 }; - + protected: /** * Constructs a new TimeAxisViewItem. * @@ -337,26 +342,30 @@ class TimeAxisViewItem : public sigc::trackable, public Selectable * @param start the start point of this item * @param duration the duration of this item */ - TimeAxisViewItem(std::string it_name, Gnome::Canvas::Group& parent, TimeAxisView& tv, double spu, Gdk::Color& base_color, - jack_nframes_t start, jack_nframes_t duration, Visibility v = Visibility (0)); - + TimeAxisViewItem(const std::string & it_name, ArdourCanvas::Group& parent, TimeAxisView& tv, double spu, Gdk::Color const & base_color, + nframes64_t start, nframes64_t duration, bool recording = false, Visibility v = Visibility (0)); + + TimeAxisViewItem (const TimeAxisViewItem& other); + + void init (const std::string& it_name, double spu, Gdk::Color const & base_color, nframes64_t start, nframes64_t duration, Visibility vis); + /** * Calculates some contrasting color for displaying various parts of this item, based upon the base color * * @param color the base color of the item */ - virtual void compute_colors(Gdk::Color& color) ; - + virtual void compute_colors (Gdk::Color const & color); + /** * 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() ; - + virtual void set_frame_color() ; + /** * Sets the colors of the start and end trim handle depending on object state * @@ -375,46 +384,49 @@ class TimeAxisViewItem : public sigc::trackable, public Selectable * @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 ; - + nframes64_t frame_position ; + /** the duration of this item upon the timeline */ - jack_nframes_t item_duration ; - + nframes64_t item_duration ; + /** the maximum duration that we allow this item to take */ - jack_nframes_t max_item_duration ; - + nframes64_t max_item_duration ; + /** the minimu duration that we allow this item to take */ - jack_nframes_t min_item_duration ; - + nframes64_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; - + + /** should the item respond to events */ + bool _sensitive; + /** * 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 */ @@ -435,21 +447,27 @@ class TimeAxisViewItem : public sigc::trackable, public Selectable 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 ; - - Gnome::Canvas::Group* group; - Gnome::Canvas::SimpleRect* vestigial_frame; - Gnome::Canvas::SimpleRect* frame; - Gnome::Canvas::Text* name_text; - Gnome::Canvas::SimpleRect* name_highlight; - Gnome::Canvas::SimpleRect* frame_handle_start; - Gnome::Canvas::SimpleRect* frame_handle_end; + uint32_t last_item_width; + int name_pixbuf_width; + + ArdourCanvas::Group* group; + ArdourCanvas::SimpleRect* vestigial_frame; + ArdourCanvas::SimpleRect* frame; + ArdourCanvas::Pixbuf* name_pixbuf; + ArdourCanvas::SimpleRect* name_highlight; + ArdourCanvas::SimpleRect* frame_handle_start; + ArdourCanvas::SimpleRect* frame_handle_end; + + Visibility visibility; + bool _recregion; + }; /* class TimeAxisViewItem */