summaryrefslogtreecommitdiff
path: root/libs/canvas/layout.cc
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2014-06-22 09:53:14 -0400
committerPaul Davis <paul@linuxaudiosystems.com>2014-06-22 09:53:14 -0400
commitf0933bf00551ce998ca441aa5611d27702f6e590 (patch)
tree4e1ed902bf98d426e2befcdefc0d6671f9b7a11c /libs/canvas/layout.cc
parentff46a3c3a216afc97fee0c796ac2eaa92d58becb (diff)
add missing new files for canvas redesign
Diffstat (limited to 'libs/canvas/layout.cc')
-rw-r--r--libs/canvas/layout.cc132
1 files changed, 132 insertions, 0 deletions
diff --git a/libs/canvas/layout.cc b/libs/canvas/layout.cc
new file mode 100644
index 0000000000..ca9f50d05e
--- /dev/null
+++ b/libs/canvas/layout.cc
@@ -0,0 +1,132 @@
+/*
+ Copyright (C) 2011-2014 Paul Davis
+ Author: Carl Hetherington <cth@carlh.net>
+
+ 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include "pbd/compose.h"
+
+#include "canvas/canvas.h"
+#include "canvas/debug.h"
+#include "canvas/layout.h"
+
+using namespace std;
+using namespace PBD;
+using namespace ArdourCanvas;
+
+Layout::Layout (Canvas* canvas)
+ : Container (canvas)
+{
+}
+
+Layout::Layout (Item* parent)
+ : Container (parent)
+{
+}
+
+Layout::Layout (Item* parent, Duple const & p)
+ : Container (parent, p)
+{
+}
+
+/** @param area Area to draw in window coordinates.
+ * @param context Context, set up with its origin at this layout's position.
+ */
+void
+Layout::render (Rect const & area, Cairo::RefPtr<Cairo::Context> context) const
+{
+ ensure_lut ();
+ std::vector<Item*> items = _lut->get (area);
+
+#ifdef CANVAS_DEBUG
+ if (DEBUG_ENABLED(PBD::DEBUG::CanvasRender)) {
+ cerr << string_compose ("%1GROUP %2 @ %7 render %5 @ %6 %3 items out of %4\n",
+ _canvas->render_indent(), (name.empty() ? string ("[unnamed]") : name), items.size(), _items.size(), area, _position, this);
+ }
+#endif
+
+ ++render_depth;
+
+ for (std::vector<Item*>::const_iterator i = items.begin(); i != items.end(); ++i) {
+
+ if (!(*i)->visible ()) {
+#ifdef CANVAS_DEBUG
+ if (DEBUG_ENABLED(PBD::DEBUG::CanvasRender)) {
+ cerr << _canvas->render_indent() << "Item " << (*i)->whatami() << " [" << (*i)->name << "] invisible - skipped\n";
+ }
+#endif
+ continue;
+ }
+
+ boost::optional<Rect> item_bbox = (*i)->bounding_box ();
+
+ if (!item_bbox) {
+#ifdef CANVAS_DEBUG
+ if (DEBUG_ENABLED(PBD::DEBUG::CanvasRender)) {
+ cerr << _canvas->render_indent() << "Item " << (*i)->whatami() << " [" << (*i)->name << "] empty - skipped\n";
+ }
+#endif
+ continue;
+ }
+
+ Rect item = (*i)->item_to_window (item_bbox.get());
+ boost::optional<Rect> d = item.intersection (area);
+
+ if (d) {
+ Rect draw = d.get();
+ if (draw.width() && draw.height()) {
+#ifdef CANVAS_DEBUG
+ if (DEBUG_ENABLED(PBD::DEBUG::CanvasRender)) {
+ if (dynamic_cast<Container*>(*i) == 0) {
+ cerr << _canvas->render_indent() << "render "
+ << ' '
+ << (*i)
+ << ' '
+ << (*i)->whatami()
+ << ' '
+ << (*i)->name
+ << " item "
+ << item_bbox.get()
+ << " window = "
+ << item
+ << " intersect = "
+ << draw
+ << " @ "
+ << _position
+ << endl;
+ }
+ }
+#endif
+
+ (*i)->render (area, context);
+ ++render_count;
+ }
+
+ } else {
+
+#ifdef CANVAS_DEBUG
+ if (DEBUG_ENABLED(PBD::DEBUG::CanvasRender)) {
+ cerr << string_compose ("%1skip render of %2 %3, no intersection between %4 and %5\n", _canvas->render_indent(), (*i)->whatami(),
+ (*i)->name, item, area);
+ }
+#endif
+
+ }
+ }
+
+ --render_depth;
+}
+