summaryrefslogtreecommitdiff
path: root/gtk2_ardour/bundle_manager.h
blob: 7ba3c7df9fd76a64ec82520f4af81ca55844102c (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) 2007-2012 Carl Hetherington <carl@carlh.net>
 * Copyright (C) 2008-2010 Paul Davis <paul@linuxaudiosystems.com>
 * Copyright (C) 2009-2014 David Robillard <d@drobilla.net>
 *
 * 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.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */

#ifndef __ardour_ui_bundle_manager_h__
#define __ardour_ui_bundle_manager_h__

#include <gtkmm/entry.h>
#include <gtkmm/liststore.h>
#include <gtkmm/treeview.h>

#include "ardour/user_bundle.h"

#include "ardour_dialog.h"
#include "port_matrix.h"

namespace ARDOUR {
	class Session;
	class Bundle;
}

class BundleEditorMatrix : public PortMatrix
{
public:
	BundleEditorMatrix (Gtk::Window *, ARDOUR::Session *, boost::shared_ptr<ARDOUR::Bundle>);

	void set_state (ARDOUR::BundleChannel c[2], bool s);
	PortMatrixNode::State get_state (ARDOUR::BundleChannel c[2]) const;

	bool can_add_channels (boost::shared_ptr<ARDOUR::Bundle>) const;

	void add_channel (boost::shared_ptr<ARDOUR::Bundle>, ARDOUR::DataType);
	bool can_remove_channels (boost::shared_ptr<ARDOUR::Bundle>) const;
	void remove_channel (ARDOUR::BundleChannel);
	bool can_rename_channels (boost::shared_ptr<ARDOUR::Bundle>) const;
	void rename_channel (ARDOUR::BundleChannel);
	void setup_ports (int);
	bool list_is_global (int) const;

	std::string disassociation_verb () const;

private:
	enum {
		OTHER = 0,
		OURS = 1
	};

	boost::shared_ptr<PortGroup> _port_group;
	boost::shared_ptr<ARDOUR::Bundle> _bundle;
};

class BundleEditor : public ArdourDialog
{
public:
	BundleEditor (ARDOUR::Session *, boost::shared_ptr<ARDOUR::UserBundle>);

protected:
	void on_map ();

private:
	void name_changed ();
	void input_or_output_changed ();
	void on_show ();

	BundleEditorMatrix _matrix;
	boost::shared_ptr<ARDOUR::UserBundle> _bundle;
	Gtk::Entry _name;
	Gtk::ComboBoxText _input_or_output;
};

class BundleManager : public ArdourDialog
{
public:
	BundleManager (ARDOUR::Session *);

private:

	void new_clicked ();
	void edit_clicked ();
	void delete_clicked ();
	void add_bundle (boost::shared_ptr<ARDOUR::Bundle>);
	void bundle_changed (ARDOUR::Bundle::Change, boost::shared_ptr<ARDOUR::UserBundle>);
	void set_button_sensitivity ();
	void row_activated (Gtk::TreeModel::Path const & p, Gtk::TreeViewColumn* c);

	class ModelColumns : public Gtk::TreeModelColumnRecord
	{
	public:
		ModelColumns () {
			add (name);
			add (bundle);
		}

		Gtk::TreeModelColumn<std::string> name;
		Gtk::TreeModelColumn<boost::shared_ptr<ARDOUR::UserBundle> > bundle;
	};

	Gtk::TreeView _tree_view;
	Glib::RefPtr<Gtk::ListStore> _list_model;
	ModelColumns _list_model_columns;
	Gtk::Button edit_button;
	Gtk::Button delete_button;
	PBD::ScopedConnectionList bundle_connections;
};

class NameChannelDialog : public ArdourDialog
{
public:
	NameChannelDialog ();
	NameChannelDialog (boost::shared_ptr<ARDOUR::Bundle>, uint32_t);

	std::string get_name () const;

private:

	void setup ();

	boost::shared_ptr<ARDOUR::Bundle> _bundle;
	Gtk::Entry _name;
	bool _adding;
};

#endif