From d4a05b52711b4e92be619037f468d5595428eb44 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Sat, 13 Oct 2007 10:38:26 +0000 Subject: Check buttons to select visibility of destination groups. git-svn-id: svn://localhost/ardour2/trunk@2551 d708f5d6-7413-0410-9779-e7cbd77b26cf --- gtk2_ardour/io_selector.cc | 68 ++++++++++++++++++++++++++++++++++++---------- gtk2_ardour/io_selector.h | 11 ++++++-- 2 files changed, 61 insertions(+), 18 deletions(-) (limited to 'gtk2_ardour') diff --git a/gtk2_ardour/io_selector.cc b/gtk2_ardour/io_selector.cc index 03cf09c042..42c9f87e87 100644 --- a/gtk2_ardour/io_selector.cc +++ b/gtk2_ardour/io_selector.cc @@ -217,7 +217,7 @@ RotatedLabelSet::on_size_request (Gtk::Requisition* requisition) /* And our width is the base plus the width of the last label */ requisition->width = _base_width; - int const n = _port_group_list.n_ports (); + int const n = _port_group_list.n_visible_ports (); if (n > 0) { std::pair const d = setup_layout (_port_group_list.get_port_by_index (n - 1, false)); requisition->width += d.first; @@ -321,15 +321,17 @@ RotatedLabelSet::on_expose_event (GdkEventExpose* event) } int const height = get_allocation().get_height (); - double const spacing = double (_base_width) / _port_group_list.n_ports(); + double const spacing = double (_base_width) / _port_group_list.n_visible_ports(); - /* Plot all the labels; really we should clip for efficiency */ + /* Plot all the visible labels; really we should clip for efficiency */ int n = 0; for (PortGroupList::const_iterator i = _port_group_list.begin(); i != _port_group_list.end(); ++i) { - for (uint32_t j = 0; j < i->ports.size(); ++j) { - std::pair const d = setup_layout (i->ports[j]); - get_window()->draw_layout (_gc, int ((n + 0.25) * spacing), height - d.second, _pango_layout, _fg_colour, _bg_colour); - ++n; + if (i->visible) { + for (uint32_t j = 0; j < i->ports.size(); ++j) { + std::pair const d = setup_layout (i->ports[j]); + get_window()->draw_layout (_gc, int ((n + 0.25) * spacing), height - d.second, _pango_layout, _fg_colour, _bg_colour); + ++n; + } } } @@ -364,6 +366,15 @@ IOSelector::IOSelector (ARDOUR::Session& session, boost::shared_ptr : _port_group_list (session, io, for_input), _io (io), _for_input (for_input), _row_labels_vbox (0), _column_labels (_port_group_list), _left_vbox_pad (0) { + Gtk::HBox* c = new Gtk::HBox; + for (PortGroupList::iterator i = _port_group_list.begin(); i != _port_group_list.end(); ++i) { + Gtk::CheckButton* b = new Gtk::CheckButton (i->name); + b->set_active (true); + b->signal_toggled().connect (sigc::bind (sigc::mem_fun (*this, &IOSelector::group_visible_toggled), b, i->name)); + c->pack_start (*Gtk::manage (b)); + } + pack_start (*Gtk::manage (c)); + _left_vbox.pack_start (*Gtk::manage (new Gtk::Label (""))); _overall_hbox.pack_start (_left_vbox, false, false); _scrolled_window.set_policy (Gtk::POLICY_ALWAYS, Gtk::POLICY_NEVER); @@ -444,7 +455,7 @@ IOSelector::setup_dimensions () } /* Column labels */ - _column_labels.set_base_width (_port_group_list.n_ports () * unit_size.first); + _column_labels.set_base_width (_port_group_list.n_visible_ports () * unit_size.first); /* Scrolled window */ /* XXX: really shouldn't set a minimum horizontal size here, but if we don't @@ -621,6 +632,33 @@ IOSelector::remove_port (int r) } } +void +IOSelector::group_visible_toggled (Gtk::CheckButton* b, std::string const & n) +{ + PortGroupList::iterator i = _port_group_list.begin(); + while (i != _port_group_list.end() & i->name != n) { + ++i; + } + + if (i == _port_group_list.end()) { + return; + } + + i->visible = b->get_active (); + + /* Update PortGroupTable visibility */ + + for (std::vector::iterator j = _port_group_tables.begin(); j != _port_group_tables.end(); ++j) { + if ((*j)->port_group().visible) { + (*j)->get_widget().show(); + } else { + (*j)->get_widget().hide(); + } + } + + _column_labels.queue_draw (); +} + PortGroupList::PortGroupList (ARDOUR::Session & session, boost::shared_ptr io, bool for_input) : _session (session), _io (io), _for_input (for_input) @@ -638,8 +676,8 @@ PortGroupList::refresh () boost::shared_ptr routes = _session.get_routes (); - PortGroup buss ("ardour:"); - PortGroup track ("ardour:"); + PortGroup buss (_("Buss"), "ardour:"); + PortGroup track (_("Track"), "ardour:"); for (ARDOUR::Session::RouteList::const_iterator i = routes->begin(); i != routes->end(); ++i) { @@ -674,8 +712,8 @@ PortGroupList::refresh () "", _io->default_type().to_jack_type(), _for_input ? JackPortIsOutput : JackPortIsInput ); - PortGroup system ("system:"); - PortGroup other (""); + PortGroup system (_("System"), "system:"); + PortGroup other (_("Other"), ""); if (ports) { @@ -704,13 +742,13 @@ PortGroupList::refresh () } int -PortGroupList::n_ports () const +PortGroupList::n_visible_ports () const { int n = 0; for (const_iterator i = begin(); i != end(); ++i) { - for (std::vector::const_iterator j = i->ports.begin(); j != i->ports.end(); ++j) { - ++n; + if (i->visible) { + n += i->ports.size(); } } diff --git a/gtk2_ardour/io_selector.h b/gtk2_ardour/io_selector.h index 04779590c1..65ad02df57 100644 --- a/gtk2_ardour/io_selector.h +++ b/gtk2_ardour/io_selector.h @@ -37,12 +37,14 @@ namespace ARDOUR { class PortGroup { public: - PortGroup (std::string const & p) : prefix (p) {} + PortGroup (std::string const & n, std::string const & p) : name (n), prefix (p), visible (true) {} void add (std::string const & p); + std::string name; std::string prefix; ///< prefix (before colon) e.g. "ardour:" std::vector ports; ///< port names + bool visible; }; /// A table of checkbuttons to provide the GUI for connecting to a PortGroup @@ -53,6 +55,7 @@ class PortGroupTable Gtk::Widget& get_widget (); std::pair unit_size () const; + PortGroup& port_group () { return _port_group; } private: void check_button_toggled (Gtk::CheckButton*, int, std::string const &); @@ -73,7 +76,7 @@ class PortGroupList : public std::list PortGroupList (ARDOUR::Session &, boost::shared_ptr, bool); void refresh (); - int n_ports () const; + int n_visible_ports () const; std::string get_port_by_index (int, bool with_prefix = true) const; private: @@ -91,7 +94,8 @@ class RotatedLabelSet : public Gtk::Widget { void set_angle (int); void set_base_width (int); - + void update_visibility (); + protected: virtual void on_size_request (Gtk::Requisition*); virtual void on_size_allocate (Gtk::Allocation&); @@ -140,6 +144,7 @@ class IOSelector : public Gtk::VBox { bool row_label_button_pressed (GdkEventButton*, int); void add_port (); void remove_port (int); + void group_visible_toggled (Gtk::CheckButton*, std::string const &); PortGroupList _port_group_list; boost::shared_ptr _io; -- cgit v1.2.3