diff --git a/src/gui/interact/ui-coord-resolver.cpp b/src/gui/interact/ui-coord-resolver.cpp index 88bb4a8d7..ae7981575 100644 --- a/src/gui/interact/ui-coord-resolver.cpp +++ b/src/gui/interact/ui-coord-resolver.cpp @@ -31,8 +31,6 @@ #include "gui/interact/ui-coord-resolver.hpp" #include "lib/util.hpp" -#include - using util::isnil; using lib::Symbol; using lib::treeExplore; diff --git a/src/gui/interact/ui-coord-resolver.hpp b/src/gui/interact/ui-coord-resolver.hpp index a199d8ac5..4617969a0 100644 --- a/src/gui/interact/ui-coord-resolver.hpp +++ b/src/gui/interact/ui-coord-resolver.hpp @@ -159,6 +159,7 @@ namespace interact { * @return the depth to which the given spec is _"covered"_ by the actual UI. * Can be zero, in which case the given coordinates can not be resolved * and addressed within the currently existing windows, panes and views. + * @remark a depth > 0 also implies that the path can be _anchored._ * @note this operation does not perform any _resolution_ or interpolation of wildcards, * it just matches explicit UI component names. * @see UICoordResolver for a facility to perform such a resolution and to navigate paths. @@ -289,12 +290,22 @@ namespace interact { /* === mutation functions === */ /** mutate the path to get it totally covered + * - make the anchorage explicit + * - possibly match and expand any wildcards + * - then truncate the UI-Coordinate spec to that part + * actually covered by the UI + * @note if the coordinate spec can not be covered at all, + * it will be truncated to zero size */ UICoordResolver cover() { if (isCoveredPartially() and not res_.covfefe) - truncateTo (res_.depth); + { + ASSERT (res_.anchor); // depth > 0 implies anchorage + window (res_.anchor); // thus make this anchor explicit + truncateTo (res_.depth); + } else if (canCover()) { ASSERT (res_.isResolved); diff --git a/tests/gui/interact/ui-coord-resolver-test.cpp b/tests/gui/interact/ui-coord-resolver-test.cpp index ade8a4095..aba573824 100644 --- a/tests/gui/interact/ui-coord-resolver-test.cpp +++ b/tests/gui/interact/ui-coord-resolver-test.cpp @@ -67,6 +67,12 @@ namespace test { /******************************************************************************//** * @test verify query and mutation of UICoord in relation to actual UI topology. + * A UI-Coordinate resolver is a special builder, which is initialised by + * the given coordinate spec, and also attached to a "location query API", + * which allows to investigate the current actual UI structure. The builder + * then exposes query and mutation operations, to determine to what extent + * the coordinate spec is "covered" by the real UI, and to match and expand + * any wildcards in the coordinate spec (pattern). * * @see UICoordResolver * @see navigator.hpp @@ -294,7 +300,7 @@ namespace test { - /** @test patch matching algorithm to resolve UI coordinates with wildcards against the current UI structure tree. + /** @test patch matching algorithm to resolve UI coordinates with wildcards against the current UI structure tree. * Since an UI coordinate path with gaps and wildcards could match anywhere, even several times, we need to perform * an exhaustive search with backtracking over the whole tree. By convention, we use the first maximal solution, * which can be just a partial solution, leaving an additional uncovered trailing part of the UI coordinate spec. @@ -385,47 +391,57 @@ namespace test { CHECK (3 ==r12.coverDepth()); CHECK ("UI:window-1[persp-A]-panelX.thirdView" == string(r12)); - auto r12_covered = r12.cover(); - CHECK (r12_covered.isCovered()); - CHECK (r12_covered.isCoveredPartially()); - CHECK (3 ==r12_covered.coverDepth()); - CHECK ("UI:window-1[persp-A]-panelX" == string(r12_covered)); + r12.cover(); + CHECK (r12.isCovered()); + CHECK (r12.isCoveredPartially()); + CHECK (3 ==r12.coverDepth()); + CHECK ("UI:window-1[persp-A]-panelX" == string(r12)); /* === expand anchor === */ UICoordResolver r21 {UICoord::firstWindow().persp("persp-A"), tree}; - cout << r21.cover()< - - - - - + + + + - - - + + @@ -8855,16 +8853,16 @@ - - + + - - - - - + + + + + - + @@ -8882,7 +8880,7 @@ - +