Move flowcanvas includes to canvas.c only
This commit is contained in:
parent
ce04e93235
commit
457e6ea861
|
@ -116,7 +116,7 @@ Patchage::Patchage(int argc, char** argv)
|
|||
_settings_filename = getenv("HOME");
|
||||
_settings_filename += "/.gladishrc";
|
||||
_state_manager = new StateManager();
|
||||
_canvas = boost::shared_ptr<PatchageCanvas>(new PatchageCanvas(this, 1600*2, 1200*2));
|
||||
//_canvas = boost::shared_ptr<PatchageCanvas>(new PatchageCanvas(this, 1600*2, 1200*2));
|
||||
|
||||
while (argc > 0) {
|
||||
if (!strcmp(*argv, "--help")) {
|
||||
|
@ -137,9 +137,9 @@ Patchage::Patchage(int argc, char** argv)
|
|||
|
||||
gtkmm_set_width_for_given_text(*_buffer_size_combo, "4096 frames", 40);
|
||||
|
||||
_main_scrolledwin->add(*_canvas);
|
||||
_canvas->scroll_to(static_cast<int>(_canvas->width()/2 - 320),
|
||||
static_cast<int>(_canvas->height()/2 - 240)); // FIXME: hardcoded
|
||||
// _main_scrolledwin->add(*_canvas);
|
||||
// _canvas->scroll_to(static_cast<int>(_canvas->width()/2 - 320),
|
||||
// static_cast<int>(_canvas->height()/2 - 240)); // FIXME: hardcoded
|
||||
|
||||
_main_scrolledwin->property_hadjustment().get_value()->set_step_increment(10);
|
||||
_main_scrolledwin->property_vadjustment().get_value()->set_step_increment(10);
|
||||
|
@ -153,8 +153,8 @@ Patchage::Patchage(int argc, char** argv)
|
|||
sigc::mem_fun(this, &Patchage::clear_load));
|
||||
_zoom_normal_but->signal_clicked().connect(sigc::bind(
|
||||
sigc::mem_fun(this, &Patchage::zoom), 1.0));
|
||||
_zoom_full_but->signal_clicked().connect(
|
||||
sigc::mem_fun(_canvas.get(), &PatchageCanvas::zoom_full));
|
||||
// _zoom_full_but->signal_clicked().connect(
|
||||
// sigc::mem_fun(_canvas.get(), &PatchageCanvas::zoom_full));
|
||||
|
||||
_menu_load_project->signal_activate().connect(
|
||||
sigc::mem_fun(this, &Patchage::load_project_ask));
|
||||
|
@ -178,7 +178,7 @@ Patchage::Patchage(int argc, char** argv)
|
|||
_menu_help_about->signal_activate().connect(
|
||||
sigc::mem_fun(this, &Patchage::on_help_about));
|
||||
|
||||
_canvas->show();
|
||||
// _canvas->show();
|
||||
_main_win->present();
|
||||
|
||||
_state_manager->load(_settings_filename);
|
||||
|
@ -221,7 +221,7 @@ Patchage::Patchage(int argc, char** argv)
|
|||
connect_widgets();
|
||||
update_state();
|
||||
|
||||
_canvas->grab_focus();
|
||||
// _canvas->grab_focus();
|
||||
|
||||
// Idle callback, check if we need to refresh
|
||||
Glib::signal_timeout().connect(
|
||||
|
@ -299,23 +299,23 @@ void
|
|||
Patchage::zoom(double z)
|
||||
{
|
||||
_state_manager->set_zoom(z);
|
||||
_canvas->set_zoom(z);
|
||||
// _canvas->set_zoom(z);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Patchage::refresh()
|
||||
{
|
||||
assert(_canvas);
|
||||
// assert(_canvas);
|
||||
|
||||
_canvas->destroy();
|
||||
// _canvas->destroy();
|
||||
|
||||
if (_jack)
|
||||
_jack->refresh();
|
||||
// if (_jack)
|
||||
// _jack->refresh();
|
||||
|
||||
for (ItemList::iterator i = _canvas->items().begin(); i != _canvas->items().end(); ++i) {
|
||||
(*i)->resize();
|
||||
}
|
||||
// for (ItemList::iterator i = _canvas->items().begin(); i != _canvas->items().end(); ++i) {
|
||||
// (*i)->resize();
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
|
@ -380,11 +380,11 @@ Patchage::status_msg(const string& msg)
|
|||
void
|
||||
Patchage::update_state()
|
||||
{
|
||||
for (ItemList::iterator i = _canvas->items().begin(); i != _canvas->items().end(); ++i) {
|
||||
shared_ptr<Module> module = dynamic_pointer_cast<Module>(*i);
|
||||
if (module)
|
||||
module->load_location();
|
||||
}
|
||||
// for (ItemList::iterator i = _canvas->items().begin(); i != _canvas->items().end(); ++i) {
|
||||
// shared_ptr<Module> module = dynamic_pointer_cast<Module>(*i);
|
||||
// if (module)
|
||||
// module->load_location();
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
|
@ -420,9 +420,9 @@ Patchage::jack_status_changed(
|
|||
void
|
||||
Patchage::on_arrange()
|
||||
{
|
||||
assert(_canvas);
|
||||
// assert(_canvas);
|
||||
|
||||
_canvas->arrange();
|
||||
// _canvas->arrange();
|
||||
}
|
||||
|
||||
|
||||
|
@ -599,6 +599,7 @@ Patchage::on_port_added(
|
|||
bool is_input,
|
||||
bool is_terminal)
|
||||
{
|
||||
#if 0
|
||||
bool is_a2j_mapped;
|
||||
string canvas_client_name;
|
||||
string canvas_port_name;
|
||||
|
@ -658,8 +659,10 @@ Patchage::on_port_added(
|
|||
module->add_port(port);
|
||||
|
||||
module->resize();
|
||||
#endif
|
||||
}
|
||||
|
||||
#if 0
|
||||
boost::shared_ptr<PatchagePort>
|
||||
Patchage::lookup_port(
|
||||
const char * jack_client_name,
|
||||
|
@ -672,12 +675,14 @@ Patchage::lookup_port(
|
|||
|
||||
return _canvas->get_port(jack_client_name, jack_port_name);
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
Patchage::on_port_removed(
|
||||
const char * jack_client_name,
|
||||
const char * jack_port_name)
|
||||
{
|
||||
#if 0
|
||||
boost::shared_ptr<PatchagePort> port = lookup_port(jack_client_name, jack_port_name);
|
||||
if (!port) {
|
||||
error_msg(str(boost::format("Unable to remove unknown port '%s':'%s'") % jack_client_name % jack_port_name));
|
||||
|
@ -696,6 +701,7 @@ Patchage::on_port_removed(
|
|||
} else {
|
||||
module->resize();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -705,6 +711,7 @@ Patchage::on_ports_connected(
|
|||
const char * jack_client2_name,
|
||||
const char * jack_port2_name)
|
||||
{
|
||||
#if 0
|
||||
boost::shared_ptr<PatchagePort> port1 = lookup_port(jack_client1_name, jack_port1_name);
|
||||
if (!port1) {
|
||||
error_msg((string)"Unable to connect unknown port '" + jack_port1_name + "' of client '" + jack_client1_name + "'");
|
||||
|
@ -718,6 +725,7 @@ Patchage::on_ports_connected(
|
|||
}
|
||||
|
||||
_canvas->add_connection(port1, port2, port1->color() + 0x22222200);
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -727,6 +735,7 @@ Patchage::on_ports_disconnected(
|
|||
const char * jack_client2_name,
|
||||
const char * jack_port2_name)
|
||||
{
|
||||
#if 0
|
||||
boost::shared_ptr<PatchagePort> port1 = lookup_port(jack_client1_name, jack_port1_name);
|
||||
if (!port1) {
|
||||
error_msg((string)"Unable to disconnect unknown port '" + jack_port1_name + "' of client '" + jack_client1_name + "'");
|
||||
|
@ -740,8 +749,10 @@ Patchage::on_ports_disconnected(
|
|||
}
|
||||
|
||||
_canvas->remove_connection(port1, port2);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if 0
|
||||
static
|
||||
bool
|
||||
port_type_match(
|
||||
|
@ -750,6 +761,7 @@ port_type_match(
|
|||
{
|
||||
return port1->type == port2->type;
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
Patchage::get_port_jack_names(
|
||||
|
@ -757,6 +769,7 @@ Patchage::get_port_jack_names(
|
|||
string& jack_client_name,
|
||||
string& jack_port_name)
|
||||
{
|
||||
#if 0
|
||||
if (port->is_a2j_mapped)
|
||||
{
|
||||
jack_client_name = _a2j->get_jack_client_name();
|
||||
|
@ -767,6 +780,7 @@ Patchage::get_port_jack_names(
|
|||
jack_client_name = port->module().lock()->name();
|
||||
jack_port_name = port->name();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -774,6 +788,7 @@ Patchage::connect(
|
|||
boost::shared_ptr<PatchagePort> port1,
|
||||
boost::shared_ptr<PatchagePort> port2)
|
||||
{
|
||||
#if 0
|
||||
string jack_client1_name;
|
||||
string jack_port1_name;
|
||||
string jack_client2_name;
|
||||
|
@ -794,6 +809,7 @@ Patchage::connect(
|
|||
{
|
||||
status_msg("ERROR: Attempt to connect ports with mismatched types");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -801,6 +817,7 @@ Patchage::disconnect(
|
|||
boost::shared_ptr<PatchagePort> port1,
|
||||
boost::shared_ptr<PatchagePort> port2)
|
||||
{
|
||||
#if 0
|
||||
string jack_client1_name;
|
||||
string jack_port1_name;
|
||||
string jack_client2_name;
|
||||
|
@ -821,6 +838,7 @@ Patchage::disconnect(
|
|||
{
|
||||
status_msg("ERROR: Attempt to disconnect ports with mismatched types");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/** Destroy all JACK (canvas) ports.
|
||||
|
@ -828,6 +846,7 @@ Patchage::disconnect(
|
|||
void
|
||||
Patchage::clear_canvas()
|
||||
{
|
||||
#if 0
|
||||
ItemList modules = _canvas->items(); // copy
|
||||
for (ItemList::iterator m = modules.begin(); m != modules.end(); ++m) {
|
||||
shared_ptr<Module> module = dynamic_pointer_cast<Module>(*m);
|
||||
|
@ -849,10 +868,12 @@ Patchage::clear_canvas()
|
|||
else
|
||||
module->resize();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
bool
|
||||
Patchage::is_canvas_empty()
|
||||
{
|
||||
return _canvas->items().empty();
|
||||
// return _canvas->items().empty();
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -22,26 +22,12 @@
|
|||
#include "PatchageModule.hpp"
|
||||
#include "PatchagePort.hpp"
|
||||
|
||||
PatchageCanvas::PatchageCanvas(Patchage* app, int width, int height)
|
||||
: FlowCanvas::Canvas(width, height)
|
||||
, _app(app)
|
||||
PatchageCanvas::PatchageCanvas(Patchage* app, int width, int height) : _app(app)
|
||||
{
|
||||
canvas_create(width, height, &_canvas);
|
||||
}
|
||||
|
||||
|
||||
boost::shared_ptr<Item>
|
||||
PatchageCanvas::get_item(const string& name)
|
||||
{
|
||||
ItemList::iterator m = _items.begin();
|
||||
|
||||
for ( ; m != _items.end(); ++m)
|
||||
if ((*m)->name() == name)
|
||||
break;
|
||||
|
||||
return (m == _items.end()) ? boost::shared_ptr<Item>() : *m;
|
||||
}
|
||||
|
||||
|
||||
#if 0
|
||||
boost::shared_ptr<PatchageModule>
|
||||
PatchageCanvas::find_module(const string& name, ModuleType type)
|
||||
{
|
||||
|
@ -118,3 +104,4 @@ PatchageCanvas::lookup_port_by_a2j_jack_port_name(
|
|||
|
||||
return boost::shared_ptr<PatchagePort>();
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -18,9 +18,8 @@
|
|||
#ifndef PATCHAGE_PATCHAGECANVAS_HPP
|
||||
#define PATCHAGE_PATCHAGECANVAS_HPP
|
||||
|
||||
#include "config.h"
|
||||
#include "common.h"
|
||||
#include <string>
|
||||
#include <flowcanvas/Canvas.hpp>
|
||||
#include "StateManager.hpp"
|
||||
|
||||
class Patchage;
|
||||
|
@ -28,21 +27,19 @@ class PatchageModule;
|
|||
class PatchagePort;
|
||||
|
||||
using std::string;
|
||||
using namespace FlowCanvas;
|
||||
|
||||
class PatchageCanvas : public Canvas {
|
||||
class PatchageCanvas
|
||||
{
|
||||
public:
|
||||
PatchageCanvas(Patchage* _app, int width, int height);
|
||||
|
||||
boost::shared_ptr<PatchageModule> find_module(const string& name, ModuleType type);
|
||||
|
||||
void connect(boost::shared_ptr<Connectable> port1, boost::shared_ptr<Connectable> port2);
|
||||
void disconnect(boost::shared_ptr<Connectable> port1, boost::shared_ptr<Connectable> port2);
|
||||
void connect(boost::shared_ptr<PatchagePort> port1, boost::shared_ptr<PatchagePort> port2);
|
||||
void disconnect(boost::shared_ptr<PatchagePort> port1, boost::shared_ptr<PatchagePort> port2);
|
||||
|
||||
void status_message(const string& msg);
|
||||
|
||||
boost::shared_ptr<Item> get_item(const string& name);
|
||||
|
||||
boost::shared_ptr<PatchagePort>
|
||||
get_port(
|
||||
const string& module_name,
|
||||
|
@ -54,6 +51,7 @@ public:
|
|||
|
||||
private:
|
||||
Patchage* _app;
|
||||
canvas_handle _canvas;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -20,33 +20,23 @@
|
|||
|
||||
#include <string>
|
||||
#include <libgnomecanvasmm.h>
|
||||
#include <flowcanvas/Canvas.hpp>
|
||||
#include <flowcanvas/Module.hpp>
|
||||
#include "PatchageCanvas.hpp"
|
||||
#include "StateManager.hpp"
|
||||
#include "PatchagePort.hpp"
|
||||
|
||||
using namespace FlowCanvas;
|
||||
|
||||
class PatchageModule : public Module
|
||||
class PatchageModule
|
||||
{
|
||||
public:
|
||||
PatchageModule(Patchage* app, const std::string& name, ModuleType type, double x=0, double y=0)
|
||||
: Module(app->canvas(), name, x, y)
|
||||
, _app(app)
|
||||
, _type(type)
|
||||
{
|
||||
PatchageModule(Patchage* app, const std::string& name, ModuleType type, double x=0, double y=0);
|
||||
|
||||
}
|
||||
|
||||
virtual ~PatchageModule() { delete _menu; _menu = NULL; }
|
||||
virtual ~PatchageModule();
|
||||
|
||||
bool
|
||||
identify(const std::string& name, ModuleType type)
|
||||
{
|
||||
return _name == name && (_type == type || _type == InputOutput);
|
||||
}
|
||||
|
||||
#if 0
|
||||
void create_menu() {
|
||||
_menu = new Gtk::Menu();
|
||||
Gtk::Menu::MenuList& items = _menu->items();
|
||||
|
@ -60,7 +50,6 @@ public:
|
|||
items.push_back(Gtk::Menu_Helpers::MenuElem("Disconnect All",
|
||||
sigc::mem_fun(this, &PatchageModule::menu_disconnect_all)));
|
||||
}
|
||||
|
||||
void move(double dx, double dy) {
|
||||
FlowCanvas::Module::move(dx, dy);
|
||||
store_location();
|
||||
|
@ -103,10 +92,12 @@ public:
|
|||
for (PortVector::iterator p = _ports.begin(); p != _ports.end(); ++p)
|
||||
(*p)->disconnect_all();
|
||||
}
|
||||
#endif
|
||||
|
||||
protected:
|
||||
Patchage* _app;
|
||||
ModuleType _type;
|
||||
std::string _name;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -18,13 +18,9 @@
|
|||
#ifndef PATCHAGE_PATCHAGEPORT_HPP
|
||||
#define PATCHAGE_PATCHAGEPORT_HPP
|
||||
|
||||
#include "config.h"
|
||||
#include "common.h"
|
||||
#include <string>
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include <flowcanvas/Port.hpp>
|
||||
#include <flowcanvas/Module.hpp>
|
||||
|
||||
using namespace FlowCanvas;
|
||||
|
||||
enum PortType { JACK_AUDIO, JACK_MIDI };
|
||||
|
||||
|
@ -33,18 +29,14 @@ enum PortType { JACK_AUDIO, JACK_MIDI };
|
|||
*
|
||||
* \ingroup OmGtk
|
||||
*/
|
||||
struct PatchagePort : public FlowCanvas::Port
|
||||
struct PatchagePort
|
||||
{
|
||||
PatchagePort(
|
||||
boost::shared_ptr<Module> module,
|
||||
canvas_module_handle module,
|
||||
const std::string& name,
|
||||
bool is_input,
|
||||
int color)
|
||||
: Port(module, name, is_input, color)
|
||||
{
|
||||
}
|
||||
|
||||
virtual ~PatchagePort() {}
|
||||
int color);
|
||||
virtual ~PatchagePort();
|
||||
|
||||
PortType type;
|
||||
bool is_a2j_mapped;
|
||||
|
|
|
@ -24,6 +24,10 @@
|
|||
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#include <flowcanvas/Canvas.hpp>
|
||||
#include <flowcanvas/Port.hpp>
|
||||
#include <flowcanvas/Module.hpp>
|
||||
|
||||
#include "canvas.h"
|
||||
|
||||
bool
|
||||
|
|
|
@ -32,4 +32,6 @@
|
|||
#include <stdbool.h> /* C99 bool */
|
||||
#include <stdint.h> /* fixed bit size ints */
|
||||
|
||||
#include "canvas.h"
|
||||
|
||||
#endif /* #ifndef COMMON_H__15E63B7A_8350_4ABD_B04C_592158354949__INCLUDED */
|
||||
|
|
Loading…
Reference in New Issue