2017-10-02 18:11:21 +02:00
|
|
|
/*
|
|
|
|
|
UI-COORD-RESOLVER.hpp - 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.hpp
|
|
|
|
|
** Evaluation of UI coordinates against a concrete window topology.
|
|
|
|
|
** [UI-Coordinates](\ref UICoord) allow to describe and locate an interface component within the
|
|
|
|
|
** Lumiera GUI through a topological access path. As such these coordinate specifications are abstract,
|
|
|
|
|
** and need to be related, attached or resolved against the actual configuration of widgets in the UI.
|
|
|
|
|
** Through this relation it becomes possible to pose meaningful queries over these coordinates, or to
|
|
|
|
|
** build, rebuild and remould a coordinate specification.
|
|
|
|
|
**
|
|
|
|
|
** We need to avoid tainting with the intrinsics of the actual UI toolkit though -- which indicates
|
|
|
|
|
** the UICoordResolver should be designed as an abstract intermediary, built on top of a command and
|
|
|
|
|
** query interface, provided by the \ref Navigator and backed by the actual UI configuration.
|
|
|
|
|
**
|
|
|
|
|
** @todo WIP 10/2017 first draft ////////////////////////////////////////////////////////////////////////////TICKET #1106 generic UI coordinate system
|
|
|
|
|
**
|
|
|
|
|
** @see UICoordResolver_test
|
|
|
|
|
** @see UICoord_test
|
|
|
|
|
** @see navigator.hpp
|
|
|
|
|
** @see view-locator.hpp
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef GUI_INTERACT_UI_COORD_RESOLVER_H
|
|
|
|
|
#define GUI_INTERACT_UI_COORD_RESOLVER_H
|
|
|
|
|
|
|
|
|
|
#include "lib/error.hpp"
|
2017-10-16 02:39:22 +02:00
|
|
|
#include "lib/symbol.hpp"
|
2017-10-02 18:11:21 +02:00
|
|
|
#include "gui/interact/ui-coord.hpp"
|
2017-10-21 01:53:13 +02:00
|
|
|
#include "lib/iter-source.hpp"
|
|
|
|
|
#include "lib/iter-stack.hpp"
|
2017-10-02 18:11:21 +02:00
|
|
|
//#include "lib/util.hpp"
|
|
|
|
|
|
|
|
|
|
//#include <boost/noncopyable.hpp>
|
|
|
|
|
//#include <string>
|
|
|
|
|
//#include <vector>
|
2017-10-16 02:39:22 +02:00
|
|
|
#include <utility>
|
2017-10-21 01:53:13 +02:00
|
|
|
#include <memory>
|
2017-10-02 18:11:21 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace gui {
|
|
|
|
|
namespace interact {
|
|
|
|
|
|
|
|
|
|
namespace error = lumiera::error;
|
|
|
|
|
|
|
|
|
|
// using std::unique_ptr;
|
|
|
|
|
// using std::string;
|
2017-10-21 01:53:13 +02:00
|
|
|
using lib::Literal;
|
|
|
|
|
// using lib::Symbol;
|
2017-10-02 18:11:21 +02:00
|
|
|
// using util::unConst;
|
|
|
|
|
// using util::isnil;
|
|
|
|
|
// using util::min;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-10-16 02:39:22 +02:00
|
|
|
/**
|
|
|
|
|
* Interface to discover a backing structure for the purpose of
|
|
|
|
|
* path navigation and resolution.
|
|
|
|
|
*/
|
|
|
|
|
class LocationQuery
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
virtual ~LocationQuery() { } ///< this is an interface
|
|
|
|
|
|
2017-10-21 01:53:13 +02:00
|
|
|
using ChildIter = lib::IterSource<Literal>;
|
|
|
|
|
|
2017-10-16 02:39:22 +02:00
|
|
|
/** */
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-10-21 01:53:13 +02:00
|
|
|
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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-10-02 18:11:21 +02:00
|
|
|
/**
|
|
|
|
|
* Query and mutate UICoord specifications in relation to actual UI topology.
|
|
|
|
|
*
|
|
|
|
|
* @todo initial draft as of 10/2017
|
|
|
|
|
*/
|
|
|
|
|
class UICoordResolver
|
2017-10-16 02:39:22 +02:00
|
|
|
: public UICoord::Builder
|
2017-10-02 18:11:21 +02:00
|
|
|
{
|
2017-10-21 01:53:13 +02:00
|
|
|
LocationQuery& query_;
|
|
|
|
|
path::Resolution res_;
|
2017-10-02 18:11:21 +02:00
|
|
|
|
|
|
|
|
public:
|
2017-10-16 02:39:22 +02:00
|
|
|
UICoordResolver (UICoord const& uic, LocationQuery& queryAPI)
|
|
|
|
|
: Builder{uic}
|
2017-10-21 01:53:13 +02:00
|
|
|
, query_{queryAPI}
|
|
|
|
|
, res_{}
|
|
|
|
|
{
|
|
|
|
|
attempt_trivialResolution();
|
|
|
|
|
}
|
2017-10-02 18:11:21 +02:00
|
|
|
|
|
|
|
|
|
2017-10-16 02:39:22 +02:00
|
|
|
/* === query functions === */
|
2017-10-02 18:11:21 +02:00
|
|
|
|
2017-10-18 03:40:26 +02:00
|
|
|
/** */
|
|
|
|
|
bool
|
|
|
|
|
isAnchored() const
|
|
|
|
|
{
|
|
|
|
|
UNIMPLEMENTED ("path anchorage check");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** */
|
|
|
|
|
bool
|
|
|
|
|
canAnchor() const
|
|
|
|
|
{
|
|
|
|
|
UNIMPLEMENTED ("determine if a mutation is possible to anchor the path explicitly");
|
|
|
|
|
}
|
|
|
|
|
|
2017-10-16 02:39:22 +02:00
|
|
|
/** */
|
|
|
|
|
bool
|
|
|
|
|
isCovered() const
|
|
|
|
|
{
|
|
|
|
|
UNIMPLEMENTED ("path coverage check");
|
|
|
|
|
}
|
2017-10-02 18:11:21 +02:00
|
|
|
|
|
|
|
|
/** */
|
2017-10-16 02:39:22 +02:00
|
|
|
bool
|
|
|
|
|
canCover() const
|
|
|
|
|
{
|
|
|
|
|
UNIMPLEMENTED ("determine if a mutation is possible to get the path covered");
|
|
|
|
|
}
|
2017-10-02 18:11:21 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-10-16 02:39:22 +02:00
|
|
|
/* === mutation functions === */
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*/
|
|
|
|
|
UICoordResolver
|
|
|
|
|
cover()
|
|
|
|
|
{
|
|
|
|
|
UNIMPLEMENTED ("mutate the path to get it covered");
|
|
|
|
|
return std::move (*this);
|
|
|
|
|
}
|
|
|
|
|
|
2017-10-02 18:11:21 +02:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*/
|
2017-10-16 02:39:22 +02:00
|
|
|
UICoordResolver
|
|
|
|
|
extend (Literal pathExtension)
|
|
|
|
|
{
|
|
|
|
|
UNIMPLEMENTED ("mutate the path to extend it while keeping it partially covered");
|
|
|
|
|
return std::move (*this);
|
|
|
|
|
}
|
2017-10-02 18:11:21 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
private:
|
2017-10-21 01:53:13 +02:00
|
|
|
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();
|
2017-10-02 18:11:21 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}}// namespace gui::interact
|
|
|
|
|
#endif /*GUI_INTERACT_UI_COORD_RESOLVER_H*/
|