don't queue redraws when various canvas item properties are "reset" to the same value, plus supporting functions
This commit is contained in:
parent
495c0de4ac
commit
c2946ee00f
@ -262,7 +262,7 @@ void
|
||||
Canvas::queue_draw_item_area (Item* item, Rect area)
|
||||
{
|
||||
ArdourCanvas::Rect canvas_area = item->item_to_canvas (area);
|
||||
// cerr << "CANVAS " << this << " for " << item->whatami() << ' ' << item->name << " invalidate " << area << " TRANSLATE AS " << canvas_area << " window = " << canvas_to_window (canvas_area) << std::endl;
|
||||
// cerr << "CANVAS " << this << " for " << item << ' ' << item->whatami() << ' ' << item->name << " invalidate " << area << " TRANSLATE AS " << canvas_area << " window = " << canvas_to_window (canvas_area) << std::endl;
|
||||
request_redraw (canvas_area);
|
||||
}
|
||||
|
||||
|
@ -72,7 +72,12 @@ public:
|
||||
};
|
||||
|
||||
void set_outline_what (What);
|
||||
void set_outline_what (int);
|
||||
void set_outline_all () {
|
||||
set_outline_what (ArdourCanvas::Rectangle::What (ArdourCanvas::Rectangle::TOP|
|
||||
ArdourCanvas::Rectangle::LEFT|
|
||||
ArdourCanvas::Rectangle::RIGHT|
|
||||
ArdourCanvas::Rectangle::BOTTOM));
|
||||
}
|
||||
|
||||
private:
|
||||
/** Our rectangle; note that x0 may not always be less than x1
|
||||
|
@ -64,6 +64,7 @@ struct LIBCANVAS_API Duple
|
||||
extern LIBCANVAS_API Duple operator- (Duple const &);
|
||||
extern LIBCANVAS_API Duple operator+ (Duple const &, Duple const &);
|
||||
extern LIBCANVAS_API bool operator== (Duple const &, Duple const &);
|
||||
extern LIBCANVAS_API bool operator!= (Duple const &, Duple const &);
|
||||
extern LIBCANVAS_API Duple operator- (Duple const &, Duple const &);
|
||||
extern LIBCANVAS_API Duple operator/ (Duple const &, double);
|
||||
extern LIBCANVAS_API std::ostream & operator<< (std::ostream &, Duple const &);
|
||||
@ -106,6 +107,8 @@ struct LIBCANVAS_API Rect
|
||||
}
|
||||
};
|
||||
|
||||
extern LIBCANVAS_API bool operator!= (Rect const &, Rect const &);
|
||||
|
||||
extern LIBCANVAS_API std::ostream & operator<< (std::ostream &, Rect const &);
|
||||
|
||||
typedef std::vector<Duple> Points;
|
||||
|
@ -77,53 +77,55 @@ Line::render (Rect const & /*area*/, Cairo::RefPtr<Cairo::Context> context) cons
|
||||
void
|
||||
Line::set (Duple a, Duple b)
|
||||
{
|
||||
begin_change ();
|
||||
|
||||
_points[0] = a;
|
||||
_points[1] = b;
|
||||
|
||||
_bounding_box_dirty = true;
|
||||
end_change ();
|
||||
|
||||
DEBUG_TRACE (PBD::DEBUG::CanvasItemsDirtied, "canvas item dirty: line change\n");
|
||||
if (a != _points[0] || b != _points[1]) {
|
||||
begin_change ();
|
||||
|
||||
_points[0] = a;
|
||||
_points[1] = b;
|
||||
|
||||
_bounding_box_dirty = true;
|
||||
end_change ();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Line::set_x (Coord x0, Coord x1)
|
||||
{
|
||||
begin_change ();
|
||||
|
||||
_points[0].x = x0;
|
||||
_points[1].x = x1;
|
||||
|
||||
_bounding_box_dirty = true;
|
||||
end_change ();
|
||||
|
||||
DEBUG_TRACE (PBD::DEBUG::CanvasItemsDirtied, "canvas item dirty: line change\n");
|
||||
if (x0 != _points[0].x || x1 != _points[1].x) {
|
||||
begin_change ();
|
||||
|
||||
_points[0].x = x0;
|
||||
_points[1].x = x1;
|
||||
|
||||
_bounding_box_dirty = true;
|
||||
end_change ();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Line::set_x0 (Coord x0)
|
||||
{
|
||||
begin_change ();
|
||||
|
||||
_points[0].x = x0;
|
||||
|
||||
_bounding_box_dirty = true;
|
||||
end_change ();
|
||||
|
||||
DEBUG_TRACE (PBD::DEBUG::CanvasItemsDirtied, "canvas item dirty: line change\n");
|
||||
if (x0 != _points[0].x) {
|
||||
begin_change ();
|
||||
|
||||
_points[0].x = x0;
|
||||
|
||||
_bounding_box_dirty = true;
|
||||
end_change ();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Line::set_y0 (Coord y0)
|
||||
{
|
||||
begin_change ();
|
||||
|
||||
_points[0].y = y0;
|
||||
|
||||
_bounding_box_dirty = true;
|
||||
end_change ();
|
||||
if (y0 != _points[0].y) {
|
||||
begin_change ();
|
||||
|
||||
_points[0].y = y0;
|
||||
|
||||
_bounding_box_dirty = true;
|
||||
end_change ();
|
||||
}
|
||||
|
||||
DEBUG_TRACE (PBD::DEBUG::CanvasItemsDirtied, "canvas item dirty: line change\n");
|
||||
}
|
||||
@ -131,27 +133,27 @@ Line::set_y0 (Coord y0)
|
||||
void
|
||||
Line::set_x1 (Coord x1)
|
||||
{
|
||||
begin_change ();
|
||||
|
||||
_points[1].x = x1;
|
||||
|
||||
_bounding_box_dirty = true;
|
||||
end_change ();
|
||||
|
||||
DEBUG_TRACE (PBD::DEBUG::CanvasItemsDirtied, "canvas item dirty: line change\n");
|
||||
if (x1 != _points[1].x) {
|
||||
begin_change ();
|
||||
|
||||
_points[1].x = x1;
|
||||
|
||||
_bounding_box_dirty = true;
|
||||
end_change ();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Line::set_y1 (Coord y1)
|
||||
{
|
||||
begin_change ();
|
||||
|
||||
_points[1].y = y1;
|
||||
|
||||
_bounding_box_dirty = true;
|
||||
end_change ();
|
||||
|
||||
DEBUG_TRACE (PBD::DEBUG::CanvasItemsDirtied, "canvas item dirty: line change\n");
|
||||
if (y1 != _points[1].y) {
|
||||
begin_change ();
|
||||
|
||||
_points[1].y = y1;
|
||||
|
||||
_bounding_box_dirty = true;
|
||||
end_change ();
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -127,12 +127,15 @@ PolyItem::render_curve (Rect const & area, Cairo::RefPtr<Cairo::Context> context
|
||||
void
|
||||
PolyItem::set (Points const & points)
|
||||
{
|
||||
begin_change ();
|
||||
|
||||
_points = points;
|
||||
|
||||
_bounding_box_dirty = true;
|
||||
end_change ();
|
||||
if (_points != points) {
|
||||
|
||||
begin_change ();
|
||||
|
||||
_points = points;
|
||||
|
||||
_bounding_box_dirty = true;
|
||||
end_change ();
|
||||
}
|
||||
}
|
||||
|
||||
Points const &
|
||||
|
@ -139,82 +139,77 @@ Rectangle::set (Rect const & r)
|
||||
/* We don't update the bounding box here; it's just
|
||||
as cheap to do it when asked.
|
||||
*/
|
||||
|
||||
begin_change ();
|
||||
|
||||
_rect = r;
|
||||
|
||||
_bounding_box_dirty = true;
|
||||
end_change ();
|
||||
|
||||
DEBUG_TRACE (PBD::DEBUG::CanvasItemsDirtied, "canvas item dirty: rectangle change (set)\n");
|
||||
if (r != _rect) {
|
||||
|
||||
begin_change ();
|
||||
|
||||
_rect = r;
|
||||
|
||||
_bounding_box_dirty = true;
|
||||
end_change ();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Rectangle::set_x0 (Coord x0)
|
||||
{
|
||||
begin_change ();
|
||||
|
||||
_rect.x0 = x0;
|
||||
|
||||
_bounding_box_dirty = true;
|
||||
end_change ();
|
||||
|
||||
DEBUG_TRACE (PBD::DEBUG::CanvasItemsDirtied, "canvas item dirty: rectangle change (x0)\n");
|
||||
if (x0 != _rect.x0) {
|
||||
begin_change ();
|
||||
|
||||
_rect.x0 = x0;
|
||||
|
||||
_bounding_box_dirty = true;
|
||||
end_change ();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Rectangle::set_y0 (Coord y0)
|
||||
{
|
||||
begin_change ();
|
||||
|
||||
_rect.y0 = y0;
|
||||
|
||||
_bounding_box_dirty = true;
|
||||
end_change();
|
||||
|
||||
DEBUG_TRACE (PBD::DEBUG::CanvasItemsDirtied, "canvas item dirty: rectangle change (y0)\n");
|
||||
if (y0 != _rect.y0) {
|
||||
begin_change ();
|
||||
|
||||
_rect.y0 = y0;
|
||||
|
||||
_bounding_box_dirty = true;
|
||||
end_change();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Rectangle::set_x1 (Coord x1)
|
||||
{
|
||||
begin_change ();
|
||||
|
||||
_rect.x1 = x1;
|
||||
|
||||
_bounding_box_dirty = true;
|
||||
end_change ();
|
||||
|
||||
DEBUG_TRACE (PBD::DEBUG::CanvasItemsDirtied, "canvas item dirty: rectangle change (x1)\n");
|
||||
if (x1 != _rect.x1) {
|
||||
begin_change ();
|
||||
|
||||
_rect.x1 = x1;
|
||||
|
||||
_bounding_box_dirty = true;
|
||||
end_change ();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Rectangle::set_y1 (Coord y1)
|
||||
{
|
||||
begin_change ();
|
||||
|
||||
_rect.y1 = y1;
|
||||
|
||||
_bounding_box_dirty = true;
|
||||
end_change ();
|
||||
|
||||
DEBUG_TRACE (PBD::DEBUG::CanvasItemsDirtied, "canvas item dirty: rectangle change (y1)\n");
|
||||
if (y1 != _rect.y1) {
|
||||
begin_change ();
|
||||
|
||||
_rect.y1 = y1;
|
||||
|
||||
_bounding_box_dirty = true;
|
||||
end_change ();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Rectangle::set_outline_what (What what)
|
||||
{
|
||||
begin_change ();
|
||||
|
||||
_outline_what = what;
|
||||
|
||||
end_change ();
|
||||
}
|
||||
|
||||
void
|
||||
Rectangle::set_outline_what (int what)
|
||||
{
|
||||
set_outline_what ((What) what);
|
||||
if (what != _outline_what) {
|
||||
begin_visual_change ();
|
||||
_outline_what = what;
|
||||
end_visual_change ();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -121,6 +121,16 @@ Rect::fix () const
|
||||
return r;
|
||||
}
|
||||
|
||||
bool
|
||||
ArdourCanvas::operator!= (Rect const& a, Rect const& b)
|
||||
{
|
||||
return a.x0 != b.x0 ||
|
||||
a.x1 != b.x1 ||
|
||||
a.y0 != b.y0 ||
|
||||
a.y1 != b.y1;
|
||||
}
|
||||
|
||||
|
||||
Duple
|
||||
ArdourCanvas::operator- (Duple const & o)
|
||||
{
|
||||
@ -139,6 +149,12 @@ ArdourCanvas::operator== (Duple const & a, Duple const & b)
|
||||
return a.x == b.x && a.y == b.y;
|
||||
}
|
||||
|
||||
bool
|
||||
ArdourCanvas::operator!= (Duple const & a, Duple const & b)
|
||||
{
|
||||
return a.x != b.x || a.y != b.y;
|
||||
}
|
||||
|
||||
Duple
|
||||
ArdourCanvas::operator- (Duple const & a, Duple const & b)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user