canvas: use Item::bb_clean() to mark _bounding_box_dirty false

This commit is contained in:
Paul Davis 2021-07-27 13:13:14 -06:00
parent 5b123441f4
commit ad6afbe68a
18 changed files with 35 additions and 21 deletions

View File

@ -64,7 +64,7 @@ Arc::compute_bounding_box () const
bbox = bbox.expand (0.5 + (_outline_width / 2));
_bounding_box = bbox;
_bounding_box_dirty = false;
bb_clean ();
}
void

View File

@ -79,7 +79,7 @@ Arrow::compute_bounding_box () const
_line->x1() + (head_width / 2.0) + outline_pad,
_line->y1());
_bounding_box_dirty = false;
bb_clean ();
}
/** Set whether to show an arrow head at one end or other

View File

@ -77,7 +77,7 @@ Box::compute_bounding_box () const
_bounding_box = Rect();
if (_items.empty()) {
_bounding_box_dirty = false;
bb_clean ();
return;
}
@ -96,7 +96,7 @@ Box::compute_bounding_box () const
0.0);
}
_bounding_box_dirty = false;
bb_clean ();
}
void

View File

@ -159,7 +159,10 @@ public:
virtual Duple intrinsic_size() const { return Duple (_intrinsic_width, _intrinsic_height); }
virtual void set_intrinsic_size (Distance, Distance);
/** bounding box is the public API to get the size of the item.
/** bounding box is the public API to get the area covered by the item
* (which may differ from its allocation). The returned Rect is in item
* coordinates (i.e. x0,y0 = 0,0 mean that the upper left corner of the
* bounding box is at the item's _position).
*/
Rect bounding_box () const;
@ -326,6 +329,9 @@ public:
mutable Rect _bounding_box;
/** true if _bounding_box might be out of date, false if its definitely not */
mutable bool _bounding_box_dirty;
void bb_clean () const;
Rect _allocation;
bool _layout_sensitive;
Distance _intrinsic_width;

View File

@ -92,7 +92,7 @@ void
ConstraintPacker::compute_bounding_box () const
{
_bounding_box = _allocation;
_bounding_box_dirty = false;
bb_clean ();
}
void

View File

@ -88,7 +88,7 @@ Grid::compute_bounding_box () const
_bounding_box = Rect();
if (_items.empty()) {
_bounding_box_dirty = false;
bb_clean ();
return;
}
@ -103,7 +103,7 @@ Grid::compute_bounding_box () const
outline_width() + left_margin + left_padding);
}
_bounding_box_dirty = false;
bb_clean ();
}
void

View File

@ -69,7 +69,7 @@ void
Image::compute_bounding_box () const
{
_bounding_box = Rect (0, 0, _width, _height);
_bounding_box_dirty = false;
bb_clean ();
}
boost::shared_ptr<Image::Data>

View File

@ -1316,3 +1316,10 @@ Item::set_layout_sensitive (bool yn)
{
_layout_sensitive = yn;
}
void
Item::bb_clean () const
{
_bounding_box_dirty = false;
}

View File

@ -52,7 +52,7 @@ Line::compute_bounding_box () const
bbox = bbox.expand (0.5 + (_outline_width / 2));
_bounding_box = bbox;
_bounding_box_dirty = false;
bb_clean ();
}
void

View File

@ -71,7 +71,7 @@ LineSet::compute_bounding_box () const
}
}
_bounding_box_dirty = false;
bb_clean ();
}
void

View File

@ -170,13 +170,13 @@ Meter::compute_bounding_box () const
{
if (!_canvas) {
_bounding_box = Rect ();
_bounding_box_dirty = false;
bb_clean ();
return;
}
Rect r (0, 0, pixwidth + 2, pixheight + 2);
_bounding_box = r;
_bounding_box_dirty = false;
bb_clean ();
}

View File

@ -52,7 +52,7 @@ Pixbuf::compute_bounding_box () const
_bounding_box = Rect ();
}
_bounding_box_dirty = false;
bb_clean ();
}
void

View File

@ -63,7 +63,7 @@ PolyItem::compute_bounding_box () const
_bounding_box = Rect ();
}
_bounding_box_dirty = false;
bb_clean ();
}
void

View File

@ -176,10 +176,11 @@ void
Rectangle::compute_bounding_box () const
{
if (!_rect.empty()) {
// _bounding_box = _rect.fix().expand (1.0 + _outline_width * 0.5);
_bounding_box = _rect.fix().expand (_outline_width * 0.5);
}
_bounding_box_dirty = false;
bb_clean ();
}
void

View File

@ -69,7 +69,7 @@ StepButton::compute_bounding_box () const
add_child_bounding_boxes ();
_bounding_box_dirty = false;
bb_clean ();
}
#define CORNER_RADIUS 5

View File

@ -239,7 +239,7 @@ Text::compute_bounding_box () const
{
if (!_canvas || _text.empty()) {
_bounding_box = Rect ();
_bounding_box_dirty = false;
bb_clean ();
return;
}
@ -253,7 +253,7 @@ Text::compute_bounding_box () const
_redraw ();
}
_bounding_box = Rect (0, 0, min (_clamped_width, (double) _image->get_width() * retina_factor), _image->get_height() * retina_factor);
_bounding_box_dirty = false;
bb_clean ();
}
}

View File

@ -143,5 +143,5 @@ Widget::compute_bounding_box () const
_widget.size_allocate (alloc);
_bounding_box_dirty = false;
bb_clean ();
}

View File

@ -115,7 +115,7 @@ XFadeCurve::compute_bounding_box () const
_bounding_box = Rect ();
}
_bounding_box_dirty = false;
bb_clean ();
}
void