From ca9abaa9d970a8547f3cc00f047deff116fb2f88 Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Sat, 7 Apr 2018 02:55:47 +0200 Subject: [PATCH] ElementAccess: change wiring in ViewLocator into a dependency ...reduce immediate coupling, since we do not really now what actions ElementAccess will actually perform, and this is likely to remain this way for some time. So just let it sit there are an on-demand dependency. Moreover, create an (empty placeholder) implementation within WindowLocator. So everything is set now for the actual implementation to be filled in --- src/gui/ctrl/elem-access-dir.hpp | 9 ++++++++- src/gui/ctrl/window-locator.cpp | 5 +++++ src/gui/ctrl/window-locator.hpp | 12 ++++++++++-- src/gui/interact/interaction-director.cpp | 2 +- src/gui/interact/view-locator.cpp | 22 +++++++++++----------- src/gui/interact/view-locator.hpp | 11 ++++++----- 6 files changed, 41 insertions(+), 20 deletions(-) diff --git a/src/gui/ctrl/elem-access-dir.hpp b/src/gui/ctrl/elem-access-dir.hpp index 6fb9c92aa..b8863dc6b 100644 --- a/src/gui/ctrl/elem-access-dir.hpp +++ b/src/gui/ctrl/elem-access-dir.hpp @@ -44,6 +44,8 @@ #include "lib/error.hpp" #include "gui/model/element-access.hpp" +#include "gui/ctrl/window-locator.hpp" +#include "gui/ctrl/panel-locator.hpp" //#include "lib/symbol.hpp" //#include "lib/util.hpp" @@ -64,11 +66,16 @@ namespace ctrl{ */ class ElemAccessDir : public model::ElementAccess + , ::util::NonCopyable { + WindowLocator& windowLoc_; + PanelLocator& panelLoc_; public: explicit - ElemAccessDir () + ElemAccessDir (WindowLocator& windowLocatorService, PanelLocator& panelLocatorService) + : windowLoc_{windowLocatorService} + , panelLoc_{panelLocatorService} { } diff --git a/src/gui/ctrl/window-locator.cpp b/src/gui/ctrl/window-locator.cpp index 2c3336e60..01d72feca 100644 --- a/src/gui/ctrl/window-locator.cpp +++ b/src/gui/ctrl/window-locator.cpp @@ -30,6 +30,7 @@ #include "gui/ctrl/global-ctx.hpp" #include "gui/ctrl/panel-locator.hpp" #include "gui/ctrl/window-locator.hpp" +#include "gui/ctrl/elem-access-dir.hpp" #include "gui/workspace/workspace-window.hpp" #include "lib/util.hpp" @@ -58,8 +59,12 @@ namespace ctrl { : globalCtx_{globals} , windowList_{} , panelLoc_{windowList_} + , elementAccess_{*this, panelLoc_} { } + WindowLocator::~WindowLocator () { } + + void WindowLocator::newWindow () diff --git a/src/gui/ctrl/window-locator.hpp b/src/gui/ctrl/window-locator.hpp index 43c7d76c6..c00d36083 100644 --- a/src/gui/ctrl/window-locator.hpp +++ b/src/gui/ctrl/window-locator.hpp @@ -37,6 +37,7 @@ #include "gui/gtk-base.hpp" #include "gui/ctrl/panel-locator.hpp" +#include "lib/depend-inject.hpp" #include "lib/nocopy.hpp" #include @@ -49,10 +50,13 @@ namespace gui { namespace controller { class Controller; } ////////////////////////////////////////////////////TICKET #1048 : rectify UI lifecycle namespace workspace { class WorkspaceWindow; } +namespace model { + class ElementAccess; +} namespace ctrl { class GlobalCtx; - + class ElemAccessDir; using std::list; @@ -61,17 +65,21 @@ namespace ctrl { * A centralised manager of all top level application windows. */ class WindowLocator - : util::NonCopyable + : ::util::NonCopyable { using PWindow = std::shared_ptr; + using Service_ElementAccess = lib::DependInject::ServiceInstance; GlobalCtx& globalCtx_; list windowList_; PanelLocator panelLoc_; + Service_ElementAccess elementAccess_; + public: WindowLocator (GlobalCtx&); + ~WindowLocator (); bool empty() const; diff --git a/src/gui/interact/interaction-director.cpp b/src/gui/interact/interaction-director.cpp index 2b4a05a3a..b8a66a50e 100644 --- a/src/gui/interact/interaction-director.cpp +++ b/src/gui/interact/interaction-director.cpp @@ -84,7 +84,7 @@ namespace interact { InteractionDirector::InteractionDirector (GlobalCtx& globals) : model::Controller(session::Root::getID(), globals.uiBus_.getAccessPoint()) , globalCtx_(globals) - , viewLocator_{new ViewLocator{globals.windowLoc_}} + , viewLocator_{new ViewLocator} , spotLocator_{new SpotLocator} , navigator_{*spotLocator_, *viewLocator_} // Service exposed as Depend , tracker_{new FocusTracker{*navigator_}} diff --git a/src/gui/interact/view-locator.cpp b/src/gui/interact/view-locator.cpp index 6778ba4cf..4a7eb4915 100644 --- a/src/gui/interact/view-locator.cpp +++ b/src/gui/interact/view-locator.cpp @@ -42,7 +42,7 @@ #include "gui/interact/view-locator.hpp" #include "gui/interact/ui-location-solver.hpp" #include "gui/ctrl/panel-locator.hpp" -#include "gui/ctrl/window-locator.hpp" +#include "gui/model/element-access.hpp" #include "gui/interact/ui-coord-resolver.hpp" #include "lib/depend.hpp" #include "lib/symbol.hpp" @@ -51,8 +51,9 @@ //using util::cStr; //using util::isnil; using lib::Symbol; -using gui::ctrl::PanelLocator; -using gui::ctrl::WindowLocator; +//using gui::ctrl::PanelLocator; +//using gui::ctrl::WindowLocator; +using gui::model::ElementAccess; namespace gui { @@ -70,9 +71,8 @@ namespace interact { - ViewLocator::ViewLocator (ctrl::WindowLocator& windowLocatorService) - : windowLoc_{windowLocatorService} - , locResolver_{LocationQuery::service} + ViewLocator::ViewLocator () + : locResolver_{LocationQuery::service} { } // dtors via smart-ptr invoked from here... @@ -82,11 +82,11 @@ namespace interact { /* === Service accessors within global context === */ - PanelLocator& - ViewLocator::panelLocator() - { - return windowLoc_.locatePanel(); - } +// PanelLocator& +// ViewLocator::panelLocator() +// { +// return windowLoc_.locatePanel(); +// } diff --git a/src/gui/interact/view-locator.hpp b/src/gui/interact/view-locator.hpp index ce23cc85f..ad71718e3 100644 --- a/src/gui/interact/view-locator.hpp +++ b/src/gui/interact/view-locator.hpp @@ -68,9 +68,11 @@ namespace gui { +namespace model{ + class ElementAccess; +} namespace ctrl{ class PanelLocator; - class WindowLocator; } namespace interact { @@ -87,16 +89,16 @@ namespace interact { * @todo initial draft as of 9/2017 -- actual implementation need to be filled in */ class ViewLocator - : util::NonCopyable + : ::util::NonCopyable { using Service_LocationSolver = lib::DependInject::ServiceInstance<>; - ctrl::WindowLocator& windowLoc_; + lib::Depend elementAccess; Service_LocationSolver locResolver_; public: - ViewLocator (ctrl::WindowLocator&); + ViewLocator (); ~ViewLocator(); @@ -108,7 +110,6 @@ namespace interact { private: /* === accessors to sibling global services === */ - ctrl::PanelLocator& panelLocator(); };