summaryrefslogtreecommitdiff
path: root/gtk2_ardour/port_matrix_component.cc
diff options
context:
space:
mode:
authorCarl Hetherington <carl@carlh.net>2009-01-20 14:46:00 +0000
committerCarl Hetherington <carl@carlh.net>2009-01-20 14:46:00 +0000
commit61db2175eb8b8fffd0c1796ace78ac33c9e1adf0 (patch)
tree6fdc23e7e0161ce54642b0bd44dc8e0a33f05efe /gtk2_ardour/port_matrix_component.cc
parentef038c1a84ecd541a540d5a5baa677d7663e535c (diff)
New matrix-based editor for connections and bundles, based on thorwil's design.
Add Bundle Manager dialog. git-svn-id: svn://localhost/ardour2/branches/3.0@4415 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'gtk2_ardour/port_matrix_component.cc')
-rw-r--r--gtk2_ardour/port_matrix_component.cc107
1 files changed, 107 insertions, 0 deletions
diff --git a/gtk2_ardour/port_matrix_component.cc b/gtk2_ardour/port_matrix_component.cc
new file mode 100644
index 0000000000..e2d1e07027
--- /dev/null
+++ b/gtk2_ardour/port_matrix_component.cc
@@ -0,0 +1,107 @@
+/*
+ Copyright (C) 2002-2009 Paul Davis
+
+ 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 <iostream>
+#include "port_matrix_component.h"
+
+/** Constructor.
+ * @param p Port matrix that we're in.
+ */
+PortMatrixComponent::PortMatrixComponent (PortMatrixBody* b)
+ : _body (b),
+ _pixmap (0),
+ _render_required (true),
+ _dimension_computation_required (true)
+{
+
+}
+
+/** Destructor */
+PortMatrixComponent::~PortMatrixComponent ()
+{
+ if (_pixmap) {
+ gdk_pixmap_unref (_pixmap);
+ }
+}
+
+void
+PortMatrixComponent::setup ()
+{
+ _dimension_computation_required = true;
+ _render_required = true;
+}
+
+GdkPixmap *
+PortMatrixComponent::get_pixmap (GdkDrawable *drawable)
+{
+ if (_render_required) {
+
+ if (_dimension_computation_required) {
+ compute_dimensions ();
+ _dimension_computation_required = false;
+ }
+
+ /* we may be zero width or height; if so, just
+ use the smallest allowable pixmap */
+ if (_width == 0) {
+ _width = 1;
+ }
+ if (_height == 0) {
+ _height = 1;
+ }
+
+ /* make a pixmap of the right size */
+ if (_pixmap) {
+ gdk_pixmap_unref (_pixmap);
+ }
+ _pixmap = gdk_pixmap_new (drawable, _width, _height, -1);
+
+ /* render */
+ cairo_t* cr = gdk_cairo_create (_pixmap);
+ render (cr);
+ cairo_destroy (cr);
+
+ _render_required = false;
+ }
+
+ return _pixmap;
+}
+
+void
+PortMatrixComponent::set_source_rgb (cairo_t *cr, Gdk::Color const & c)
+{
+ cairo_set_source_rgb (cr, c.get_red_p(), c.get_green_p(), c.get_blue_p());
+}
+
+void
+PortMatrixComponent::set_source_rgba (cairo_t *cr, Gdk::Color const & c, double a)
+{
+ cairo_set_source_rgba (cr, c.get_red_p(), c.get_green_p(), c.get_blue_p(), a);
+}
+
+std::pair<uint32_t, uint32_t>
+PortMatrixComponent::dimensions ()
+{
+ if (_dimension_computation_required) {
+ compute_dimensions ();
+ _dimension_computation_required = false;
+ }
+
+ return std::make_pair (_width, _height);
+}