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
This commit is contained in:
Fischlurch 2018-04-07 02:55:47 +02:00
parent 09359cf92a
commit ca9abaa9d9
6 changed files with 41 additions and 20 deletions

View file

@ -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}
{ }

View file

@ -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 ()

View file

@ -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 <memory>
@ -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<workspace::WorkspaceWindow>;
using Service_ElementAccess = lib::DependInject<model::ElementAccess>::ServiceInstance<ElemAccessDir>;
GlobalCtx& globalCtx_;
list<PWindow> windowList_;
PanelLocator panelLoc_;
Service_ElementAccess elementAccess_;
public:
WindowLocator (GlobalCtx&);
~WindowLocator ();
bool empty() const;

View file

@ -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<LocationQuery>
, tracker_{new FocusTracker{*navigator_}}

View file

@ -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();
// }

View file

@ -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<UILocationSolver>::ServiceInstance<>;
ctrl::WindowLocator& windowLoc_;
lib::Depend<model::ElementAccess> 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();
};