always compute range for a redirect automation line, even if it will not be drawn...
[ardour.git] / gtk2_ardour / ghostregion.cc
1 /*
2     Copyright (C) 2000-2007 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 */
19
20 #include "simplerect.h"
21 #include "waveview.h"
22 #include "ghostregion.h"
23 #include "automation_time_axis.h"
24 #include "rgb_macros.h"
25 #include "ardour_ui.h"
26
27 using namespace Editing;
28 using namespace ArdourCanvas;
29
30 GhostRegion::GhostRegion (AutomationTimeAxisView& atv, double initial_pos)
31         : trackview (atv)
32 {
33   //group = gnome_canvas_item_new (GNOME_CANVAS_GROUP(trackview.canvas_display),
34   //                         gnome_canvas_group_get_type(),
35   //                         "x", initial_pos,
36   //                         "y", 0.0,
37   //                         NULL);
38         group = new ArdourCanvas::Group (*trackview.canvas_display);
39         group->property_x() = initial_pos;
40         group->property_y() = 0.0;
41
42         base_rect = new ArdourCanvas::SimpleRect (*group);
43         base_rect->property_x1() = (double) 0.0;
44         base_rect->property_y1() = (double) 0.0;
45         base_rect->property_y2() = (double) trackview.current_height();
46         base_rect->property_outline_what() = (guint32) 0;
47         base_rect->property_outline_color_rgba() = ARDOUR_UI::config()->canvasvar_GhostTrackBase.get();
48         base_rect->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_GhostTrackBase.get();
49         group->lower_to_bottom ();
50
51         atv.add_ghost (this);
52 }
53
54 GhostRegion::~GhostRegion ()
55 {
56         GoingAway (this);
57         delete base_rect;
58         delete group;
59 }
60
61 void
62 GhostRegion::set_samples_per_unit (double spu)
63 {
64         for (vector<WaveView*>::iterator i = waves.begin(); i != waves.end(); ++i) {
65                 (*i)->property_samples_per_unit() = spu;
66         }               
67 }
68
69 void
70 GhostRegion::set_duration (double units)
71 {
72         base_rect->property_x2() = units;
73 }
74
75 void
76 GhostRegion::set_height ()
77 {
78         gdouble ht;
79         vector<WaveView*>::iterator i;
80         uint32_t n;
81
82         base_rect->property_y2() = (double) trackview.current_height();
83         ht = ((trackview.current_height()) / (double) waves.size());
84         
85         for (n = 0, i = waves.begin(); i != waves.end(); ++i, ++n) {
86                 gdouble yoff = n * ht;
87                 (*i)->property_height() = ht;
88                 (*i)->property_y() = yoff;
89         }
90 }
91
92 void
93 GhostRegion::set_colors ()
94 {
95         base_rect->property_outline_color_rgba() = ARDOUR_UI::config()->canvasvar_GhostTrackBase.get();
96         base_rect->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_GhostTrackBase.get();
97
98     for (uint32_t n=0; n < waves.size(); ++n) {
99         waves[n]->property_wave_color() = ARDOUR_UI::config()->canvasvar_GhostTrackWave.get();
100         waves[n]->property_fill_color() = ARDOUR_UI::config()->canvasvar_GhostTrackWave.get();
101
102         waves[n]->property_clip_color() = ARDOUR_UI::config()->canvasvar_GhostTrackWaveClip.get();
103         waves[n]->property_zero_color() = ARDOUR_UI::config()->canvasvar_GhostTrackZeroLine.get();
104     }
105 }