mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-07 15:25:01 +01:00
mostly fix conceptual error in how canvas rectangle frames are drawn
This commit is contained in:
parent
5fec68e6c5
commit
c235d3da99
1 changed files with 38 additions and 24 deletions
|
|
@ -36,7 +36,6 @@ Rectangle::Rectangle (Group* parent)
|
||||||
, Fill (parent)
|
, Fill (parent)
|
||||||
, _outline_what ((What) (LEFT | RIGHT | TOP | BOTTOM))
|
, _outline_what ((What) (LEFT | RIGHT | TOP | BOTTOM))
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Rectangle::Rectangle (Group* parent, Rect const & rect)
|
Rectangle::Rectangle (Group* parent, Rect const & rect)
|
||||||
|
|
@ -76,39 +75,54 @@ Rectangle::render (Rect const & area, Cairo::RefPtr<Cairo::Context> context) con
|
||||||
|
|
||||||
setup_outline_context (context);
|
setup_outline_context (context);
|
||||||
|
|
||||||
context->save ();
|
if (_outline_what == What (LEFT|RIGHT|BOTTOM|TOP)) {
|
||||||
context->rectangle (draw.x0, draw.y0, draw.width(), draw.height());
|
|
||||||
context->clip ();
|
context->rectangle (self.x0 + 0.5, self.y0 + 0.5, self.width(), self.height());
|
||||||
|
|
||||||
if (_outline_what & LEFT) {
|
} else {
|
||||||
context->move_to (self.x0, self.y0);
|
|
||||||
context->line_to (self.x0, self.y1);
|
context->set_line_cap (Cairo::LINE_CAP_SQUARE);
|
||||||
}
|
|
||||||
|
/* see the cairo FAQ on single pixel lines to see why we do
|
||||||
if (_outline_what & BOTTOM) {
|
* this expansion of the perimeter.
|
||||||
context->move_to (self.x0, self.y1);
|
*/
|
||||||
context->line_to (self.x1, self.y1);
|
|
||||||
}
|
if (_outline_what & LEFT) {
|
||||||
|
/* vertical line: move x-coordinate by 0.5 pixels */
|
||||||
if (_outline_what & RIGHT) {
|
context->move_to (self.x0 + 0.5, self.y0);
|
||||||
context->move_to (self.x1, self.y0);
|
context->line_to (self.x0 + 0.5, self.y1);
|
||||||
context->line_to (self.x1, self.y1);
|
}
|
||||||
}
|
|
||||||
|
if (_outline_what & BOTTOM) {
|
||||||
if (_outline_what & TOP) {
|
/* horizontal line: move y-coordinate by 0.5 pixels */
|
||||||
context->move_to (self.x0, self.y0);
|
context->move_to (self.x0, self.y1 - 0.5);
|
||||||
context->line_to (self.x1, self.y0);
|
context->line_to (self.x1, self.y1 - 0.5);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_outline_what & RIGHT) {
|
||||||
|
/* vertical line: move x-coordinate by 0.5 pixels */
|
||||||
|
context->move_to (self.x1 - 0.5, self.y0);
|
||||||
|
context->line_to (self.x1 - 0.5, self.y1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_outline_what & TOP) {
|
||||||
|
/* horizontal line: move y-coordinate by 0.5 pixels */
|
||||||
|
context->move_to (self.x0, self.y0 + 0.5);
|
||||||
|
context->line_to (self.x1, self.y0 + 0.5);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
context->stroke ();
|
context->stroke ();
|
||||||
context->restore ();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Rectangle::compute_bounding_box () const
|
Rectangle::compute_bounding_box () const
|
||||||
{
|
{
|
||||||
Rect r = _rect.fix ();
|
/* boundary is drawn inside our coordinates but expanded by 0.5 to get
|
||||||
|
* single-pixel drawing correct.
|
||||||
|
*/
|
||||||
|
Rect r = _rect.fix();
|
||||||
_bounding_box = boost::optional<Rect> (r.expand (_outline_width/2.0));
|
_bounding_box = boost::optional<Rect> (r.expand (_outline_width/2.0));
|
||||||
_bounding_box_dirty = false;
|
_bounding_box_dirty = false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue