Superficial code cleanup.

git-svn-id: svn://localhost/ardour2/branches/3.0@3804 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
David Robillard 2008-09-24 19:39:01 +00:00
parent 8d3d196440
commit 10d57b266c
6 changed files with 90 additions and 104 deletions

View file

@ -66,7 +66,7 @@ CanvasNoteEvent::move_event(double dx, double dy)
} }
void void
CanvasNoteEvent::show_velocity(void) CanvasNoteEvent::show_velocity()
{ {
hide_velocity(); hide_velocity();
_text = new Text(*(_item->property_parent())); _text = new Text(*(_item->property_parent()));
@ -83,9 +83,9 @@ CanvasNoteEvent::show_velocity(void)
} }
void void
CanvasNoteEvent::hide_velocity(void) CanvasNoteEvent::hide_velocity()
{ {
if(_text) { if (_text) {
_text->hide(); _text->hide();
delete _text; delete _text;
} }

View file

@ -34,7 +34,7 @@ namespace Gnome {
class Line; class Line;
class Points; class Points;
class ImageFrame; class ImageFrame;
class Lineset; class LineSet;
} }
} }

View file

@ -31,11 +31,11 @@ using namespace std;
namespace Gnome { namespace Gnome {
namespace Canvas { namespace Canvas {
LinesetClass Lineset::lineset_class; LineSetClass LineSet::lineset_class;
//static const char* overlap_error_str = "Lineset error: Line overlap"; //static const char* overlap_error_str = "LineSet error: Line overlap";
Lineset::Line::Line(double c, double w, uint32_t color) LineSet::Line::Line(double c, double w, uint32_t color)
: coord(c) : coord(c)
, width(w) , width(w)
{ {
@ -43,22 +43,22 @@ Lineset::Line::Line(double c, double w, uint32_t color)
} }
/* Constructor for dummy lines that are used only with the coordinate */ /* Constructor for dummy lines that are used only with the coordinate */
Lineset::Line::Line(double c) LineSet::Line::Line(double c)
: coord(c) : coord(c)
{ {
} }
void void
Lineset::Line::set_color(uint32_t color) LineSet::Line::set_color(uint32_t color)
{ {
UINT_TO_RGBA (color, &r, &g, &b, &a); UINT_TO_RGBA (color, &r, &g, &b, &a);
} }
const Glib::Class& const Glib::Class&
LinesetClass::init() LineSetClass::init()
{ {
if (!gtype_) { if (!gtype_) {
class_init_func_ = &LinesetClass::class_init_function; class_init_func_ = &LineSetClass::class_init_function;
register_derived_type(Item::get_type()); register_derived_type(Item::get_type());
} }
@ -66,12 +66,12 @@ LinesetClass::init()
} }
void void
LinesetClass::class_init_function(void* g_class, void* class_data) LineSetClass::class_init_function(void* g_class, void* class_data)
{ {
} }
Lineset::Lineset(Group& parent, Orientation o) LineSet::LineSet(Group& parent, Orientation o)
: Glib::ObjectBase("GnomeCanvasLineset") : Glib::ObjectBase("GnomeCanvasLineSet")
, Item(Glib::ConstructParams(lineset_class.init())) , Item(Glib::ConstructParams(lineset_class.init()))
, cached_pos(lines.end()) , cached_pos(lines.end())
, orientation(o) , orientation(o)
@ -89,24 +89,24 @@ Lineset::Lineset(Group& parent, Orientation o)
item_construct(parent); item_construct(parent);
property_x1().signal_changed().connect(mem_fun(*this, &Lineset::bounds_need_update)); property_x1().signal_changed().connect(mem_fun(*this, &LineSet::bounds_need_update));
property_y1().signal_changed().connect(mem_fun(*this, &Lineset::bounds_need_update)); property_y1().signal_changed().connect(mem_fun(*this, &LineSet::bounds_need_update));
property_x2().signal_changed().connect(mem_fun(*this, &Lineset::bounds_need_update)); property_x2().signal_changed().connect(mem_fun(*this, &LineSet::bounds_need_update));
property_y2().signal_changed().connect(mem_fun(*this, &Lineset::bounds_need_update)); property_y2().signal_changed().connect(mem_fun(*this, &LineSet::bounds_need_update));
} }
Lineset::~Lineset() LineSet::~LineSet()
{ {
} }
bool bool
Lineset::line_compare(const Line& a, const Line& b) LineSet::line_compare(const Line& a, const Line& b)
{ {
return a.coord < b.coord; return a.coord < b.coord;
} }
void void
Lineset::print_lines() LineSet::print_lines()
{ {
for (Lines::iterator it = lines.begin(); it != lines.end(); ++it) for (Lines::iterator it = lines.begin(); it != lines.end(); ++it)
{ {
@ -115,7 +115,7 @@ Lineset::print_lines()
} }
void void
Lineset::move_line(double coord, double dest) LineSet::move_line(double coord, double dest)
{ {
if (coord == dest) { if (coord == dest) {
return; return;
@ -142,7 +142,7 @@ Lineset::move_line(double coord, double dest)
} }
void void
Lineset::change_line_width(double coord, double width) LineSet::change_line_width(double coord, double width)
{ {
Lines::iterator it = line_at(coord); Lines::iterator it = line_at(coord);
@ -163,7 +163,7 @@ Lineset::change_line_width(double coord, double width)
} }
void void
Lineset::change_line_color(double coord, uint32_t color) LineSet::change_line_color(double coord, uint32_t color)
{ {
Lines::iterator it = line_at(coord); Lines::iterator it = line_at(coord);
@ -174,7 +174,7 @@ Lineset::change_line_color(double coord, uint32_t color)
} }
void void
Lineset::add_line(double coord, double width, uint32_t color) LineSet::add_line(double coord, double width, uint32_t color)
{ {
Line l(coord, width, color); Line l(coord, width, color);
@ -201,7 +201,7 @@ Lineset::add_line(double coord, double width, uint32_t color)
} }
void void
Lineset::remove_line(double coord) LineSet::remove_line(double coord)
{ {
Lines::iterator it = line_at(coord); Lines::iterator it = line_at(coord);
@ -216,7 +216,7 @@ Lineset::remove_line(double coord)
} }
void void
Lineset::remove_lines(double c1, double c2) LineSet::remove_lines(double c1, double c2)
{ {
if (!lines.empty()) { if (!lines.empty()) {
region_needs_update(c1, c2); region_needs_update(c1, c2);
@ -224,7 +224,7 @@ Lineset::remove_lines(double c1, double c2)
} }
void void
Lineset::remove_until(double coord) LineSet::remove_until(double coord)
{ {
if (!lines.empty()) { if (!lines.empty()) {
double first = lines.front().coord; double first = lines.front().coord;
@ -236,7 +236,7 @@ Lineset::remove_until(double coord)
} }
void void
Lineset::remove_from(double coord) LineSet::remove_from(double coord)
{ {
if (!lines.empty()) { if (!lines.empty()) {
double last = lines.back().coord + lines.back().width; double last = lines.back().coord + lines.back().width;
@ -248,7 +248,7 @@ Lineset::remove_from(double coord)
} }
void void
Lineset::clear() LineSet::clear()
{ {
if (!lines.empty()) { if (!lines.empty()) {
double coord1 = lines.front().coord; double coord1 = lines.front().coord;
@ -263,8 +263,8 @@ Lineset::clear()
* this function is optimized to work faster if we access elements that are adjacent to each other. * this function is optimized to work faster if we access elements that are adjacent to each other.
* so if a large number of lines are modified, it is wise to modify them in sorted order. * so if a large number of lines are modified, it is wise to modify them in sorted order.
*/ */
Lineset::Lines::iterator LineSet::Lines::iterator
Lineset::line_at(double coord) LineSet::line_at(double coord)
{ {
if (cached_pos != lines.end()) { if (cached_pos != lines.end()) {
if (coord < cached_pos->coord) { if (coord < cached_pos->coord) {
@ -323,13 +323,13 @@ Lineset::line_at(double coord)
} }
void void
Lineset::redraw_request(ArtIRect& r) LineSet::redraw_request(ArtIRect& r)
{ {
get_canvas()->request_redraw(r.x0, r.y0, r.x1, r.y1); get_canvas()->request_redraw(r.x0, r.y0, r.x1, r.y1);
} }
void void
Lineset::redraw_request(ArtDRect& r) LineSet::redraw_request(ArtDRect& r)
{ {
int x0, y0, x1, y1; int x0, y0, x1, y1;
Canvas& cv = *get_canvas(); Canvas& cv = *get_canvas();
@ -342,7 +342,7 @@ Lineset::redraw_request(ArtDRect& r)
} }
void void
Lineset::update_lines(bool need_redraw) LineSet::update_lines(bool need_redraw)
{ {
//cerr << "update_lines need_redraw=" << need_redraw << endl; //cerr << "update_lines need_redraw=" << need_redraw << endl;
if (!need_redraw) { if (!need_redraw) {
@ -353,7 +353,7 @@ Lineset::update_lines(bool need_redraw)
if (update_region2 > update_region1) { if (update_region2 > update_region1) {
ArtDRect redraw; ArtDRect redraw;
Lineset::bounds_vfunc(&redraw.x0, &redraw.y0, &redraw.x1, &redraw.y1); LineSet::bounds_vfunc(&redraw.x0, &redraw.y0, &redraw.x1, &redraw.y1);
i2w(redraw.x0, redraw.y0); i2w(redraw.x0, redraw.y0);
i2w(redraw.x1, redraw.y1); i2w(redraw.x1, redraw.y1);
@ -379,7 +379,7 @@ Lineset::update_lines(bool need_redraw)
* return true if nothing or only parts of the rect area has been requested for redraw * return true if nothing or only parts of the rect area has been requested for redraw
*/ */
bool bool
Lineset::update_bounds() LineSet::update_bounds()
{ {
GnomeCanvasItem* item = GNOME_CANVAS_ITEM(gobj()); GnomeCanvasItem* item = GNOME_CANVAS_ITEM(gobj());
ArtDRect old_b; ArtDRect old_b;
@ -392,7 +392,7 @@ Lineset::update_bounds()
old_b.y0 = item->y1; old_b.y0 = item->y1;
old_b.x1 = item->x2; old_b.x1 = item->x2;
old_b.y1 = item->y2; old_b.y1 = item->y2;
Lineset::bounds_vfunc(&new_b.x0, &new_b.y0, &new_b.x1, &new_b.y1); LineSet::bounds_vfunc(&new_b.x0, &new_b.y0, &new_b.x1, &new_b.y1);
i2w(new_b.x0, new_b.y0); i2w(new_b.x0, new_b.y0);
i2w(new_b.x1, new_b.y1); i2w(new_b.x1, new_b.y1);
@ -503,7 +503,7 @@ Lineset::update_bounds()
* N. find out if the item moved. if it moved, the old bbox and the new bbox need to be updated. * N. find out if the item moved. if it moved, the old bbox and the new bbox need to be updated.
*/ */
void void
Lineset::update_vfunc(double* affine, ArtSVP* clip_path, int flags) LineSet::update_vfunc(double* affine, ArtSVP* clip_path, int flags)
{ {
GnomeCanvasItem* item = GNOME_CANVAS_ITEM(gobj()); GnomeCanvasItem* item = GNOME_CANVAS_ITEM(gobj());
bool lines_need_redraw = true; bool lines_need_redraw = true;
@ -539,14 +539,14 @@ Lineset::update_vfunc(double* affine, ArtSVP* clip_path, int flags)
} }
void void
Lineset::draw_vfunc(const Glib::RefPtr<Gdk::Drawable>& drawable, int x, int y, int width, int height) LineSet::draw_vfunc(const Glib::RefPtr<Gdk::Drawable>& drawable, int x, int y, int width, int height)
{ {
cerr << "please don't use the GnomeCanvasLineset item in a non-aa Canvas" << endl; cerr << "please don't use the GnomeCanvasLineSet item in a non-aa Canvas" << endl;
abort(); abort();
} }
inline void inline void
Lineset::paint_vert(GnomeCanvasBuf* buf, Lineset::Line& line, int x1, int y1, int x2, int y2) LineSet::paint_vert(GnomeCanvasBuf* buf, LineSet::Line& line, int x1, int y1, int x2, int y2)
{ {
if (line.width == 1.0) { if (line.width == 1.0) {
PAINT_VERTA(buf, line.r, line.g, line.b, line.a, x1, y1, y2); PAINT_VERTA(buf, line.r, line.g, line.b, line.a, x1, y1, y2);
@ -556,7 +556,7 @@ Lineset::paint_vert(GnomeCanvasBuf* buf, Lineset::Line& line, int x1, int y1, in
} }
inline void inline void
Lineset::paint_horiz(GnomeCanvasBuf* buf, Lineset::Line& line, int x1, int y1, int x2, int y2) LineSet::paint_horiz(GnomeCanvasBuf* buf, LineSet::Line& line, int x1, int y1, int x2, int y2)
{ {
if (line.width == 1.0) { if (line.width == 1.0) {
PAINT_HORIZA(buf, line.r, line.g, line.b, line.a, x1, x2, y1); PAINT_HORIZA(buf, line.r, line.g, line.b, line.a, x1, x2, y1);
@ -566,7 +566,7 @@ Lineset::paint_horiz(GnomeCanvasBuf* buf, Lineset::Line& line, int x1, int y1, i
} }
void void
Lineset::render_vfunc(GnomeCanvasBuf* buf) LineSet::render_vfunc(GnomeCanvasBuf* buf)
{ {
ArtIRect rect; ArtIRect rect;
int pos0, pos1, offset; int pos0, pos1, offset;
@ -694,7 +694,7 @@ Lineset::render_vfunc(GnomeCanvasBuf* buf)
} }
void void
Lineset::bounds_vfunc(double* _x1, double* _y1, double* _x2, double* _y2) LineSet::bounds_vfunc(double* _x1, double* _y1, double* _x2, double* _y2)
{ {
*_x1 = x1; *_x1 = x1;
*_y1 = y1; *_y1 = y1;
@ -704,12 +704,12 @@ Lineset::bounds_vfunc(double* _x1, double* _y1, double* _x2, double* _y2)
double double
Lineset::point_vfunc(double x, double y, int cx, int cy, GnomeCanvasItem** actual_item) LineSet::point_vfunc(double x, double y, int cx, int cy, GnomeCanvasItem** actual_item)
{ {
double x1, y1, x2, y2; double x1, y1, x2, y2;
double dx, dy; double dx, dy;
Lineset::bounds_vfunc(&x1, &y1, &x2, &y2); LineSet::bounds_vfunc(&x1, &y1, &x2, &y2);
*actual_item = gobj(); *actual_item = gobj();
@ -739,13 +739,13 @@ Lineset::point_vfunc(double x, double y, int cx, int cy, GnomeCanvasItem** actua
/* If not overrided emit the signal */ /* If not overrided emit the signal */
void void
Lineset::request_lines(double c1, double c2) LineSet::request_lines(double c1, double c2)
{ {
signal_request_lines(*this, c1, c2); signal_request_lines(*this, c1, c2);
} }
void void
Lineset::bounds_need_update() LineSet::bounds_need_update()
{ {
bounds_changed = true; bounds_changed = true;
@ -755,7 +755,7 @@ Lineset::bounds_need_update()
} }
void void
Lineset::region_needs_update(double coord1, double coord2) LineSet::region_needs_update(double coord1, double coord2)
{ {
if (update_region1 > update_region2) { if (update_region1 > update_region2) {
update_region1 = coord1; update_region1 = coord1;
@ -774,15 +774,15 @@ Lineset::region_needs_update(double coord1, double coord2)
* These have been defined to avoid endless recursion with gnomecanvasmm. * These have been defined to avoid endless recursion with gnomecanvasmm.
* Don't know why this happens * Don't know why this happens
*/ */
bool Lineset::on_event(GdkEvent* p1) bool LineSet::on_event(GdkEvent* p1)
{ {
return false; return false;
} }
void Lineset::realize_vfunc() { } void LineSet::realize_vfunc() { }
void Lineset::unrealize_vfunc() { } void LineSet::unrealize_vfunc() { }
void Lineset::map_vfunc() { } void LineSet::map_vfunc() { }
void Lineset::unmap_vfunc() { } void LineSet::unmap_vfunc() { }
} /* namespace Canvas */ } /* namespace Canvas */
} /* namespace Gnome */ } /* namespace Gnome */

View file

@ -23,58 +23,52 @@
namespace Gnome { namespace Gnome {
namespace Canvas { namespace Canvas {
class LinesetClass : public Glib::Class { class LineSetClass : public Glib::Class {
public: public:
const Glib::Class& init(); const Glib::Class& init();
static void class_init_function(void* g_class, void* class_data); static void class_init_function(void* g_class, void* class_data);
}; };
/** /** A canvas item that displays a set of vertical or horizontal lines,
* A canvas item that displays a list of lines vertically or horizontally,
* spanning the entire size of the item. * spanning the entire size of the item.
*/ */
class Lineset : public Item { class LineSet : public Item {
public: public:
enum Orientation { enum Orientation {
Vertical, Vertical,
Horizontal Horizontal
}; };
Lineset(Group& parent, Orientation); LineSet(Group& parent, Orientation);
virtual ~Lineset(); virtual ~LineSet();
Glib::PropertyProxy<double> property_x1() { return x1.get_proxy(); } Glib::PropertyProxy<double> property_x1() { return x1.get_proxy(); }
Glib::PropertyProxy<double> property_y1() { return y1.get_proxy(); } Glib::PropertyProxy<double> property_y1() { return y1.get_proxy(); }
Glib::PropertyProxy<double> property_x2() { return x2.get_proxy(); } Glib::PropertyProxy<double> property_x2() { return x2.get_proxy(); }
Glib::PropertyProxy<double> property_y2() { return y2.get_proxy(); } Glib::PropertyProxy<double> property_y2() { return y2.get_proxy(); }
/* /* Note: every line operation takes a coord parameter, as an index to
* Note: every line operation takes a coord parameter, as an index to
* the line it modifies. The index will identify a line if it is between * the line it modifies. The index will identify a line if it is between
* line.coord and line.coord + line.width. * line.coord and line.coord + line.width.
*/ */
/** /** Move a line to a new position.
* Move a line to a new position * For this to work (to move the desired line) it is important that
* for this to work (to move the desired line) it is important that
* lines have unique coordinates. This also applies to every line * lines have unique coordinates. This also applies to every line
* accessing functions below * accessing functions below
*/ */
void move_line(double coord, double dest); void move_line(double coord, double dest);
/** /** Change the width of a line.
* Change the width of a line. Only allow it if the new width doesn't * Only allow if the new width doesn't overlap the next line (see below)
* overlap the next line (see below)
*/ */
void change_line_width(double coord, double width); void change_line_width(double coord, double width);
/** /** Change the color of a line.
* Change the color of a line
*/ */
void change_line_color(double coord, uint32_t color); void change_line_color(double coord, uint32_t color);
/** /** Add a line to draw.
* this function adds a line to draw.
* width is an offset, so that coord + width specifies the end of the line. * width is an offset, so that coord + width specifies the end of the line.
* lines should not overlap, as no layering information is provided. * lines should not overlap, as no layering information is provided.
* however, line_coord[i] + line_width[i] == line_coord[i+1] is * however, line_coord[i] + line_width[i] == line_coord[i+1] is
@ -84,49 +78,41 @@ public:
*/ */
void add_line(double coord, double width, uint32_t color); void add_line(double coord, double width, uint32_t color);
/** /** Remove the line at coord
* remove the line at coord
*/ */
void remove_line(double coord); void remove_line(double coord);
/** /** Remove all lines in a coordinate range
* remove all lines in a coordinate range
*/ */
void remove_lines(double c1, double c2); void remove_lines(double c1, double c2);
/** /** Remove all lines with a coordinate lower than coord
* remove all lines with a coordinate lower than coord
*/ */
void remove_until(double coord); void remove_until(double coord);
/** /** Remove all lines with a coordinate equal to or higher than coord.
* remove all lines with a coordinate equal to or higher than coord
*/ */
void remove_from(double coord); void remove_from(double coord);
/** /** Remove all lines.
* remove all lines
*/ */
void clear(); void clear();
/** /** Add a set of lines in the given range.
* this is a request of information on lines in a coordinate range. * For every line visible in the provided coordinate range, call add_line().
* for every line visible in the provided coordinate range,
* call add_line() on it.
* This is called when the area between c1 and c2 becomes visible, when * This is called when the area between c1 and c2 becomes visible, when
* previously outside any possible view. So the number of calls to this * previously outside any possible view.
* function will be kept at a minimum. * The number of calls to this function should be kept at a minimum.
*/ */
virtual void request_lines(double c1, double c2); virtual void request_lines(double c1, double c2);
/** /** Instead of overriding the update_lines function one can connect to this
* instead of overriding the update_lines function one can connect to this * and add lines externally instead.
* and add lines externally instead. If add_lines() is overrided, this * If add_lines() is overrided, this signal will not be emitted.
* signal will not be emitted.
*/ */
sigc::signal<void, Lineset&, double, double> signal_request_lines; sigc::signal<void, LineSet&, double, double> signal_request_lines;
/* overrided from Gnome::Canvas::Item */ /* overridden from Gnome::Canvas::Item */
void update_vfunc(double* affine, ArtSVP* clip_path, int flags); void update_vfunc(double* affine, ArtSVP* clip_path, int flags);
void realize_vfunc(); void realize_vfunc();
void unrealize_vfunc(); void unrealize_vfunc();
@ -156,8 +142,8 @@ protected:
unsigned char a; unsigned char a;
}; };
static inline void paint_vert(GnomeCanvasBuf* buf, Lineset::Line& line, int x1, int y1, int x2, int y2); static inline void paint_vert(GnomeCanvasBuf* buf, LineSet::Line& line, int x1, int y1, int x2, int y2);
static inline void paint_horiz(GnomeCanvasBuf* buf, Lineset::Line& line, int x1, int y1, int x2, int y2); static inline void paint_horiz(GnomeCanvasBuf* buf, LineSet::Line& line, int x1, int y1, int x2, int y2);
static bool line_compare(const Line& a, const Line& b); static bool line_compare(const Line& a, const Line& b);
@ -171,10 +157,10 @@ protected:
Lines::iterator line_at(double coord); Lines::iterator line_at(double coord);
/* store that last accessed line so adjacent lines are found faster */ /** Stores last accessed line so adjacent lines are found faster */
Lines::iterator cached_pos; Lines::iterator cached_pos;
static LinesetClass lineset_class; static LineSetClass lineset_class;
Orientation orientation; Orientation orientation;
Lines lines; Lines lines;
@ -184,12 +170,12 @@ protected:
Glib::Property<double> x2; Glib::Property<double> x2;
Glib::Property<double> y2; Glib::Property<double> y2;
/* cached bounding box in canvas coordinates*/ /** Cached bounding box in canvas coordinates */
ArtIRect bbox; ArtIRect bbox;
private: private:
Lineset(); LineSet();
Lineset(const Lineset&); LineSet(const LineSet&);
bool in_update; bool in_update;

View file

@ -75,7 +75,7 @@ MidiStreamView::MidiStreamView (MidiTimeAxisView& tv)
/* put the note lines in the timeaxisview's group, so it /* put the note lines in the timeaxisview's group, so it
can be put below ghost regions from MIDI underlays*/ can be put below ghost regions from MIDI underlays*/
_note_lines = new ArdourCanvas::Lineset(*canvas_group, ArdourCanvas::Lineset::Horizontal); _note_lines = new ArdourCanvas::LineSet(*canvas_group, ArdourCanvas::LineSet::Horizontal);
_note_lines->property_x1() = 0; _note_lines->property_x1() = 0;
_note_lines->property_y1() = 0; _note_lines->property_y1() = 0;

View file

@ -134,7 +134,7 @@ class MidiStreamView : public StreamView
uint8_t _highest_note; ///< currently visible uint8_t _highest_note; ///< currently visible
uint8_t _data_note_min; ///< in data uint8_t _data_note_min; ///< in data
uint8_t _data_note_max; ///< in data uint8_t _data_note_max; ///< in data
ArdourCanvas::Lineset* _note_lines; ArdourCanvas::LineSet* _note_lines;
}; };
#endif /* __ardour_midi_streamview_h__ */ #endif /* __ardour_midi_streamview_h__ */