From b15864870d34a1188eda93ad215734275037278e Mon Sep 17 00:00:00 2001 From: David Robillard Date: Mon, 11 Sep 2006 11:10:35 +0000 Subject: Switched homebrew CountedPtr to boost::shared_ptr. Factories for patch windows, controller. Robustness updated in many places. Tons of cleanups, rewrites, bugfixes, etc. git-svn-id: http://svn.drobilla.net/lad/ingen@128 a436a847-0d15-0410-975c-d299462d15a1 --- src/progs/ingenuity/SubpatchModule.cpp | 41 +++++++++++++++------------------- 1 file changed, 18 insertions(+), 23 deletions(-) (limited to 'src/progs/ingenuity/SubpatchModule.cpp') diff --git a/src/progs/ingenuity/SubpatchModule.cpp b/src/progs/ingenuity/SubpatchModule.cpp index d0492618..598cc9db 100644 --- a/src/progs/ingenuity/SubpatchModule.cpp +++ b/src/progs/ingenuity/SubpatchModule.cpp @@ -26,51 +26,46 @@ #include "OmFlowCanvas.h" #include "PatchController.h" #include "OmPort.h" +#include "WindowFactory.h" using std::cerr; using std::cout; using std::endl; namespace Ingenuity { -SubpatchModule::SubpatchModule(OmFlowCanvas* canvas, PatchController* patch) -: OmModule(canvas, patch), +SubpatchModule::SubpatchModule(OmFlowCanvas* canvas, CountedPtr patch) +: OmModule(canvas, patch.get()), m_patch(patch) { - assert(canvas != NULL); - assert(patch != NULL); + assert(canvas); + assert(patch); } void SubpatchModule::on_double_click(GdkEventButton* event) { - assert(m_patch != NULL); - - // If window is visible - if (m_patch->window() != NULL - && m_patch->window()->is_visible()) { - m_patch->show_patch_window(); // just raise it - // No window visible - } else { - if (event->state & GDK_SHIFT_MASK) - m_patch->show_patch_window(); // open a new window - else - browse_to_patch(); - } + assert(m_patch); + + CountedPtr parent = PtrCast(m_patch->model()->parent()->controller()); + + PatchWindow* const preferred + = (event->state & GDK_SHIFT_MASK) ? NULL : parent->window(); + + App::instance().window_factory()->present(m_patch, preferred); } -/** Browse to this patch in current (parent's) window. */ +/** Browse to this patch in current (parent's) window + * (unless an existing window is displaying it) + */ void SubpatchModule::browse_to_patch() { assert(m_patch->model()->parent()); - PatchController* pc = (PatchController*)m_patch->model()->parent()->controller(); - assert(pc != NULL); - assert(pc->window() != NULL); + CountedPtr pc = PtrCast(m_patch->model()->parent()->controller()); - assert(pc->window() != NULL); - pc->window()->patch_controller(m_patch); + App::instance().window_factory()->present(m_patch, pc->window()); } -- cgit v1.2.1