1 /* -*- Mode: C ; c-basic-offset: 2 -*- */
3 * LADI Session Handler (ladish)
5 * Copyright (C) 2007 Dave Robillard <http://drobilla.net>
7 **************************************************************************
8 * This file implements the canvas module class
9 **************************************************************************
11 * LADI Session Handler is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * LADI Session Handler is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with LADI Session Handler. If not, see <http://www.gnu.org/licenses/>
23 * or write to the Free Software Foundation, Inc.,
24 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
27 #ifndef PATCHAGE_PATCHAGEMODULE_HPP
28 #define PATCHAGE_PATCHAGEMODULE_HPP
31 #include "PatchageCanvas.hpp"
36 PatchageModule(Patchage
* app
, const std::string
& name
, ModuleType type
, double x
=0, double y
=0);
38 virtual ~PatchageModule();
41 identify(const std::string
& name
, ModuleType type
)
43 return _name
== name
&& (_type
== type
|| _type
== InputOutput
);
47 _menu
= new Gtk::Menu();
48 Gtk::Menu::MenuList
& items
= _menu
->items();
49 if (_type
== InputOutput
) {
50 items
.push_back(Gtk::Menu_Helpers::MenuElem("Split",
51 sigc::mem_fun(this, &PatchageModule::split
)));
53 items
.push_back(Gtk::Menu_Helpers::MenuElem("Join",
54 sigc::mem_fun(this, &PatchageModule::join
)));
56 items
.push_back(Gtk::Menu_Helpers::MenuElem("Disconnect All",
57 sigc::mem_fun(this, &PatchageModule::menu_disconnect_all
)));
59 void move(double dx
, double dy
) {
60 FlowCanvas::Module::move(dx
, dy
);
64 void load_location() {
65 boost::shared_ptr
<Canvas
> canvas
= _canvas
.lock();
71 if (_app
->state_manager()->get_module_location(_name
, _type
, loc
))
72 move_to(loc
.x
, loc
.y
);
74 move_to((canvas
->width()/2) - 100 + rand() % 400,
75 (canvas
->height()/2) - 100 + rand() % 400);
78 virtual void store_location() {
79 Coord
loc(property_x().get_value(), property_y().get_value());
80 _app
->state_manager()->set_module_location(_name
, _type
, loc
);
84 assert(_type
== InputOutput
);
85 _app
->state_manager()->set_module_split(_name
, true);
90 assert(_type
!= InputOutput
);
91 _app
->state_manager()->set_module_split(_name
, false);
95 virtual void show_dialog() {}
97 virtual void menu_disconnect_all() {
98 for (PortVector::iterator p
= _ports
.begin(); p
!= _ports
.end(); ++p
)
99 (*p
)->disconnect_all();
110 #endif // PATCHAGE_PATCHAGEMODULE_HPP