2 #include <cairomm/context.h>
3 #include "pbd/compose.h"
4 #include "canvas/line.h"
5 #include "canvas/types.h"
6 #include "canvas/debug.h"
7 #include "canvas/utils.h"
10 using namespace ArdourCanvas;
12 Line::Line (Group* parent)
20 Line::compute_bounding_box () const
24 bbox.x0 = min (_points[0].x, _points[1].x);
25 bbox.y0 = min (_points[0].y, _points[1].y);
26 bbox.x1 = max (_points[0].x, _points[1].x);
27 bbox.y1 = max (_points[0].y, _points[1].y);
29 bbox = bbox.expand (_outline_width / 2);
32 _bounding_box_dirty = false;
36 Line::render (Rect const & /*area*/, Cairo::RefPtr<Cairo::Context> context) const
38 setup_outline_context (context);
41 Duple (min (_points[0].x, CAIRO_MAX), min (_points[0].y, CAIRO_MAX)),
42 Duple (min (_points[1].x, CAIRO_MAX), min (_points[1].y, CAIRO_MAX))
45 context->move_to (plot[0].x, plot[0].y);
46 context->line_to (plot[1].x, plot[1].y);
51 Line::set (Duple a, Duple b)
58 _bounding_box_dirty = true;
61 DEBUG_TRACE (PBD::DEBUG::CanvasItemsDirtied, "canvas item dirty: line change\n");
65 Line::set_x0 (Coord x0)
71 _bounding_box_dirty = true;
74 DEBUG_TRACE (PBD::DEBUG::CanvasItemsDirtied, "canvas item dirty: line change\n");
78 Line::set_y0 (Coord y0)
84 _bounding_box_dirty = true;
87 DEBUG_TRACE (PBD::DEBUG::CanvasItemsDirtied, "canvas item dirty: line change\n");
91 Line::set_x1 (Coord x1)
97 _bounding_box_dirty = true;
100 DEBUG_TRACE (PBD::DEBUG::CanvasItemsDirtied, "canvas item dirty: line change\n");
104 Line::set_y1 (Coord y1)
110 _bounding_box_dirty = true;
113 DEBUG_TRACE (PBD::DEBUG::CanvasItemsDirtied, "canvas item dirty: line change\n");