summaryrefslogtreecommitdiff
path: root/gtk2_ardour
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2005-11-15 03:12:16 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2005-11-15 03:12:16 +0000
commitbeb3ee233969b7a1a7863102d0d38484f327dae3 (patch)
tree53d971313be7736e83c37a8f1fcf2a717f0ad1aa /gtk2_ardour
parentb373ef6a243b0cf8fbb0ef7190f0631ee0cd8899 (diff)
fix sigc++ SConscript, get crossfade_edit.cc to compile
git-svn-id: svn://localhost/trunk/ardour2@97 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'gtk2_ardour')
-rw-r--r--gtk2_ardour/automation_time_axis.cc5
-rw-r--r--gtk2_ardour/crossfade_edit.cc442
-rw-r--r--gtk2_ardour/crossfade_edit.h31
-rw-r--r--gtk2_ardour/waveview.cc14
-rw-r--r--gtk2_ardour/waveview.h10
5 files changed, 224 insertions, 278 deletions
diff --git a/gtk2_ardour/automation_time_axis.cc b/gtk2_ardour/automation_time_axis.cc
index 4e548491e0..5339b0a02e 100644
--- a/gtk2_ardour/automation_time_axis.cc
+++ b/gtk2_ardour/automation_time_axis.cc
@@ -74,9 +74,8 @@ AutomationTimeAxisView::AutomationTimeAxisView (Session& s, Route& r, PublicEdit
base_rect->set_data ("trackview", this);
- gtk_signal_connect (GTK_OBJECT(base_rect), "event",
- (GtkSignalFunc) PublicEditor::canvas_automation_track_event,
- this);
+ base_rect->signal_event().connect (bind (mem_fun (editor, &PublicEditor::canvas_automation_track_event),
+ base_rect, this));
hide_button.add (*(manage (new Gtk::Image (Gdk::Pixbuf::create_from_xpm_data(small_x_xpm)))));
diff --git a/gtk2_ardour/crossfade_edit.cc b/gtk2_ardour/crossfade_edit.cc
index d999c823ac..f244e337f1 100644
--- a/gtk2_ardour/crossfade_edit.cc
+++ b/gtk2_ardour/crossfade_edit.cc
@@ -26,6 +26,8 @@
#include <gtkmm/image.h>
#include <gtkmm/scrolledwindow.h>
+#include <libgnomecanvasmm/line.h>
+
#include <ardour/automation_event.h>
#include <ardour/curve.h>
#include <ardour/crossfade.h>
@@ -39,11 +41,12 @@
#include "ardour_ui.h"
#include "crossfade_edit.h"
#include "rgb_macros.h"
-#include "canvas-simplerect.h"
-#include "canvas-waveview.h"
#include "keyboard.h"
#include "utils.h"
#include "gui_thread.h"
+#include "canvas_impl.h"
+#include "simplerect.h"
+#include "waveview.h"
using namespace std;
using namespace ARDOUR;
@@ -113,71 +116,38 @@ CrossfadeEditor::CrossfadeEditor (Session& s, Crossfade& xf, double my, double m
point_grabbed = false;
toplevel = 0;
- _canvas = gnome_canvas_new_aa ();
-
- canvas = Glib::wrap (_canvas);
+ canvas = new ArdourCanvas::CanvasAA ();
canvas->signal_size_allocate().connect (mem_fun(*this, &CrossfadeEditor::canvas_allocation));
canvas->set_size_request (425, 200);
-
- toplevel = gnome_canvas_item_new (gnome_canvas_root (GNOME_CANVAS(_canvas)),
- gnome_canvas_simplerect_get_type(),
- "x1", 0.0,
- "y1", 0.0,
- "x2", 10.0,
- "y2", 10.0,
- "fill", (gboolean) TRUE,
- "fill_color_rgba", (guint32) color_map[cCrossfadeEditorBase],
- "outline_pixels", 0,
- NULL);
-
- gtk_signal_connect (GTK_OBJECT(toplevel),
- "event",
- (GtkSignalFunc) _canvas_event,
- this);
-
- fade[Out].line = gnome_canvas_item_new (gnome_canvas_root (GNOME_CANVAS(_canvas)),
- gnome_canvas_line_get_type (),
- "width_pixels", (guint) 1,
- "fill_color_rgba", color_map[cCrossfadeEditorLine],
- NULL);
-
- fade[Out].shading = gnome_canvas_item_new (gnome_canvas_root (GNOME_CANVAS(_canvas)),
- gnome_canvas_polygon_get_type(),
- "fill_color_rgba", color_map[cCrossfadeEditorLineShading],
- NULL);
- fade[In].line = gnome_canvas_item_new (gnome_canvas_root (GNOME_CANVAS(_canvas)),
- gnome_canvas_line_get_type (),
- "width_pixels", (guint) 1,
- "fill_color_rgba", color_map[cCrossfadeEditorLine],
- NULL);
+ toplevel = new ArdourCanvas::SimpleRect (*(canvas->root()));
+ toplevel->property_x1() = 0.0;
+ toplevel->property_y1() = 0.0;
+ toplevel->property_x2() = 10.0;
+ toplevel->property_y2() = 10.0;
+ toplevel->property_fill() = true;
+ toplevel->property_fill_color_rgba() = (guint32) color_map[cCrossfadeEditorBase];
+ toplevel->property_outline_pixels() = 0;
+ toplevel->signal_event().connect (mem_fun (*this, &CrossfadeEditor::canvas_event));
- fade[In].shading = gnome_canvas_item_new (gnome_canvas_root (GNOME_CANVAS(_canvas)),
- gnome_canvas_polygon_get_type(),
- "fill_color_rgba", color_map[cCrossfadeEditorLineShading],
- NULL);
-
- gtk_signal_connect (GTK_OBJECT(fade[In].shading),
- "event",
- (GtkSignalFunc) _canvas_event,
- this);
-
-
- gtk_signal_connect (GTK_OBJECT(fade[Out].shading),
- "event",
- (GtkSignalFunc) _canvas_event,
- this);
-
- gtk_signal_connect (GTK_OBJECT(fade[In].line),
- "event",
- (GtkSignalFunc) _curve_event,
- this);
-
- gtk_signal_connect (GTK_OBJECT(fade[Out].line),
- "event",
- (GtkSignalFunc) _curve_event,
- this);
+ fade[Out].line = new ArdourCanvas::Line (*(canvas->root()));
+ fade[Out].line->property_width_pixels() = 1;
+ fade[Out].line->property_fill_color_rgba() = color_map[cCrossfadeEditorLine];
+
+ fade[Out].shading = new ArdourCanvas::Polygon (*(canvas->root()));
+ fade[Out].shading->property_fill_color_rgba() = color_map[cCrossfadeEditorLineShading];
+ fade[In].line = new ArdourCanvas::Line (*(canvas->root()));
+ fade[In].line->property_width_pixels() = 1;
+ fade[In].line->property_fill_color_rgba() = color_map[cCrossfadeEditorLine];
+
+ fade[In].shading = new ArdourCanvas::Polygon (*(canvas->root()));
+ fade[In].shading->property_fill_color_rgba() = color_map[cCrossfadeEditorLineShading];
+
+ fade[In].shading->signal_event().connect (mem_fun (*this, &CrossfadeEditor::canvas_event));
+ fade[In].line->signal_event().connect (mem_fun (*this, &CrossfadeEditor::curve_event));
+ fade[Out].shading->signal_event().connect (mem_fun (*this, &CrossfadeEditor::canvas_event));
+ fade[Out].line->signal_event().connect (mem_fun (*this, &CrossfadeEditor::curve_event));
select_in_button.set_name (X_("CrossfadeEditCurveButton"));
select_out_button.set_name (X_("CrossfadeEditCurveButton"));
@@ -416,15 +386,63 @@ CrossfadeEditor::set (const ARDOUR::Curve& curve, WhichFade which)
swap (which, current);
}
-gint
-CrossfadeEditor::_canvas_event (GnomeCanvasItem* item, GdkEvent* event, gpointer data)
+bool
+CrossfadeEditor::curve_event (GdkEvent* event)
+{
+ /* treat it like a toplevel event */
+
+ return canvas_event (event);
+}
+
+bool
+CrossfadeEditor::point_event (GdkEvent* event, Point* point)
{
- CrossfadeEditor* ed = static_cast<CrossfadeEditor*> (data);
- return ed->canvas_event (item, event);
+
+ if (point->curve != fade[current].line) {
+ return FALSE;
+ }
+
+ switch (event->type) {
+ case GDK_BUTTON_PRESS:
+ point_grabbed = true;
+ break;
+ case GDK_BUTTON_RELEASE:
+ point_grabbed = false;
+
+ if (Keyboard::is_delete_event (&event->button)) {
+ fade[current].points.remove (point);
+ delete point;
+ }
+
+ redraw ();
+ break;
+
+ case GDK_MOTION_NOTIFY:
+ if (point_grabbed) {
+ double new_x, new_y;
+
+ /* can't drag first or last points horizontally */
+
+ if (point == fade[current].points.front() || point == fade[current].points.back()) {
+ new_x = point->x;
+ } else {
+ new_x = (event->motion.x - canvas_border)/effective_width();
+ }
+
+ new_y = 1.0 - ((event->motion.y - canvas_border)/effective_height());
+ point->move_to (x_coordinate (new_x), y_coordinate (new_y),
+ new_x, new_y);
+ redraw ();
+ }
+ break;
+ default:
+ break;
+ }
+ return TRUE;
}
-gint
-CrossfadeEditor::canvas_event (GnomeCanvasItem* item, GdkEvent* event)
+bool
+CrossfadeEditor::canvas_event (GdkEvent* event)
{
switch (event->type) {
case GDK_BUTTON_PRESS:
@@ -448,20 +466,15 @@ CrossfadeEditor::make_point ()
{
Point* p = new Point;
- p->box = gnome_canvas_item_new (gnome_canvas_root (GNOME_CANVAS(_canvas)),
- gnome_canvas_simplerect_get_type(),
- "fill", (gboolean) TRUE,
- "fill_color_rgba", color_map[cCrossfadeEditorPointFill],
- "outline_color_rgba", color_map[cCrossfadeEditorPointOutline],
- "outline_pixels", (gint) 1,
- NULL);
+ p->box = new ArdourCanvas::SimpleRect (*(canvas->root()));
+ p->box->property_fill() = true;
+ p->box->property_fill_color_rgba() = color_map[cCrossfadeEditorPointFill];
+ p->box->property_outline_color_rgba() = color_map[cCrossfadeEditorPointOutline];
+ p->box->property_outline_pixels() = 1;
p->curve = fade[current].line;
- gtk_object_set_data (GTK_OBJECT(p->box), "point", p);
- gtk_signal_connect (GTK_OBJECT(p->box), "event",
- (GtkSignalFunc) _point_event,
- this);
+ p->box->signal_event().connect (bind (mem_fun (*this, &CrossfadeEditor::point_event), p));
return p;
}
@@ -496,12 +509,12 @@ CrossfadeEditor::Point::move_to (double nx, double ny, double xfract, double yfr
double x1 = nx - half_size;
double x2 = nx + half_size;
- gnome_canvas_item_set (box,
- "x1", x1,
- "x2", x2,
- "y1", ny - half_size,
- "y2", ny + half_size,
- NULL);
+ box->property_x1() = x1;
+ box->property_x2() = x2;
+
+ box->property_y1() = ny - half_size;
+ box->property_y2() = ny + half_size;
+
x = xfract;
y = yfract;
}
@@ -510,17 +523,15 @@ void
CrossfadeEditor::canvas_allocation (Gtk::Allocation& alloc)
{
if (toplevel) {
- gnome_canvas_item_set (toplevel,
- "x1", 0.0,
- "y1", 0.0,
- "x2", (double) _canvas->allocation.width + canvas_border,
- "y2", (double) _canvas->allocation.height + canvas_border,
- NULL);
+ toplevel->property_x1() = 0.0;
+ toplevel->property_y1() = 0.0;
+ toplevel->property_x2() = (double) canvas->get_allocation().get_width() + canvas_border;
+ toplevel->property_y2() = (double) canvas->get_allocation().get_height() + canvas_border;
}
-
- gnome_canvas_set_scroll_region (GNOME_CANVAS(_canvas), 0.0, 0.0,
- _canvas->allocation.width,
- _canvas->allocation.height);
+
+ canvas->set_scroll_region (0.0, 0.0,
+ canvas->get_allocation().get_width(),
+ canvas->get_allocation().get_height());
Point* end = make_point ();
PointSorter cmp;
@@ -590,108 +601,35 @@ CrossfadeEditor::canvas_allocation (Gtk::Allocation& alloc)
}
double ht;
- vector<GnomeCanvasItem*>::iterator i;
+ vector<ArdourCanvas::WaveView*>::iterator i;
uint32_t n;
- ht = _canvas->allocation.height / xfade.in().n_channels();
+ ht = canvas->get_allocation().get_height() / xfade.in().n_channels();
for (n = 0, i = fade[In].waves.begin(); i != fade[In].waves.end(); ++i, ++n) {
double yoff;
yoff = n * ht;
- gnome_canvas_item_set ((*i),
- "y", yoff,
- "height", ht,
- "samples_per_unit", spu,
- NULL);
+ (*i)->property_y() = yoff;
+ (*i)->property_height() = ht;
+ (*i)->property_samples_per_unit() = spu;
}
- ht = _canvas->allocation.height / xfade.out().n_channels();
+ ht = canvas->get_allocation().get_height() / xfade.out().n_channels();
for (n = 0, i = fade[Out].waves.begin(); i != fade[Out].waves.end(); ++i, ++n) {
double yoff;
yoff = n * ht;
- gnome_canvas_item_set ((*i),
- "y", yoff,
- "height", ht,
- "samples_per_unit", spu,
- NULL);
+ (*i)->property_y() = yoff;
+ (*i)->property_height() = ht;
+ (*i)->property_samples_per_unit() = spu;
}
}
-gint
-CrossfadeEditor::_point_event (GnomeCanvasItem* item, GdkEvent* event, gpointer data)
-{
- CrossfadeEditor* ed = static_cast<CrossfadeEditor*> (data);
- return ed->point_event (item, event);
-}
-
-gint
-CrossfadeEditor::point_event (GnomeCanvasItem* item, GdkEvent* event)
-{
- Point* point = static_cast<Point*> (gtk_object_get_data (GTK_OBJECT (item), "point"));
-
- if (point->curve != fade[current].line) {
- return FALSE;
- }
-
- switch (event->type) {
- case GDK_BUTTON_PRESS:
- point_grabbed = true;
- break;
- case GDK_BUTTON_RELEASE:
- point_grabbed = false;
-
- if (Keyboard::is_delete_event (&event->button)) {
- fade[current].points.remove (point);
- delete point;
- }
-
- redraw ();
- break;
-
- case GDK_MOTION_NOTIFY:
- if (point_grabbed) {
- double new_x, new_y;
-
- /* can't drag first or last points horizontally */
-
- if (point == fade[current].points.front() || point == fade[current].points.back()) {
- new_x = point->x;
- } else {
- new_x = (event->motion.x - canvas_border)/effective_width();
- }
-
- new_y = 1.0 - ((event->motion.y - canvas_border)/effective_height());
- point->move_to (x_coordinate (new_x), y_coordinate (new_y),
- new_x, new_y);
- redraw ();
- }
- break;
- default:
- break;
- }
- return TRUE;
-}
-
-gint
-CrossfadeEditor::_curve_event (GnomeCanvasItem* item, GdkEvent* event, gpointer data)
-{
- CrossfadeEditor* ed = static_cast<CrossfadeEditor*> (data);
- return ed->curve_event (item, event);
-}
-
-gint
-CrossfadeEditor::curve_event (GnomeCanvasItem* item, GdkEvent* event)
-{
- /* treat it like a toplevel event */
-
- return canvas_event (item, event);
-}
void
CrossfadeEditor::xfade_changed (Change ignored)
@@ -703,7 +641,7 @@ CrossfadeEditor::xfade_changed (Change ignored)
void
CrossfadeEditor::redraw ()
{
- if (_canvas->allocation.width < 2) {
+ if (canvas->get_allocation().get_width() < 2) {
return;
}
@@ -722,8 +660,16 @@ CrossfadeEditor::redraw ()
fade[current].normative_curve.get_vector (0, 1.0, vec, npoints);
- GnomeCanvasPoints* pts = get_canvas_points ("xfade edit1", npoints);
- GnomeCanvasPoints* spts = get_canvas_points ("xfade edit2", npoints + 3);
+ Gnome::Canvas::Points pts;
+ Gnome::Canvas::Points spts;
+
+ while (pts.size() < npoints) {
+ pts.push_back (Gnome::Art::Point (0,0));
+ }
+
+ while (spts.size() < npoints + 3) {
+ spts.push_back (Gnome::Art::Point (0,0));
+ }
/* the shade coordinates *MUST* be in anti-clockwise order.
*/
@@ -732,60 +678,59 @@ CrossfadeEditor::redraw ()
/* lower left */
- spts->coords[0] = canvas_border;
- spts->coords[1] = effective_height() + canvas_border;
+ spts[0].set_x (canvas_border);
+ spts[0].set_y (effective_height() + canvas_border);
/* lower right */
- spts->coords[2] = effective_width() + canvas_border;
- spts->coords[3] = effective_height() + canvas_border;
+ spts[1].set_x (effective_width() + canvas_border);
+ spts[1].set_y (effective_height() + canvas_border);
/* upper right */
- spts->coords[4] = effective_width() + canvas_border;
- spts->coords[5] = canvas_border;
+ spts[2].set_x (effective_width() + canvas_border);
+ spts[2].set_y (canvas_border);
} else {
/* upper left */
- spts->coords[0] = canvas_border;
- spts->coords[1] = canvas_border;
+ spts[0].set_x (canvas_border);
+ spts[0].set_y (canvas_border);
/* lower left */
- spts->coords[2] = canvas_border;
- spts->coords[3] = effective_height() + canvas_border;
+ spts[1].set_x (canvas_border);
+ spts[1].set_y (effective_height() + canvas_border);
/* lower right */
- spts->coords[4] = effective_width() + canvas_border;
- spts->coords[5] = effective_height() + canvas_border;
+ spts[2].set_x (effective_width() + canvas_border);
+ spts[2].set_y (effective_height() + canvas_border);
}
- size_t last_spt = ((npoints + 3) * 2) - 2;
+ // GTK2FIX some odd math to fix up here
+
+ size_t last_spt = (npoints + 3) - 1;
for (size_t i = 0; i < npoints; ++i) {
double y = vec[i];
- pts->coords[i*2] = canvas_border + i;
- pts->coords[(i*2)+1] = y_coordinate (y);
+ pts[i].set_x (canvas_border + i);
+ pts[i].set_y (y_coordinate (y));
- spts->coords[last_spt - (i*2)] = canvas_border + i;
- spts->coords[last_spt - (i*2) + 1] = pts->coords[(i*2)+1];
+ spts[last_spt - i].set_x (canvas_border + i);
+ spts[last_spt - i].set_y (pts[i].get_y());
}
- gnome_canvas_item_set (fade[current].line, "points", pts, NULL);
- gnome_canvas_item_set (fade[current].shading, "points", spts, NULL);
+ fade[current].line->property_points() = pts;
+ fade[current].shading->property_points() = spts;
- gnome_canvas_points_unref (pts);
- gnome_canvas_points_unref (spts);
-
- for (vector<GnomeCanvasItem*>::iterator i = fade[current].waves.begin(); i != fade[current].waves.end(); ++i) {
- gnome_canvas_item_set ((*i), "gain_src", &fade[current].gain_curve, NULL);
+ for (vector<Gnome::Canvas::WaveView*>::iterator i = fade[current].waves.begin(); i != fade[current].waves.end(); ++i) {
+ (*i)->property_gain_src() = &fade[current].gain_curve;
}
}
@@ -1000,28 +945,28 @@ void
CrossfadeEditor::curve_select_clicked (WhichFade wf)
{
current = wf;
-
+
if (wf == In) {
-
- for (vector<GnomeCanvasItem*>::iterator i = fade[In].waves.begin(); i != fade[In].waves.end(); ++i) {
- gnome_canvas_item_set ((*i), "wave_color", color_map[cSelectedCrossfadeEditorWave], NULL);
+
+ for (vector<ArdourCanvas::WaveView*>::iterator i = fade[In].waves.begin(); i != fade[In].waves.end(); ++i) {
+ (*i)->property_wave_color() = color_map[cSelectedCrossfadeEditorWave];
}
- for (vector<GnomeCanvasItem*>::iterator i = fade[Out].waves.begin(); i != fade[Out].waves.end(); ++i) {
- gnome_canvas_item_set ((*i), "wave_color", color_map[cCrossfadeEditorWave], NULL);
+ for (vector<ArdourCanvas::WaveView*>::iterator i = fade[Out].waves.begin(); i != fade[Out].waves.end(); ++i) {
+ (*i)->property_wave_color() = color_map[cCrossfadeEditorWave];
}
- gnome_canvas_item_set (fade[In].line, "fill_color_rgba", color_map[cSelectedCrossfadeEditorLine], NULL);
- gnome_canvas_item_set (fade[Out].line, "fill_color_rgba", color_map[cCrossfadeEditorLine], NULL);
- gnome_canvas_item_hide (fade[Out].shading);
- gnome_canvas_item_show (fade[In].shading);
+ fade[In].line->property_fill_color_rgba() = color_map[cSelectedCrossfadeEditorLine];
+ fade[Out].line->property_fill_color_rgba() = color_map[cCrossfadeEditorLine];
+ fade[Out].shading->hide();
+ fade[In].shading->show();
for (list<Point*>::iterator i = fade[Out].points.begin(); i != fade[Out].points.end(); ++i) {
- gnome_canvas_item_hide ((*i)->box);
+ (*i)->box->hide();
}
for (list<Point*>::iterator i = fade[In].points.begin(); i != fade[In].points.end(); ++i) {
- gnome_canvas_item_show ((*i)->box);
+ (*i)->box->show ();
}
for (vector<Button*>::iterator i = fade_out_buttons.begin(); i != fade_out_buttons.end(); ++i) {
@@ -1034,25 +979,25 @@ CrossfadeEditor::curve_select_clicked (WhichFade wf)
} else {
- for (vector<GnomeCanvasItem*>::iterator i = fade[In].waves.begin(); i != fade[In].waves.end(); ++i) {
- gnome_canvas_item_set ((*i), "wave_color", color_map[cCrossfadeEditorWave], NULL);
+ for (vector<ArdourCanvas::WaveView*>::iterator i = fade[In].waves.begin(); i != fade[In].waves.end(); ++i) {
+ (*i)->property_wave_color() = color_map[cCrossfadeEditorWave];
}
- for (vector<GnomeCanvasItem*>::iterator i = fade[Out].waves.begin(); i != fade[Out].waves.end(); ++i) {
- gnome_canvas_item_set ((*i), "wave_color", color_map[cSelectedCrossfadeEditorWave], NULL);
+ for (vector<ArdourCanvas::WaveView*>::iterator i = fade[Out].waves.begin(); i != fade[Out].waves.end(); ++i) {
+ (*i)->property_wave_color() = color_map[cSelectedCrossfadeEditorWave];
}
- gnome_canvas_item_set (fade[Out].line, "fill_color_rgba", color_map[cSelectedCrossfadeEditorLine], NULL);
- gnome_canvas_item_set (fade[In].line, "fill_color_rgba", color_map[cCrossfadeEditorLine], NULL);
- gnome_canvas_item_hide (fade[In].shading);
- gnome_canvas_item_show (fade[Out].shading);
+ fade[Out].line->property_fill_color_rgba() = color_map[cSelectedCrossfadeEditorLine];
+ fade[In].line->property_fill_color_rgba() = color_map[cCrossfadeEditorLine];
+ fade[In].shading->hide();
+ fade[Out].shading->show();
for (list<Point*>::iterator i = fade[In].points.begin(); i != fade[In].points.end(); ++i) {
- gnome_canvas_item_hide ((*i)->box);
+ (*i)->box->hide();
}
for (list<Point*>::iterator i = fade[Out].points.begin(); i != fade[Out].points.end(); ++i) {
- gnome_canvas_item_show ((*i)->box);
+ (*i)->box->hide();
}
for (vector<Button*>::iterator i = fade_out_buttons.begin(); i != fade_out_buttons.end(); ++i) {
@@ -1081,7 +1026,7 @@ CrossfadeEditor::y_coordinate (double& yfract) const
yfract = min (1.0, yfract);
yfract = max (0.0, yfract);
- return (_canvas->allocation.height - (canvas_border)) - (yfract * effective_height());
+ return (canvas->get_allocation().get_height() - (canvas_border)) - (yfract * effective_height());
}
void
@@ -1098,7 +1043,7 @@ CrossfadeEditor::make_waves (AudioRegion& region, WhichFade which)
color = color_map[cCrossfadeEditorWave];
}
- ht = _canvas->allocation.height / (double) nchans;
+ ht = canvas->get_allocation().get_height() / (double) nchans;
spu = xfade.length() / (double) effective_width();
for (uint32_t n = 0; n < nchans; ++n) {
@@ -1107,31 +1052,30 @@ CrossfadeEditor::make_waves (AudioRegion& region, WhichFade which)
if (region.source(n).peaks_ready (bind (mem_fun(*this, &CrossfadeEditor::peaks_ready), &region, which))) {
- GnomeCanvasItem *wave = gnome_canvas_item_new (gnome_canvas_root (GNOME_CANVAS(_canvas)),
- gnome_canvas_waveview_get_type (),
- "data_src", (gpointer) &region,
- "cache_updater", (gboolean) TRUE,
- "cache", gnome_canvas_waveview_cache_new (),
- "channel", (guint32) n,
- "length_function", (gpointer) region_length_from_c,
- "sourcefile_length_function", (gpointer) sourcefile_length_from_c,
- "peak_function", (gpointer) region_read_peaks_from_c,
- "gain_function", (gpointer) curve_get_vector_from_c,
- "gain_src", &fade[which].gain_curve,
- "x", (double) canvas_border,
- "y", yoff,
- "height", ht,
- "samples_per_unit", spu,
- "amplitude_above_axis", 2.0,
- "wave_color", color,
- NULL);
+ WaveView* waveview = new WaveView (*(canvas->root()));
+
+ waveview->property_data_src() = &region;
+ waveview->property_cache_updater() = true;
+ waveview->property_cache() = WaveView::create_cache();
+ waveview->property_channel() = n;
+ waveview->property_length_function() = (void*) region_length_from_c;
+ waveview->property_sourcefile_length_function() = (void*) sourcefile_length_from_c;
+ waveview->property_peak_function() = (void*) region_read_peaks_from_c;
+ waveview->property_gain_function() = (void*) curve_get_vector_from_c;
+ waveview->property_gain_src() = &fade[which].gain_curve;
+ waveview->property_x() = canvas_border;
+ waveview->property_y() = yoff;
+ waveview->property_height() = ht;
+ waveview->property_samples_per_unit() = spu;
+ waveview->property_amplitude_above_axis() = 2.0;
+ waveview->property_wave_color() = color;
- gnome_canvas_item_lower_to_bottom (wave);
- fade[which].waves.push_back (wave);
+ waveview->lower_to_bottom();
+ fade[which].waves.push_back (waveview);
}
}
- gnome_canvas_item_lower_to_bottom (toplevel);
+ toplevel->lower_to_bottom();
}
void
diff --git a/gtk2_ardour/crossfade_edit.h b/gtk2_ardour/crossfade_edit.h
index 0c3bca97ba..d3c509ca4b 100644
--- a/gtk2_ardour/crossfade_edit.h
+++ b/gtk2_ardour/crossfade_edit.h
@@ -6,10 +6,10 @@
#include <gtkmm/box.h>
#include <gtkmm/button.h>
#include <gtkmm/radiobutton.h>
-#include <libgnomecanvas/libgnomecanvas.h>
#include <ardour/curve.h>
#include "ardour_dialog.h"
+#include "canvas.h"
namespace ARDOUR
{
@@ -63,8 +63,8 @@ class CrossfadeEditor : public ArdourDialog
struct Point {
~Point();
- GnomeCanvasItem* box;
- GnomeCanvasItem* curve;
+ ArdourCanvas::SimpleRect* box;
+ ArdourCanvas::Line* curve;
double x;
double y;
@@ -80,17 +80,16 @@ class CrossfadeEditor : public ArdourDialog
}
};
- GtkWidget* _canvas;
- GnomeCanvasItem* toplevel;
- Gtk::Widget* canvas;
+ ArdourCanvas::SimpleRect* toplevel;
+ ArdourCanvas::Canvas* canvas;
struct Half {
- GnomeCanvasItem* line;
- GnomeCanvasItem* shading;
+ ArdourCanvas::Line* line;
+ ArdourCanvas::Polygon* shading;
list<Point*> points;
ARDOUR::Curve normative_curve; /* 0 - 1.0, linear */
ARDOUR::Curve gain_curve; /* 0 - 2.0, gain mapping */
- vector<GnomeCanvasItem*> waves;
+ vector<ArdourCanvas::WaveView*> waves;
Half();
};
@@ -127,21 +126,17 @@ class CrossfadeEditor : public ArdourDialog
gint event_handler (GdkEvent*);
- static gint _canvas_event (GnomeCanvasItem*, GdkEvent* event, gpointer data);
- static gint _point_event (GnomeCanvasItem*, GdkEvent* event, gpointer data);
- static gint _curve_event (GnomeCanvasItem*, GdkEvent* event, gpointer data);
-
- gint canvas_event (GnomeCanvasItem*, GdkEvent* event);
- gint point_event (GnomeCanvasItem*, GdkEvent* event);
- gint curve_event (GnomeCanvasItem*, GdkEvent* event);
+ bool canvas_event (GdkEvent* event);
+ bool point_event (GdkEvent* event, Point*);
+ bool curve_event (GdkEvent* event);
void canvas_allocation (Gtk::Allocation&);
void add_control_point (double x, double y);
Point* make_point ();
void redraw ();
- double effective_width () const { return _canvas->allocation.width - (2.0 * canvas_border); }
- double effective_height () const { return _canvas->allocation.height - (2.0 * canvas_border); }
+ double effective_width () const { return canvas->get_allocation().get_width() - (2.0 * canvas_border); }
+ double effective_height () const { return canvas->get_allocation().get_height() - (2.0 * canvas_border); }
void clear ();
void reset ();
diff --git a/gtk2_ardour/waveview.cc b/gtk2_ardour/waveview.cc
index b84edd03e0..9c2fa409f6 100644
--- a/gtk2_ardour/waveview.cc
+++ b/gtk2_ardour/waveview.cc
@@ -126,6 +126,12 @@ GType WaveView::get_base_type()
return gnome_canvas_waveview_get_type();
}
+void*
+WaveView::create_cache ()
+{
+ return gnome_canvas_waveview_cache_new ();
+}
+
Glib::PropertyProxy<void*> WaveView::property_data_src()
{
return Glib::PropertyProxy<void*> (this, "data-src");
@@ -134,11 +140,11 @@ Glib::PropertyProxy_ReadOnly<void*> WaveView::property_data_src() const
{
return Glib::PropertyProxy_ReadOnly<void*> (this, "data-src");
}
-Glib::PropertyProxy<void*> WaveView::property_channel()
+Glib::PropertyProxy<uint32_t*> WaveView::property_channel()
{
return Glib::PropertyProxy<void*> (this, "channel");
}
-Glib::PropertyProxy_ReadOnly<void*> WaveView::property_channel() const
+Glib::PropertyProxy_ReadOnly<uint32_t*> WaveView::property_channel() const
{
return Glib::PropertyProxy_ReadOnly<void*> (this, "channel");
}
@@ -190,11 +196,11 @@ Glib::PropertyProxy_ReadOnly<void*> WaveView::property_cache() const
{
return Glib::PropertyProxy_ReadOnly<void*> (this, "cache");
}
-Glib::PropertyProxy<void*> WaveView::property_cache_updater()
+Glib::PropertyProxy<bool> WaveView::property_cache_updater()
{
return Glib::PropertyProxy<void*> (this, "cache-updater");
}
-Glib::PropertyProxy_ReadOnly<void*> WaveView::property_cache_updater() const
+Glib::PropertyProxy_ReadOnly<bool> WaveView::property_cache_updater() const
{
return Glib::PropertyProxy_ReadOnly<void*> (this, "cache-updater");
}
diff --git a/gtk2_ardour/waveview.h b/gtk2_ardour/waveview.h
index 047d125cdd..87e38fe1da 100644
--- a/gtk2_ardour/waveview.h
+++ b/gtk2_ardour/waveview.h
@@ -111,10 +111,12 @@ private:
public:
WaveView(Group& parent);
+ static void* create_cache();
+
Glib::PropertyProxy<void*> property_data_src();
Glib::PropertyProxy_ReadOnly<void*> property_data_src() const;
- Glib::PropertyProxy<void*> property_channel();
- Glib::PropertyProxy_ReadOnly<void*> property_channel() const;
+ Glib::PropertyProxy<uint32_t> property_channel();
+ Glib::PropertyProxy_ReadOnly<uint32_t> property_channel() const;
Glib::PropertyProxy<void*> property_length_function();
Glib::PropertyProxy_ReadOnly<void*> property_length_function() const;
Glib::PropertyProxy<void*> property_sourcefile_length_function();
@@ -127,8 +129,8 @@ public:
Glib::PropertyProxy_ReadOnly<void*> property_gain_src() const;
Glib::PropertyProxy<void*> property_cache();
Glib::PropertyProxy_ReadOnly<void*> property_cache() const;
- Glib::PropertyProxy<void*> property_cache_updater();
- Glib::PropertyProxy_ReadOnly<void*> property_cache_updater() const;
+ Glib::PropertyProxy<bool> property_cache_updater();
+ Glib::PropertyProxy_ReadOnly<bool> property_cache_updater() const;
Glib::PropertyProxy<double> property_samples_per_unit();
Glib::PropertyProxy_ReadOnly<double> property_samples_per_unit() const;
Glib::PropertyProxy<double> property_amplitude_above_axis();