X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;ds=sidebyside;f=gtk2_ardour%2Fport_matrix.h;h=0dc88f02f2e19e6413177437291bf56f8b1484f6;hb=da03bc931b4c82497fb4b02003804c18768c56b6;hp=27f295b89dad6e6a0964d0e3827a1b8f6a61cbce;hpb=954e1a6e795a5a53865f9278105579f00143cdb1;p=ardour.git diff --git a/gtk2_ardour/port_matrix.h b/gtk2_ardour/port_matrix.h index 27f295b89d..0dc88f02f2 100644 --- a/gtk2_ardour/port_matrix.h +++ b/gtk2_ardour/port_matrix.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2007 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 @@ -17,89 +17,177 @@ */ -#ifndef __ardour_ui_port_matrix_h__ -#define __ardour_ui_port_matrix_h__ +#ifndef __gtk_ardour_port_matrix_h__ +#define __gtk_ardour_port_matrix_h__ +#include #include -#include +#include #include -#include -#include -#include - -#include "ardour_dialog.h" +#include +#include +#include +#include "ardour/bundle.h" #include "port_group.h" -#include "matrix.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 + * things together. + * + * 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 + * Table that we inherit from. + */ namespace ARDOUR { - class Session; - class IO; - class PortInsert; + class Bundle; } -class PortMatrix : public Gtk::VBox { - public: - PortMatrix (ARDOUR::Session&, ARDOUR::DataType, bool, PortGroupList::Mask); +class PortMatrixBody; + +class PortMatrix : public Gtk::Table +{ +public: + PortMatrix (Gtk::Window*, ARDOUR::Session&, ARDOUR::DataType); ~PortMatrix (); - void setup (); + void set_type (ARDOUR::DataType); - enum Result { - Cancelled, - Accepted + ARDOUR::DataType type () const { + return _type; + } + + void disassociate_all (); + void setup_scrollbars (); + void popup_menu ( + std::pair, ARDOUR::BundleChannel>, + std::pair, 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 + LEFT_TO_BOTTOM ///< row labels to the left, column labels on the bottom }; - sigc::signal Finished; + /** @return Arrangement in use */ + Arrangement arrangement () const { + return _arrangement; + } - void set_type (ARDOUR::DataType); - void set_offer_inputs (bool); - bool offering_input() const { return _offer_inputs; } + 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 */ + int column_index () const { + return _column_index; + } - /** @param r Our row index. - * @param p Other port. + PortGroupList const * rows () const; + + /** @return index into the _ports array for the list which is displayed as rows */ + int row_index () const { + return _row_index; + } + + PortGroupList const * ports (int d) const { + return &_ports[d]; + } + + void setup (); + virtual void setup_ports (int) = 0; + void setup_all_ports (); + + std::pair max_size () const; + + /** @param c Channels; where c[0] is from _ports[0] and c[1] is from _ports[1]. * @param s New state. - * @param k XXX */ - virtual void set_state (int r, std::string const & p, bool s, uint32_t k) = 0; + virtual void set_state (ARDOUR::BundleChannel c[2], bool s) = 0; - /** @param r Our row index. - * @param p Other port. - * @return true if r is connected to p, otherwise false. + /** @param c Channels; where c[0] is from _ports[0] and c[1] is from _ports[1]. + * @return state */ - virtual bool get_state (int r, std::string const &p) const = 0; - - virtual uint32_t n_rows () const = 0; - virtual uint32_t maximum_rows () const = 0; - virtual uint32_t minimum_rows () const = 0; - virtual std::string row_name (int) const = 0; - virtual void add_row () = 0; - virtual void remove_row (int) = 0; - virtual std::string row_descriptor () 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) const; + virtual void add_channel (boost::shared_ptr); + virtual bool can_remove_channels (boost::shared_ptr) const; + virtual void remove_channel (ARDOUR::BundleChannel); + virtual bool can_rename_channels (boost::shared_ptr) const { + return false; + } + virtual void rename_channel (ARDOUR::BundleChannel) {} + virtual std::string disassociation_verb () const = 0; + virtual std::string channel_noun () const { return _("channel"); } - Gtk::Widget& scrolled_window() { return _scrolled_window; } - - protected: + enum Result { + Cancelled, + Accepted + }; - bool _offer_inputs; - void set_ports (const std::list&); + sigc::signal Finished; - private: - PortGroupList _port_group_list; +protected: + + /** We have two port group lists. One will be presented on the rows of the matrix, + the other on the columns. The PortMatrix chooses the arrangement based on which has + more ports in it. Subclasses must fill these two lists with the port groups that they + wish to present. The PortMatrix will arrange its layout such that signal flow is vaguely + from left to right as you go from list 0 to list 1. Hence subclasses which deal with + 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 select_arrangement (); + void add_channel_proxy (boost::weak_ptr); + void remove_channel_proxy (boost::weak_ptr, uint32_t); + void rename_channel_proxy (boost::weak_ptr, uint32_t); + void disassociate_all_on_channel (boost::weak_ptr, uint32_t, int); + void setup_global_ports (); + void hide_group (boost::weak_ptr); + void show_group (boost::weak_ptr); + void toggle_show_only_bundles (); + bool on_scroll_event (GdkEventScroll *); + boost::shared_ptr io_from_bundle (boost::shared_ptr) const; + void bundle_changed (ARDOUR::Bundle::Change); + + Gtk::Window* _parent; + + /// port type that we are working with ARDOUR::DataType _type; - Matrix matrix; - std::vector _port_group_ui; - std::vector _row_labels; - Gtk::VBox* _row_labels_vbox; - Gtk::HBox _overall_hbox; - Gtk::VBox _side_vbox; - Gtk::HBox _port_group_hbox; - Gtk::ScrolledWindow _scrolled_window; - Gtk::Label* _side_vbox_pad; - Gtk::HBox _visibility_checkbutton_box; - - void clear (); - bool row_label_button_pressed (GdkEventButton*, int); - void reset_visibility (); + std::vector _route_connections; + + PortMatrixBody* _body; + Gtk::HScrollbar _hscroll; + Gtk::VScrollbar _vscroll; + Gtk::Menu* _menu; + 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