setup_polygon (i);
CANVAS_DEBUG_NAME (_heads[i].polygon, string_compose ("arrow head %1", i));
}
-
+
_line = new Line (this);
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.
Arrow::set_show_head (int which, bool show)
{
assert (which == 0 || which == 1);
-
+
begin_change ();
-
+
if (!show) {
delete _heads[which].polygon;
_heads[which].polygon = 0;
Arrow::set_head_outward (int which, bool outward)
{
assert (which == 0 || which == 1);
-
+
begin_change ();
_heads[which].outward = outward;
Arrow::set_head_height (int which, Distance height)
{
assert (which == 0 || which == 1);
-
+
begin_change ();
-
+
_heads[which].height = height;
setup_polygon (which);
Arrow::set_head_width (int which, Distance width)
{
assert (which == 0 || which == 1);
-
+
begin_change ();
-
+
_heads[which].width = width;
setup_polygon (which);
Arrow::setup_polygon (int which)
{
assert (which == 0 || which == 1);
-
+
Points points;
if ((which == 0 && _heads[which].outward) || (which == 1 && !_heads[which].outward)) {