2 Copyright (C) 2003 Paul Davis
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 #include <pbd/error.h>
21 #include <pbd/stacktrace.h>
23 #include <ardour/types.h>
24 #include <ardour/ardour.h>
26 #include <gtkmm2ext/utils.h>
28 #include "public_editor.h"
29 #include "time_axis_view_item.h"
30 #include "time_axis_view.h"
31 #include "simplerect.h"
33 #include "canvas_impl.h"
34 #include "rgb_macros.h"
35 #include "ardour_ui.h"
40 using namespace Editing;
43 using namespace ARDOUR;
45 //------------------------------------------------------------------------------
46 /** Initialize const static memeber data */
48 Pango::FontDescription* TimeAxisViewItem::NAME_FONT = 0;
49 bool TimeAxisViewItem::have_name_font = false;
50 const double TimeAxisViewItem::NAME_X_OFFSET = 15.0;
51 const double TimeAxisViewItem::GRAB_HANDLE_LENGTH = 6 ;
53 double TimeAxisViewItem::NAME_Y_OFFSET;
54 double TimeAxisViewItem::NAME_HIGHLIGHT_SIZE;
55 double TimeAxisViewItem::NAME_HIGHLIGHT_THRESH;
58 //---------------------------------------------------------------------------------------//
59 // Constructor / Desctructor
62 * Constructs a new TimeAxisViewItem.
64 * @param it_name the unique name/Id of this item
65 * @param parant the parent canvas group
66 * @param tv the TimeAxisView we are going to be added to
67 * @param spu samples per unit
69 * @param start the start point of this item
70 * @param duration the duration of this item
72 TimeAxisViewItem::TimeAxisViewItem(const string & it_name, ArdourCanvas::Group& parent, TimeAxisView& tv, double spu, Gdk::Color& base_color,
73 nframes_t start, nframes_t duration, bool recording,
75 : trackview (tv), _recregion(recording)
77 if (!have_name_font) {
79 /* first constructed item sets up font info */
81 NAME_FONT = get_font_for_style (N_("TimeAxisViewItemName"));
87 Glib::RefPtr<Pango::Layout> layout = foo.create_pango_layout (X_("Hg")); /* ascender + descender */
91 layout->set_font_description (*NAME_FONT);
92 Gtkmm2ext::get_ink_pixel_size (layout, width, height);
94 NAME_Y_OFFSET = height + 5;
95 NAME_HIGHLIGHT_SIZE = height + 6;
96 NAME_HIGHLIGHT_THRESH = NAME_HIGHLIGHT_SIZE * 2;
98 have_name_font = true;
101 group = new ArdourCanvas::Group (parent);
103 init (it_name, spu, base_color, start, duration, vis);
107 TimeAxisViewItem::TimeAxisViewItem (const TimeAxisViewItem& other)
108 : trackview (other.trackview)
114 UINT_TO_RGBA (other.fill_color, &r, &g, &b, &a);
115 c.set_rgb_p (r/255.0, g/255.0, b/255.0);
117 /* share the other's parent, but still create a new group */
119 Gnome::Canvas::Group* parent = other.group->property_parent();
121 group = new ArdourCanvas::Group (*parent);
123 init (other.item_name, other.samples_per_unit, c, other.frame_position, other.item_duration, other.visibility);
128 TimeAxisViewItem::init (const string& it_name, double spu, Gdk::Color& base_color, nframes_t start, nframes_t duration, Visibility vis)
130 item_name = it_name ;
131 name_text_width = ::pixel_width (it_name, *NAME_FONT);
132 last_name_text_width = 0;
133 samples_per_unit = spu ;
134 should_show_selection = true;
135 frame_position = start ;
136 item_duration = duration ;
137 name_connected = false;
138 // why? fill_opacity = 60;
139 position_locked = false ;
140 max_item_duration = ARDOUR::max_frames;
141 min_item_duration = 0 ;
142 show_vestigial = true;
147 warning << "Time Axis Item Duration == 0" << endl ;
150 vestigial_frame = new ArdourCanvas::SimpleRect (*group);
151 vestigial_frame->property_x1() = (double) 0.0;
152 vestigial_frame->property_y1() = (double) 1.0;
153 vestigial_frame->property_x2() = (double) 2.0;
154 vestigial_frame->property_y2() = (double) trackview.current_height();
155 vestigial_frame->property_outline_what() = 0xF;
156 vestigial_frame->property_outline_color_rgba() = ARDOUR_UI::config()->canvasvar_VestigialFrame.get();
157 vestigial_frame->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_VestigialFrame.get();
158 vestigial_frame->hide ();
160 if (visibility & ShowFrame) {
161 frame = new ArdourCanvas::SimpleRect (*group);
162 frame->property_x1() = (double) 0.0;
163 frame->property_y1() = (double) 1.0;
164 frame->property_x2() = (double) trackview.editor.frame_to_pixel(duration);
165 frame->property_y2() = (double) trackview.current_height();
166 frame->property_outline_pixels() = 1;
167 frame->property_outline_what() = 0xF;
168 frame->property_outline_color_rgba() = ARDOUR_UI::config()->canvasvar_TimeAxisFrame.get();
169 frame->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_TimeAxisFrame.get();
171 /* by default draw all 4 edges */
173 uint32_t outline_what = 0x1|0x2|0x4|0x8;
175 if (visibility & HideFrameLeft) {
176 outline_what &= ~(0x1);
179 if (visibility & HideFrameRight) {
180 outline_what &= ~(0x2);
183 if (visibility & HideFrameTB) {
184 outline_what &= ~(0x4 | 0x8);
187 frame->property_outline_what() = outline_what;
193 if (visibility & ShowNameHighlight) {
194 name_highlight = new ArdourCanvas::SimpleRect (*group);
195 if (visibility & FullWidthNameHighlight) {
196 name_highlight->property_x1() = (double) 0.0;
197 name_highlight->property_x2() = (double) (trackview.editor.frame_to_pixel(item_duration));
199 name_highlight->property_x1() = (double) 1.0;
200 name_highlight->property_x2() = (double) (trackview.editor.frame_to_pixel(item_duration)) - 1;
202 name_highlight->property_y1() = (double) (trackview.current_height() - TimeAxisViewItem::NAME_HIGHLIGHT_SIZE);
203 name_highlight->property_y2() = (double) (trackview.current_height() - 1);
204 name_highlight->property_outline_color_rgba() = ARDOUR_UI::config()->canvasvar_NameHighlightFill.get();
205 name_highlight->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_NameHighlightOutline.get();
207 name_highlight->set_data ("timeaxisviewitem", this);
213 if (visibility & ShowNameText) {
214 name_text = new ArdourCanvas::Text (*group);
215 name_text->property_x() = (double) TimeAxisViewItem::NAME_X_OFFSET;
216 /* trackview.current_height() is the bottom of the trackview. subtract 1 to get back to the bottom of the highlight,
217 then NAME_Y_OFFSET to position the text in the vertical center of the highlight
219 name_text->property_y() = (double) trackview.current_height() - 1.0 - TimeAxisViewItem::NAME_Y_OFFSET;
220 name_text->property_font_desc() = *NAME_FONT;
221 name_text->property_anchor() = Gtk::ANCHOR_NW;
223 name_text->set_data ("timeaxisviewitem", this);
229 /* create our grab handles used for trimming/duration etc */
231 if (visibility & ShowHandles) {
232 frame_handle_start = new ArdourCanvas::SimpleRect (*group);
233 frame_handle_start->property_x1() = (double) 0.0;
234 frame_handle_start->property_x2() = (double) TimeAxisViewItem::GRAB_HANDLE_LENGTH;
235 frame_handle_start->property_y1() = (double) 1.0;
236 frame_handle_start->property_y2() = (double) TimeAxisViewItem::GRAB_HANDLE_LENGTH+1;
237 frame_handle_start->property_outline_color_rgba() = ARDOUR_UI::config()->canvasvar_FrameHandle.get();
238 frame_handle_start->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_FrameHandle.get();
240 frame_handle_end = new ArdourCanvas::SimpleRect (*group);
241 frame_handle_end->property_x1() = (double) (trackview.editor.frame_to_pixel(get_duration())) - (TimeAxisViewItem::GRAB_HANDLE_LENGTH);
242 frame_handle_end->property_x2() = (double) trackview.editor.frame_to_pixel(get_duration());
243 frame_handle_end->property_y1() = (double) 1;
244 frame_handle_end->property_y2() = (double) TimeAxisViewItem::GRAB_HANDLE_LENGTH + 1;
245 frame_handle_end->property_outline_color_rgba() = ARDOUR_UI::config()->canvasvar_FrameHandle.get();
246 frame_handle_end->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_FrameHandle.get();
249 frame_handle_start = 0;
250 frame_handle_end = 0;
253 set_color (base_color) ;
255 set_duration (item_duration, this) ;
256 set_position (start, this) ;
262 TimeAxisViewItem::~TimeAxisViewItem()
268 //---------------------------------------------------------------------------------------//
269 // Position and duration Accessors/Mutators
272 * Set the position of this item upon the timeline to the specified value
274 * @param pos the new position
275 * @param src the identity of the object that initiated the change
276 * @return true if the position change was a success, false otherwise
279 TimeAxisViewItem::set_position(nframes_t pos, void* src, double* delta)
281 if (position_locked) {
285 frame_position = pos;
287 /* This sucks. The GnomeCanvas version I am using
288 doesn't correctly implement gnome_canvas_group_set_arg(),
289 so that simply setting the "x" arg of the group
290 fails to move the group. Instead, we have to
291 use gnome_canvas_item_move(), which does the right
292 thing. I see that in GNOME CVS, the current (Sept 2001)
293 version of GNOME Canvas rectifies this issue cleanly.
296 double old_unit_pos ;
297 double new_unit_pos = pos / samples_per_unit ;
299 old_unit_pos = group->property_x();
301 if (new_unit_pos != old_unit_pos) {
302 group->move (new_unit_pos - old_unit_pos, 0.0);
306 (*delta) = new_unit_pos - old_unit_pos;
309 PositionChanged (frame_position, src) ; /* EMIT_SIGNAL */
315 * Return the position of this item upon the timeline
317 * @return the position of this item
320 TimeAxisViewItem::get_position() const
322 return frame_position;
326 * Sets the duration of this item
328 * @param dur the new duration of this item
329 * @param src the identity of the object that initiated the change
330 * @return true if the duration change was succesful, false otherwise
333 TimeAxisViewItem::set_duration (nframes_t dur, void* src)
335 if ((dur > max_item_duration) || (dur < min_item_duration)) {
336 warning << string_compose (_("new duration %1 frames is out of bounds for %2"), get_item_name(), dur)
347 reset_width_dependent_items (trackview.editor.frame_to_pixel (dur));
349 DurationChanged (dur, src) ; /* EMIT_SIGNAL */
354 * Returns the duration of this item
358 TimeAxisViewItem::get_duration() const
360 return (item_duration);
364 * Sets the maximum duration that this item make have.
366 * @param dur the new maximum duration
367 * @param src the identity of the object that initiated the change
370 TimeAxisViewItem::set_max_duration(nframes_t dur, void* src)
372 max_item_duration = dur ;
373 MaxDurationChanged(max_item_duration, src) ; /* EMIT_SIGNAL */
377 * Returns the maxmimum duration that this item may be set to
379 * @return the maximum duration that this item may be set to
382 TimeAxisViewItem::get_max_duration() const
384 return (max_item_duration) ;
388 * Sets the minimu duration that this item may be set to
390 * @param the minimum duration that this item may be set to
391 * @param src the identity of the object that initiated the change
394 TimeAxisViewItem::set_min_duration(nframes_t dur, void* src)
396 min_item_duration = dur ;
397 MinDurationChanged(max_item_duration, src) ; /* EMIT_SIGNAL */
401 * Returns the minimum duration that this item mey be set to
403 * @return the nimum duration that this item mey be set to
406 TimeAxisViewItem::get_min_duration() const
408 return(min_item_duration) ;
412 * Sets whether the position of this Item is locked to its current position
413 * Locked items cannot be moved until the item is unlocked again.
415 * @param yn set to true to lock this item to its current position
416 * @param src the identity of the object that initiated the change
419 TimeAxisViewItem::set_position_locked(bool yn, void* src)
421 position_locked = yn ;
422 set_trim_handle_colors() ;
423 PositionLockChanged (position_locked, src); /* EMIT_SIGNAL */
427 * Returns whether this item is locked to its current position
429 * @return true if this item is locked to its current posotion
433 TimeAxisViewItem::get_position_locked() const
435 return (position_locked);
439 * Sets whether the Maximum Duration constraint is active and should be enforced
441 * @param active set true to enforce the max duration constraint
442 * @param src the identity of the object that initiated the change
445 TimeAxisViewItem::set_max_duration_active(bool active, void* src)
447 max_duration_active = active ;
451 * Returns whether the Maximum Duration constraint is active and should be enforced
453 * @return true if the maximum duration constraint is active, false otherwise
456 TimeAxisViewItem::get_max_duration_active() const
458 return(max_duration_active) ;
462 * Sets whether the Minimum Duration constraint is active and should be enforced
464 * @param active set true to enforce the min duration constraint
465 * @param src the identity of the object that initiated the change
468 TimeAxisViewItem::set_min_duration_active(bool active, void* src)
470 min_duration_active = active ;
474 * Returns whether the Maximum Duration constraint is active and should be enforced
476 * @return true if the maximum duration constraint is active, false otherwise
479 TimeAxisViewItem::get_min_duration_active() const
481 return(min_duration_active) ;
484 //---------------------------------------------------------------------------------------//
485 // Name/Id Accessors/Mutators
488 * Set the name/Id of this item.
490 * @param new_name the new name of this item
491 * @param src the identity of the object that initiated the change
494 TimeAxisViewItem::set_item_name(std::string new_name, void* src)
496 if (new_name != item_name) {
497 std::string temp_name = item_name ;
498 item_name = new_name ;
499 name_text_width = ::pixel_width (new_name, *NAME_FONT);
500 NameChanged (item_name, temp_name, src) ; /* EMIT_SIGNAL */
505 * Returns the name/id of this item
507 * @return the name/id of this item
510 TimeAxisViewItem::get_item_name() const
515 //---------------------------------------------------------------------------------------//
519 * Set to true to indicate that this item is currently selected
521 * @param yn true if this item is currently selected
522 * @param src the identity of the object that initiated the change
525 TimeAxisViewItem::set_selected(bool yn)
527 if (_selected != yn) {
528 Selectable::set_selected (yn);
534 TimeAxisViewItem::set_should_show_selection (bool yn)
536 if (should_show_selection != yn) {
537 should_show_selection = yn;
542 //---------------------------------------------------------------------------------------//
543 // Parent Componenet Methods
546 * Returns the TimeAxisView that this item is upon
548 * @return the timeAxisView that this item is placed upon
551 TimeAxisViewItem::get_time_axis_view()
555 //---------------------------------------------------------------------------------------//
559 * Sets the displayed item text
560 * This item is the visual text name displayed on the canvas item, this can be different to the name of the item
562 * @param new_name the new name text to display
565 TimeAxisViewItem::set_name_text(const ustring& new_name)
568 name_text->property_text() = new_name;
569 name_text_width = pixel_width (new_name, *NAME_FONT);
570 name_text_size_cache.clear ();
575 * Set the height of this item
577 * @param h the new height
580 TimeAxisViewItem::set_height (double height)
582 if (name_highlight) {
583 if (height < NAME_HIGHLIGHT_THRESH) {
584 name_highlight->hide();
589 name_highlight->show();
595 if (height > NAME_HIGHLIGHT_SIZE) {
596 name_highlight->property_y1() = (double) height+1 - NAME_HIGHLIGHT_SIZE;
597 name_highlight->property_y2() = (double) height;
600 /* it gets hidden now anyway */
601 name_highlight->property_y1() = (double) 1.0;
602 name_highlight->property_y2() = (double) height;
607 name_text->property_y() = height+1 - NAME_Y_OFFSET;
608 if (height < NAME_HIGHLIGHT_THRESH) {
609 name_text->property_fill_color_rgba() = fill_color;
612 name_text->property_fill_color_rgba() = label_color;
617 frame->property_y2() = height+1;
620 vestigial_frame->property_y2() = height+1;
627 TimeAxisViewItem::set_color(Gdk::Color& base_color)
629 compute_colors (base_color);
637 TimeAxisViewItem::get_canvas_frame()
646 TimeAxisViewItem::get_canvas_group()
655 TimeAxisViewItem::get_name_highlight()
657 return (name_highlight) ;
664 TimeAxisViewItem::get_name_text()
670 * Calculates some contrasting color for displaying various parts of this item, based upon the base color
672 * @param color the base color of the item
675 TimeAxisViewItem::compute_colors(Gdk::Color& base_color)
677 unsigned char radius ;
680 unsigned char r,g,b ;
682 /* FILL: this is simple */
683 r = base_color.get_red()/256 ;
684 g = base_color.get_green()/256 ;
685 b = base_color.get_blue()/256 ;
686 fill_color = RGBA_TO_UINT(r,g,b,160) ;
689 if the overall saturation is strong, make the minor colors light.
690 if its weak, make them dark.
692 we do this by moving an equal distance to the other side of the
693 central circle in the color wheel from where we started.
696 radius = (unsigned char) rint (floor (sqrt (static_cast<double>(r*r + g*g + b+b))/3.0f)) ;
697 minor_shift = 125 - radius ;
699 /* LABEL: rotate around color wheel by 120 degrees anti-clockwise */
701 r = base_color.get_red()/256;
702 g = base_color.get_green()/256;
703 b = base_color.get_blue()/256;
709 /* red sector => green */
714 /* green sector => blue */
722 /* blue sector => red */
727 /* green sector => blue */
736 label_color = RGBA_TO_UINT(r,g,b,255);
737 r = (base_color.get_red()/256) + 127 ;
738 g = (base_color.get_green()/256) + 127 ;
739 b = (base_color.get_blue()/256) + 127 ;
741 label_color = RGBA_TO_UINT(r,g,b,255);
743 /* XXX can we do better than this ? */
744 /* We're trying ;) */
747 //frame_color_r = 192;
748 //frame_color_g = 192;
749 //frame_color_b = 194;
751 //selected_frame_color_r = 182;
752 //selected_frame_color_g = 145;
753 //selected_frame_color_b = 168;
755 //handle_color_r = 25 ;
756 //handle_color_g = 0 ;
757 //handle_color_b = 255 ;
758 //lock_handle_color_r = 235 ;
759 //lock_handle_color_g = 16;
760 //lock_handle_color_b = 16;
764 * Convenience method to set the various canvas item colors
767 TimeAxisViewItem::set_colors()
771 double height = NAME_HIGHLIGHT_THRESH;
774 height = frame->property_y2();
777 if (height < NAME_HIGHLIGHT_THRESH) {
778 name_text->property_fill_color_rgba() = fill_color;
781 name_text->property_fill_color_rgba() = label_color;
785 if (name_highlight) {
786 name_highlight->property_fill_color_rgba() = fill_color;
787 name_highlight->property_outline_color_rgba() = fill_color;
789 set_trim_handle_colors() ;
793 * Sets the frame color depending on whether this item is selected
796 TimeAxisViewItem::set_frame_color()
801 if (_selected && should_show_selection) {
802 UINT_TO_RGBA(ARDOUR_UI::config()->canvasvar_SelectedFrameBase.get(), &r, &g, &b, &a);
803 frame->property_fill_color_rgba() = RGBA_TO_UINT(r, g, b, a);
806 UINT_TO_RGBA(ARDOUR_UI::config()->canvasvar_RecordingRect.get(), &r, &g, &b, &a);
807 frame->property_fill_color_rgba() = RGBA_TO_UINT(r, g, b, a);
809 UINT_TO_RGBA(ARDOUR_UI::config()->canvasvar_FrameBase.get(), &r, &g, &b, &a);
810 frame->property_fill_color_rgba() = RGBA_TO_UINT(r, g, b, fill_opacity ? fill_opacity : a);
817 * Sets the colors of the start and end trim handle depending on object state
821 TimeAxisViewItem::set_trim_handle_colors()
823 if (frame_handle_start) {
824 if (position_locked) {
825 frame_handle_start->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_TrimHandleLocked.get();
826 frame_handle_end->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_TrimHandleLocked.get();
828 frame_handle_start->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_TrimHandle.get();
829 frame_handle_end->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_TrimHandle.get();
835 TimeAxisViewItem::get_samples_per_unit()
837 return(samples_per_unit) ;
841 TimeAxisViewItem::set_samples_per_unit (double spu)
843 samples_per_unit = spu ;
844 set_position (this->get_position(), this);
845 reset_width_dependent_items ((double)get_duration() / samples_per_unit);
849 TimeAxisViewItem::reset_width_dependent_items (double pixel_width)
851 if (pixel_width < GRAB_HANDLE_LENGTH * 2) {
853 if (frame_handle_start) {
854 frame_handle_start->hide();
855 frame_handle_end->hide();
858 } if (pixel_width < 2.0) {
860 if (show_vestigial) {
861 vestigial_frame->show();
864 if (name_highlight) {
865 name_highlight->hide();
875 if (frame_handle_start) {
876 frame_handle_start->hide();
877 frame_handle_end->hide();
881 vestigial_frame->hide();
883 if (name_highlight) {
885 double height = name_highlight->property_y2 ();
887 if (height < NAME_HIGHLIGHT_THRESH) {
888 name_highlight->hide();
893 name_highlight->show();
894 if (name_text && !get_item_name().empty()) {
896 reset_name_width (pixel_width);
900 if (visibility & FullWidthNameHighlight) {
901 name_highlight->property_x2() = pixel_width;
903 name_highlight->property_x2() = pixel_width - 1.0;
910 frame->property_x2() = pixel_width;
913 if (frame_handle_start) {
914 if (pixel_width < (2*TimeAxisViewItem::GRAB_HANDLE_LENGTH)) {
915 frame_handle_start->hide();
916 frame_handle_end->hide();
918 frame_handle_start->show();
919 frame_handle_end->property_x1() = pixel_width - (TimeAxisViewItem::GRAB_HANDLE_LENGTH);
920 frame_handle_end->show();
921 frame_handle_end->property_x2() = pixel_width;
927 TimeAxisViewItem::reset_name_width (double pixel_width)
929 if (name_text == 0) {
933 int limit = (int) floor (pixel_width - NAME_X_OFFSET);
934 bool shrinking = (last_name_text_width > pixel_width);
937 ustring::size_type n;
939 if ((last_name_text_width && // we did this once
940 shrinking && // we're getting smaller
941 (name_text_width <= limit) && // fits the new size
942 (name_text_width <= last_name_text_width - NAME_X_OFFSET))) { // fit into the old size too
943 last_name_text_width = pixel_width;
947 /* now check the cache of existing truncations */
950 Glib::RefPtr<Pango::Layout> layout = foo.create_pango_layout ("");
952 for (n = item_name.length(); n > 0; --n) {
954 map<ustring::size_type,int>::iterator i;
956 if ((i = name_text_size_cache.find (n)) != name_text_size_cache.end()) {
958 /* we know the length of this substring already */
960 if ((actual_width = (*i).second) < limit) {
962 /* it fits, use it */
964 ustr = item_name.substr (0, n);
970 /* we don't know the length of this substring already, so compute
971 it and put it into the cache.
974 layout->set_text (item_name.substr (0, n));
977 Gtkmm2ext::get_ink_pixel_size (layout, width, height);
979 name_text_size_cache[n] = width;
981 if ((actual_width = width) < limit) {
982 ustr = item_name.substr (0, n);
989 name_text->property_text() = "";
990 last_name_text_width = pixel_width;
994 /* don't use name for event handling if it leaves no room
995 for trimming to work.
998 if (pixel_width - actual_width < (NAME_X_OFFSET * 2.0)) {
999 if (name_connected) {
1000 name_connected = false;
1003 if (!name_connected) {
1004 name_connected = true;
1008 name_text->property_text() = ustr;
1009 name_text_width = actual_width;
1011 last_name_text_width = pixel_width;
1016 //---------------------------------------------------------------------------------------//
1017 // Handle time axis removal
1020 * Handles the Removal of this time axis item
1021 * This _needs_ to be called to alert others of the removal properly, ie where the source
1022 * of the removal came from.
1024 * XXX Although im not too happy about this method of doing things, I cant think of a cleaner method
1025 * just now to capture the source of the removal
1027 * @param src the identity of the object that initiated the change
1030 TimeAxisViewItem::remove_this_item(void* src)
1033 defer to idle loop, otherwise we'll delete this object
1034 while we're still inside this function ...
1036 Glib::signal_idle().connect(bind (sigc::ptr_fun (&TimeAxisViewItem::idle_remove_this_item), this, src));
1040 * Callback used to remove this time axis item during the gtk idle loop
1041 * This is used to avoid deleting the obejct while inside the remove_this_item
1044 * @param item the TimeAxisViewItem to remove
1045 * @param src the identity of the object that initiated the change
1048 TimeAxisViewItem::idle_remove_this_item(TimeAxisViewItem* item, void* src)
1050 item->ItemRemoved (item->get_item_name(), src) ; /* EMIT_SIGNAL */