ViewSpec: get rid of all the lambdas and global vars. LocationQuery is a service now
Harvesting the fruits of the DependencyFactory rework....
This commit is contained in:
parent
71bb2b48b6
commit
4de2ea2abe
6 changed files with 16 additions and 33 deletions
|
|
@ -84,7 +84,7 @@ namespace interact {
|
|||
InteractionDirector::InteractionDirector (GlobalCtx& globals)
|
||||
: model::Controller(session::Root::getID(), globals.uiBus_.getAccessPoint())
|
||||
, globalCtx_(globals)
|
||||
, viewLocator_{new ViewLocator{globals, [this]() -> LocationQuery& { return *navigator_; }}}
|
||||
, viewLocator_{new ViewLocator{globals}}
|
||||
, spotLocator_{new SpotLocator}
|
||||
, navigator_{*spotLocator_, *viewLocator_} // Service exposed as Depend<LocationQuery>
|
||||
, tracker_{new FocusTracker{*navigator_}}
|
||||
|
|
|
|||
|
|
@ -44,6 +44,9 @@ namespace interact {
|
|||
|
||||
LocationQuery::~LocationQuery() { }
|
||||
|
||||
/** storage for the global LocationQuery service access point */
|
||||
lib::Depend<LocationQuery> LocationQuery::service;
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -121,6 +121,7 @@
|
|||
#include "gui/interact/ui-coord.hpp"
|
||||
#include "lib/iter-tree-explorer.hpp"
|
||||
#include "lib/iter-source.hpp"
|
||||
#include "lib/depend.hpp"
|
||||
#include "lib/util.hpp"
|
||||
|
||||
#include <utility>
|
||||
|
|
@ -191,6 +192,7 @@ namespace interact {
|
|||
* they may be resolved against any tree-like topological structure, which can be queried through
|
||||
* this interface.
|
||||
* @see Navigator the implementation used in the Lumiera UI, as backed by actual GUI components
|
||||
* @see InteractionDirector manages the Navigator and exposes it via lib::Depend<LocationQuery>
|
||||
* @see GenNodeLocationQuery a dummy/test implementation, where the "UI topology" is hard wired
|
||||
* as a tree of GenNode elements. This serves the purpose of unit testing, without having
|
||||
* to rely on an actual UI.
|
||||
|
|
@ -200,6 +202,10 @@ namespace interact {
|
|||
public:
|
||||
virtual ~LocationQuery(); ///< this is an interface
|
||||
|
||||
/** access point to global LocationQuery service implementation */
|
||||
static lib::Depend<LocationQuery> service;
|
||||
|
||||
|
||||
using ChildIter = decltype (TreeStructureNavigator::buildIterator(0));
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -91,8 +91,6 @@ namespace interact {
|
|||
class LocationQuery;
|
||||
using LocationQueryAccess = std::function<LocationQuery&()>;
|
||||
|
||||
/** @internal access UI service to query and discover locations within UI topology */
|
||||
extern LocationQueryAccess loactionQuery; ///////////////////////////////////////////////////////////////TODO this global variable seems to be dispensable
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@
|
|||
#include "gui/ctrl/window-locator.hpp"
|
||||
#include "gui/interact/ui-coord-resolver.hpp"
|
||||
#include "gui/ctrl/global-ctx.hpp"
|
||||
#include "lib/depend.hpp"
|
||||
#include "lib/symbol.hpp"
|
||||
//#include "lib/util.hpp"
|
||||
|
||||
|
|
@ -69,39 +70,14 @@ namespace interact {
|
|||
|
||||
|
||||
|
||||
namespace {
|
||||
const LocationQueryAccess LOCATION_QUERY_SERIVCE_NOT_AVAILABLE
|
||||
= []() -> LocationQuery&
|
||||
{
|
||||
throw error::State (error::LUMIERA_ERROR_LIFECYCLE
|
||||
,"No LocationQuery service available. Is the GUI running?");
|
||||
};
|
||||
}
|
||||
|
||||
/** @internal global access point to some implementation of the LocationQuery API.
|
||||
* Typically, this is provided by the Navigator service in conjunction with the ViewLocator;
|
||||
* both are components managed by the InteractionDirector. Thus, when the UI starts, a suitable
|
||||
* access functor will be installed here, and likewise removed/disabled on shutdown.
|
||||
* ///////////////////////////////////////////////////////////////////////////////////////TICKET #1127 looks like we could get rid of that global state
|
||||
*/
|
||||
LocationQueryAccess locationQuery = LOCATION_QUERY_SERIVCE_NOT_AVAILABLE;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
ViewLocator::ViewLocator (ctrl::GlobalCtx& uiTopLevel, LocationQueryAccess getLocQuery)
|
||||
ViewLocator::ViewLocator (ctrl::GlobalCtx& uiTopLevel)
|
||||
: globals_{uiTopLevel}
|
||||
, locResolver_{new UILocationSolver{getLocQuery}}
|
||||
{
|
||||
locationQuery = getLocQuery;
|
||||
}
|
||||
, locResolver_{new UILocationSolver{LocationQuery::service}}
|
||||
{ }
|
||||
|
||||
// dtors via smart-ptr invoked from here...
|
||||
ViewLocator::~ViewLocator()
|
||||
{
|
||||
locationQuery = LOCATION_QUERY_SERIVCE_NOT_AVAILABLE;
|
||||
}
|
||||
ViewLocator::~ViewLocator() { }
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -93,7 +93,7 @@ namespace interact {
|
|||
unique_ptr<UILocationSolver> locResolver_;
|
||||
|
||||
public:
|
||||
ViewLocator (ctrl::GlobalCtx&, LocationQueryAccess);
|
||||
ViewLocator (ctrl::GlobalCtx&);
|
||||
~ViewLocator();
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue