projects
/
ardour.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Lua Script Example to toggle monitor section
[ardour.git]
/
libs
/
canvas
/
polygon.cc
diff --git
a/libs/canvas/polygon.cc
b/libs/canvas/polygon.cc
index 2e818236160d77335aec155aae1245d3de4a2a6c..53fea1c5f4f9bdacaa419f0e7270c20d2b95ff1e 100644
(file)
--- a/
libs/canvas/polygon.cc
+++ b/
libs/canvas/polygon.cc
@@
-21,15
+21,20
@@
using namespace ArdourCanvas;
using namespace ArdourCanvas;
-Polygon::Polygon (Group* parent)
- : Item (parent)
- , PolyItem (parent)
- , Fill (parent)
+Polygon::Polygon (Canvas* c)
+ : PolyItem (c)
, multiple (0)
, constant (0)
, cached_size (0)
{
, multiple (0)
, constant (0)
, cached_size (0)
{
+}
+Polygon::Polygon (Item* parent)
+ : PolyItem (parent)
+ , multiple (0)
+ , constant (0)
+ , cached_size (0)
+{
}
Polygon::~Polygon ()
}
Polygon::~Polygon ()
@@
-41,17
+46,24
@@
Polygon::~Polygon ()
void
Polygon::render (Rect const & area, Cairo::RefPtr<Cairo::Context> context) const
{
void
Polygon::render (Rect const & area, Cairo::RefPtr<Cairo::Context> context) const
{
- if (_outline) {
- setup_outline_context (context);
+ if (_outline || _fill) {
render_path (area, context);
render_path (area, context);
-
+
if (!_points.empty ()) {
/* close path */
Duple p = item_to_window (Duple (_points.front().x, _points.front().y));
if (!_points.empty ()) {
/* close path */
Duple p = item_to_window (Duple (_points.front().x, _points.front().y));
- context->
mov
e_to (p.x, p.y);
+ context->
lin
e_to (p.x, p.y);
}
}
- context->stroke_preserve ();
+ }
+
+ if (_outline) {
+ setup_outline_context (context);
+ if (_fill) {
+ context->stroke_preserve ();
+ } else {
+ context->stroke ();
+ }
}
if (_fill) {
}
if (_fill) {
@@
-60,7
+72,7
@@
Polygon::render (Rect const & area, Cairo::RefPtr<Cairo::Context> context) const
}
}
}
}
-void
+void
Polygon::cache_shape_computation () const
{
Points::size_type npoints = _points.size();
Polygon::cache_shape_computation () const
{
Points::size_type npoints = _points.size();
@@
-83,20
+95,20
@@
Polygon::cache_shape_computation () const
for (i = 0; i < npoints; i++) {
if (_points[j].y == _points[i].y) {
constant[i] = _points[i].x;
for (i = 0; i < npoints; i++) {
if (_points[j].y == _points[i].y) {
constant[i] = _points[i].x;
- multiple[i] = 0;
+ multiple[i] = 0;
} else {
constant[i] = _points[i].x-(_points[i].y*_points[j].x)/(_points[j].y-_points[i].y)+(_points[i].y*_points[i].x)/(_points[j].y-_points[i].y);
} else {
constant[i] = _points[i].x-(_points[i].y*_points[j].x)/(_points[j].y-_points[i].y)+(_points[i].y*_points[i].x)/(_points[j].y-_points[i].y);
- multiple[i] = (_points[j].x-_points[i].x)/(_points[j].y-_points[i].y);
+ multiple[i] = (_points[j].x-_points[i].x)/(_points[j].y-_points[i].y);
}
}
- j = i;
+ j = i;
}
}
}
}
-bool
+bool
Polygon::covers (Duple const & point) const
{
Polygon::covers (Duple const & point) const
{
- Duple p =
canvas
_to_item (point);
+ Duple p =
window
_to_item (point);
Points::size_type npoints = _points.size();
Points::size_type npoints = _points.size();
@@
-107,20
+119,20
@@
Polygon::covers (Duple const & point) const
Points::size_type i;
Points::size_type j = npoints -1;
bool oddNodes = false;
Points::size_type i;
Points::size_type j = npoints -1;
bool oddNodes = false;
-
+
if (_bounding_box_dirty) {
compute_bounding_box ();
}
if (_bounding_box_dirty) {
compute_bounding_box ();
}
-
+
for (i = 0; i < npoints; i++) {
if (((_points[i].y < p.y && _points[j].y >= p.y) || (_points[j].y < p.y && _points[i].y >= p.y))) {
for (i = 0; i < npoints; i++) {
if (((_points[i].y < p.y && _points[j].y >= p.y) || (_points[j].y < p.y && _points[i].y >= p.y))) {
- oddNodes ^= (p.y * multiple[i] + constant[i] < p.x);
+ oddNodes ^= (p.y * multiple[i] + constant[i] < p.x);
}
}
- j = i;
+ j = i;
}
}
- return oddNodes;
-}
+ return oddNodes;
+}
void
Polygon::compute_bounding_box () const
void
Polygon::compute_bounding_box () const