* Added CanvasSysEx class for displaying SysExes
[ardour.git] / gtk2_ardour / port_group.h
index 0641d231ef7b43c64a21b7207d690b40285e3a1e..c2daae341a2632a3bd173e53e079d174eff9e334 100644 (file)
@@ -26,6 +26,7 @@
 #include <gtkmm/checkbutton.h>
 #include <boost/shared_ptr.hpp>
 #include <ardour/data_type.h>
+#include <ardour/types.h>
 
 namespace ARDOUR {
        class Session;
@@ -38,73 +39,108 @@ class PortMatrix;
  *  type e.g. busses, tracks, system.  Each group has 0 or more bundles
  *  and 0 or more ports, where the ports are not in the bundles.
  */
-class PortGroup
+class PortGroup : public sigc::trackable
 {
-  public:
-       /** PortGroup constructor.
-        * @param n Name.
-        * @param v true if group should be visible in the UI, otherwise false.
-        */
-       PortGroup (std::string const & n, bool v)
-               : name (n), visible (v) {}
+public:
+       PortGroup (std::string const & n);
 
        void add_bundle (boost::shared_ptr<ARDOUR::Bundle>);
-       void add_port (std::string const &);
+       void remove_bundle (boost::shared_ptr<ARDOUR::Bundle>);
+       boost::shared_ptr<ARDOUR::Bundle> only_bundle ();
        void clear ();
+       uint32_t total_channels () const;
 
        std::string name; ///< name for the group
-       std::vector<boost::shared_ptr<ARDOUR::Bundle> > bundles;
-       std::vector<std::string> ports;
-       bool visible; ///< true if the group is visible in the UI
-};
 
-/// The UI for a PortGroup
-class PortGroupUI
-{
-  public:
-       PortGroupUI (PortMatrix*, PortGroup*);
+       ARDOUR::BundleList const & bundles () const {
+               return _bundles;
+       }
+       
+       bool visible () const {
+               return _visible;
+       }
 
-       Gtk::Widget& visibility_checkbutton () {
-               return _visibility_checkbutton;
+       void set_visible (bool v) {
+               _visible = v;
+               Modified ();
        }
 
-  private:
-       void visibility_checkbutton_toggled ();
-       void setup_visibility_checkbutton ();
+       bool has_port (std::string const &) const;
+
+       sigc::signal<void> Modified;
+       sigc::signal<void, ARDOUR::Bundle::Change> BundleChanged;
+
+private:
+       void bundle_changed (ARDOUR::Bundle::Change);
+       
+       ARDOUR::BundleList _bundles;
 
-       PortMatrix* _port_matrix; ///< the PortMatrix that we are working for
-       PortGroup* _port_group; ///< the PortGroup that we are representing
-       Gtk::CheckButton _visibility_checkbutton;
+       typedef std::map<boost::shared_ptr<ARDOUR::Bundle>, sigc::connection> ConnectionList;
+       ConnectionList _bundle_changed_connections;
+       
+       bool _visible; ///< true if the group is visible in the UI
 };
 
 /// A list of PortGroups
-class PortGroupList : public std::list<PortGroup*>
+class PortGroupList : public sigc::trackable
 {
   public:
-       enum Mask {
-               BUSS = 0x1,
-               TRACK = 0x2,
-               SYSTEM = 0x4,
-               OTHER = 0x8
-       };
+       PortGroupList ();
 
-       PortGroupList (ARDOUR::Session &, ARDOUR::DataType, bool, Mask);
+       typedef std::vector<boost::shared_ptr<PortGroup> > List;
 
-       void refresh ();
+       void add_group (boost::shared_ptr<PortGroup>);
        void set_type (ARDOUR::DataType);
-       void set_offer_inputs (bool);
-       
+       void gather (ARDOUR::Session &, bool);
+       ARDOUR::BundleList const & bundles () const;
+       void clear ();
+       void remove_bundle (boost::shared_ptr<ARDOUR::Bundle>);
+       uint32_t total_visible_channels () const;
+       uint32_t size () const {
+               return _groups.size();
+       }
+
+       void suspend_signals ();
+       void resume_signals ();
+
+       List::const_iterator begin () const {
+               return _groups.begin();
+       }
+
+       List::const_iterator end () const {
+               return _groups.end();
+       }
+
+       sigc::signal<void> Changed;
+
   private:
-       void maybe_add_session_bundle (boost::shared_ptr<ARDOUR::Bundle>);
+       bool port_has_prefix (std::string const &, std::string const &) const;
+       std::string common_prefix (std::vector<std::string> const &) const;
+       std::string common_prefix_before (std::vector<std::string> const &, std::string const &) const;
+       void emit_changed ();
+       boost::shared_ptr<ARDOUR::Bundle> make_bundle_from_ports (std::vector<std::string> const &, bool) const;
        
-       ARDOUR::Session& _session;
        ARDOUR::DataType _type;
-       bool _offer_inputs;
+       mutable ARDOUR::BundleList _bundles;
+       List _groups;
+       std::vector<sigc::connection> _bundle_changed_connections;
+       bool _signals_suspended;
+       bool _pending_change;
+};
 
-       PortGroup _buss;
-       PortGroup _track;
-       PortGroup _system;
-       PortGroup _other;
+
+class RouteBundle : public ARDOUR::Bundle
+{
+public:
+       RouteBundle (boost::shared_ptr<ARDOUR::Bundle>);
+
+       void add_processor_bundle (boost::shared_ptr<ARDOUR::Bundle>);
+
+private:
+       void reread_component_bundles ();
+       
+       boost::shared_ptr<ARDOUR::Bundle> _route;
+       std::vector<boost::shared_ptr<ARDOUR::Bundle> > _processor;
 };
 
 #endif /* __gtk_ardour_port_group_h__ */