From c39442a287c50510d0cf970a6d4467060b889e76 Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Sat, 28 Oct 2017 00:06:44 +0200 Subject: [PATCH] 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.... --- src/gui/interact/gen-node-location-query.hpp | 4 +- src/gui/interact/ui-coord.hpp | 2 +- tests/gui/interact/ui-coord-resolver-test.cpp | 106 +++++++++--------- wiki/thinkPad.ichthyo.mm | 8 +- 4 files changed, 62 insertions(+), 58 deletions(-) diff --git a/src/gui/interact/gen-node-location-query.hpp b/src/gui/interact/gen-node-location-query.hpp index 5d3cbd6b4..1ad2fb78a 100644 --- a/src/gui/interact/gen-node-location-query.hpp +++ b/src/gui/interact/gen-node-location-query.hpp @@ -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 diff --git a/src/gui/interact/ui-coord.hpp b/src/gui/interact/ui-coord.hpp index 8f2816d76..75145fae7 100644 --- a/src/gui/interact/ui-coord.hpp +++ b/src/gui/interact/ui-coord.hpp @@ -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 */ diff --git a/tests/gui/interact/ui-coord-resolver-test.cpp b/tests/gui/interact/ui-coord-resolver-test.cpp index 327d8a5e0..45e84c4be 100644 --- a/tests/gui/interact/ui-coord-resolver-test.cpp +++ b/tests/gui/interact/ui-coord-resolver-test.cpp @@ -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(); diff --git a/wiki/thinkPad.ichthyo.mm b/wiki/thinkPad.ichthyo.mm index 3f6ec7113..469a5ef6a 100644 --- a/wiki/thinkPad.ichthyo.mm +++ b/wiki/thinkPad.ichthyo.mm @@ -4577,11 +4577,14 @@ - + + - + + + @@ -4614,6 +4617,7 @@ +