diff options
Diffstat (limited to 'src/progs')
-rw-r--r-- | src/progs/ingenuity/LoadPluginWindow.cpp | 3 | ||||
-rw-r--r-- | src/progs/ingenuity/LoadPluginWindow.h | 6 | ||||
-rw-r--r-- | src/progs/ingenuity/LoadSubpatchWindow.cpp | 22 | ||||
-rw-r--r-- | src/progs/ingenuity/LoadSubpatchWindow.h | 6 | ||||
-rw-r--r-- | src/progs/ingenuity/NewSubpatchWindow.cpp | 8 | ||||
-rw-r--r-- | src/progs/ingenuity/NewSubpatchWindow.h | 6 | ||||
-rw-r--r-- | src/progs/ingenuity/OmFlowCanvas.cpp | 13 | ||||
-rw-r--r-- | src/progs/ingenuity/OmFlowCanvas.h | 1 | ||||
-rw-r--r-- | src/progs/ingenuity/PatchController.cpp | 28 | ||||
-rw-r--r-- | src/progs/ingenuity/PatchController.h | 2 | ||||
-rw-r--r-- | src/progs/ingenuity/PortController.cpp | 16 | ||||
-rw-r--r-- | src/progs/ingenuity/PortController.h | 2 | ||||
-rw-r--r-- | src/progs/ingenuity/ingenuity.glade | 2 |
13 files changed, 64 insertions, 51 deletions
diff --git a/src/progs/ingenuity/LoadPluginWindow.cpp b/src/progs/ingenuity/LoadPluginWindow.cpp index 3037dd93..9d18cec4 100644 --- a/src/progs/ingenuity/LoadPluginWindow.cpp +++ b/src/progs/ingenuity/LoadPluginWindow.cpp @@ -20,6 +20,7 @@ #include <algorithm> #include <cctype> #include "PatchController.h" +#include "PatchView.h" #include "NodeModel.h" #include "Controller.h" #include "App.h" @@ -287,7 +288,7 @@ LoadPluginWindow::add_clicked() nm->polyphonic(polyphonic); if (m_new_module_x == 0 && m_new_module_y == 0) { - m_patch_controller->get_new_module_location( + m_patch_controller->view()->canvas()->get_new_module_location( m_new_module_x, m_new_module_y); } nm->x(m_new_module_x); diff --git a/src/progs/ingenuity/LoadPluginWindow.h b/src/progs/ingenuity/LoadPluginWindow.h index 6f04d25c..00035b13 100644 --- a/src/progs/ingenuity/LoadPluginWindow.h +++ b/src/progs/ingenuity/LoadPluginWindow.h @@ -90,7 +90,7 @@ public: void patch_controller(PatchController* pc); void set_plugin_list(const std::map<string, CountedPtr<PluginModel> >& m); - void set_next_module_location(int x, int y) + void set_next_module_location(double x, double y) { m_new_module_x = x; m_new_module_y = y; } void add_plugin(CountedPtr<PluginModel> plugin); @@ -125,8 +125,8 @@ private: int m_plugin_name_offset; // see comments for generate_plugin_name - int m_new_module_x; - int m_new_module_y; + double m_new_module_x; + double m_new_module_y; Gtk::TreeView* m_plugins_treeview; Gtk::CheckButton* m_polyphonic_checkbutton; diff --git a/src/progs/ingenuity/LoadSubpatchWindow.cpp b/src/progs/ingenuity/LoadSubpatchWindow.cpp index dbf40c00..0ec98771 100644 --- a/src/progs/ingenuity/LoadSubpatchWindow.cpp +++ b/src/progs/ingenuity/LoadSubpatchWindow.cpp @@ -20,6 +20,8 @@ #include <cassert> #include "App.h" #include "PatchController.h" +#include "PatchView.h" +#include "OmFlowCanvas.h" #include "NodeModel.h" #include "Controller.h" #include "PatchModel.h" @@ -130,9 +132,11 @@ LoadSubpatchWindow::ok_clicked() assert(m_patch_controller != NULL); assert(m_patch_controller->model()); - // These values are interpreted by load_patch() as "not defined", ie load from file - string name = ""; - int poly = 0; + const string filename = get_filename(); + + // FIXME + string name = filename.substr(filename.find_last_of("/")+1); + int poly = 1; if (m_name_from_user_radio->get_active()) name = m_name_entry->get_text(); @@ -143,21 +147,21 @@ LoadSubpatchWindow::ok_clicked() poly = m_patch_controller->patch_model()->poly(); if (m_new_module_x == 0 && m_new_module_y == 0) { - m_patch_controller->get_new_module_location( + m_patch_controller->view()->canvas()->get_new_module_location( m_new_module_x, m_new_module_y); } PatchModel* pm = new PatchModel(m_patch_controller->model()->base_path() + name, poly); - pm->filename(get_filename()); + pm->filename(filename); pm->set_parent(m_patch_controller->model().get()); pm->x(m_new_module_x); pm->y(m_new_module_y); - if (name == "") - pm->set_path(""); + //if (name == "") + // pm->set_path(""); char temp_buf[16]; - snprintf(temp_buf, 16, "%d", m_new_module_x); + snprintf(temp_buf, 16, "%16f", m_new_module_x); pm->set_metadata("module-x", temp_buf); - snprintf(temp_buf, 16, "%d", m_new_module_y); + snprintf(temp_buf, 16, "%16f", m_new_module_y); pm->set_metadata("module-y", temp_buf); Controller::instance().load_patch(pm); diff --git a/src/progs/ingenuity/LoadSubpatchWindow.h b/src/progs/ingenuity/LoadSubpatchWindow.h index 2ec37432..c4696628 100644 --- a/src/progs/ingenuity/LoadSubpatchWindow.h +++ b/src/progs/ingenuity/LoadSubpatchWindow.h @@ -41,7 +41,7 @@ public: void patch_controller(PatchController* pc); - void set_next_module_location(int x, int y) + void set_next_module_location(double x, double y) { m_new_module_x = x; m_new_module_y = y; } protected: @@ -58,8 +58,8 @@ private: PatchController* m_patch_controller; - int m_new_module_x; - int m_new_module_y; + double m_new_module_x; + double m_new_module_y; Gtk::RadioButton* m_name_from_file_radio; Gtk::RadioButton* m_name_from_user_radio; diff --git a/src/progs/ingenuity/NewSubpatchWindow.cpp b/src/progs/ingenuity/NewSubpatchWindow.cpp index 3f1e19fd..84f9bb7f 100644 --- a/src/progs/ingenuity/NewSubpatchWindow.cpp +++ b/src/progs/ingenuity/NewSubpatchWindow.cpp @@ -16,6 +16,8 @@ #include "NewSubpatchWindow.h" #include "PatchController.h" +#include "PatchView.h" +#include "OmFlowCanvas.h" #include "NodeModel.h" #include "Controller.h" #include "PatchModel.h" @@ -84,7 +86,7 @@ NewSubpatchWindow::ok_clicked() m_poly_spinbutton->get_value_as_int()); if (m_new_module_x == 0 && m_new_module_y == 0) { - m_patch_controller->get_new_module_location( + m_patch_controller->view()->canvas()->get_new_module_location( m_new_module_x, m_new_module_y); } @@ -92,9 +94,9 @@ NewSubpatchWindow::ok_clicked() pm->x(m_new_module_x); pm->y(m_new_module_y); char temp_buf[16]; - snprintf(temp_buf, 16, "%d", m_new_module_x); + snprintf(temp_buf, 16, "%16f", m_new_module_x); pm->set_metadata("module-x", temp_buf); - snprintf(temp_buf, 16, "%d", m_new_module_y); + snprintf(temp_buf, 16, "%16f", m_new_module_y); pm->set_metadata("module-y", temp_buf); Controller::instance().create_patch_from_model(pm); hide(); diff --git a/src/progs/ingenuity/NewSubpatchWindow.h b/src/progs/ingenuity/NewSubpatchWindow.h index de6c4150..46fa9e1c 100644 --- a/src/progs/ingenuity/NewSubpatchWindow.h +++ b/src/progs/ingenuity/NewSubpatchWindow.h @@ -41,7 +41,7 @@ public: void patch_controller(PatchController* pc); - void set_next_module_location(int x, int y) + void set_next_module_location(double x, double y) { m_new_module_x = x; m_new_module_y = y; } private: @@ -51,8 +51,8 @@ private: PatchController* m_patch_controller; - int m_new_module_x; - int m_new_module_y; + double m_new_module_x; + double m_new_module_y; Gtk::Entry* m_name_entry; Gtk::Label* m_message_label; diff --git a/src/progs/ingenuity/OmFlowCanvas.cpp b/src/progs/ingenuity/OmFlowCanvas.cpp index 94dc9b17..7d4bd3a4 100644 --- a/src/progs/ingenuity/OmFlowCanvas.cpp +++ b/src/progs/ingenuity/OmFlowCanvas.cpp @@ -203,6 +203,19 @@ OmFlowCanvas::menu_add_port(const string& name, const string& type, bool is_outp } +/** Try to guess a suitable location for a new module. + */ +void +OmFlowCanvas::get_new_module_location(double& x, double& y) +{ + int scroll_x; + int scroll_y; + get_scroll_offsets(scroll_x, scroll_y); + x = scroll_x + 20; + y = scroll_y + 20; +} + + /* void OmFlowCanvas::menu_add_audio_input() diff --git a/src/progs/ingenuity/OmFlowCanvas.h b/src/progs/ingenuity/OmFlowCanvas.h index 656cc2c2..310aa5b8 100644 --- a/src/progs/ingenuity/OmFlowCanvas.h +++ b/src/progs/ingenuity/OmFlowCanvas.h @@ -46,6 +46,7 @@ public: void connect(const Port* src_port, const Port* dst_port); void disconnect(const Port* src_port, const Port* dst_port); + void get_new_module_location(double& x, double& y); bool canvas_event(GdkEvent* event); void destroy_selected(); diff --git a/src/progs/ingenuity/PatchController.cpp b/src/progs/ingenuity/PatchController.cpp index 79084cdc..49c7491c 100644 --- a/src/progs/ingenuity/PatchController.cpp +++ b/src/progs/ingenuity/PatchController.cpp @@ -313,8 +313,8 @@ PatchController::create_view() /* Set sane default coordinates if not set already yet */ if (nm->x() == 0.0f && nm->y() == 0.0f) { - int x, y; - get_new_module_location(x, y); + double x, y; + m_patch_view->canvas()->get_new_module_location(x, y); nm->x(x); nm->y(y); } @@ -338,7 +338,7 @@ PatchController::create_view() PortController* const pc = dynamic_cast<PortController*>((*i)->controller()); assert(pc); if (pc->module() == NULL) - pc->create_module(m_patch_view->canvas(), 1600, 1200); + pc->create_module(m_patch_view->canvas()); assert(pc->module() != NULL); m_patch_view->canvas()->add_module(pc->module()); pc->module()->resize(); @@ -471,8 +471,8 @@ PatchController::add_node(CountedPtr<NodeModel> object) assert(node->controller() == nc); if (m_patch_view != NULL) { - int x, y; - get_new_module_location(x, y); + double x, y; + m_patch_view->canvas()->get_new_module_location(x, y); node->x(x); node->y(y); @@ -557,8 +557,6 @@ PatchController::add_port(CountedPtr<PortModel> pm) // Create port's (pseudo) module on this patch's canvas (if there is one) if (m_patch_view != NULL) { - int x, y; - get_new_module_location(x, y); // Set zoom to 1.0 so module isn't messed up (Death to GnomeCanvas) float old_zoom = m_patch_view->canvas()->zoom(); @@ -566,7 +564,7 @@ PatchController::add_port(CountedPtr<PortModel> pm) m_patch_view->canvas()->zoom(1.0); if (pc->module() == NULL) - pc->create_module(m_patch_view->canvas(), x, y); + pc->create_module(m_patch_view->canvas()); assert(pc->module() != NULL); m_patch_view->canvas()->add_module(pc->module()); pc->module()->resize(); @@ -662,20 +660,6 @@ PatchController::disconnection(const Path& src_port_path, const Path& dst_port_p */ } - -/** Try to guess a suitable location for a new module. - */ -void -PatchController::get_new_module_location(int& x, int& y) -{ - assert(m_patch_view != NULL); - assert(m_patch_view->canvas() != NULL); - m_patch_view->canvas()->get_scroll_offsets(x, y); - x += 20; - y += 20; -} - - void PatchController::show_patch_window() { diff --git a/src/progs/ingenuity/PatchController.h b/src/progs/ingenuity/PatchController.h index 54c11888..ef8a438e 100644 --- a/src/progs/ingenuity/PatchController.h +++ b/src/progs/ingenuity/PatchController.h @@ -79,8 +79,6 @@ public: void disconnection(const Path& src_port_path, const Path& dst_port_path); void clear(); - void get_new_module_location(int& x, int& y); - void show_control_window(); void show_properties_window(); void show_patch_window(); diff --git a/src/progs/ingenuity/PortController.cpp b/src/progs/ingenuity/PortController.cpp index 335e673c..a26c14eb 100644 --- a/src/progs/ingenuity/PortController.cpp +++ b/src/progs/ingenuity/PortController.cpp @@ -15,6 +15,7 @@ */ #include "PortController.h" +#include "OmFlowCanvas.h" #include "OmModule.h" #include "PortModel.h" #include "ControlPanel.h" @@ -54,10 +55,19 @@ PortController::destroy() void -PortController::create_module(OmFlowCanvas* canvas, double x, double y) +PortController::create_module(OmFlowCanvas* canvas) { cerr << "Creating port module " << m_model->path() << endl; + const string x_str = m_model->get_metadata("module-x"); + const string y_str = m_model->get_metadata("module-y"); + + double default_x; + double default_y; + canvas->get_new_module_location(default_x, default_y); + const double x = (x_str == "") ? default_x : atof(x_str.c_str()); + const double y = (y_str == "") ? default_y : atof(y_str.c_str()); + assert(canvas); assert(port_model()); m_module = new OmPortModule(canvas, this, x, y); @@ -65,8 +75,8 @@ PortController::create_module(OmFlowCanvas* canvas, double x, double y) // FIXME: leak m_patch_port = new OmPatchPort(m_module, port_model()); m_module->add_port(m_patch_port, false); - - m_module->move_to(x, y); + + m_module->move_to(x, y); // FIXME: redundant (?) } diff --git a/src/progs/ingenuity/PortController.h b/src/progs/ingenuity/PortController.h index c4ff83db..53c2cd48 100644 --- a/src/progs/ingenuity/PortController.h +++ b/src/progs/ingenuity/PortController.h @@ -53,7 +53,7 @@ public: virtual void destroy(); - virtual void create_module(OmFlowCanvas* canvas, double x, double y); + virtual void create_module(OmFlowCanvas* canvas); OmPortModule* module() { return m_module; } /* virtual void add_to_store(); diff --git a/src/progs/ingenuity/ingenuity.glade b/src/progs/ingenuity/ingenuity.glade index 67286660..178eac88 100644 --- a/src/progs/ingenuity/ingenuity.glade +++ b/src/progs/ingenuity/ingenuity.glade @@ -3607,7 +3607,7 @@ Contributors: <widget class="GtkImageMenuItem" id="canvas_menu_load_patch"> <property name="visible">True</property> <property name="tooltip" translatable="yes">Load a patch as a child of this patch</property> - <property name="label" translatable="yes">Patch From _File...</property> + <property name="label" translatable="yes">_Load Patch...</property> <property name="use_underline">True</property> <signal name="activate" handler="on_canvas_menu_load_patch_activate" last_modification_time="Fri, 16 Jun 2006 16:41:40 GMT"/> |