LocationQuery: recast syntax for inline structure definitions
this fixes a silly mistake: obviously we want named sub-nodes, aka. "Attributes", but we used the anonymous sub-nodes instead, aka. "Children" Incidentally, this renders the definitions also way more readable; in fact the strange post-fix naming notation of the original version was a clear indication of using the system backwards....
This commit is contained in:
parent
16abe82cde
commit
c39442a287
4 changed files with 62 additions and 58 deletions
|
|
@ -40,8 +40,8 @@
|
|||
** - 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.
|
||||
** structure as nested inline tree; named nested elements can be added with the `set(key, val)`
|
||||
** builder function, and for each nested scope, we start a new nested builder with `MakeRec()`.
|
||||
** - 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
|
||||
|
|
|
|||
|
|
@ -611,7 +611,7 @@ namespace interact {
|
|||
inline UICoord::Builder
|
||||
UICoord::firstWindow()
|
||||
{
|
||||
return window (UIC_CURRENT_WINDOW);
|
||||
return window (UIC_FIRST_WINDOW);
|
||||
}
|
||||
|
||||
/** @return aBuilder with just the windowID defined */
|
||||
|
|
|
|||
|
|
@ -99,14 +99,17 @@ namespace test {
|
|||
verify_simpleUsage()
|
||||
{
|
||||
// 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")
|
||||
);
|
||||
Rec dummyUiStructure = MakeRec()
|
||||
.set("window-1"
|
||||
, MakeRec()
|
||||
.type("perspective-A")
|
||||
)
|
||||
.set("window-2"
|
||||
, MakeRec()
|
||||
.type("perspective-B")
|
||||
.set("panelX", MakeRec())
|
||||
.set("panelXX", MakeRec())
|
||||
);
|
||||
|
||||
// helper to answer "location queries" backed by this structure
|
||||
GenNodeLocationQuery locationQuery{dummyUiStructure};
|
||||
|
|
@ -138,9 +141,9 @@ namespace test {
|
|||
* since these are named nested elements, and the whole notion of an
|
||||
* UI coordinate path is based on named child components
|
||||
* - we use the _object builder_ helper to define the 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.
|
||||
* as nested inline tree; named nested elements ("attributes") are
|
||||
* added with the `set(key, val)` builder function, and for each
|
||||
* nested scope, we start a new nested builder with `MakeRec()`.
|
||||
* - there is a special convention _for this test setup solely_ 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
|
||||
|
|
@ -150,36 +153,31 @@ namespace test {
|
|||
void
|
||||
verify_backingQuery()
|
||||
{
|
||||
GenNodeLocationQuery queryAPI{MakeRec().scope(
|
||||
MakeRec()
|
||||
.type("perspective-A")
|
||||
.scope(
|
||||
MakeRec()
|
||||
.scope(
|
||||
MakeRec()
|
||||
.genNode("firstView"),
|
||||
MakeRec()
|
||||
.genNode("secondView")
|
||||
).genNode("panelX")
|
||||
).genNode("window-1"),
|
||||
MakeRec()
|
||||
.type("perspective-B")
|
||||
.scope(
|
||||
MakeRec()
|
||||
.genNode("panelY")
|
||||
).genNode("window-2"),
|
||||
MakeRec()
|
||||
.type("perspective-C")
|
||||
.scope(
|
||||
MakeRec()
|
||||
.scope(
|
||||
MakeRec()
|
||||
.genNode("thirdView")
|
||||
).genNode("panelZ"),
|
||||
MakeRec()
|
||||
.genNode("panelZZ")
|
||||
).genNode("window-3")
|
||||
)};
|
||||
GenNodeLocationQuery queryAPI{MakeRec()
|
||||
.set("window-1"
|
||||
, MakeRec()
|
||||
.type("perspective-A")
|
||||
.set("panelX"
|
||||
, MakeRec()
|
||||
.set("firstView", MakeRec())
|
||||
.set("secondView", MakeRec())
|
||||
)
|
||||
)
|
||||
.set("window-2"
|
||||
, MakeRec()
|
||||
.type("perspective-B")
|
||||
.set("panelY", MakeRec())
|
||||
)
|
||||
.set("window-3"
|
||||
, MakeRec()
|
||||
.type("perspective-C")
|
||||
.set("panelZ"
|
||||
, MakeRec()
|
||||
.set("thirdView", MakeRec())
|
||||
)
|
||||
.set("panelZZ", MakeRec())
|
||||
)
|
||||
};
|
||||
|
||||
// the LocationQuery API works by matching a UICoord spec against the "real" structure
|
||||
UICoord uic1 = UICoord::window("window-2").persp("perspective-B");
|
||||
|
|
@ -232,18 +230,20 @@ namespace test {
|
|||
void
|
||||
verify_queryAnchor()
|
||||
{
|
||||
GenNodeLocationQuery loQu{MakeRec().scope(
|
||||
MakeRec().type("perspective-A")
|
||||
.genNode("window-1"),
|
||||
MakeRec().type("perspective-B")
|
||||
.scope(
|
||||
MakeRec()
|
||||
.scope(
|
||||
MakeRec()
|
||||
.genNode("someView")
|
||||
).genNode("panelX")
|
||||
).genNode("window-2")
|
||||
)};
|
||||
GenNodeLocationQuery loQu{MakeRec()
|
||||
.set("window-1"
|
||||
, MakeRec()
|
||||
.type("perspective-A")
|
||||
)
|
||||
.set("window-2"
|
||||
, MakeRec()
|
||||
.type("perspective-B")
|
||||
.set("panelX"
|
||||
, MakeRec()
|
||||
.set("someView", MakeRec())
|
||||
)
|
||||
)
|
||||
};
|
||||
UICoord uic1 = UICoord::window("window-1").persp("perspective-A");
|
||||
UICoord uic2 = UICoord::window("windows");
|
||||
UICoord uic3 = UICoord::firstWindow();
|
||||
|
|
|
|||
|
|
@ -4577,11 +4577,14 @@
|
|||
</node>
|
||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1506984645747" ID="ID_517262443" MODIFIED="1508625810426" TEXT="verify_backingQuery">
|
||||
<icon BUILTIN="pencil"/>
|
||||
<node CREATED="1508809610790" ID="ID_1860790851" MODIFIED="1508809620175" TEXT="Builder-Syntax war falsch"/>
|
||||
<node CREATED="1508809610790" ID="ID_1860790851" MODIFIED="1509142631190" TEXT="Builder-Syntax war falsch">
|
||||
<icon BUILTIN="button_ok"/>
|
||||
<node CREATED="1508809620762" ID="ID_236111511" MODIFIED="1508809630860" TEXT="muß die Attribute-Collection nutzen"/>
|
||||
<node CREATED="1508809631448" ID="ID_956153388" MODIFIED="1508809644482" TEXT="Builder wohl noch nie für diesen Fall verwendet"/>
|
||||
<node CREATED="1508809645470" ID="ID_1846245702" MODIFIED="1508809656617" TEXT="erlaube Move-Initialisierung"/>
|
||||
<node CREATED="1508809657253" ID="ID_108704029" MODIFIED="1508809659905" TEXT="Segfault">
|
||||
</node>
|
||||
<node CREATED="1508809657253" FOLDED="true" ID="ID_108704029" MODIFIED="1509142625887" TEXT="Segfault">
|
||||
<icon BUILTIN="button_ok"/>
|
||||
<node CREATED="1508809662036" ID="ID_1522595538" MODIFIED="1508809674479" TEXT="sehe zwar die drei Window-Elemente"/>
|
||||
<node CREATED="1508809674994" ID="ID_1781272984" MODIFIED="1508809683317" TEXT="aber die ID-Strings sind komisch">
|
||||
<node CREATED="1508809684338" ID="ID_1268163778" MODIFIED="1508809688341" TEXT="erster String ist """/>
|
||||
|
|
@ -4614,6 +4617,7 @@
|
|||
<icon BUILTIN="ksmiletris"/>
|
||||
</node>
|
||||
</node>
|
||||
<node CREATED="1509142651113" ID="ID_99734013" MODIFIED="1509142657805" TEXT="Spezialbehandlung Perspektive"/>
|
||||
</node>
|
||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1506984645748" ID="ID_1254044275" MODIFIED="1506984664457" TEXT="verify_queryAnchor">
|
||||
<icon BUILTIN="flag-yellow"/>
|
||||
|
|
|
|||
Loading…
Reference in a new issue