summaryrefslogtreecommitdiff
path: root/gtk2_ardour/port_matrix.h
blob: 425e3915c4e0e9cc8974f011d8bf5b65942b1130 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
/*
    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
    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.

*/

#ifndef __gtk_ardour_port_matrix_h__
#define __gtk_ardour_port_matrix_h__

#include <list>
#include <gtkmm/box.h>
#include <gtkmm/scrollbar.h>
#include <boost/shared_ptr.hpp>
#include "port_matrix_body.h"
#include "port_group.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.
 *
 *  The columns are labelled with various ports from around Ardour and the
 *  system.
 *
 *  It is made up of a body, PortMatrixBody, which is rendered using cairo,
 *  and some scrollbars.  All of this is arranged inside the VBox that we
 *  inherit from.
 */

namespace ARDOUR {
	class Bundle;
}

class PortMatrix : public Gtk::VBox
{
public:
	PortMatrix (ARDOUR::Session&, ARDOUR::DataType, bool);
	~PortMatrix ();

	virtual void setup ();
	void set_offer_inputs (bool);
	void set_type (ARDOUR::DataType);

	ARDOUR::DataType type () const {
		return _type;
	}
	
	bool offering_input () const {
		return _offer_inputs;
	}
	
	void disassociate_all ();

	enum Result {
		Cancelled,
		Accepted
	};

	sigc::signal<void, Result> Finished;

	/** @param ab Our bundle.
	 *  @param ac Channel on our bundle.
	 *  @param bb Other bundle.
	 *  @arapm bc Channel on other bundle.
	 *  @param s New state.
	 *  @param k XXX
	 */
	virtual void set_state (
		boost::shared_ptr<ARDOUR::Bundle> ab,
		uint32_t ac,
		boost::shared_ptr<ARDOUR::Bundle> bb,
		uint32_t bc,
		bool s,
		uint32_t k
		) = 0;

	enum State {
		ASSOCIATED,
		NOT_ASSOCIATED,
		UNKNOWN
	};

	/** @param ab Our bundle.
	 *  @param ac Channel on our bundle.
	 *  @param bb Other bundle.
	 *  @arapm bc Channel on other bundle.
	 *  @return state
	 */
	virtual State get_state (
		boost::shared_ptr<ARDOUR::Bundle> ab,
		uint32_t ac,
		boost::shared_ptr<ARDOUR::Bundle> bb,
		uint32_t bc
		) const = 0;

	virtual void add_channel (boost::shared_ptr<ARDOUR::Bundle>) = 0;
	virtual void remove_channel (boost::shared_ptr<ARDOUR::Bundle>, uint32_t) = 0;
	virtual bool can_rename_channels () const = 0;
	virtual void rename_channel (boost::shared_ptr<ARDOUR::Bundle>, uint32_t) {}
	
	void setup_scrollbars ();

protected:

	PortGroupList _row_ports;
	PortGroupList _column_ports;
	
private:

	void hscroll_changed ();
	void vscroll_changed ();
	void routes_changed ();

	ARDOUR::Session& _session;
	/// true to offer inputs, otherwise false
	bool _offer_inputs;
	/// port type that we are working with
	ARDOUR::DataType _type;

	PortMatrixBody _body;
	Gtk::HScrollbar _hscroll;
	Gtk::VScrollbar _vscroll;
	std::list<PortGroupUI*> _port_group_uis;
	std::vector<sigc::connection> _route_connections;
};

#endif