Navigator: continue draft of UI coordinate resolver

This commit is contained in:
Fischlurch 2017-10-18 03:40:26 +02:00
parent 7b2c98474f
commit 2d5717bfd7
4 changed files with 84 additions and 4 deletions

View file

@ -105,6 +105,20 @@ namespace interact {
/* === query functions === */
/** */
bool
isAnchored() const
{
UNIMPLEMENTED ("path anchorage check");
}
/** */
bool
canAnchor() const
{
UNIMPLEMENTED ("determine if a mutation is possible to anchor the path explicitly");
}
/** */
bool
isCovered() const

View file

@ -92,6 +92,7 @@ namespace interact {
extern Symbol UIC_CURRENT_WINDOW; ///< window spec to refer to the _current window_ @see view-locator.cpp
extern Symbol UIC_FIRST_WINDOW; ///< window spec to refer to the _first window_ of the application
extern Symbol UIC_ELIDED; ///< indicate that a component is elided or irrelevant here
@ -136,6 +137,9 @@ namespace interact {
/** shortcut to allow init from builder expression */
UICoord (Builder&& builder);
/** Builder: start definition of UI-Coordinates rooted in the `firstWindow` */
static Builder firstWindow();
/** Builder: start definition of UI-Coordinates rooted in the `currentWindow` */
static Builder currentWindow();
@ -144,6 +148,7 @@ namespace interact {
//----- convenience shortcuts to start a copy-builder....
Builder persp (Literal perspectiveID) const;
Builder panel (Literal panelID)const;
Builder view (Literal viewID) const;
Builder tab (Literal tabID) const;
Builder tab (uint tabIdx) const;
@ -501,6 +506,14 @@ namespace interact {
return std::move (*this);
}
/** augment UI coordinates to indicate a specific view to be used */
Builder
panel (Literal panelID)
{
uic_.setComponent (UIC_PANEL, panelID);
return std::move (*this);
}
/** augment UI coordinates to indicate a specific view to be used */
Builder
view (Literal viewID)
@ -586,9 +599,8 @@ namespace interact {
}
/** @return an empty Builder allowing to define further parts;
* to finish the definition, cast / store it into
* UICoord, which itself is immutable.
/** @return a minimally defined Builder, allowing to define further parts;
* to finish the definition, cast / store it into UICoord, which itself is immutable.
*/
inline UICoord::Builder
UICoord::currentWindow()
@ -596,6 +608,12 @@ namespace interact {
return window (UIC_CURRENT_WINDOW);
}
inline UICoord::Builder
UICoord::firstWindow()
{
return window (UIC_CURRENT_WINDOW);
}
/** @return aBuilder with just the windowID defined */
inline UICoord::Builder
UICoord::window (Literal windowID)
@ -616,6 +634,12 @@ namespace interact {
return Builder(*this).persp (perspectiveID);
}
inline UICoord::Builder
UICoord::panel (Literal panelID) const
{
return Builder(*this).panel (panelID);
}
inline UICoord::Builder
UICoord::view (Literal viewID) const
{

View file

@ -44,6 +44,7 @@ namespace interact {
/* ==== definitions and concrete bindings for the View-Spec-DSL ==== */
Symbol UIC_CURRENT_WINDOW{"currentWindow"};
Symbol UIC_FIRST_WINDOW {"firstWindow"};
Symbol UIC_ELIDED {"."};

View file

@ -130,10 +130,51 @@ namespace test {
}
/** @test query anchorage of given UI coordinates.
* - an anchored UI coordinate spec explicitly rooted within a top level window.
*/
void
verify_queryAnchor()
{
UNIMPLEMENTED ("query anchorage of given UI coordinates");
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")
)};
UICoord uic1 = UICoord::window("window-1").persp("perspective-A");
UICoord uic2 = UICoord::window("windows");
UICoord uic3 = UICoord::firstWindow();
UICoord uic4 = UICoord::currentWindow().persp("perspective-B");
UICoord uic5 = UICoord::currentWindow().panel("panelY");
UICoord uic6 = UICoord().view("someView").path("α/β/γ");
UICoordResolver r1{uic1, loQu};
UICoordResolver r2{uic2, loQu};
UICoordResolver r3{uic3, loQu};
UICoordResolver r4{uic4, loQu};
UICoordResolver r5{uic5, loQu};
UICoordResolver r6{uic6, loQu};
CHECK ( r1.isAnchored());
CHECK (not r2.isAnchored());
CHECK ( r3.isAnchored());
CHECK ( r4.isAnchored());
CHECK (not r5.isAnchored());
CHECK (not r6.isAnchored());
CHECK ( r1.canAnchor());
CHECK (not r2.canAnchor());
CHECK ( r3.canAnchor());
CHECK ( r4.canAnchor());
CHECK (not r5.canAnchor());
CHECK ( r6.canAnchor());
}