From ee4e28751edae18bc2c2d3960472f15446b17306 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Wed, 4 Feb 2009 17:05:26 +0000 Subject: Reduce header dependencies. git-svn-id: svn://localhost/ardour2/branches/3.0@4490 d708f5d6-7413-0410-9779-e7cbd77b26cf --- gtk2_ardour/port_matrix.cc | 30 ++++--- gtk2_ardour/port_matrix.h | 6 +- gtk2_ardour/port_matrix_body.cc | 145 +++++++++++++++++-------------- gtk2_ardour/port_matrix_body.h | 14 +-- gtk2_ardour/port_matrix_column_labels.cc | 1 + gtk2_ardour/port_matrix_grid.cc | 1 + gtk2_ardour/port_matrix_row_labels.cc | 1 + 7 files changed, 110 insertions(+), 88 deletions(-) diff --git a/gtk2_ardour/port_matrix.cc b/gtk2_ardour/port_matrix.cc index cf7c8215f9..1963818203 100644 --- a/gtk2_ardour/port_matrix.cc +++ b/gtk2_ardour/port_matrix.cc @@ -29,6 +29,7 @@ #include "ardour/session.h" #include "ardour/route.h" #include "port_matrix.h" +#include "port_matrix_body.h" #include "i18n.h" /** PortMatrix constructor. @@ -38,7 +39,6 @@ PortMatrix::PortMatrix (ARDOUR::Session& session, ARDOUR::DataType type) : _session (session), _type (type), - _body (this), _column_visibility_box_added (false), _row_visibility_box_added (false), _menu (0), @@ -47,6 +47,8 @@ PortMatrix::PortMatrix (ARDOUR::Session& session, ARDOUR::DataType type) _row_index (0), _column_index (1) { + _body = new PortMatrixBody (this); + _ports[0].set_type (type); _ports[1].set_type (type); @@ -66,6 +68,8 @@ PortMatrix::PortMatrix (ARDOUR::Session& session, ARDOUR::DataType type) PortMatrix::~PortMatrix () { + delete _body; + for (std::vector::iterator i = _column_visibility_buttons.begin(); i != _column_visibility_buttons.end(); ++i) { delete *i; } @@ -106,7 +110,7 @@ void PortMatrix::setup () { select_arrangement (); - _body.setup (); + _body->setup (); setup_scrollbars (); queue_draw (); @@ -132,7 +136,7 @@ PortMatrix::setup () _row_visibility_buttons.clear (); _scroller_table.remove (_vscroll); - _scroller_table.remove (_body); + _scroller_table.remove (*_body); _scroller_table.remove (_hscroll); _main_hbox.remove (_scroller_table); @@ -175,7 +179,7 @@ PortMatrix::setup () if (_arrangement == TOP_TO_RIGHT) { _scroller_table.attach (_hscroll, 0, 1, 0, 1, Gtk::FILL | Gtk::EXPAND, Gtk::SHRINK); - _scroller_table.attach (_body, 0, 1, 1, 2); + _scroller_table.attach (*_body, 0, 1, 1, 2); _scroller_table.attach (_vscroll, 1, 2, 1, 2, Gtk::SHRINK); _main_hbox.pack_start (_scroller_table); @@ -198,7 +202,7 @@ PortMatrix::setup () } else { _scroller_table.attach (_vscroll, 0, 1, 0, 1, Gtk::SHRINK); - _scroller_table.attach (_body, 1, 2, 0, 1); + _scroller_table.attach (*_body, 1, 2, 0, 1); _scroller_table.attach (_hscroll, 1, 2, 1, 2, Gtk::FILL | Gtk::EXPAND, Gtk::SHRINK); if (rows()->size() > 1) { @@ -237,13 +241,13 @@ PortMatrix::set_type (ARDOUR::DataType t) void PortMatrix::hscroll_changed () { - _body.set_xoffset (_hscroll.get_adjustment()->get_value()); + _body->set_xoffset (_hscroll.get_adjustment()->get_value()); } void PortMatrix::vscroll_changed () { - _body.set_yoffset (_vscroll.get_adjustment()->get_value()); + _body->set_yoffset (_vscroll.get_adjustment()->get_value()); } void @@ -251,15 +255,15 @@ PortMatrix::setup_scrollbars () { Gtk::Adjustment* a = _hscroll.get_adjustment (); a->set_lower (0); - a->set_upper (_body.full_scroll_width()); - a->set_page_size (_body.alloc_scroll_width()); + a->set_upper (_body->full_scroll_width()); + a->set_page_size (_body->alloc_scroll_width()); a->set_step_increment (32); a->set_page_increment (128); a = _vscroll.get_adjustment (); a->set_lower (0); - a->set_upper (_body.full_scroll_height()); - a->set_page_size (_body.alloc_scroll_height()); + a->set_upper (_body->full_scroll_height()); + a->set_page_size (_body->alloc_scroll_height()); a->set_step_increment (32); a->set_page_increment (128); } @@ -288,7 +292,7 @@ PortMatrix::disassociate_all () } } - _body.rebuild_and_draw_grid (); + _body->rebuild_and_draw_grid (); } /* Decide how to arrange the components of the matrix */ @@ -347,7 +351,7 @@ PortMatrix::visibility_toggled (boost::weak_ptr w, Gtk::CheckButton* } g->set_visible (b->get_active()); - _body.setup (); + _body->setup (); setup_scrollbars (); queue_draw (); } diff --git a/gtk2_ardour/port_matrix.h b/gtk2_ardour/port_matrix.h index 44dc14acae..a789ea6203 100644 --- a/gtk2_ardour/port_matrix.h +++ b/gtk2_ardour/port_matrix.h @@ -27,7 +27,7 @@ #include #include #include -#include "port_matrix_body.h" +#include "ardour/bundle.h" #include "port_group.h" /** The `port matrix' UI. This is a widget which lets the user alter @@ -43,6 +43,8 @@ namespace ARDOUR { class Bundle; } +class PortMatrixBody; + class PortMatrix : public Gtk::VBox { public: @@ -144,7 +146,7 @@ private: ARDOUR::DataType _type; std::vector _route_connections; - PortMatrixBody _body; + PortMatrixBody* _body; Gtk::HScrollbar _hscroll; Gtk::VScrollbar _vscroll; Gtk::HBox _main_hbox; diff --git a/gtk2_ardour/port_matrix_body.cc b/gtk2_ardour/port_matrix_body.cc index de73adcaff..81c332da86 100644 --- a/gtk2_ardour/port_matrix_body.cc +++ b/gtk2_ardour/port_matrix_body.cc @@ -22,21 +22,32 @@ #include "ardour/types.h" #include "port_matrix_body.h" #include "port_matrix.h" +#include "port_matrix_column_labels.h" +#include "port_matrix_row_labels.h" +#include "port_matrix_grid.h" PortMatrixBody::PortMatrixBody (PortMatrix* p) : _matrix (p), - _column_labels (p, this), - _row_labels (p, this), - _grid (p, this), _xoffset (0), _yoffset (0), _mouse_over_grid (false) { + _column_labels = new PortMatrixColumnLabels (p, this); + _row_labels = new PortMatrixRowLabels (p, this); + _grid = new PortMatrixGrid (p, this); + modify_bg (Gtk::STATE_NORMAL, Gdk::Color ("#00000")); add_events (Gdk::LEAVE_NOTIFY_MASK | Gdk::POINTER_MOTION_MASK); } +PortMatrixBody::~PortMatrixBody () +{ + delete _column_labels; + delete _row_labels; + delete _grid; +} + bool PortMatrixBody::on_expose_event (GdkEventExpose* event) { @@ -46,15 +57,15 @@ PortMatrixBody::on_expose_event (GdkEventExpose* event) bool intersects; Gdk::Rectangle r = exposure; - r.intersect (_column_labels.parent_rectangle(), intersects); + r.intersect (_column_labels->parent_rectangle(), intersects); if (intersects) { gdk_draw_drawable ( get_window()->gobj(), get_style()->get_fg_gc (Gtk::STATE_NORMAL)->gobj(), - _column_labels.get_pixmap (get_window()->gobj()), - _column_labels.parent_to_component_x (r.get_x()), - _column_labels.parent_to_component_y (r.get_y()), + _column_labels->get_pixmap (get_window()->gobj()), + _column_labels->parent_to_component_x (r.get_x()), + _column_labels->parent_to_component_y (r.get_y()), r.get_x(), r.get_y(), r.get_width(), @@ -63,15 +74,15 @@ PortMatrixBody::on_expose_event (GdkEventExpose* event) } r = exposure; - r.intersect (_row_labels.parent_rectangle(), intersects); + r.intersect (_row_labels->parent_rectangle(), intersects); if (intersects) { gdk_draw_drawable ( get_window()->gobj(), get_style()->get_fg_gc (Gtk::STATE_NORMAL)->gobj(), - _row_labels.get_pixmap (get_window()->gobj()), - _row_labels.parent_to_component_x (r.get_x()), - _row_labels.parent_to_component_y (r.get_y()), + _row_labels->get_pixmap (get_window()->gobj()), + _row_labels->parent_to_component_x (r.get_x()), + _row_labels->parent_to_component_y (r.get_y()), r.get_x(), r.get_y(), r.get_width(), @@ -80,15 +91,15 @@ PortMatrixBody::on_expose_event (GdkEventExpose* event) } r = exposure; - r.intersect (_grid.parent_rectangle(), intersects); + r.intersect (_grid->parent_rectangle(), intersects); if (intersects) { gdk_draw_drawable ( get_window()->gobj(), get_style()->get_fg_gc (Gtk::STATE_NORMAL)->gobj(), - _grid.get_pixmap (get_window()->gobj()), - _grid.parent_to_component_x (r.get_x()), - _grid.parent_to_component_y (r.get_y()), + _grid->get_pixmap (get_window()->gobj()), + _grid->parent_to_component_x (r.get_x()), + _grid->parent_to_component_y (r.get_y()), r.get_x(), r.get_y(), r.get_width(), @@ -99,18 +110,18 @@ PortMatrixBody::on_expose_event (GdkEventExpose* event) cairo_t* cr = gdk_cairo_create (get_window()->gobj()); cairo_save (cr); - set_cairo_clip (cr, _grid.parent_rectangle ()); - _grid.draw_extra (cr); + set_cairo_clip (cr, _grid->parent_rectangle ()); + _grid->draw_extra (cr); cairo_restore (cr); cairo_save (cr); - set_cairo_clip (cr, _row_labels.parent_rectangle ()); - _row_labels.draw_extra (cr); + set_cairo_clip (cr, _row_labels->parent_rectangle ()); + _row_labels->draw_extra (cr); cairo_restore (cr); cairo_save (cr); - set_cairo_clip (cr, _column_labels.parent_rectangle ()); - _column_labels.draw_extra (cr); + set_cairo_clip (cr, _column_labels->parent_rectangle ()); + _column_labels->draw_extra (cr); cairo_restore (cr); cairo_destroy (cr); @@ -121,9 +132,9 @@ PortMatrixBody::on_expose_event (GdkEventExpose* event) void PortMatrixBody::on_size_request (Gtk::Requisition *req) { - std::pair const col = _column_labels.dimensions (); - std::pair const row = _row_labels.dimensions (); - std::pair const grid = _grid.dimensions (); + std::pair const col = _column_labels->dimensions (); + std::pair const row = _row_labels->dimensions (); + std::pair const grid = _grid->dimensions (); /* don't ask for the maximum size of our contents, otherwise GTK won't let the containing window shrink below this size */ @@ -148,9 +159,9 @@ void PortMatrixBody::compute_rectangles () { /* full sizes of components */ - std::pair const col = _column_labels.dimensions (); - std::pair const row = _row_labels.dimensions (); - std::pair const grid = _grid.dimensions (); + std::pair const col = _column_labels->dimensions (); + std::pair const row = _row_labels->dimensions (); + std::pair const grid = _grid->dimensions (); Gdk::Rectangle col_rect; Gdk::Rectangle row_rect; @@ -239,9 +250,9 @@ PortMatrixBody::compute_rectangles () row_rect.set_y (grid_rect.get_y()); } - _row_labels.set_parent_rectangle (row_rect); - _column_labels.set_parent_rectangle (col_rect); - _grid.set_parent_rectangle (grid_rect); + _row_labels->set_parent_rectangle (row_rect); + _column_labels->set_parent_rectangle (col_rect); + _grid->set_parent_rectangle (grid_rect); } void @@ -272,9 +283,9 @@ PortMatrixBody::setup () ); } - _column_labels.setup (); - _row_labels.setup (); - _grid.setup (); + _column_labels->setup (); + _row_labels->setup (); + _grid->setup (); set_mouseover (PortMatrixNode ()); compute_rectangles (); @@ -283,26 +294,26 @@ PortMatrixBody::setup () uint32_t PortMatrixBody::full_scroll_width () { - return _grid.dimensions().first; + return _grid->dimensions().first; } uint32_t PortMatrixBody::alloc_scroll_width () { - return _grid.parent_rectangle().get_width(); + return _grid->parent_rectangle().get_width(); } uint32_t PortMatrixBody::full_scroll_height () { - return _grid.dimensions().second; + return _grid->dimensions().second; } uint32_t PortMatrixBody::alloc_scroll_height () { - return _grid.parent_rectangle().get_height(); + return _grid->parent_rectangle().get_height(); } void @@ -322,27 +333,27 @@ PortMatrixBody::set_yoffset (uint32_t yo) bool PortMatrixBody::on_button_press_event (GdkEventButton* ev) { - if (Gdk::Region (_grid.parent_rectangle()).point_in (ev->x, ev->y)) { + if (Gdk::Region (_grid->parent_rectangle()).point_in (ev->x, ev->y)) { - _grid.button_press ( - _grid.parent_to_component_x (ev->x), - _grid.parent_to_component_y (ev->y), + _grid->button_press ( + _grid->parent_to_component_x (ev->x), + _grid->parent_to_component_y (ev->y), ev->button ); - } else if (Gdk::Region (_row_labels.parent_rectangle()).point_in (ev->x, ev->y)) { + } else if (Gdk::Region (_row_labels->parent_rectangle()).point_in (ev->x, ev->y)) { - _row_labels.button_press ( - _row_labels.parent_to_component_x (ev->x), - _row_labels.parent_to_component_y (ev->y), + _row_labels->button_press ( + _row_labels->parent_to_component_x (ev->x), + _row_labels->parent_to_component_y (ev->y), ev->button, ev->time ); - } else if (Gdk::Region (_column_labels.parent_rectangle()).point_in (ev->x, ev->y)) { + } else if (Gdk::Region (_column_labels->parent_rectangle()).point_in (ev->x, ev->y)) { - _column_labels.button_press ( - _column_labels.parent_to_component_x (ev->x), - _column_labels.parent_to_component_y (ev->y), + _column_labels->button_press ( + _column_labels->parent_to_component_x (ev->x), + _column_labels->parent_to_component_y (ev->y), ev->button, ev->time ); } @@ -353,11 +364,11 @@ PortMatrixBody::on_button_press_event (GdkEventButton* ev) bool PortMatrixBody::on_button_release_event (GdkEventButton* ev) { - if (Gdk::Region (_row_labels.parent_rectangle()).point_in (ev->x, ev->y) || - Gdk::Region (_column_labels.parent_rectangle()).point_in (ev->x, ev->y)) { + if (Gdk::Region (_row_labels->parent_rectangle()).point_in (ev->x, ev->y) || + Gdk::Region (_column_labels->parent_rectangle()).point_in (ev->x, ev->y)) { - _row_labels.clear_channel_highlights (); - _column_labels.clear_channel_highlights (); + _row_labels->clear_channel_highlights (); + _column_labels->clear_channel_highlights (); } @@ -367,21 +378,21 @@ PortMatrixBody::on_button_release_event (GdkEventButton* ev) void PortMatrixBody::rebuild_and_draw_grid () { - _grid.require_rebuild (); + _grid->require_rebuild (); queue_draw (); } void PortMatrixBody::rebuild_and_draw_column_labels () { - _column_labels.require_rebuild (); + _column_labels->require_rebuild (); queue_draw (); } void PortMatrixBody::rebuild_and_draw_row_labels () { - _row_labels.require_rebuild (); + _row_labels->require_rebuild (); queue_draw (); } @@ -398,10 +409,10 @@ PortMatrixBody::on_leave_notify_event (GdkEventCrossing* ev) bool PortMatrixBody::on_motion_notify_event (GdkEventMotion* ev) { - if (Gdk::Region (_grid.parent_rectangle()).point_in (ev->x, ev->y)) { - _grid.mouseover_event ( - _grid.parent_to_component_x (ev->x), - _grid.parent_to_component_y (ev->y) + if (Gdk::Region (_grid->parent_rectangle()).point_in (ev->x, ev->y)) { + _grid->mouseover_event ( + _grid->parent_to_component_x (ev->x), + _grid->parent_to_component_y (ev->y) ); _mouse_over_grid = true; } else { @@ -424,9 +435,9 @@ PortMatrixBody::set_mouseover (PortMatrixNode const & n) PortMatrixNode old = _mouseover; _mouseover = n; - _grid.mouseover_changed (old); - _row_labels.mouseover_changed (old); - _column_labels.mouseover_changed (old); + _grid->mouseover_changed (old); + _row_labels->mouseover_changed (old); + _column_labels->mouseover_changed (old); } @@ -451,9 +462,9 @@ PortMatrixBody::highlight_associated_channels (int dim, uint32_t N) } if (dim == _matrix->column_index()) { - _column_labels.add_channel_highlight (bc[dim]); + _column_labels->add_channel_highlight (bc[dim]); } else { - _row_labels.add_channel_highlight (bc[dim]); + _row_labels->add_channel_highlight (bc[dim]); } ARDOUR::BundleList const b = _matrix->ports(1 - dim)->bundles (); @@ -463,9 +474,9 @@ PortMatrixBody::highlight_associated_channels (int dim, uint32_t N) bc[1 - dim] = ARDOUR::BundleChannel (*i, j); if (_matrix->get_state (bc) == PortMatrix::ASSOCIATED) { if (dim == _matrix->column_index()) { - _row_labels.add_channel_highlight (bc[1 - dim]); + _row_labels->add_channel_highlight (bc[1 - dim]); } else { - _column_labels.add_channel_highlight (bc[1 - dim]); + _column_labels->add_channel_highlight (bc[1 - dim]); } } } diff --git a/gtk2_ardour/port_matrix_body.h b/gtk2_ardour/port_matrix_body.h index cbf985dd0b..50a656522a 100644 --- a/gtk2_ardour/port_matrix_body.h +++ b/gtk2_ardour/port_matrix_body.h @@ -20,13 +20,14 @@ #ifndef __gtk_ardour_port_matrix_body_h__ #define __gtk_ardour_port_matrix_body_h__ -#include "port_matrix_column_labels.h" -#include "port_matrix_row_labels.h" -#include "port_matrix_grid.h" +#include #include "port_group.h" #include "port_matrix_types.h" class PortMatrix; +class PortMatrixColumnLabels; +class PortMatrixRowLabels; +class PortMatrixGrid; /** The main body of the port matrix. It is made up of three parts: * column labels, grid and row labels, each drawn using cairo. @@ -35,6 +36,7 @@ class PortMatrixBody : public Gtk::EventBox { public: PortMatrixBody (PortMatrix *); + ~PortMatrixBody (); void setup (); @@ -78,9 +80,9 @@ private: void set_cairo_clip (cairo_t *, Gdk::Rectangle const &) const; PortMatrix* _matrix; - PortMatrixColumnLabels _column_labels; - PortMatrixRowLabels _row_labels; - PortMatrixGrid _grid; + PortMatrixColumnLabels* _column_labels; + PortMatrixRowLabels* _row_labels; + PortMatrixGrid* _grid; uint32_t _alloc_width; ///< allocated width uint32_t _alloc_height; ///< allocated height diff --git a/gtk2_ardour/port_matrix_column_labels.cc b/gtk2_ardour/port_matrix_column_labels.cc index 7bbf0e64c0..06a635b41d 100644 --- a/gtk2_ardour/port_matrix_column_labels.cc +++ b/gtk2_ardour/port_matrix_column_labels.cc @@ -22,6 +22,7 @@ #include "ardour/types.h" #include "port_matrix_column_labels.h" #include "port_matrix.h" +#include "port_matrix_body.h" PortMatrixColumnLabels::PortMatrixColumnLabels (PortMatrix* m, PortMatrixBody* b) : PortMatrixLabels (m, b) diff --git a/gtk2_ardour/port_matrix_grid.cc b/gtk2_ardour/port_matrix_grid.cc index 7deab22b85..6e7fad7091 100644 --- a/gtk2_ardour/port_matrix_grid.cc +++ b/gtk2_ardour/port_matrix_grid.cc @@ -23,6 +23,7 @@ #include "ardour/types.h" #include "port_matrix_grid.h" #include "port_matrix.h" +#include "port_matrix_body.h" PortMatrixGrid::PortMatrixGrid (PortMatrix* m, PortMatrixBody* b) : PortMatrixComponent (m, b) diff --git a/gtk2_ardour/port_matrix_row_labels.cc b/gtk2_ardour/port_matrix_row_labels.cc index d8162d715e..8d5b31693b 100644 --- a/gtk2_ardour/port_matrix_row_labels.cc +++ b/gtk2_ardour/port_matrix_row_labels.cc @@ -23,6 +23,7 @@ #include "ardour/bundle.h" #include "port_matrix_row_labels.h" #include "port_matrix.h" +#include "port_matrix_body.h" #include "i18n.h" PortMatrixRowLabels::PortMatrixRowLabels (PortMatrix* m, PortMatrixBody* b) -- cgit v1.2.3