Fix update of the editor mixer when its route is removed; this stops routes (and...
[ardour.git] / gtk2_ardour / port_matrix.h
index b93a288c5012f5e5c904f641b7072b984a3dbf73..0dc88f02f2e19e6413177437291bf56f8b1484f6 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2002-2009 Paul Davis 
+    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
 #include <gtkmm/label.h>
 #include <gtkmm/checkbutton.h>
 #include <boost/shared_ptr.hpp>
-#include "port_matrix_body.h"
+#include "ardour/bundle.h"
 #include "port_group.h"
+#include "port_matrix_types.h"
+#include "i18n.h"
 
 /** The `port matrix' UI.  This is a widget which lets the user alter
  *  associations between one set of ports and another.  e.g. to connect
  *
  *  It is made up of a body, PortMatrixBody, which is rendered using cairo,
  *  and some scrollbars and other stuff.  All of this is arranged inside the
- *  VBox that we inherit from.
+ *  Table that we inherit from.
  */
 
 namespace ARDOUR {
        class Bundle;
 }
 
-class PortMatrix : public Gtk::VBox
+class PortMatrixBody;
+
+class PortMatrix : public Gtk::Table
 {
 public:
-       PortMatrix (ARDOUR::Session&, ARDOUR::DataType);
+       PortMatrix (Gtk::Window*, ARDOUR::Session&, ARDOUR::DataType);
        ~PortMatrix ();
 
        void set_type (ARDOUR::DataType);
@@ -54,10 +58,21 @@ public:
        ARDOUR::DataType type () const {
                return _type;
        }
-       
+
        void disassociate_all ();
        void setup_scrollbars ();
-       void popup_channel_context_menu (int, uint32_t, uint32_t);
+       void popup_menu (
+               std::pair<boost::shared_ptr<PortGroup>, ARDOUR::BundleChannel>,
+               std::pair<boost::shared_ptr<PortGroup>, ARDOUR::BundleChannel>,
+               uint32_t
+               );
+
+       int min_height_divisor () const {
+               return _min_height_divisor;
+       }
+       void set_min_height_divisor (int f) {
+               _min_height_divisor = f;
+       }
 
        enum Arrangement {
                TOP_TO_RIGHT,  ///< column labels on top, row labels to the right
@@ -69,6 +84,10 @@ public:
                return _arrangement;
        }
 
+       bool show_only_bundles () const {
+               return _show_only_bundles;
+       }
+
        PortGroupList const * columns () const;
 
        /** @return index into the _ports array for the list which is displayed as columns */
@@ -82,31 +101,39 @@ public:
        int row_index () const {
                return _row_index;
        }
-       
-       virtual void setup ();
+
+       PortGroupList const * ports (int d) const {
+               return &_ports[d];
+       }
+
+       void setup ();
+       virtual void setup_ports (int) = 0;
+       void setup_all_ports ();
+
+       std::pair<uint32_t, uint32_t> max_size () const;
 
        /** @param c Channels; where c[0] is from _ports[0] and c[1] is from _ports[1].
         *  @param s New state.
         */
        virtual void set_state (ARDOUR::BundleChannel c[2], bool s) = 0;
 
-       enum State {
-               ASSOCIATED,     ///< the ports are associaed
-               NOT_ASSOCIATED, ///< the ports are not associated
-               UNKNOWN         ///< we don't know anything about these two ports' relationship
-       };
-
        /** @param c Channels; where c[0] is from _ports[0] and c[1] is from _ports[1].
         *  @return state
         */
-       virtual State get_state (ARDOUR::BundleChannel c[2]) const = 0;
-
-       virtual void add_channel (boost::shared_ptr<ARDOUR::Bundle>) = 0;
-       virtual bool can_remove_channels (int) const = 0;
-       virtual void remove_channel (ARDOUR::BundleChannel) = 0;
-       virtual bool can_rename_channels (int) const = 0;
+       virtual PortMatrixNode::State get_state (ARDOUR::BundleChannel c[2]) const = 0;
+       virtual bool list_is_global (int) const = 0;
+
+       virtual bool can_add_channel (boost::shared_ptr<ARDOUR::Bundle>) const;
+       virtual void add_channel (boost::shared_ptr<ARDOUR::Bundle>);
+       virtual bool can_remove_channels (boost::shared_ptr<ARDOUR::Bundle>) const;
+       virtual void remove_channel (ARDOUR::BundleChannel);
+       virtual bool can_rename_channels (boost::shared_ptr<ARDOUR::Bundle>) const {
+               return false;
+       }
        virtual void rename_channel (ARDOUR::BundleChannel) {}
-       
+       virtual std::string disassociation_verb () const = 0;
+       virtual std::string channel_noun () const { return _("channel"); }
+
        enum Result {
                Cancelled,
                Accepted
@@ -124,38 +151,43 @@ protected:
            inputs and outputs should put outputs in list 0 and inputs in list 1. */
        PortGroupList _ports[2];
        ARDOUR::Session& _session;
-       
+
 private:
 
        void hscroll_changed ();
        void vscroll_changed ();
        void routes_changed ();
        void reconnect_to_routes ();
-       void visibility_toggled (boost::weak_ptr<PortGroup>, Gtk::CheckButton *);
        void select_arrangement ();
+       void add_channel_proxy (boost::weak_ptr<ARDOUR::Bundle>);
        void remove_channel_proxy (boost::weak_ptr<ARDOUR::Bundle>, uint32_t);
        void rename_channel_proxy (boost::weak_ptr<ARDOUR::Bundle>, uint32_t);
+       void disassociate_all_on_channel (boost::weak_ptr<ARDOUR::Bundle>, uint32_t, int);
+       void setup_global_ports ();
+       void hide_group (boost::weak_ptr<PortGroup>);
+       void show_group (boost::weak_ptr<PortGroup>);
+       void toggle_show_only_bundles ();
+       bool on_scroll_event (GdkEventScroll *);
+       boost::shared_ptr<ARDOUR::IO> io_from_bundle (boost::shared_ptr<ARDOUR::Bundle>) const;
+       void bundle_changed (ARDOUR::Bundle::Change);
+
+       Gtk::Window* _parent;
 
        /// port type that we are working with
        ARDOUR::DataType _type;
        std::vector<sigc::connection> _route_connections;
 
-       PortMatrixBody _body;
+       PortMatrixBody* _body;
        Gtk::HScrollbar _hscroll;
        Gtk::VScrollbar _vscroll;
-       Gtk::HBox _main_hbox;
-       Gtk::HBox _column_visibility_box;
-       Gtk::Label _column_visibility_label;
-       std::vector<Gtk::CheckButton*> _column_visibility_buttons;
-       Gtk::VBox _row_visibility_box;
-       Gtk::Label _row_visibility_label;
-       std::vector<Gtk::CheckButton*> _row_visibility_buttons;
-       Gtk::Table _scroller_table;
        Gtk::Menu* _menu;
-       bool _setup_once;
        Arrangement _arrangement;
        int _row_index;
        int _column_index;
+       int _min_height_divisor;
+       bool _show_only_bundles;
+       bool _inhibit_toggle_show_only_bundles;
+       bool _realized;
 };
 
 #endif