fix compose mess, and a number of 64 bit printf specs
[ardour.git] / gtk2_ardour / time_axis_view.cc
1 /*
2     Copyright (C) 2000 Paul Davis 
3
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.
8
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.
13
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.
17
18     $Id$
19 */
20
21 #include <cstdlib>
22 #include <cmath>
23 #include <algorithm>
24 #include <string>
25 #include <list>
26
27 #include <pbd/error.h>
28
29 #include <gtkmm2ext/utils.h>
30 #include <gtkmm2ext/selector.h>
31 #include <gtkmm2ext/stop_signal.h>
32
33 #include <ardour/session.h>
34 #include <ardour/utils.h>
35 #include <ardour/ladspa_plugin.h>
36 #include <ardour/insert.h>
37 #include <ardour/location.h>
38
39 #include "ardour_ui.h"
40 #include "public_editor.h"
41 #include "time_axis_view.h"
42 #include "canvas-simplerect.h"
43 #include "selection.h"
44 #include "keyboard.h"
45 #include "rgb_macros.h"
46
47 #include "i18n.h"
48
49 using namespace Gtk;
50 /*can't use sigc namespace while we have the string_compose() in libs/pbd3/pbd */
51 //using namespace sigc; 
52 using namespace ARDOUR;
53 using namespace Editing;
54
55 const double trim_handle_size = 6.0; /* pixels */
56
57 TimeAxisView::TimeAxisView(ARDOUR::Session& sess, PublicEditor& ed, TimeAxisView* rent, Gtk::Widget *canvas) 
58         : AxisView(sess), 
59           editor(ed),
60           controls_table (2, 9)
61 {
62         canvas_display = gnome_canvas_item_new (gnome_canvas_root(GNOME_CANVAS(canvas->gobj())),
63                                               gnome_canvas_group_get_type(),
64                                               "x", 0.0,
65                                               "y", 0.0,
66                                               NULL);
67
68         selection_group = gnome_canvas_item_new (GNOME_CANVAS_GROUP(canvas_display), 
69                                                gnome_canvas_group_get_type (), 
70                                                NULL);
71         gnome_canvas_item_hide (selection_group);
72         
73         control_parent = 0;
74         display_menu = 0;
75         size_menu = 0;
76         _marked_for_display = false;
77         _hidden = false;
78         height = 0;
79         effective_height = 0;
80         parent = rent;
81         _has_state = false;
82
83         /*
84           Create the standard LHS Controls
85           We create the top-level container and name add the name label here,
86           subclasses can add to the layout as required
87         */
88
89         name_entry.set_name ("EditorTrackNameDisplay");
90         name_entry.signal_button_release_event().connect (mem_fun (*this, &TimeAxisView::name_entry_button_release));
91         name_entry.signal_button_press_event().connect (mem_fun (*this, &TimeAxisView::name_entry_button_press));
92         
93         name_entry.signal_focus_in_event().connect (sigc::ptr_fun (ARDOUR_UI::generic_focus_in_event));
94         name_entry.signal_focus_out_event().connect (sigc::ptr_fun (ARDOUR_UI::generic_focus_out_event));
95
96         Gtkmm2ext::set_size_request_to_display_given_text (name_entry, N_("gTortnam"), 10, 10); // just represents a short name
97
98         name_label.set_name ("TrackLabel");
99         name_label.set_alignment (0.0, 0.5);
100
101         // name_hbox.set_border_width (2);
102         // name_hbox.set_spacing (5);
103
104         /* typically, either name_label OR name_entry are visible,
105            but not both. its up to derived classes to show/hide them as they
106            wish.
107         */
108
109         name_hbox.pack_start (name_label, true, true);
110         name_hbox.pack_start (name_entry, true, true);
111         name_hbox.show ();
112
113         controls_table.set_border_width (2);
114         controls_table.set_row_spacings (0);
115         controls_table.set_col_spacings (0);
116         controls_table.set_homogeneous (true);
117         controls_table.show ();
118
119         controls_table.attach (name_hbox, 0, 5, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
120
121         controls_table.show ();
122
123         controls_vbox.pack_start (controls_table, false, false);
124         controls_vbox.show ();
125
126         controls_ebox.set_name ("TimeAxisViewControlsBaseUnselected");
127         controls_ebox.add (controls_vbox);
128         controls_ebox.set_events (Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK);
129         controls_ebox.set_flags (Gtk::CAN_FOCUS);
130
131         controls_ebox.signal_button_release_event().connect (mem_fun (*this, &TimeAxisView::controls_ebox_button_release));
132         
133         controls_lhs_pad.set_name ("TimeAxisViewControlsPadding");
134         controls_hbox.pack_start (controls_lhs_pad,false,false);
135         controls_hbox.pack_start (controls_ebox,true,true);
136         controls_hbox.show ();
137
138         controls_frame.add (controls_hbox);
139         controls_frame.set_name ("TimeAxisViewControlsBaseUnselected");
140         controls_frame.set_shadow_type (Gtk::SHADOW_OUT);
141 }
142
143 TimeAxisView::~TimeAxisView()
144 {
145         for (vector<TimeAxisView*>::iterator i = children.begin(); i != children.end(); ++i) {
146                 delete *i;
147         }
148
149         for (list<SelectionRect*>::iterator i = free_selection_rects.begin(); i != free_selection_rects.end(); ++i) {
150                 gtk_object_destroy (GTK_OBJECT((*i)->rect));
151                 gtk_object_destroy (GTK_OBJECT((*i)->start_trim));
152                 gtk_object_destroy (GTK_OBJECT((*i)->end_trim));
153         }
154
155         for (list<SelectionRect*>::iterator i = used_selection_rects.begin(); i != used_selection_rects.end(); ++i) {
156                 gtk_object_destroy (GTK_OBJECT((*i)->rect));
157                 gtk_object_destroy (GTK_OBJECT((*i)->start_trim));
158                 gtk_object_destroy (GTK_OBJECT((*i)->end_trim));
159         }
160
161         if (selection_group) {
162                 gtk_object_destroy (GTK_OBJECT (selection_group));
163                 selection_group = 0;
164         }
165
166         if (canvas_display) {
167                 gtk_object_destroy (GTK_OBJECT (canvas_display));       
168                 canvas_display = 0;
169         }
170
171         if (display_menu) {
172                 delete display_menu;
173                 display_menu = 0;
174         }
175
176         if (size_menu) {
177                 delete size_menu;
178                 size_menu = 0;
179         }
180 }
181
182 guint32
183 TimeAxisView::show_at (double y, int& nth, VBox *parent)
184 {
185         gdouble ix1, ix2, iy1, iy2;
186         effective_height = 0;
187
188         if (control_parent) {
189                 control_parent->reorder_child (controls_frame, nth);
190         } else {
191                 control_parent = parent;
192                 parent->pack_start (controls_frame, false, false);
193                 parent->reorder_child (controls_frame, nth);
194         }
195
196         controls_frame.show ();
197         controls_ebox.show ();
198
199         /* the coordinates used here are in the system of the
200            item's parent ...
201         */
202
203         gnome_canvas_item_get_bounds (canvas_display, &ix1, &iy1, &ix2, &iy2);
204         gnome_canvas_item_i2w (canvas_display->parent, &ix1, &iy1);
205         if (iy1 < 0) {
206                 iy1 = 0;
207         }
208         gnome_canvas_item_move (canvas_display, 0.0, y - iy1);
209         gnome_canvas_item_show (canvas_display); /* XXX not necessary */
210
211         y_position = y;
212         order = nth;
213         _hidden = false;
214         
215         effective_height = height;
216
217         /* now show children */
218         
219         for (vector<TimeAxisView*>::iterator i = children.begin(); i != children.end(); ++i) {
220                 
221                 if ((*i)->marked_for_display()) {
222                         gnome_canvas_item_show ((*i)->canvas_display);
223                 }
224                 
225                 if (GTK_OBJECT_FLAGS(GTK_OBJECT((*i)->canvas_display)) & GNOME_CANVAS_ITEM_VISIBLE) {
226                         ++nth;
227                         effective_height += (*i)->show_at (y + effective_height, nth, parent);
228                 }
229         }
230
231         return effective_height;
232 }
233
234 gint
235 TimeAxisView::controls_ebox_button_release (GdkEventButton* ev)
236 {
237         switch (ev->button) {
238         case 1:
239                 selection_click (ev);
240                 break;
241
242         case 3:
243                 popup_display_menu (ev->time);
244                 break;
245
246         case 4:
247                 if (Keyboard::no_modifier_keys_pressed (ev)) {
248                         editor.scroll_tracks_up_line ();
249                 } else if (Keyboard::modifier_state_equals (ev->state, Keyboard::Control)) {
250                         step_height (true);
251                 }
252                 break;
253
254         case 5:
255                 if (Keyboard::no_modifier_keys_pressed (ev)) {
256                         editor.scroll_tracks_down_line ();
257                 } else if (Keyboard::modifier_state_equals (ev->state, Keyboard::Control)) {
258                         step_height (false);
259                 }
260                 break;
261                 
262
263         }
264
265         return TRUE;
266 }
267
268 void
269 TimeAxisView::selection_click (GdkEventButton* ev)
270 {
271         if (Keyboard::modifier_state_contains (ev->state, Keyboard::Shift)) {
272
273                 if (editor.get_selection().selected (this)) {
274                         editor.get_selection().remove (this);
275                 } else {
276                         editor.get_selection().add (this);
277                 }
278
279         } else {
280
281                 editor.get_selection().set (this);
282         }
283 }
284
285 void
286 TimeAxisView::hide ()
287 {
288         if (_hidden) {
289                 return;
290         }
291
292         gnome_canvas_item_hide (canvas_display);
293         controls_frame.hide ();
294
295         if (control_parent) {
296                 control_parent->remove (controls_frame);
297                 control_parent = 0;
298         }
299
300         y_position = -1;
301         _hidden = true;
302         
303         /* now hide children */
304         
305         for (vector<TimeAxisView*>::iterator i = children.begin(); i != children.end(); ++i) {
306                 (*i)->hide ();
307         }
308         
309         Hiding ();
310 }
311
312 void
313 TimeAxisView::step_height (bool bigger)
314 {
315         switch (height) {
316         case Largest:
317                 if (!bigger) set_height (Large);
318                 break;
319         case Large:
320                 if (bigger) set_height (Largest);
321                 else set_height (Larger);
322                 break;
323         case Larger:
324                 if (bigger) set_height (Large);
325                 else set_height (Normal);
326                 break;
327         case Normal:
328                 if (bigger) set_height (Larger);
329                 else set_height (Smaller);
330                 break;
331         case Smaller:
332                 if (bigger) set_height (Normal);
333                 else set_height (Small);
334                 break;
335         case Small:
336                 if (bigger) set_height (Smaller);
337                 break;
338         }
339 }
340
341
342 void
343 TimeAxisView::set_height (TrackHeight h)
344 {
345         height = (guint32) h;
346         controls_frame.set_size_request (-1, height);
347
348         if (GTK_OBJECT_FLAGS(GTK_OBJECT(selection_group)) & GNOME_CANVAS_ITEM_VISIBLE) {
349                 /* resize the selection rect */
350                 show_selection (editor.get_selection().time);
351         }
352
353 //      for (vector<TimeAxisView*>::iterator i = children.begin(); i != children.end(); ++i) {
354 //              (*i)->set_height (h);
355 //      }
356
357 }
358
359
360 gint
361 TimeAxisView::name_entry_button_press (GdkEventButton *ev)
362 {
363         if (ev->button == 3) {
364                 return do_not_propagate (ev);
365         }
366         return FALSE;
367 }
368
369 gint
370 TimeAxisView::name_entry_button_release (GdkEventButton *ev)
371 {
372         if (ev->button == 3) {
373                 popup_display_menu (ev->time);
374                 return stop_signal (name_entry, "button_release_event");
375         }
376         return FALSE;
377 }
378
379 void
380 TimeAxisView::popup_display_menu (guint32 when)
381 {
382         if (display_menu == 0) {
383                 build_display_menu ();
384         }
385         display_menu->popup (1, when);  
386 }
387
388 gint
389 TimeAxisView::size_click (GdkEventButton *ev)
390 {
391         popup_size_menu (ev->time);
392         return TRUE;
393 }
394
395 void
396 TimeAxisView::popup_size_menu (guint32 when)
397 {
398         if (size_menu == 0) {
399                 build_size_menu ();
400         }
401         size_menu->popup (1, when);
402 }
403
404 void
405 TimeAxisView::set_selected (bool yn)
406 {
407         AxisView::set_selected (yn);
408
409         if (_selected) {
410                 controls_ebox.set_name (controls_base_selected_name);
411                 controls_frame.set_name (controls_base_selected_name);
412
413                 /* propagate any existing selection, if the mode is right */
414
415                 if (editor.current_mouse_mode() == Editing::MouseRange && !editor.get_selection().time.empty()) {
416                         show_selection (editor.get_selection().time);
417                 }
418
419         } else {
420                 controls_ebox.set_name (controls_base_unselected_name);
421                 controls_frame.set_name (controls_base_unselected_name);
422
423                 hide_selection ();
424
425                 /* children will be set for the yn=true case. but when deselecting
426                    the editor only has a list of top-level trackviews, so we
427                    have to do this here.
428                 */
429
430                 for (vector<TimeAxisView*>::iterator i = children.begin(); i != children.end(); ++i) {
431                         (*i)->set_selected (false);
432                 }
433
434                 
435         }
436 }
437
438 void
439 TimeAxisView::build_size_menu ()
440 {
441         using namespace Menu_Helpers;
442
443         size_menu = new Menu;
444         size_menu->set_name ("ArdourContextMenu");
445         MenuList& items = size_menu->items();
446         
447         items.push_back (MenuElem (_("Largest"), bind (mem_fun (*this, &TimeAxisView::set_height), Largest)));
448         items.push_back (MenuElem (_("Large"), bind (mem_fun (*this, &TimeAxisView::set_height), Large)));
449         items.push_back (MenuElem (_("Larger"), bind (mem_fun (*this, &TimeAxisView::set_height), Larger)));
450         items.push_back (MenuElem (_("Normal"), bind (mem_fun (*this, &TimeAxisView::set_height), Normal)));
451         items.push_back (MenuElem (_("Smaller"), bind (mem_fun (*this, &TimeAxisView::set_height), Smaller)));
452         items.push_back (MenuElem (_("Small"), bind (mem_fun (*this, &TimeAxisView::set_height), Small)));
453 }
454
455 void
456 TimeAxisView::build_display_menu ()
457 {
458         using namespace Menu_Helpers;
459
460         display_menu = new Menu;
461         display_menu->set_name ("ArdourContextMenu");
462
463         // Just let implementing classes define what goes into the manu
464 }
465
466 void
467 TimeAxisView::set_samples_per_unit (double spu)
468 {
469         for (vector<TimeAxisView*>::iterator i = children.begin(); i != children.end(); ++i) {
470                 (*i)->set_samples_per_unit (spu);
471         }
472 }
473
474 void
475 TimeAxisView::show_timestretch (jack_nframes_t start, jack_nframes_t end)
476 {
477         for (vector<TimeAxisView*>::iterator i = children.begin(); i != children.end(); ++i) {
478                 (*i)->show_timestretch (start, end);
479         }
480 }
481
482 void
483 TimeAxisView::hide_timestretch ()
484 {
485         for (vector<TimeAxisView*>::iterator i = children.begin(); i != children.end(); ++i) {
486                 (*i)->hide_timestretch ();
487         }
488 }
489
490 void
491 TimeAxisView::show_selection (TimeSelection& ts)
492 {
493         double x1;
494         double x2;
495         double y2;
496         SelectionRect *rect;
497
498         for (vector<TimeAxisView*>::iterator i = children.begin(); i != children.end(); ++i) {
499                 (*i)->show_selection (ts);
500         }
501
502         if (GTK_OBJECT_FLAGS(GTK_OBJECT(selection_group)) & GNOME_CANVAS_ITEM_VISIBLE) {
503                 while (!used_selection_rects.empty()) {
504                         free_selection_rects.push_front (used_selection_rects.front());
505                         used_selection_rects.pop_front();
506                         gnome_canvas_item_hide (free_selection_rects.front()->rect);
507                         gnome_canvas_item_hide (free_selection_rects.front()->start_trim);
508                         gnome_canvas_item_hide (free_selection_rects.front()->end_trim);
509                 }
510                 gnome_canvas_item_hide (selection_group);
511         }
512
513         gnome_canvas_item_show (selection_group);
514         gnome_canvas_item_raise_to_top (selection_group);
515         
516         for (list<AudioRange>::iterator i = ts.begin(); i != ts.end(); ++i) {
517                 jack_nframes_t start, end, cnt;
518
519                 start = (*i).start;
520                 end = (*i).end;
521                 cnt = end - start + 1;
522
523                 rect = get_selection_rect ((*i).id);
524                 
525                 x1 = start / editor.get_current_zoom();
526                 x2 = (start + cnt - 1) / editor.get_current_zoom();
527                 y2 = height;
528
529                 gtk_object_set (GTK_OBJECT(rect->rect), 
530                                 "x1", x1,
531                                 "y1", 1.0,
532                                 "x2", x2,
533                                 "y2", y2,
534                                 NULL);
535                 
536                 // trim boxes are at the top for selections
537                 
538                 if (x2 > x1) {
539                         gtk_object_set (GTK_OBJECT(rect->start_trim), 
540                                         "x1", x1,
541                                         "y1", 1.0,
542                                         "x2", x1 + trim_handle_size,
543                                         "y2", 1.0 + trim_handle_size,
544                                         NULL);
545                         gtk_object_set (GTK_OBJECT(rect->end_trim), 
546                                         "x1", x2 - trim_handle_size,
547                                         "y1", 1.0,
548                                         "x2", x2,
549                                         "y2", 1.0 + trim_handle_size,
550                                         NULL);
551                         gnome_canvas_item_show (rect->start_trim);
552                         gnome_canvas_item_show (rect->end_trim);
553                 } else {
554                         gnome_canvas_item_hide (rect->start_trim);
555                         gnome_canvas_item_hide (rect->end_trim);
556                 }
557
558                 gnome_canvas_item_show (rect->rect);
559                 used_selection_rects.push_back (rect);
560         }
561 }
562
563 void
564 TimeAxisView::reshow_selection (TimeSelection& ts)
565 {
566         show_selection (ts);
567
568         for (vector<TimeAxisView*>::iterator i = children.begin(); i != children.end(); ++i) {
569                 (*i)->show_selection (ts);
570         }
571 }
572
573 void
574 TimeAxisView::hide_selection ()
575 {
576         if (GTK_OBJECT_FLAGS(GTK_OBJECT(selection_group)) & GNOME_CANVAS_ITEM_VISIBLE) {
577                 while (!used_selection_rects.empty()) {
578                         free_selection_rects.push_front (used_selection_rects.front());
579                         used_selection_rects.pop_front();
580                         gnome_canvas_item_hide (free_selection_rects.front()->rect);
581                         gnome_canvas_item_hide (free_selection_rects.front()->start_trim);
582                         gnome_canvas_item_hide (free_selection_rects.front()->end_trim);
583                 }
584                 gnome_canvas_item_hide (selection_group);
585         }
586         
587         for (vector<TimeAxisView*>::iterator i = children.begin(); i != children.end(); ++i) {
588                 (*i)->hide_selection ();
589         }
590 }
591
592 void
593 TimeAxisView::order_selection_trims (GnomeCanvasItem *item, bool put_start_on_top)
594 {
595         /* find the selection rect this is for. we have the item corresponding to one
596            of the trim handles.
597          */
598
599         for (list<SelectionRect*>::iterator i = used_selection_rects.begin(); i != used_selection_rects.end(); ++i) {
600                 if ((*i)->start_trim == item || (*i)->end_trim == item) {
601
602                         /* make one trim handle be "above" the other so that if they overlap,
603                            the top one is the one last used.
604                         */
605
606                         gnome_canvas_item_raise_to_top ((*i)->rect);
607                         gnome_canvas_item_raise_to_top (put_start_on_top ? (*i)->start_trim : (*i)->end_trim);
608                         gnome_canvas_item_raise_to_top (put_start_on_top ? (*i)->end_trim : (*i)->start_trim);
609
610                         break;
611                 }
612         }
613 }
614
615 SelectionRect *
616 TimeAxisView::get_selection_rect (uint32_t id)
617 {
618         SelectionRect *rect;
619
620         /* check to see if we already have a visible rect for this particular selection ID */
621
622         for (list<SelectionRect*>::iterator i = used_selection_rects.begin(); i != used_selection_rects.end(); ++i) {
623                 if ((*i)->id == id) {
624                         return (*i);
625                 }
626         }
627
628         /* ditto for the free rect list */
629
630         for (list<SelectionRect*>::iterator i = free_selection_rects.begin(); i != free_selection_rects.end(); ++i) {
631                 if ((*i)->id == id) {
632                         free_selection_rects.erase (i);
633                         return (*i);
634                 }
635         }
636
637         /* no existing matching rect, so go get a new one from the free list, or create one if there are none */
638         
639         if (free_selection_rects.empty()) {
640
641                 rect = new SelectionRect;
642
643                 rect->rect = gnome_canvas_item_new (GNOME_CANVAS_GROUP(selection_group),
644                                                   gnome_canvas_simplerect_get_type(),
645                                                   "x1", 0.0,
646                                                   "y1", 0.0,
647                                                   "x2", 0.0,
648                                                   "y2", 0.0,
649                                                   "fill_color_rgba", color_map[cSelectionRectFill],
650                                                   "outline_color_rgba" , color_map[cSelectionRectOutline],
651                                                   NULL);
652                 
653                 
654                 rect->start_trim = gnome_canvas_item_new (GNOME_CANVAS_GROUP(selection_group),
655                                                             gnome_canvas_simplerect_get_type(),
656                                                             "x1", (gdouble) 0.0,
657                                                             "x2", (gdouble) 0.0,
658                                                             "fill_color_rgba" , color_map[cSelectionStartFill],
659                                                             "outline_color_rgba" , color_map[cSelectionStartOutline],
660                                                             NULL);
661                 
662                 rect->end_trim = gnome_canvas_item_new (GNOME_CANVAS_GROUP(selection_group),
663                                                           gnome_canvas_simplerect_get_type(),
664                                                           "x1", 0.0,
665                                                           "x2", 0.0,
666                                                           "fill_color_rgba" , color_map[cSelectionEndFill],
667                                                           "outline_color_rgba" , color_map[cSelectionEndOutline],
668                                                           NULL);
669                 free_selection_rects.push_front (rect);
670
671                 gtk_signal_connect (GTK_OBJECT(rect->rect), "event",
672                                     (GtkSignalFunc) PublicEditor::canvas_selection_rect_event,
673                                     &editor);
674                 gtk_signal_connect (GTK_OBJECT(rect->start_trim), "event",
675                                     (GtkSignalFunc) PublicEditor::canvas_selection_start_trim_event,
676                                     &editor);
677                 gtk_signal_connect (GTK_OBJECT(rect->end_trim), "event",
678                                     (GtkSignalFunc) PublicEditor::canvas_selection_end_trim_event,
679                                     &editor);
680
681                 gtk_object_set_data(GTK_OBJECT(rect->rect), "rect", rect);
682                 gtk_object_set_data(GTK_OBJECT(rect->start_trim), "rect", rect);
683                 gtk_object_set_data(GTK_OBJECT(rect->end_trim), "rect", rect);
684         } 
685
686         rect = free_selection_rects.front();
687         rect->id = id;
688         free_selection_rects.pop_front();
689         return rect;
690 }
691
692 bool
693 TimeAxisView::is_child (TimeAxisView* tav)
694 {
695         return find (children.begin(), children.end(), tav) != children.end();
696 }
697
698 void
699 TimeAxisView::add_child (TimeAxisView* child)
700 {
701         children.push_back (child);
702 }
703
704 void
705 TimeAxisView::remove_child (TimeAxisView* child)
706 {
707         vector<TimeAxisView*>::iterator i;
708
709         if ((i = find (children.begin(), children.end(), child)) != children.end()) {
710                 children.erase (i);
711         }
712 }
713
714 void
715 TimeAxisView::get_selectables (jack_nframes_t start, jack_nframes_t end, double top, double bot, list<Selectable*>& result)
716 {
717         return;
718 }
719
720 void
721 TimeAxisView::get_inverted_selectables (Selection& sel, list<Selectable*>& result)
722 {
723         return;
724 }
725
726 bool
727 TimeAxisView::touched (double top, double bot)
728 {
729         /* remember: this is X Window - coordinate space starts in upper left and moves down.
730            y_position is the "origin" or "top" of the track.
731          */
732
733         double mybot = y_position + height; // XXX need to include Editor::track_spacing; 
734         
735         return ((y_position <= bot && y_position >= top) || 
736                 ((mybot <= bot) && (top < mybot)) || 
737                 (mybot >= bot && y_position < top));
738 }               
739
740 void
741 TimeAxisView::set_parent (TimeAxisView& p)
742 {
743         parent = &p;
744 }
745
746 bool
747 TimeAxisView::has_state () const
748 {
749         return _has_state;
750 }
751
752 TimeAxisView*
753 TimeAxisView::get_parent_with_state ()
754 {
755         if (parent == 0) {
756                 return 0;
757         }
758
759         if (parent->has_state()) {
760                 return parent;
761         } 
762
763         return parent->get_parent_with_state ();
764 }               
765
766 void
767 TimeAxisView::set_state (const XMLNode& node)
768 {
769         const XMLProperty *prop;
770
771         if ((prop = node.property ("track_height")) != 0) {
772
773                 if (prop->value() == "largest") {
774                         set_height (Largest);
775                 } else if (prop->value() == "large") {
776                         set_height (Large);
777                 } else if (prop->value() == "larger") {
778                         set_height (Larger);
779                 } else if (prop->value() == "normal") {
780                         set_height (Normal);
781                 } else if (prop->value() == "smaller") {
782                         set_height (Smaller);
783                 } else if (prop->value() == "small") {
784                         set_height (Small);
785                 } else {
786                         error << string_compose(_("unknown track height name \"%1\" in XML GUI information"), prop->value()) << endmsg;
787                         set_height (Normal);
788                 }
789
790         } else {
791                 set_height (Normal);
792         }
793 }
794
795 void
796 TimeAxisView::reset_height()
797 {
798         set_height ((TrackHeight) height);
799
800         for (vector<TimeAxisView*>::iterator i = children.begin(); i != children.end(); ++i) {
801                 (*i)->set_height ((TrackHeight)(*i)->height);
802         }
803 }
804