mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-10 00:34:59 +01:00
do not sort lineset every time a coord is added; use RAII to create scope and sort at end
This commit is contained in:
parent
d4bca18108
commit
4f87506e5c
4 changed files with 29 additions and 9 deletions
|
|
@ -47,6 +47,15 @@ public:
|
|||
void set_extent (Distance);
|
||||
Distance extent() const { return _extent; }
|
||||
|
||||
void begin_add ();
|
||||
void end_add ();
|
||||
|
||||
struct ResetRAII {
|
||||
ResetRAII (LineSet& l) : lines (l) { lines.clear(); lines.begin_add(); }
|
||||
~ResetRAII () { lines.end_add (); }
|
||||
LineSet& lines;
|
||||
};
|
||||
|
||||
void add_coord (Coord, Distance, Gtkmm2ext::Color);
|
||||
void clear ();
|
||||
|
||||
|
|
|
|||
|
|
@ -131,12 +131,23 @@ LineSet::render (Rect const & area, Cairo::RefPtr<Cairo::Context> context) const
|
|||
}
|
||||
|
||||
void
|
||||
LineSet::add_coord (Coord y, Distance width, Gtkmm2ext::Color color)
|
||||
LineSet::add_coord (Coord pos, Distance width, Gtkmm2ext::Color color)
|
||||
{
|
||||
_lines.push_back (Line (pos, width, color));
|
||||
}
|
||||
|
||||
void
|
||||
LineSet::begin_add ()
|
||||
{
|
||||
begin_change ();
|
||||
}
|
||||
|
||||
_lines.push_back (Line (y, width, color));
|
||||
sort (_lines.begin(), _lines.end(), LineSorter());
|
||||
void
|
||||
LineSet::end_add ()
|
||||
{
|
||||
if (!_lines.empty()) {
|
||||
sort (_lines.begin(), _lines.end(), LineSorter());
|
||||
}
|
||||
|
||||
set_bbox_dirty ();
|
||||
end_change ();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue