2007-10-19 09:30:07 -04:00
|
|
|
/*
|
2009-01-20 09:46:00 -05:00
|
|
|
Copyright (C) 2002-2009 Paul Davis
|
2007-10-19 09:30:07 -04:00
|
|
|
|
|
|
|
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
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
2009-01-20 09:46:00 -05:00
|
|
|
#ifndef __gtk_ardour_port_matrix_h__
|
|
|
|
#define __gtk_ardour_port_matrix_h__
|
2007-10-19 09:30:07 -04:00
|
|
|
|
2009-01-20 09:46:00 -05:00
|
|
|
#include <list>
|
2007-10-19 09:30:07 -04:00
|
|
|
#include <gtkmm/box.h>
|
2009-01-20 09:46:00 -05:00
|
|
|
#include <gtkmm/scrollbar.h>
|
2009-01-30 10:08:09 -05:00
|
|
|
#include <gtkmm/table.h>
|
|
|
|
#include <gtkmm/label.h>
|
|
|
|
#include <gtkmm/checkbutton.h>
|
2009-01-20 09:46:00 -05:00
|
|
|
#include <boost/shared_ptr.hpp>
|
2009-02-04 12:05:26 -05:00
|
|
|
#include "ardour/bundle.h"
|
2008-12-08 11:07:28 -05:00
|
|
|
#include "port_group.h"
|
2009-01-20 09:46:00 -05:00
|
|
|
|
|
|
|
/** 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,
|
2009-01-30 10:08:09 -05:00
|
|
|
* and some scrollbars and other stuff. All of this is arranged inside the
|
|
|
|
* VBox that we inherit from.
|
2009-01-20 09:46:00 -05:00
|
|
|
*/
|
2007-10-19 09:30:07 -04:00
|
|
|
|
|
|
|
namespace ARDOUR {
|
2009-01-20 09:46:00 -05:00
|
|
|
class Bundle;
|
2007-10-19 09:30:07 -04:00
|
|
|
}
|
|
|
|
|
2009-02-04 12:05:26 -05:00
|
|
|
class PortMatrixBody;
|
|
|
|
|
2009-01-20 09:46:00 -05:00
|
|
|
class PortMatrix : public Gtk::VBox
|
|
|
|
{
|
|
|
|
public:
|
2009-01-30 10:08:09 -05:00
|
|
|
PortMatrix (ARDOUR::Session&, ARDOUR::DataType);
|
2007-10-19 09:30:07 -04:00
|
|
|
~PortMatrix ();
|
|
|
|
|
2009-01-20 09:46:00 -05:00
|
|
|
void set_type (ARDOUR::DataType);
|
2009-01-25 01:47:11 -05:00
|
|
|
|
|
|
|
ARDOUR::DataType type () const {
|
|
|
|
return _type;
|
|
|
|
}
|
|
|
|
|
2009-01-20 09:46:00 -05:00
|
|
|
void disassociate_all ();
|
2009-01-30 10:08:09 -05:00
|
|
|
void setup_scrollbars ();
|
|
|
|
void popup_channel_context_menu (int, uint32_t, uint32_t);
|
2007-10-19 09:30:07 -04:00
|
|
|
|
2009-02-09 21:09:46 -05:00
|
|
|
int min_height_divisor () const {
|
|
|
|
return _min_height_divisor;
|
|
|
|
}
|
|
|
|
void set_min_height_divisor (int f) {
|
|
|
|
_min_height_divisor = f;
|
|
|
|
}
|
|
|
|
|
2009-01-30 10:08:09 -05:00
|
|
|
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
|
2007-10-19 09:30:07 -04:00
|
|
|
};
|
|
|
|
|
2009-01-30 10:08:09 -05:00
|
|
|
/** @return Arrangement in use */
|
|
|
|
Arrangement arrangement () const {
|
|
|
|
return _arrangement;
|
|
|
|
}
|
2007-10-19 09:30:07 -04:00
|
|
|
|
2009-01-30 10:08:09 -05:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
2009-02-02 20:55:25 -05:00
|
|
|
|
|
|
|
PortGroupList const * ports (int d) const {
|
|
|
|
return &_ports[d];
|
|
|
|
}
|
2009-01-30 10:08:09 -05:00
|
|
|
|
2009-02-08 22:18:10 -05:00
|
|
|
void setup ();
|
|
|
|
virtual void setup_ports (int) = 0;
|
|
|
|
void setup_all_ports ();
|
2009-01-30 10:08:09 -05:00
|
|
|
|
|
|
|
/** @param c Channels; where c[0] is from _ports[0] and c[1] is from _ports[1].
|
2009-01-12 20:15:19 -05:00
|
|
|
* @param s New state.
|
|
|
|
*/
|
2009-01-30 10:08:09 -05:00
|
|
|
virtual void set_state (ARDOUR::BundleChannel c[2], bool s) = 0;
|
2009-01-20 09:46:00 -05:00
|
|
|
|
2009-01-23 16:24:11 -05:00
|
|
|
enum State {
|
2009-01-30 10:08:09 -05:00
|
|
|
ASSOCIATED, ///< the ports are associaed
|
|
|
|
NOT_ASSOCIATED, ///< the ports are not associated
|
|
|
|
UNKNOWN ///< we don't know anything about these two ports' relationship
|
2009-01-23 16:24:11 -05:00
|
|
|
};
|
|
|
|
|
2009-01-30 10:08:09 -05:00
|
|
|
/** @param c Channels; where c[0] is from _ports[0] and c[1] is from _ports[1].
|
2009-01-23 16:24:11 -05:00
|
|
|
* @return state
|
2009-01-12 20:15:19 -05:00
|
|
|
*/
|
2009-01-30 10:08:09 -05:00
|
|
|
virtual State get_state (ARDOUR::BundleChannel c[2]) const = 0;
|
2009-02-08 22:18:10 -05:00
|
|
|
virtual bool list_is_global (int) const = 0;
|
2009-01-20 09:46:00 -05:00
|
|
|
|
|
|
|
virtual void add_channel (boost::shared_ptr<ARDOUR::Bundle>) = 0;
|
2009-01-30 10:08:09 -05:00
|
|
|
virtual bool can_remove_channels (int) const = 0;
|
|
|
|
virtual void remove_channel (ARDOUR::BundleChannel) = 0;
|
|
|
|
virtual bool can_rename_channels (int) const = 0;
|
|
|
|
virtual void rename_channel (ARDOUR::BundleChannel) {}
|
2009-01-12 20:15:19 -05:00
|
|
|
|
2009-01-30 10:08:09 -05:00
|
|
|
enum Result {
|
|
|
|
Cancelled,
|
|
|
|
Accepted
|
|
|
|
};
|
|
|
|
|
|
|
|
sigc::signal<void, Result> Finished;
|
2008-10-01 05:18:30 -04:00
|
|
|
|
2009-01-20 09:46:00 -05:00
|
|
|
protected:
|
2009-01-23 16:24:11 -05:00
|
|
|
|
2009-01-30 10:08:09 -05:00
|
|
|
/** 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;
|
2009-01-20 09:46:00 -05:00
|
|
|
|
|
|
|
private:
|
2007-10-19 09:30:07 -04:00
|
|
|
|
2009-01-20 09:46:00 -05:00
|
|
|
void hscroll_changed ();
|
|
|
|
void vscroll_changed ();
|
2009-01-27 12:37:07 -05:00
|
|
|
void routes_changed ();
|
2009-01-30 10:08:09 -05:00
|
|
|
void reconnect_to_routes ();
|
|
|
|
void visibility_toggled (boost::weak_ptr<PortGroup>, Gtk::CheckButton *);
|
|
|
|
void select_arrangement ();
|
|
|
|
void remove_channel_proxy (boost::weak_ptr<ARDOUR::Bundle>, uint32_t);
|
|
|
|
void rename_channel_proxy (boost::weak_ptr<ARDOUR::Bundle>, uint32_t);
|
2009-02-08 22:18:10 -05:00
|
|
|
void disassociate_all_on_channel (boost::weak_ptr<ARDOUR::Bundle>, uint32_t, int);
|
|
|
|
void setup_global_ports ();
|
2009-01-25 01:47:11 -05:00
|
|
|
|
2009-01-20 09:46:00 -05:00
|
|
|
/// port type that we are working with
|
2007-10-19 09:30:07 -04:00
|
|
|
ARDOUR::DataType _type;
|
2009-01-30 10:08:09 -05:00
|
|
|
std::vector<sigc::connection> _route_connections;
|
2009-01-20 09:46:00 -05:00
|
|
|
|
2009-02-04 12:05:26 -05:00
|
|
|
PortMatrixBody* _body;
|
2009-01-20 09:46:00 -05:00
|
|
|
Gtk::HScrollbar _hscroll;
|
|
|
|
Gtk::VScrollbar _vscroll;
|
2009-01-30 10:08:09 -05:00
|
|
|
Gtk::HBox _main_hbox;
|
|
|
|
Gtk::HBox _column_visibility_box;
|
2009-02-02 19:07:51 -05:00
|
|
|
bool _column_visibility_box_added;
|
2009-01-30 10:08:09 -05:00
|
|
|
Gtk::Label _column_visibility_label;
|
|
|
|
std::vector<Gtk::CheckButton*> _column_visibility_buttons;
|
|
|
|
Gtk::VBox _row_visibility_box;
|
2009-02-02 19:07:51 -05:00
|
|
|
bool _row_visibility_box_added;
|
2009-01-30 10:08:09 -05:00
|
|
|
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;
|
2009-02-09 21:09:46 -05:00
|
|
|
int _min_height_divisor;
|
2007-10-19 09:30:07 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|