Navigator: initial draft of a UI coordinate resolver
...which in turn will drive the design of the LoactionQuery API
This commit is contained in:
parent
121b13e665
commit
7b2c98474f
4 changed files with 174 additions and 13 deletions
99
src/gui/interact/gen-node-location-query.hpp
Normal file
99
src/gui/interact/gen-node-location-query.hpp
Normal file
|
|
@ -0,0 +1,99 @@
|
|||
/*
|
||||
GEN-NODE-LOCATION-QUERY.hpp - pose UI-coordinate location queries against a GenNode structure
|
||||
|
||||
Copyright (C) Lumiera.org
|
||||
2017, Hermann Vosseler <Ichthyostega@web.de>
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation; either version 2 of
|
||||
the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
/** @file gen-node-location-query.hpp
|
||||
** Implementation of the gui::interact::LocationQuery interface to work on a GenNode tree.
|
||||
** The interface allows to pose queries against a concrete structure to verify and reshape some
|
||||
** [UI Coordinate specification](\ref UICoord); basically it offers methods to navigate within a
|
||||
** tree-like structure. While in the actual implementation, such a query interface would be backed
|
||||
** by navigating real UI structures, the implementation given here instead uses a generic tree structure
|
||||
** given as `Record<GenNode>`.
|
||||
**
|
||||
** @todo WIP 10/2017 started in the effort of shaping the LoactionQuery interface, and used
|
||||
** to support writing unit tests, to verify the UiCoordResolver. It remains to be seen
|
||||
** if this implementation can be used beyond this limited purpose
|
||||
**
|
||||
** @see UICoordResolver_test
|
||||
** @see ui-coord-resolver.hpp
|
||||
** @see navigator.hpp
|
||||
*/
|
||||
|
||||
|
||||
#ifndef GUI_INTERACT_GEN_NODE_LOCATION_QUERY_H
|
||||
#define GUI_INTERACT_GEN_NODE_LOCATION_QUERY_H
|
||||
|
||||
#include "lib/error.hpp"
|
||||
//#include "lib/symbol.hpp"
|
||||
#include "gui/interact/ui-coord-resolver.hpp"
|
||||
#include "lib/diff/gen-node.hpp"
|
||||
//#include "lib/util.hpp"
|
||||
|
||||
//#include <boost/noncopyable.hpp>
|
||||
//#include <string>
|
||||
//#include <vector>
|
||||
//#include <utility>
|
||||
//#include <memory>
|
||||
|
||||
|
||||
namespace gui {
|
||||
namespace interact {
|
||||
|
||||
namespace error = lumiera::error;
|
||||
|
||||
// using std::unique_ptr;
|
||||
// using std::string;
|
||||
// using lib::Literal;
|
||||
// using lib::Symbol;
|
||||
using lib::diff::Rec;
|
||||
// using util::unConst;
|
||||
// using util::isnil;
|
||||
// using util::min;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Query and mutate UICoord specifications in relation to actual UI topology.
|
||||
*
|
||||
* @todo initial draft as of 10/2017
|
||||
*/
|
||||
class GenNodeLocationQuery
|
||||
: public LocationQuery
|
||||
{
|
||||
|
||||
public:
|
||||
GenNodeLocationQuery(Rec const& backingStructure)
|
||||
{ }
|
||||
|
||||
|
||||
/* === LocationQuery interface === */
|
||||
|
||||
/** */
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
|
||||
|
||||
}}// namespace gui::interact
|
||||
#endif /*GUI_INTERACT_GEN_NODE_LOCATION_QUERY_H*/
|
||||
|
|
@ -46,14 +46,14 @@
|
|||
#define GUI_INTERACT_UI_COORD_RESOLVER_H
|
||||
|
||||
#include "lib/error.hpp"
|
||||
//#include "lib/symbol.hpp"
|
||||
#include "lib/symbol.hpp"
|
||||
#include "gui/interact/ui-coord.hpp"
|
||||
//#include "lib/util.hpp"
|
||||
|
||||
//#include <boost/noncopyable.hpp>
|
||||
//#include <string>
|
||||
//#include <vector>
|
||||
//#include <utility>
|
||||
#include <utility>
|
||||
//#include <memory>
|
||||
|
||||
|
||||
|
|
@ -65,7 +65,7 @@ namespace interact {
|
|||
// using std::unique_ptr;
|
||||
// using std::string;
|
||||
// using lib::Literal;
|
||||
// using lib::Symbol;
|
||||
using lib::Symbol;
|
||||
// using util::unConst;
|
||||
// using util::isnil;
|
||||
// using util::min;
|
||||
|
|
@ -73,28 +73,74 @@ namespace interact {
|
|||
|
||||
|
||||
|
||||
/**
|
||||
* Interface to discover a backing structure for the purpose of
|
||||
* path navigation and resolution.
|
||||
*/
|
||||
class LocationQuery
|
||||
{
|
||||
public:
|
||||
virtual ~LocationQuery() { } ///< this is an interface
|
||||
|
||||
/** */
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Query and mutate UICoord specifications in relation to actual UI topology.
|
||||
*
|
||||
* @todo initial draft as of 10/2017
|
||||
*/
|
||||
class UICoordResolver
|
||||
: public UICoord::Builder
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
|
||||
|
||||
/* === named component access === */
|
||||
|
||||
/** */
|
||||
|
||||
UICoordResolver (UICoord const& uic, LocationQuery& queryAPI)
|
||||
: Builder{uic}
|
||||
{ }
|
||||
|
||||
|
||||
/* === query functions === */
|
||||
|
||||
/** */
|
||||
bool
|
||||
isCovered() const
|
||||
{
|
||||
UNIMPLEMENTED ("path coverage check");
|
||||
}
|
||||
|
||||
/** */
|
||||
bool
|
||||
canCover() const
|
||||
{
|
||||
UNIMPLEMENTED ("determine if a mutation is possible to get the path covered");
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* === mutation functions === */
|
||||
|
||||
/**
|
||||
*/
|
||||
UICoordResolver
|
||||
cover()
|
||||
{
|
||||
UNIMPLEMENTED ("mutate the path to get it covered");
|
||||
return std::move (*this);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*/
|
||||
UICoordResolver
|
||||
extend (Literal pathExtension)
|
||||
{
|
||||
UNIMPLEMENTED ("mutate the path to extend it while keeping it partially covered");
|
||||
return std::move (*this);
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
|
|
|
|||
|
|
@ -463,9 +463,10 @@ namespace interact {
|
|||
{
|
||||
UICoord uic_;
|
||||
|
||||
/** builder instances created by UICoord solely */
|
||||
/** builder instances created by UICoord */
|
||||
friend class UICoord;
|
||||
|
||||
protected:
|
||||
template<typename...ARGS>
|
||||
explicit
|
||||
Builder (ARGS&& ...args) : uic_{std::forward<ARGS> (args)...} { }
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@
|
|||
#include "lib/test/test-helper.hpp"
|
||||
#include "gui/interact/ui-coord.hpp"
|
||||
#include "gui/interact/ui-coord-resolver.hpp"
|
||||
#include "gui/interact/gen-node-location-query.hpp"
|
||||
#include "lib/diff/gen-node.hpp"
|
||||
#include "lib/format-cout.hpp"/////////////////////////TODO RLY?
|
||||
#include "lib/format-util.hpp"
|
||||
|
|
@ -96,15 +97,29 @@ namespace test {
|
|||
void
|
||||
verify_simpleUsage()
|
||||
{
|
||||
Rec dummyUiStrcture = MakeRec().scope(
|
||||
// a Test dummy placeholder for the real UI structure
|
||||
Rec dummyUiStructure = MakeRec().scope(
|
||||
MakeRec().type("perspective-A")
|
||||
.genNode("window-1"),
|
||||
MakeRec().type("perspective-B")
|
||||
.scope(
|
||||
MakeRec().genNode("panelX")
|
||||
).genNode("window-2")
|
||||
);
|
||||
);
|
||||
|
||||
// helper to answer "location queries" backed by this structure
|
||||
GenNodeLocationQuery locationQuery{dummyUiStructure};
|
||||
|
||||
UICoord uic{"window-1","*","panelX","someView"};
|
||||
UICoordResolver resolver{uic, locationQuery};
|
||||
|
||||
CHECK (not resolver.isCovered());
|
||||
CHECK (not resolver.canCover());
|
||||
|
||||
UICoord uic2 = resolver.cover()
|
||||
.extend("otherView");
|
||||
|
||||
CHECK ("UI:window-2[perspective-B]-panelX.otherView" == string(uic2));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue