goodbye USE_TRACKS_CODE_FEATURES and is_tracks_build
[ardour.git] / libs / canvas / outline.cc
1 /*
2  * Copyright (C) 2012 Carl Hetherington <carl@carlh.net>
3  * Copyright (C) 2013-2014 Paul Davis <paul@linuxaudiosystems.com>
4  * Copyright (C) 2017 Robin Gareus <robin@gareus.org>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License along
17  * with this program; if not, write to the Free Software Foundation, Inc.,
18  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19  */
20
21 #include <cairomm/context.h>
22
23 #include "pbd/compose.h"
24 #include "pbd/convert.h"
25
26 #include "canvas/item.h"
27 #include "canvas/outline.h"
28 #include "canvas/debug.h"
29
30 using namespace ArdourCanvas;
31
32 Outline::Outline (Item& self)
33         : _self (self)
34         , _outline_color (0x000000ff)
35         , _outline_width (1.0)
36         , _outline (true)
37 {
38 }
39
40 void
41 Outline::set_outline_color (Gtkmm2ext::Color color)
42 {
43         if (color != _outline_color) {
44                 _self.begin_visual_change ();
45                 _outline_color = color;
46                 _self.end_visual_change ();
47         }
48 }
49
50 void
51 Outline::set_outline_width (Distance width)
52 {
53         if (width != _outline_width) {
54                 _self.begin_change ();
55                 _outline_width = width;
56                 _self._bounding_box_dirty = true;
57                 _self.end_change ();
58         }
59 }
60
61 void
62 Outline::set_outline (bool outline)
63 {
64         if (outline != _outline) {
65                 _self.begin_change ();
66                 _outline = outline;
67                 _self._bounding_box_dirty = true;
68                 _self.end_change ();
69         }
70 }
71
72 void
73 Outline::setup_outline_context (Cairo::RefPtr<Cairo::Context> context) const
74 {
75         Gtkmm2ext::set_source_rgba (context, _outline_color);
76         context->set_line_width (_outline_width);
77 }
78