2 cleanup patches from nickm, plus work on mixer_ui.cc so that it compiles
[ardour.git] / gtk2_ardour / ghostregion.cc
1 #include "canvas-simplerect.h"
2 #include "ghostregion.h"
3 #include "automation_time_axis.h"
4 #include "rgb_macros.h"
5
6 using namespace Editing;
7
8 GhostRegion::GhostRegion (AutomationTimeAxisView& atv, double initial_pos)
9         : trackview (atv)
10 {
11         group = gnome_canvas_item_new (GNOME_CANVAS_GROUP(trackview.canvas_display),
12                                      gnome_canvas_group_get_type(),
13                                      "x", initial_pos,
14                                      "y", 0.0,
15                                      NULL);
16
17         base_rect = gnome_canvas_item_new (GNOME_CANVAS_GROUP(group),
18                                          gnome_canvas_simplerect_get_type(),
19                                          "x1", (double) 0.0,
20                                          "y1", (double) 0.0,
21                                          "y2", (double) trackview.height,
22                                          "outline_what", (guint32) 0,
23                                          "outline_color_rgba", color_map[cGhostTrackBaseOutline],
24                                          "fill_color_rgba", color_map[cGhostTrackBaseFill],
25                                          NULL);
26
27         gnome_canvas_item_lower_to_bottom (group);
28
29         atv.add_ghost (this);
30 }
31
32 GhostRegion::~GhostRegion ()
33 {
34         GoingAway (this);
35         gtk_object_destroy (GTK_OBJECT(group));
36 }
37
38 void
39 GhostRegion::set_samples_per_unit (double spu)
40 {
41         for (vector<GnomeCanvasItem*>::iterator i = waves.begin(); i != waves.end(); ++i) {
42                 gnome_canvas_item_set ((*i), "samples_per_unit", spu, NULL);
43         }               
44 }
45
46 void
47 GhostRegion::set_duration (double units)
48 {
49         gnome_canvas_item_set (base_rect, "x2", units, NULL);
50 }
51
52 void
53 GhostRegion::set_height ()
54 {
55         gdouble ht;
56         vector<GnomeCanvasItem*>::iterator i;
57         uint32_t n;
58
59         gnome_canvas_item_set (base_rect, "y2", (double) trackview.height, NULL);
60
61         ht = ((trackview.height) / (double) waves.size());
62         
63         for (n = 0, i = waves.begin(); i != waves.end(); ++i, ++n) {
64                 gdouble yoff = n * ht;
65                 gnome_canvas_item_set ((*i), "height", ht, "y", yoff, NULL);
66         }
67 }
68