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