LocationQuery: implement simple resolution of explicit anchoring by window-ID

This commit is contained in:
Fischlurch 2017-10-23 02:16:57 +02:00
parent 2c96fcd164
commit 240459c550
2 changed files with 42 additions and 5 deletions

View file

@ -29,6 +29,24 @@
** by navigating real UI structures, the implementation given here instead uses a generic tree structure
** given as `Record<GenNode>`.
**
** # Representing UI structure as GenNode tree
**
** While basically the interface LocationQuery abstracts and reduces the structure of an UI into
** just some hierarchically arranged and nested IDs, we should note some specific twists how a GenNode
** tree is used here to represent the structure elements as defined through [UI coordinates](\ref UICoord):
** - we use the special _type_ attribute to represent the _perspective_ within each window;
** deliberately, we'll use this twisted structure here to highlight the fact that the
** backing structure need not be homogeneous; rather, it may require explicit branching
** - we use the _attributes_ within the GenNode "object" representation, since these are _named_
** nested elements, and the whole notion of an UI coordinate path is based on named child components
** - relying upon the [object builder notation](\ref Record::Mutator), it is possible to define a whole
** structure as nested inline tree; this leads to a somewhat confusing notation, where the names of
** the child nodes are spelled of at the closing bracket of each construct.
** - since GenNodeLocationQuery is conceived for writing test and verification code, there is a
** special convention to set the `currentWindow` to be the last one in list -- in a real UI
** this would not of course not be a configurable property of the LocationQuery, and rather
** just reflect the transient window state and return the currently activated window
**
** @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
@ -46,7 +64,8 @@
//#include "lib/symbol.hpp"
#include "gui/interact/ui-coord-resolver.hpp"
#include "lib/diff/gen-node.hpp"
//#include "lib/util.hpp"
#include "lib/itertools.hpp"
#include "lib/util.hpp"
//#include <boost/noncopyable.hpp>
//#include <string>
@ -81,10 +100,12 @@ namespace interact {
class GenNodeLocationQuery
: public LocationQuery
{
Rec const& tree_;
public:
GenNodeLocationQuery(Rec const& backingStructure)
{ }
: tree_(backingStructure)
{ }
/* === LocationQuery interface === */
@ -93,7 +114,13 @@ namespace interact {
virtual Literal
determineAnchor (UICoord const& path)
{
UNIMPLEMENTED ("resolve Anchor against GenNode tree");
if (isnil(tree_) or not path.isPresent(UIC_WINDOW))
return Symbol::BOTTOM;
if (UIC_FIRST_WINDOW == path.getWindow())
return getFirstWindow();
if (UIC_CURRENT_WINDOW == path.getWindow())
return getCurrentWindow();
return path.getWindow();
}
@ -114,6 +141,16 @@ namespace interact {
}
private:
Literal
getFirstWindow()
{
return Symbol{*tree_.keys()}; //////////////////////////////////////////////TICKET #1113 : warning use of Symbol table becomes obsolete when EntryID relies on Literal
}
Literal
getCurrentWindow()
{
return Symbol{lib::pull_last (tree_.keys())}; //////////////////////////////////////////////TICKET #1113 : warning use of Symbol table becomes obsolete when EntryID relies on Literal
}
};

View file

@ -4486,8 +4486,8 @@
</node>
<node CREATED="1508539089208" ID="ID_1071949477" MODIFIED="1508539131769" TEXT="Query">
<icon BUILTIN="info"/>
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1508619321957" ID="ID_1269390045" MODIFIED="1508619327957" TEXT="anchor">
<icon BUILTIN="flag-yellow"/>
<node COLOR="#338800" CREATED="1508619321957" ID="ID_1269390045" MODIFIED="1508717810127" TEXT="anchor">
<icon BUILTIN="button_ok"/>
<node CREATED="1508619329420" ID="ID_360997488" MODIFIED="1508619334447" TEXT="in: expliziter Pfad"/>
<node CREATED="1508619335131" ID="ID_327874233" MODIFIED="1508619413280" TEXT="out: Anker-Literal">
<richcontent TYPE="NOTE"><html>