2014-06-22 09:53:14 -04:00
|
|
|
/*
|
2019-08-02 22:40:09 -04:00
|
|
|
* Copyright (C) 2012 Carl Hetherington <carl@carlh.net>
|
|
|
|
* Copyright (C) 2014-2017 Paul Davis <paul@linuxaudiosystems.com>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*/
|
2014-06-22 09:53:14 -04:00
|
|
|
|
|
|
|
#include "canvas/container.h"
|
|
|
|
|
|
|
|
using namespace ArdourCanvas;
|
|
|
|
|
2015-10-04 14:51:05 -04:00
|
|
|
Container::Container (Canvas* canvas)
|
2014-06-22 09:53:14 -04:00
|
|
|
: Item (canvas)
|
2022-12-08 19:34:01 -05:00
|
|
|
, _render_with_alpha (-1)
|
2014-06-22 09:53:14 -04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2015-10-04 14:51:05 -04:00
|
|
|
Container::Container (Item* parent)
|
2014-06-22 09:53:14 -04:00
|
|
|
: Item (parent)
|
2022-12-08 19:34:01 -05:00
|
|
|
, _render_with_alpha (-1)
|
2014-06-22 09:53:14 -04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-10-04 14:51:05 -04:00
|
|
|
Container::Container (Item* parent, Duple const & p)
|
2014-06-22 09:53:14 -04:00
|
|
|
: Item (parent, p)
|
2022-12-08 19:34:01 -05:00
|
|
|
, _render_with_alpha (-1)
|
2014-06-22 09:53:14 -04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2017-04-01 09:02:49 -04:00
|
|
|
void
|
|
|
|
Container::prepare_for_render (Rect const & area) const
|
|
|
|
{
|
|
|
|
Item::prepare_for_render_children (area);
|
|
|
|
}
|
|
|
|
|
2014-06-22 11:41:05 -04:00
|
|
|
void
|
|
|
|
Container::render (Rect const & area, Cairo::RefPtr<Cairo::Context> context) const
|
|
|
|
{
|
2022-12-08 19:34:01 -05:00
|
|
|
if (_render_with_alpha == 0) {
|
|
|
|
return;
|
|
|
|
} else if (_render_with_alpha > 0) {
|
|
|
|
context->push_group ();
|
|
|
|
}
|
|
|
|
|
2014-06-22 11:41:05 -04:00
|
|
|
Item::render_children (area, context);
|
2022-12-08 19:34:01 -05:00
|
|
|
|
|
|
|
if (_render_with_alpha >= 1.0) {
|
|
|
|
context->pop_group ();
|
|
|
|
} else if (_render_with_alpha > 0) {
|
|
|
|
context->pop_group_to_source ();
|
|
|
|
context->paint_with_alpha (_render_with_alpha);
|
|
|
|
}
|
2014-06-22 11:41:05 -04:00
|
|
|
}
|
|
|
|
|
2014-06-22 09:53:14 -04:00
|
|
|
void
|
|
|
|
Container::compute_bounding_box () const
|
|
|
|
{
|
2017-01-19 14:54:24 -05:00
|
|
|
_bounding_box = Rect ();
|
2021-07-27 15:21:03 -04:00
|
|
|
/* nothing to do here; Item::bounding_box() will add all children for us */
|
2022-04-27 00:02:22 -04:00
|
|
|
set_bbox_clean ();
|
2014-06-22 09:53:14 -04:00
|
|
|
}
|
2022-12-08 19:34:01 -05:00
|
|
|
|
|
|
|
void
|
|
|
|
Container::set_render_with_alpha (double alpha)
|
|
|
|
{
|
|
|
|
if (_render_with_alpha == alpha) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
_render_with_alpha = alpha;
|
|
|
|
redraw ();
|
|
|
|
}
|