Navigator: consider how to approach path resolution
obviously, we get a trivial case, when the path is explicit, and we need a tricky full blown resolution with backtracking when forced to interpolate wildcards to cover a given UICoord spec against the actual UI topology. Do we need it? * actually not right now * but already a complete implementation of the ViewSpec concept requires such a resolution
This commit is contained in:
parent
2d5717bfd7
commit
0dd516a298
4 changed files with 687 additions and 230 deletions
53
src/gui/interact/ui-coord-resolver.cpp
Normal file
53
src/gui/interact/ui-coord-resolver.cpp
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
/*
|
||||
UICoordResolver - resolve UI coordinate spec against actual window topology
|
||||
|
||||
Copyright (C) Lumiera.org
|
||||
2017, Hermann Vosseler <Ichthyostega@web.de>
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation; either version 2 of
|
||||
the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
* *****************************************************/
|
||||
|
||||
|
||||
/** @file ui-coord-resolver.cpp
|
||||
** Implementation details of resolving a UICoord path against the actual UI topology.
|
||||
**
|
||||
** @todo WIP 10/2017 initial draft ////////////////////////////////////////////////////////////TICKET #1107
|
||||
*/
|
||||
|
||||
|
||||
#include "gui/interact/ui-coord-resolver.hpp"
|
||||
//#include "gui/ctrl/global-ctx.hpp"
|
||||
//#include "lib/symbol.hpp"
|
||||
//#include "lib/util.hpp"
|
||||
|
||||
//using util::cStr;
|
||||
//using util::isnil;
|
||||
using lib::Symbol;
|
||||
|
||||
|
||||
namespace gui {
|
||||
namespace interact {
|
||||
|
||||
/** */
|
||||
bool
|
||||
UICoordResolver::pathResolution()
|
||||
{
|
||||
UNIMPLEMENTED ("backtracking reolution of path wildcards");
|
||||
}
|
||||
|
||||
|
||||
|
||||
}}// namespace gui::interact
|
||||
|
|
@ -48,13 +48,15 @@
|
|||
#include "lib/error.hpp"
|
||||
#include "lib/symbol.hpp"
|
||||
#include "gui/interact/ui-coord.hpp"
|
||||
#include "lib/iter-source.hpp"
|
||||
#include "lib/iter-stack.hpp"
|
||||
//#include "lib/util.hpp"
|
||||
|
||||
//#include <boost/noncopyable.hpp>
|
||||
//#include <string>
|
||||
//#include <vector>
|
||||
#include <utility>
|
||||
//#include <memory>
|
||||
#include <memory>
|
||||
|
||||
|
||||
namespace gui {
|
||||
|
|
@ -64,8 +66,8 @@ namespace interact {
|
|||
|
||||
// using std::unique_ptr;
|
||||
// using std::string;
|
||||
// using lib::Literal;
|
||||
using lib::Symbol;
|
||||
using lib::Literal;
|
||||
// using lib::Symbol;
|
||||
// using util::unConst;
|
||||
// using util::isnil;
|
||||
// using util::min;
|
||||
|
|
@ -82,12 +84,36 @@ namespace interact {
|
|||
public:
|
||||
virtual ~LocationQuery() { } ///< this is an interface
|
||||
|
||||
using ChildIter = lib::IterSource<Literal>;
|
||||
|
||||
/** */
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
namespace path { ///< @internal implementation details of UICoord resolution against actual UI
|
||||
|
||||
struct Resolution
|
||||
{
|
||||
const char* anchor = nullptr;
|
||||
size_t depth = 0;
|
||||
std::unique_ptr<UICoord> covfefe;
|
||||
bool isComplete = false;
|
||||
};
|
||||
|
||||
struct ResolutionState
|
||||
{
|
||||
using ChildIter = LocationQuery::ChildIter;
|
||||
|
||||
lib::IterStack<ChildIter> backlog;
|
||||
lib::IterQueue<Resolution> solutions;
|
||||
};
|
||||
|
||||
}//(End) implementation details
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Query and mutate UICoord specifications in relation to actual UI topology.
|
||||
*
|
||||
|
|
@ -96,11 +122,17 @@ namespace interact {
|
|||
class UICoordResolver
|
||||
: public UICoord::Builder
|
||||
{
|
||||
LocationQuery& query_;
|
||||
path::Resolution res_;
|
||||
|
||||
public:
|
||||
UICoordResolver (UICoord const& uic, LocationQuery& queryAPI)
|
||||
: Builder{uic}
|
||||
{ }
|
||||
, query_{queryAPI}
|
||||
, res_{}
|
||||
{
|
||||
attempt_trivialResolution();
|
||||
}
|
||||
|
||||
|
||||
/* === query functions === */
|
||||
|
|
@ -158,6 +190,14 @@ namespace interact {
|
|||
|
||||
|
||||
private:
|
||||
void
|
||||
attempt_trivialResolution()
|
||||
{
|
||||
UNIMPLEMENTED ("if possible, establish a trivial anchorage and coverage right away");
|
||||
}
|
||||
|
||||
/** @internal algorithm to resolve this UICoord path against the actual UI topology */
|
||||
bool pathResolution();
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -114,7 +114,7 @@ namespace test {
|
|||
UICoordResolver resolver{uic, locationQuery};
|
||||
|
||||
CHECK (not resolver.isCovered());
|
||||
CHECK (not resolver.canCover());
|
||||
CHECK ( resolver.canCover());
|
||||
|
||||
UICoord uic2 = resolver.cover()
|
||||
.extend("otherView");
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue