From fc70b5a9f92a501053658c90c0a7af26deb9d74d Mon Sep 17 00:00:00 2001 From: David Robillard Date: Fri, 16 Jan 2015 22:04:26 -0500 Subject: [PATCH] Compute arrow bbox manually to appease crazy canvas. --- libs/canvas/arrow.cc | 17 +++++++++++++++++ libs/canvas/canvas/arrow.h | 2 ++ 2 files changed, 19 insertions(+) diff --git a/libs/canvas/arrow.cc b/libs/canvas/arrow.cc index 92a795c954..d78b04ef58 100644 --- a/libs/canvas/arrow.cc +++ b/libs/canvas/arrow.cc @@ -63,6 +63,23 @@ Arrow::setup () CANVAS_DEBUG_NAME (_line, "arrow line"); } +void +Arrow::compute_bounding_box () const +{ + /* Compute our bounding box manually rather than using the default + container algorithm, since having the bounding box with origin other + than zero causes strange problems for mysterious reasons. */ + + const double outline_pad = 0.5 + (_line->outline_width() / 2.0); + const double head_width = std::max(_heads[0].width, _heads[1].width); + + _bounding_box = Rect(0, + 0, + _line->x1() + (head_width / 2.0) + outline_pad, + _line->y1()); + + _bounding_box_dirty = false; +} /** Set whether to show an arrow head at one end or other * of the line. diff --git a/libs/canvas/canvas/arrow.h b/libs/canvas/canvas/arrow.h index 45c6eb110e..6617e13bd2 100644 --- a/libs/canvas/canvas/arrow.h +++ b/libs/canvas/canvas/arrow.h @@ -51,6 +51,8 @@ public: Arrow (Canvas*); Arrow (Item*); + void compute_bounding_box () const; + void set_show_head (int, bool); void set_head_outward (int, bool); void set_head_height (int, Distance); -- 2.30.2