diff --git a/src/gui/interact/elem-access-dir.hpp b/src/gui/interact/elem-access-dir.hpp index 32b1baa42..5aa5d0cb4 100644 --- a/src/gui/interact/elem-access-dir.hpp +++ b/src/gui/interact/elem-access-dir.hpp @@ -83,7 +83,7 @@ namespace ctrl{ /* == ElementAccess interface == */ RawResult - performAccessTo (UICoord const&, size_t limitCreation) override + performAccessTo (UICoord::Builder & target, size_t limitCreation) override { UNIMPLEMENTED ("implementation of access function based on real UI widgets"); } diff --git a/src/gui/interact/ui-coord.hpp b/src/gui/interact/ui-coord.hpp index 6d3f4fabb..066cb4c0d 100644 --- a/src/gui/interact/ui-coord.hpp +++ b/src/gui/interact/ui-coord.hpp @@ -522,6 +522,14 @@ namespace interact { size_t size() const { return uic_.size(); } bool empty() const { return uic_.empty();} + /** @warning exposes transient state, + * not normalised. */ + UICoord const& + uiCoord() + { + return uic_; + } + /* == Builder functions == */ diff --git a/src/gui/model/element-access.hpp b/src/gui/model/element-access.hpp index 397728796..c0338dd73 100644 --- a/src/gui/model/element-access.hpp +++ b/src/gui/model/element-access.hpp @@ -101,17 +101,14 @@ namespace model { template lib::Result access (UICoord const& destination); - template - lib::Result access_or_create (UICoord const& destination, size_t limitCreation = LUMIERA_MAX_ORDINAL_NUMBER); - - UICoord allocate (UICoord const& destination, size_t limitCreation = LUMIERA_MAX_ORDINAL_NUMBER); + UICoord locate_or_create (UICoord const& destination, size_t limitCreation = LUMIERA_MAX_ORDINAL_NUMBER); protected: using RawResult = lib::Variant>; /** @internal drill down according to coordinates, maybe create element */ - virtual RawResult performAccessTo (UICoord const&, size_t limitCreation) =0; + virtual RawResult performAccessTo (UICoord::Builder &, size_t limitCreation) =0; private: template @@ -141,7 +138,7 @@ namespace model { struct ElementAccess::TypeConverter : RawResult::Visitor { - lib::Result result{"not convertible"}; + lib::Result result{"not convertible to desired target widget"}; template // note the "backward" use. We pick that base interface using canUpcast = std::is_convertible; // into which our desired result type can be upcast, because @@ -152,7 +149,11 @@ namespace model { handle (Base& pb) override { if (pb) - result = *dynamic_cast (pb); + { + TAR* downcasted = dynamic_cast (pb); + if (downcasted) + result = *downcasted; + } else result = lib::Result{"access returns empty answer"}; } @@ -175,25 +176,25 @@ namespace model { inline lib::Result ElementAccess::access (UICoord const& destination) { - return access_or_create (destination, 0); + UICoord::Builder targetLocation{destination.rebuild()}; + TypeConverter converter; + RawResult targetElm = performAccessTo (targetLocation, 0); + targetElm.accept (converter); + return converter.result; } /** Navigate to the designated component, possibly create the element and parents - * @return suitably converted direct (language) reference to the desired element - * wrapped as _result proxy_ + * @return location of the actual element to use, as UI-coordinates. * @note when access was not possible because the element could not been created, - * or is not convertible to the desired target type, the result proxy is empty, - * and convertible to `bool(false)` (or raises an exception on attempted access) + * the indicated location returned is an _empty coordinate spec._ */ - template - inline lib::Result - ElementAccess::access_or_create (UICoord const& destination, size_t limitCreation) + inline UICoord + ElementAccess::locate_or_create (UICoord const& destination, size_t limitCreation) { - TypeConverter converter; - RawResult targetElm = performAccessTo (destination, limitCreation); - targetElm.accept (converter); - return converter.result; + UICoord::Builder targetLocation{destination.rebuild()}; + performAccessTo (targetLocation, limitCreation); + return targetLocation; } diff --git a/tests/gui/interact/view-spec-dsl-test.cpp b/tests/gui/interact/view-spec-dsl-test.cpp index 4cfb20c62..8f8984f36 100644 --- a/tests/gui/interact/view-spec-dsl-test.cpp +++ b/tests/gui/interact/view-spec-dsl-test.cpp @@ -51,25 +51,14 @@ using lib::diff::Rec; //using util::isnil; -namespace gui { +namespace gui { namespace idi { //------Mock ViewSpec definitions for component test - struct MockView1 - : gui::test::DummyWidget - { - using DummyWidget::DummyWidget; - }; - - struct MockView2 - : gui::test::DummyWidget - { - using DummyWidget::DummyWidget; - }; /* ==== Dummy ViewSpec rules for those two mock view types (--> see id-scheme.hpp) ==== */ template<> - struct Descriptor + struct Descriptor { ViewSpec locate = UICoord::currentWindow().panel("parentLocation"); Allocator alloc = limitAllocation(2); @@ -222,12 +211,11 @@ namespace test { //--------------------------------------------------------------Staging: Testcase-1 - using idi::MockView1; fakeAccessor->existingPath = UICoord{"win-1","perspective","parentLocation"}; CHECK (not fakeAccessor->response); // not yet created //--------------------------------------------------------------Staging: Testcase-1 - MockView1& view1 = viewLocator.get(); + DummyView& view1 = viewLocator.get(); cout << "created view:" << view1.getID() << endl; /////////////////////////////////////////////TICKET 1129 : some way to verify the last allocated path. Should be a child of "parentLocation" diff --git a/tests/gui/test/test-element-access.hpp b/tests/gui/test/test-element-access.hpp index d42f57553..8cd2fb2c8 100644 --- a/tests/gui/test/test-element-access.hpp +++ b/tests/gui/test/test-element-access.hpp @@ -125,18 +125,20 @@ namespace test { /* == ElementAccess interface == */ RawResult - performAccessTo (UICoord const& target, size_t limitCreation) override + performAccessTo (UICoord::Builder & target, size_t limitCreation) override { - CHECK (existingPath >= target); - if (existingPath > target and !response) + UICoord const& location = target.uiCoord(); + + CHECK (existingPath >= location); + if (existingPath > location and !response) { - if (target.leafLevel() == UIC_VIEW) - response.reset(new DummyView(target[UIC_VIEW])); + if (location.leafLevel() == UIC_VIEW) + response.reset(new DummyView(location[UIC_VIEW])); else - if (target.leafLevel() == UIC_TAB) - response.reset(new DummyTab(target[UIC_TAB])); + if (location.leafLevel() == UIC_TAB) + response.reset(new DummyTab(location[UIC_TAB])); else - throw error::Invalid("Mock ElementAccess supports only creation of VIEW and TAB. Requested Target was "+string(target)); + throw error::Invalid("Mock ElementAccess supports only creation of VIEW and TAB. Requested Target was "+string(location)); } return response.get(); diff --git a/wiki/thinkPad.ichthyo.mm b/wiki/thinkPad.ichthyo.mm index 7673d3e70..044155bd6 100644 --- a/wiki/thinkPad.ichthyo.mm +++ b/wiki/thinkPad.ichthyo.mm @@ -11451,14 +11451,14 @@ - - - + + + - + - - + + @@ -11479,8 +11479,8 @@ - - + + @@ -11519,7 +11519,7 @@ - + @@ -11536,8 +11536,7 @@ Mithin schiebe ich mir Platzhalter von der linken in die rechte Tasche

- -
+
@@ -11563,8 +11562,7 @@ und an der Implementierung zu kleben

- -
+
@@ -11597,14 +11595,14 @@ dann und nur dann würde die zusätzliche API-Komplexität Sinn machen.

- -
+
- - - - - + + + + + + @@ -11614,9 +11612,34 @@ die verfickte Performance wird ignoriert

+
+
+
+
+ + + + + + + + + + + + + + + + +

+ ....jaaaaa, das ist verschwenderisch +

+
+