LocationSolver: Documentation and clean-up (#1127)
This commit is contained in:
parent
da8fd6a031
commit
0f26f1e0f4
4 changed files with 107 additions and 29 deletions
|
|
@ -29,7 +29,34 @@
|
|||
** actual event handling code. Rather, the ViewLocator, as a service related to the InteractionDirector,
|
||||
** can be invoked to draw on some default configuration plus the actual UI topology present at this time.
|
||||
**
|
||||
** @todo WIP 2/2018 early draft ////////////////////////////////////////////////////////////TICKET #1127
|
||||
** ## Pattern matching against the actual UI-tree
|
||||
**
|
||||
** This Location solver is based on the pattern matching algorithm [embedded](\ref ui-coord-resolver.cpp)
|
||||
** within the UICoordResolver component. This mechanism allows to treat (typically) incomplete coordinate
|
||||
** specifications as rules for locating an element. Several such coordinate _clauses_ can be combined into
|
||||
** a _disjunctive_ LocationRule, which is evaluated by matching the clauses one by one, in given order,
|
||||
** against the currently existing UI tree (topology). Each clause is evaluated individually from scratch
|
||||
** (there is no common variable binding); the first clause to produce a successful match is used as
|
||||
** solution -- with any placeholders replaced by the actually matching UI elements.
|
||||
**
|
||||
** ## Default View location configuration DSL
|
||||
**
|
||||
** Whenever a new UI element of a given kind is to be created, we query a standard location configuration
|
||||
** to determine it's actual location within the interface. This standard configuration is known as
|
||||
** ["ViewSpec DSL"](\ref id-scheme.hpp) and hard-wired into the UI code. Based on the aforementioned
|
||||
** pattern matching rules, it allows to express placement rules dependent on the already existing UI.
|
||||
** There are two kinds of location clauses
|
||||
** - the standard rules describe an element required to exist. Typically this is the _parent element_
|
||||
** of the UI widget in question. But it is also possible to write clauses directly mentioning this
|
||||
** element, in which case such an element must already exist in the UI and will be retrieved as result.
|
||||
** - the more relaxed _create clauses_ describe a new location / path within the UI-tree, meaning that
|
||||
** any (parent) elements not yet present are to be created. A _create clause_ is defined within the
|
||||
** DSL by ending a UI coordinate specification with the term `.create()`. It may still be incomplete
|
||||
** (i.e. contain wildcards), which means, that the first explicitly given element after (below) the
|
||||
** wildcards must exist in the tree, to allow for an unambiguous pattern match. Otherwise, for
|
||||
** creating a new path completely from scratch, all elements have to be given explicitly.
|
||||
** As a minimum requirement, each LocationRule should be concluded with such a "catch-all" explicit
|
||||
** create clause, which describes the standard location of the element in question.
|
||||
**
|
||||
** @see UILocationResolver_test
|
||||
** @see ViewSpecDSL_test
|
||||
|
|
@ -43,9 +70,6 @@
|
|||
|
||||
#include "lib/error.hpp"
|
||||
#include "lib/symbol.hpp"
|
||||
//#include "lib/meta/function.hpp"
|
||||
//#include "lib/meta/tuple-helper.hpp"
|
||||
//#include "lib/meta/function-closure.hpp"
|
||||
#include "lib/format-util.hpp"
|
||||
#include "gui/interact/ui-coord.hpp"
|
||||
#include "gui/interact/ui-coord-resolver.hpp"
|
||||
|
|
@ -68,10 +92,16 @@ namespace interact {
|
|||
using LocationQueryAccess = std::function<LocationQuery&()>;
|
||||
|
||||
/** @internal access UI service to query and discover locations within UI topology */
|
||||
extern LocationQueryAccess loactionQuery;
|
||||
extern LocationQueryAccess loactionQuery; ///////////////////////////////////////////////////////////////TODO this global variable seems to be dispensable
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* A single location specification to be matched and fulfilled.
|
||||
* It is created from a -- typically incomplete -- UICoord spec,
|
||||
* which in turn can be built through a DSL notation.
|
||||
* @todo maybe add a flag to require the current query goal to exist in tree //////////////////////////////TICKET #1130
|
||||
*/
|
||||
struct LocationClause
|
||||
: boost::noncopyable
|
||||
{
|
||||
|
|
@ -92,6 +122,12 @@ namespace interact {
|
|||
};
|
||||
|
||||
|
||||
/**
|
||||
* A rule to determine some location by matching against the UI-tree.
|
||||
* It is comprised of one or several disjunctive [clauses](\ref LocationClause),
|
||||
* each of which is a coordinate pattern to be matched. The clauses are tried
|
||||
* in order and the first successfully matched clause wins.
|
||||
*/
|
||||
class LocationRule
|
||||
: boost::noncopyable
|
||||
{
|
||||
|
|
@ -127,6 +163,7 @@ namespace interact {
|
|||
|
||||
|
||||
|
||||
|
||||
/* ==== Support of UI-Coordinate notation within the ViewSpec-DSL ==== */
|
||||
|
||||
/** interprets the current (inline) contents of an UICoord builder expression
|
||||
|
|
@ -191,14 +228,13 @@ namespace interact {
|
|||
|
||||
|
||||
/**
|
||||
* Access or allocate a UI component view
|
||||
*
|
||||
* @todo initial draft as of 2/2018 -- actual implementation need to be filled in
|
||||
* Service to determine the location of an UI component view.
|
||||
* @see LocationRule
|
||||
* @see UILocationResolver_test::simple_usage_example()
|
||||
*/
|
||||
class UILocationSolver
|
||||
: boost::noncopyable
|
||||
{
|
||||
// ctrl::GlobalCtx& globals_;
|
||||
LocationQueryAccess getLocationQuery;
|
||||
|
||||
public:
|
||||
|
|
|
|||
|
|
@ -22,6 +22,13 @@ return: 0
|
|||
END
|
||||
|
||||
|
||||
PLANNED "solving for UI location" UILocationSolver_test <<END
|
||||
TEST "solving for UI location" UILocationSolver_test <<END
|
||||
out-lit: =~ .. UI:?[edit]-viewer
|
||||
out-lit: OR UI:currentWindow[*]-viewer
|
||||
out-lit: OR UI:?-viewer
|
||||
out-lit: OR UI:?[asset]-*.asset
|
||||
out-lit: OR UI:?-asset.asset create!
|
||||
out-lit: OR UI:currentWindow[.]-viewer create!
|
||||
out-lit: OR UI:meta[config]-infobox.inspect create!
|
||||
return: 0
|
||||
END
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ namespace test {
|
|||
|
||||
|
||||
/******************************************************************************//**
|
||||
* @test cover a mechanism to resolve the desired location of an UI-element.
|
||||
* @test verify a mechanism to resolve the desired location of an UI-element.
|
||||
* The UILocationSolver is operated by the ViewLocator service, which itself
|
||||
* is part of the InteractionDirector. In typical usage, the location rules
|
||||
* are drawn from the [ViewSpec-DSL](\ref view-spec-dsl.hpp), evaluated
|
||||
|
|
@ -84,7 +84,7 @@ namespace test {
|
|||
Rec dummyUiStructure = MakeRec()
|
||||
.set("window-1"
|
||||
, MakeRec()
|
||||
.type("perspective-A")
|
||||
.type("perspective")
|
||||
.set("exclusivePanel", MakeRec())
|
||||
);
|
||||
// helper to answer "location queries" backed by this structure
|
||||
|
|
@ -111,7 +111,7 @@ namespace test {
|
|||
CHECK (not isnil (location));
|
||||
|
||||
// the full solution filled in the missing parts and added the new view on top
|
||||
CHECK ("UI:window-1[perspective-A]-exclusivePanel.worldview" == string(location));
|
||||
CHECK ("UI:window-1[perspective]-exclusivePanel.worldview" == string(location));
|
||||
|
||||
// NOTE: the new view does not (yet) exist, but the preceding part can be "covered"
|
||||
// To verify this, we attach a coordinate resolver (likewise backed by our dummy UI)
|
||||
|
|
@ -217,7 +217,7 @@ namespace test {
|
|||
CHECK ("UI:win[A]" == string{solver.solve (r41, UIC_PERSP, "x")});
|
||||
CHECK ("UI:win[A]-x" == string{solver.solve (r41, UIC_PANEL, "x")});
|
||||
|
||||
/* === query on elided perspective === */
|
||||
/* === query on elided perspective ("just any existing") === */
|
||||
LocationRule r42{UICoord().persp(UIC_ELIDED)};
|
||||
CHECK ("UI:win[A]" == string{solver.solve (r42, UIC_PERSP, "x")});
|
||||
CHECK ("UI:win[A]-x" == string{solver.solve (r42, UIC_PANEL, "x")});
|
||||
|
|
|
|||
|
|
@ -9758,9 +9758,9 @@
|
|||
<icon BUILTIN="forward"/>
|
||||
</node>
|
||||
</node>
|
||||
<node COLOR="#338800" CREATED="1518658487899" FOLDED="true" ID="ID_1831478029" MODIFIED="1518762127977" TEXT="wie können Regeln auf den Anwendungs-Kontext Bezug nehmen?">
|
||||
<node COLOR="#338800" CREATED="1518658487899" FOLDED="true" ID="ID_1831478029" MODIFIED="1518835344832" TEXT="wie können Regeln auf den Anwendungs-Kontext Bezug nehmen?">
|
||||
<linktarget COLOR="#967ea6" DESTINATION="ID_1831478029" ENDARROW="Default" ENDINCLINATION="-800;514;" ID="Arrow_ID_162294902" SOURCE="ID_986224819" STARTARROW="None" STARTINCLINATION="693;-50;"/>
|
||||
<icon BUILTIN="button_ok"/>
|
||||
<icon BUILTIN="button_cancel"/>
|
||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1518658506857" ID="ID_589229909" MODIFIED="1518658523711" TEXT="das Problem "asset Tab"">
|
||||
<icon BUILTIN="messagebox_warning"/>
|
||||
</node>
|
||||
|
|
@ -9790,14 +9790,12 @@
|
|||
<node CREATED="1518762048186" ID="ID_1857576258" MODIFIED="1518762055013" TEXT="möchte ich eigentlich nicht einführen"/>
|
||||
<node CREATED="1518762055881" ID="ID_1976334061" MODIFIED="1518762100381" TEXT="vorerst nicht weiter verfolgt">
|
||||
<icon BUILTIN="yes"/>
|
||||
<node CREATED="1518762071967" ID="ID_1501187790" MODIFIED="1518762110266" TEXT="ggfs partielle Lösung?">
|
||||
<icon BUILTIN="hourglass"/>
|
||||
</node>
|
||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1518746009058" ID="ID_1800549154" MODIFIED="1518746024360" TEXT="#1130 allow view location by similar kind">
|
||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1518746009058" ID="ID_1800549154" MODIFIED="1518830352525" TEXT="#1130 allow view location by similar kind">
|
||||
<arrowlink COLOR="#77546e" DESTINATION="ID_1501187790" ENDARROW="Default" ENDINCLINATION="447;-339;" ID="Arrow_ID_437325251" STARTARROW="None" STARTINCLINATION="486;0;"/>
|
||||
<icon BUILTIN="flag-yellow"/>
|
||||
</node>
|
||||
</node>
|
||||
</node>
|
||||
<node CREATED="1518659028202" ID="ID_1880101392" MODIFIED="1518659037749" TEXT="betrifft eigentlich auch currentWindow()"/>
|
||||
<node CREATED="1518659526767" ID="ID_839916178" MODIFIED="1518742936572" TEXT="⟹ ist Variablen-Bindung und Funktionsauswertung">
|
||||
<arrowlink COLOR="#8e6e9e" DESTINATION="ID_1208480183" ENDARROW="Default" ENDINCLINATION="-458;-16;" ID="Arrow_ID_504124124" STARTARROW="None" STARTINCLINATION="-600;49;"/>
|
||||
|
|
@ -10047,6 +10045,43 @@
|
|||
</node>
|
||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1518746009058" ID="ID_43313184" MODIFIED="1518746024360" TEXT="#1130 allow view location by similar kind">
|
||||
<icon BUILTIN="flag-yellow"/>
|
||||
<node CREATED="1518762071967" FOLDED="true" ID="ID_1501187790" MODIFIED="1518830656615" TEXT="ggfs partielle Lösung?">
|
||||
<linktarget COLOR="#77546e" DESTINATION="ID_1501187790" ENDARROW="Default" ENDINCLINATION="447;-339;" ID="Arrow_ID_437325251" SOURCE="ID_1800549154" STARTARROW="None" STARTINCLINATION="486;0;"/>
|
||||
<icon BUILTIN="hourglass"/>
|
||||
<node CREATED="1518830375356" ID="ID_580870700" MODIFIED="1518830460134">
|
||||
<richcontent TYPE="NODE"><html>
|
||||
<head>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<p>
|
||||
<i>nur eingeschränkt</i> auf die TypID?
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
||||
</richcontent>
|
||||
<icon BUILTIN="help"/>
|
||||
</node>
|
||||
<node CREATED="1518830433876" ID="ID_486080918" MODIFIED="1518830471955" TEXT="Flag, um diese vor Matching injizieren">
|
||||
<icon BUILTIN="idea"/>
|
||||
<node CREATED="1518830500331" ID="ID_314535087" MODIFIED="1518830531395">
|
||||
<richcontent TYPE="NODE"><html>
|
||||
<head>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<p>
|
||||
Preprocessing beim <i>Anlegen</i> der Klausel
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
||||
</richcontent>
|
||||
</node>
|
||||
<node CREATED="1518830545773" ID="ID_533394110" MODIFIED="1518830552887" TEXT="setzt spezielle Syntax in Flag um"/>
|
||||
<node CREATED="1518830581200" ID="ID_1879545754" MODIFIED="1518830625478" TEXT="Flag ⟹ aktuelle typID wird als Term angehängt"/>
|
||||
<node CREATED="1518830626306" ID="ID_1109967783" MODIFIED="1518830635572" TEXT="...und muß somit schon existieren"/>
|
||||
</node>
|
||||
</node>
|
||||
</node>
|
||||
</node>
|
||||
</node>
|
||||
|
|
@ -10173,7 +10208,7 @@
|
|||
<node COLOR="#338800" CREATED="1517506994783" ID="ID_1943710017" MODIFIED="1518487921069" TEXT="baut jeweils UICorrdResolver">
|
||||
<icon BUILTIN="button_ok"/>
|
||||
</node>
|
||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1518658805744" FOLDED="true" ID="ID_1208480183" MODIFIED="1518762230442" TEXT="Kontext-Bindung">
|
||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1518658805744" FOLDED="true" ID="ID_1208480183" MODIFIED="1518830196573" TEXT="Kontext-Bindung">
|
||||
<arrowlink COLOR="#e46465" DESTINATION="ID_68856104" ENDARROW="Default" ENDINCLINATION="74;449;" ID="Arrow_ID_110301671" STARTARROW="None" STARTINCLINATION="-232;7;"/>
|
||||
<linktarget COLOR="#8e6e9e" DESTINATION="ID_1208480183" ENDARROW="Default" ENDINCLINATION="-458;-16;" ID="Arrow_ID_504124124" SOURCE="ID_839916178" STARTARROW="None" STARTINCLINATION="-600;49;"/>
|
||||
<linktarget COLOR="#b78791" DESTINATION="ID_1208480183" ENDARROW="Default" ENDINCLINATION="-1240;134;" ID="Arrow_ID_831550289" SOURCE="ID_481219776" STARTARROW="None" STARTINCLINATION="1654;0;"/>
|
||||
|
|
@ -10426,9 +10461,9 @@
|
|||
<icon BUILTIN="button_ok"/>
|
||||
</node>
|
||||
</node>
|
||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1517505737977" ID="ID_1981924615" MODIFIED="1518487921070" TEXT="Unit-Test">
|
||||
<node COLOR="#338800" CREATED="1517505737977" ID="ID_1981924615" MODIFIED="1518835363372" TEXT="Unit-Test">
|
||||
<arrowlink COLOR="#465888" DESTINATION="ID_957265584" ENDARROW="Default" ENDINCLINATION="351;-62;" ID="Arrow_ID_1922023705" STARTARROW="None" STARTINCLINATION="-226;69;"/>
|
||||
<icon BUILTIN="flag-yellow"/>
|
||||
<icon BUILTIN="button_ok"/>
|
||||
<node COLOR="#338800" CREATED="1518312788963" ID="ID_1715641481" MODIFIED="1518487921070" TEXT="brauche Setup">
|
||||
<icon BUILTIN="button_ok"/>
|
||||
</node>
|
||||
|
|
@ -10510,15 +10545,15 @@
|
|||
</node>
|
||||
</node>
|
||||
</node>
|
||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1518312758758" ID="ID_675085959" MODIFIED="1518487921070" TEXT="Schreibweise für create-Klauseln">
|
||||
<icon BUILTIN="flag-yellow"/>
|
||||
<node COLOR="#338800" CREATED="1518312758758" ID="ID_675085959" MODIFIED="1518835387835" TEXT="Schreibweise für create-Klauseln">
|
||||
<icon BUILTIN="button_ok"/>
|
||||
</node>
|
||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1515631675752" ID="ID_1586757410" MODIFIED="1518487921070" TEXT="Repräsentation als Liste von UICoord">
|
||||
<icon BUILTIN="flag-yellow"/>
|
||||
<node COLOR="#338800" CREATED="1515631675752" ID="ID_1586757410" MODIFIED="1518835393496" TEXT="Repräsentation als Liste von UICoord">
|
||||
<icon BUILTIN="button_ok"/>
|
||||
</node>
|
||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1515631690390" ID="ID_783849930" MODIFIED="1518487921070" TEXT=""committed choice" Lösungsmechanismus">
|
||||
<node COLOR="#338800" CREATED="1515631690390" ID="ID_783849930" MODIFIED="1518835396708" TEXT=""committed choice" Lösungsmechanismus">
|
||||
<arrowlink COLOR="#8b9e9d" DESTINATION="ID_606655578" ENDARROW="Default" ENDINCLINATION="-152;43;" ID="Arrow_ID_1433975114" STARTARROW="None" STARTINCLINATION="213;-13;"/>
|
||||
<icon BUILTIN="flag-yellow"/>
|
||||
<icon BUILTIN="button_ok"/>
|
||||
</node>
|
||||
</node>
|
||||
</node>
|
||||
|
|
|
|||
Loading…
Reference in a new issue