13
0

canvas: when an item has its bbox marked dirty, this should propagate to all parents

This commit is contained in:
Paul Davis 2022-04-26 21:57:39 -06:00
parent d54d63da3a
commit c75ceb31ab
16 changed files with 71 additions and 58 deletions

View File

@ -102,7 +102,7 @@ Arc::set_center (Duple const & c)
_center = c;
_bounding_box_dirty = true;
set_bbox_dirty ();
end_change ();
}
@ -113,7 +113,7 @@ Arc::set_radius (Coord r)
_radius = r;
_bounding_box_dirty = true;
set_bbox_dirty ();
end_change ();
}
@ -124,7 +124,7 @@ Arc::set_arc (double deg)
_arc_degrees = deg;
_bounding_box_dirty = true;
set_bbox_dirty ();
end_change ();
}
@ -136,7 +136,7 @@ Arc::set_start (double deg)
_start_degrees = deg;
_bounding_box_dirty = true;
set_bbox_dirty ();
end_change ();
}
@ -166,5 +166,5 @@ Arc::_size_allocate (Rect const & r)
_radius = min (r.width(),r.height()) / 2.0;
_center = Duple ((r.width()/2.), (r.height() /2.));
_bounding_box_dirty = true;
set_bbox_dirty ();
}

View File

@ -101,7 +101,7 @@ Arrow::set_show_head (int which, bool show)
setup_polygon (which);
}
_bounding_box_dirty = true;
set_bbox_dirty ();
end_change ();
}
@ -121,7 +121,7 @@ Arrow::set_head_outward (int which, bool outward)
_heads[which].outward = outward;
setup_polygon (which);
_bounding_box_dirty = true;
set_bbox_dirty ();
end_change ();
}
@ -139,7 +139,7 @@ Arrow::set_head_height (int which, Distance height)
_heads[which].height = height;
setup_polygon (which);
_bounding_box_dirty = true;
set_bbox_dirty ();
end_change ();
}
@ -157,7 +157,7 @@ Arrow::set_head_width (int which, Distance width)
_heads[which].width = width;
setup_polygon (which);
_bounding_box_dirty = true;
set_bbox_dirty ();
end_change ();
}
@ -174,7 +174,7 @@ Arrow::set_outline_width (Distance width)
if (_heads[1].polygon) {
_heads[1].polygon->set_outline_width (width);
}
_bounding_box_dirty = true;
set_bbox_dirty ();
}
/** Set the x position of our line.
@ -190,7 +190,7 @@ Arrow::set_x (Coord x)
_heads[i].polygon->set_x_position (x - _heads[i].width / 2);
}
}
_bounding_box_dirty = true;
set_bbox_dirty ();
}
/** Set the y position of end 0 of our line.
@ -203,7 +203,7 @@ Arrow::set_y0 (Coord y0)
if (_heads[0].polygon) {
_heads[0].polygon->set_y_position (y0);
}
_bounding_box_dirty = true;
set_bbox_dirty ();
}
/** Set the y position of end 1 of our line.
@ -216,7 +216,7 @@ Arrow::set_y1 (Coord y1)
if (_heads[1].polygon) {
_heads[1].polygon->set_y_position (y1 - _heads[1].height);
}
_bounding_box_dirty = true;
set_bbox_dirty ();
}
/** @return x position of our line in pixels (in our coordinate system) */

View File

@ -333,11 +333,11 @@ public:
/** our bounding box; may be out of date if _bounding_box_dirty is true */
mutable Rect _bounding_box;
/** true if _bounding_box might be out of date, false if its definitely not */
mutable bool _bounding_box_dirty;
PackOptions _pack_options;
void bb_clean () const;
void set_bbox_dirty () const;
bool bbox_dirty() const { return _bounding_box_dirty; }
Rect _allocation;
bool _layout_sensitive;
@ -373,7 +373,9 @@ private:
std::string _tooltip;
bool _ignore_events;
bool _scroll_translation;
/** true if _bounding_box might be out of date, false if its definitely not */
mutable bool _bounding_box_dirty;
void find_scroll_parent ();
void propagate_show_hide ();
};

View File

@ -161,7 +161,7 @@ Grid::set_margin (double t, double r, double b, double l)
void
Grid::reset_bg ()
{
if (_bounding_box_dirty) {
if (bbox_dirty()) {
(void) bounding_box ();
}
@ -331,7 +331,7 @@ Grid::reposition_children ()
(*i)->set_position (Duple (col_dimens[c->second.x], row_dimens[c->second.y]));
}
_bounding_box_dirty = true;
set_bbox_dirty ();
reset_bg ();
}

View File

@ -26,6 +26,7 @@
#include "canvas/canvas.h"
#include "canvas/debug.h"
#include "canvas/item.h"
#include "canvas/root_group.h"
#include "canvas/scroll_group.h"
using namespace std;
@ -41,7 +42,6 @@ Item::Item (Canvas* canvas)
, _parent (0)
, _scroll_parent (0)
, _visible (true)
, _bounding_box_dirty (true)
, _pack_options (PackOptions (0))
, _layout_sensitive (false)
, _lut (0)
@ -50,6 +50,7 @@ Item::Item (Canvas* canvas)
, _requested_height (-1)
, _ignore_events (false)
, _scroll_translation (true)
, _bounding_box_dirty (true)
{
DEBUG_TRACE (DEBUG::CanvasItems, string_compose ("new canvas item %1\n", this));
}
@ -61,7 +62,6 @@ Item::Item (Item* parent)
, _parent (parent)
, _scroll_parent (0)
, _visible (true)
, _bounding_box_dirty (true)
, _pack_options (PackOptions (0))
, _layout_sensitive (false)
, _lut (0)
@ -70,6 +70,7 @@ Item::Item (Item* parent)
, _requested_height (-1)
, _ignore_events (false)
, _scroll_translation (true)
, _bounding_box_dirty (true)
{
DEBUG_TRACE (DEBUG::CanvasItems, string_compose ("new canvas item %1\n", this));
@ -88,7 +89,6 @@ Item::Item (Item* parent, Duple const& p)
, _scroll_parent (0)
, _position (p)
, _visible (true)
, _bounding_box_dirty (true)
, _pack_options (PackOptions (0))
, _layout_sensitive (false)
, _requested_width (-1.)
@ -97,6 +97,7 @@ Item::Item (Item* parent, Duple const& p)
, _resize_queued (false)
, _ignore_events (false)
, _scroll_translation (true)
, _bounding_box_dirty (true)
{
DEBUG_TRACE (DEBUG::CanvasItems, string_compose ("new canvas item %1\n", this));
@ -607,7 +608,7 @@ Item::size_allocate (Rect const & r)
{
begin_change ();
_size_allocate (r);
_bounding_box_dirty = true;
set_bbox_dirty ();
end_change ();
}
@ -661,7 +662,7 @@ Item::set_size_request (double w, double h)
begin_change ();
_requested_width = w;
_requested_height = h;
_bounding_box_dirty = true;
set_bbox_dirty ();
end_change ();
}
@ -709,7 +710,7 @@ Item::set_size_request_to_display_given_text (const std::vector<std::string>& st
ArdourCanvas::Rect
Item::bounding_box () const
{
if (_bounding_box_dirty) {
if (bbox_dirty()) {
compute_bounding_box ();
assert (!_bounding_box_dirty);
add_child_bounding_boxes ();
@ -848,7 +849,7 @@ Item::covers (Duple const & point) const
{
Duple p = window_to_item (point);
if (_bounding_box_dirty) {
if (bbox_dirty()) {
(void) bounding_box ();
}
@ -1055,7 +1056,7 @@ Item::add (Item* i)
_items.push_back (i);
i->reparent (this, true);
invalidate_lut ();
_bounding_box_dirty = true;
set_bbox_dirty ();
}
void
@ -1066,7 +1067,7 @@ Item::add_front (Item* i)
_items.push_front (i);
i->reparent (this, true);
invalidate_lut ();
_bounding_box_dirty = true;
set_bbox_dirty();
}
void
@ -1093,7 +1094,7 @@ Item::remove (Item* i)
i->set_layout_sensitive (false);
_items.remove (i);
invalidate_lut ();
_bounding_box_dirty = true;
set_bbox_dirty ();
end_change ();
}
@ -1106,8 +1107,7 @@ Item::clear (bool with_delete)
clear_items (with_delete);
invalidate_lut ();
_bounding_box_dirty = true;
set_bbox_dirty ();
end_change ();
}
@ -1207,7 +1207,7 @@ Item::child_changed (bool bbox_changed)
invalidate_lut ();
if (bbox_changed) {
_bounding_box_dirty = true;
set_bbox_dirty ();
}
if (_parent) {
@ -1339,6 +1339,17 @@ Item::bb_clean () const
_bounding_box_dirty = false;
}
void
Item::set_bbox_dirty () const
{
_bounding_box_dirty = true;
Item* i = _parent;
while (i) {
i->set_bbox_dirty ();
i = i->parent ();
}
}
void
Item::set_pack_options (PackOptions po)
{

View File

@ -86,7 +86,7 @@ Line::set (Duple a, Duple b)
_points[0] = a;
_points[1] = b;
_bounding_box_dirty = true;
set_bbox_dirty ();
end_change ();
}
}
@ -100,7 +100,7 @@ Line::set_x (Coord x0, Coord x1)
_points[0].x = x0;
_points[1].x = x1;
_bounding_box_dirty = true;
set_bbox_dirty ();
end_change ();
}
}
@ -113,7 +113,7 @@ Line::set_x0 (Coord x0)
_points[0].x = x0;
_bounding_box_dirty = true;
set_bbox_dirty ();
end_change ();
}
}
@ -126,7 +126,7 @@ Line::set_y0 (Coord y0)
_points[0].y = y0;
_bounding_box_dirty = true;
set_bbox_dirty ();
end_change ();
}
@ -141,7 +141,7 @@ Line::set_x1 (Coord x1)
_points[1].x = x1;
_bounding_box_dirty = true;
set_bbox_dirty ();
end_change ();
}
}
@ -154,7 +154,7 @@ Line::set_y1 (Coord y1)
_points[1].y = y1;
_bounding_box_dirty = true;
set_bbox_dirty ();
end_change ();
}
}

View File

@ -80,7 +80,7 @@ LineSet::set_extent (Distance e)
begin_change ();
_extent = e;
_bounding_box_dirty = true;
set_bbox_dirty ();
end_change ();
}
@ -138,7 +138,7 @@ LineSet::add_coord (Coord y, Distance width, Gtkmm2ext::Color color)
_lines.push_back (Line (y, width, color));
sort (_lines.begin(), _lines.end(), LineSorter());
_bounding_box_dirty = true;
set_bbox_dirty ();
end_change ();
}
@ -147,7 +147,7 @@ LineSet::clear ()
{
begin_change ();
_lines.clear ();
_bounding_box_dirty = true;
set_bbox_dirty ();
end_change ();
}

View File

@ -53,7 +53,7 @@ Outline::set_outline_width (Distance width)
if (width != _outline_width) {
_self.begin_change ();
_outline_width = width;
_self._bounding_box_dirty = true;
_self.set_bbox_dirty ();
_self.end_change ();
}
}
@ -64,7 +64,7 @@ Outline::set_outline (bool outline)
if (outline != _outline) {
_self.begin_change ();
_outline = outline;
_self._bounding_box_dirty = true;
_self.set_bbox_dirty ();
_self.end_change ();
}
}

View File

@ -61,7 +61,7 @@ Pixbuf::set (Glib::RefPtr<Gdk::Pixbuf> pixbuf)
begin_change ();
_pixbuf = pixbuf;
_bounding_box_dirty = true;
set_bbox_dirty ();
end_change ();
}

View File

@ -135,7 +135,7 @@ PolyItem::set (Points const& points)
_points = points;
_bounding_box_dirty = true;
set_bbox_dirty ();
end_change ();
}
}

View File

@ -57,7 +57,7 @@ void
PolyLine::set_fill_y1 (double y1)
{
begin_change ();
_bounding_box_dirty = true;
set_bbox_dirty ();
_y1 = y1;
end_change ();
}

View File

@ -128,7 +128,7 @@ Polygon::covers (Duple const & point) const
Points::size_type j = npoints -1;
bool oddNodes = false;
if (_bounding_box_dirty) {
if (bbox_dirty()) {
(void) bounding_box ();
}

View File

@ -191,7 +191,7 @@ Rectangle::set (Rect const & r)
_rect = r;
_bounding_box_dirty = true;
set_bbox_dirty ();
end_change ();
}
}
@ -204,7 +204,7 @@ Rectangle::set_x0 (Coord x0)
_rect.x0 = x0;
_bounding_box_dirty = true;
set_bbox_dirty ();
end_change ();
}
}
@ -217,7 +217,7 @@ Rectangle::set_y0 (Coord y0)
_rect.y0 = y0;
_bounding_box_dirty = true;
set_bbox_dirty ();
end_change();
}
}
@ -230,7 +230,7 @@ Rectangle::set_x1 (Coord x1)
_rect.x1 = x1;
_bounding_box_dirty = true;
set_bbox_dirty ();
end_change ();
}
}
@ -243,7 +243,7 @@ Rectangle::set_y1 (Coord y1)
_rect.y1 = y1;
_bounding_box_dirty = true;
set_bbox_dirty ();
end_change ();
}
}

View File

@ -107,7 +107,7 @@ StepButton::set_size (double w, double h)
width = w;
height = h;
_bounding_box_dirty = true;
set_bbox_dirty ();
create_patterns ();

View File

@ -92,7 +92,7 @@ Text::set (string const & text)
_text = text;
_need_redraw = true;
_bounding_box_dirty = true;
set_bbox_dirty ();
end_change ();
}
@ -245,7 +245,7 @@ Text::clamp_width (double w)
}
begin_change ();
_clamped_width = w;
_bounding_box_dirty = true;
set_bbox_dirty ();
end_change ();
}
@ -258,7 +258,7 @@ Text::compute_bounding_box () const
return;
}
if (_bounding_box_dirty) {
if (bbox_dirty()) {
#ifdef __APPLE__
const float retina_factor = 0.5;
#else
@ -283,7 +283,7 @@ Text::set_alignment (Pango::Alignment alignment)
_alignment = alignment;
_need_redraw = true;
_bounding_box_dirty = true;
set_bbox_dirty ();
end_change ();
}
@ -296,7 +296,7 @@ Text::set_font_description (Pango::FontDescription font_description)
_need_redraw = true;
_width_correction = -1.0;
_bounding_box_dirty = true;
set_bbox_dirty ();
end_change ();
}

View File

@ -127,7 +127,7 @@ XFadeCurve::set_inout (Points const & in, Points const & out)
begin_change ();
_in.points = in;
_out.points = out;
_bounding_box_dirty = true;
set_bbox_dirty ();
interpolate ();
end_change ();
}