82 #ifndef STAGE_INTERACT_UI_COORD_H 83 #define STAGE_INTERACT_UI_COORD_H 152 template<
typename...ARGS>
186 Builder tab (uint tabIdx)
const;
199 Literal getWindow()
const {
return accesComponent (UIC_WINDOW);}
200 Literal getPersp()
const {
return accesComponent (UIC_PERSP); }
201 Literal getPanel()
const {
return accesComponent (UIC_PANEL); }
202 Literal getView()
const {
return accesComponent (UIC_VIEW); }
203 Literal getTab()
const {
return accesComponent (UIC_TAB); }
218 and isnil (getWindow());
225 and not isnil (getWindow());
237 and not util::contains (*
this, Symbol::ANY);
242 isPresent (
size_t idx)
const 244 Literal* elm = unConst(
this)->getPosition(idx);
245 return not isnil(elm)
246 and *elm != Symbol::ANY;
251 isWildcard (
size_t idx)
const 253 Literal* elm = unConst(
this)->getPosition(idx);
255 and *elm == Symbol::ANY;
273 size_t subSiz = this->size(),
274 parSiz = parent.size(),
277 if (parSiz >= subSiz)
281 and ( (*
this)[idx]== parent[idx]
282 or Symbol::ANY == parent[idx]
283 or isnil (parent[idx])))
286 ENSURE (idx < subSiz);
287 return idx == parSiz;
295 operator string()
const 300 string component = getComp();
301 string path = getPath();
303 if (isnil (component))
304 return "UI:?/" +
path;
307 return "UI:" + component;
309 return "UI:" + component +
"/" +
path;
315 if (empty())
return "";
317 size_t end = min (size(), UIC_PATH);
329 for ( ; pos<end; ++pos )
335 buff +=
"["+getPersp()+
"]";
338 buff +=
"-"+getPanel();
341 buff +=
"."+getView();
344 if (UIC_ELIDED != getTab())
345 buff +=
"."+getTab();
348 NOTREACHED (
"component index numbering broken");
361 buff.reserve (10 * (siz - UIC_PATH));
374 size_t len = buff.length();
384 return size()<= UIC_PATH? end()
385 :
iterator{
this, unConst(
this)->getPosition(UIC_PATH)};
396 REQUIRE (not empty());
401 accesComponent (UIPathElm idx)
const 403 Literal* elm = unConst(
this)->getPosition(idx);
404 return elm? *elm : Symbol::EMPTY;
408 setComponent (
size_t idx,
Literal newContent)
425 std::vector<Literal> elms;
426 if (not isnil (newContent))
428 if (not std::strchr (newContent,
'/'))
432 elms.emplace_back (newContent);
438 string sequence{newContent};
441 while (string::npos != (last = sequence.find (
'/', pos)))
443 elms.emplace_back (
Symbol{sequence.substr(pos, last - pos)});
446 sequence = sequence.substr(pos);
447 if (not isnil (sequence))
448 elms.emplace_back (
Symbol{sequence});
465 size_t cnt = pathElms.size();
467 for (
size_t i=0 ; i < cnt; ++i)
470 for (
size_t i = idx+cnt; i<end; ++i)
480 return static_cast<PathArray const&
> (l) == static_cast<PathArray const&> (r);
489 friend bool operator> (
UICoord const& l,
UICoord const& r) {
return (r < l); }
490 friend bool operator<= (
UICoord const& l,
UICoord const& r) {
return (l < r) or (l == r); }
491 friend bool operator>= (
UICoord const& l,
UICoord const& r) {
return (r < l) or (l == r); }
492 friend bool operator!= (
UICoord const& l,
UICoord const& r) {
return not (l == r); }
509 template<
typename...ARGS>
511 Builder (ARGS&& ...args) : uic_{std::forward<ARGS> (args)...} { }
522 size_t size()
const {
return uic_.size(); }
523 bool empty()
const {
return uic_.empty();}
541 uic_.setComponent (UIC_WINDOW, windowID);
542 return std::move (*
this);
549 uic_.setComponent (UIC_PERSP, perspectiveID);
550 return std::move (*
this);
557 uic_.setComponent (UIC_PANEL, panelID);
558 return std::move (*
this);
565 uic_.setComponent (UIC_VIEW, viewID);
566 return std::move (*
this);
573 uic_.setComponent (UIC_TAB, tabID);
574 return std::move (*
this);
581 uic_.setComponent (UIC_TAB,
Symbol{
"#"+util::toString (tabIdx)});
582 return std::move (*
this);
590 uic_.setComponent (UIC_TAB, UIC_ELIDED);
591 return std::move (*
this);
604 return std::move (*
this);
613 +
" to the complete rooted path "+
string(uic_));
615 uic_.setComponent (uic_.findStartIdx() - 1, elmID);
616 return std::move (*
this);
628 return std::move (*
this);
635 uic_.truncateTo (depth);
636 return std::move (*
this);
648 return std::move (*
this);
652 overwrite (
size_t depth,
Literal newSpec)
656 return std::move (*
this);
668 :
UICoord{std::move (builder.uic_)}
670 PathArray::normalise();
680 return window (UIC_CURRENT_WINDOW);
686 return window (UIC_FIRST_WINDOW);
706 return Builder(*this).persp (perspectiveID);
710 UICoord::panel (
Literal panelID)
const 712 return Builder(*this).panel (panelID);
716 UICoord::view (
Literal viewID)
const 718 return Builder(*this).view (viewID);
722 UICoord::tab (
Literal tabID)
const 724 return Builder(*this).tab (tabID);
728 UICoord::tab (uint tabIdx)
const 730 return Builder(*this).tab (tabIdx);
734 UICoord::noTab ()
const 747 return Builder(*this).path (pathDefinition);
751 UICoord::append (
Literal elmID)
const 753 return Builder(*this).append (elmID);
757 UICoord::prepend (
Literal elmID)
const 759 return Builder(*this).prepend (elmID);
763 UICoord::rebuild ()
const
Literal * expandPosition(size_t idx)
Builder && truncateTo(size_t depth)
possibly shorten this path specification to a limited depth
Describe a location within the UI through structural/topological coordinates.
Builder && path(Literal pathDef)
augment UI coordinates to define a complete local path
Builder persp(Literal perspectiveID) const
void setTailSequence(size_t idx, std::vector< Literal > &pathElms)
replace the existing path information with the given elements
Builder && window(Literal windowID)
change UI coordinate spec to define it to be rooted within the given window
UICoord(ARGS &&...args)
UI-Coordinates can be created explicitly by specifying a sequence of Literal tokens, which will be used to initialise and then normalise the underlying PathArray.
Builder path(Literal pathDefinition) const
convenience builder function so set a full path definition
Builder && persp(Literal perspectiveID)
augment UI coordinates to mandate a specific perspective to be active within the window ...
inline string literal This is a marker type to indicate that
Types marked with this mix-in may be moved but not copied.
Builder && append(Literal elm)
augment UI coordinates by appending a further component at the end.
const Symbol UIC_ELIDED
indicate that a component is elided or irrelevant here
Derived specific exceptions within Lumiera's exception hierarchy.
Builder && tab(Literal tabID)
augment UI coordinates to indicate a specific tab within the view"
Abstraction for path-like topological coordinates.
Token or Atom with distinct identity.
Mix-Ins to allow or prohibit various degrees of copying and cloning.
A single location specification to be matched and fulfilled.
Builder && panel(Literal panelID)
augment UI coordinates to indicate a specific view to be used
Marker types to indicate a literal string and a Symbol.
void normalise()
establish the contract of PathArray
Lumiera GTK UI implementation root.
Tiny helper functions and shortcuts to be used everywhere Consider this header to be effectively incl...
Builder && noTab()
augment UI coordinates to indicate that no tab specification is necessary
const Symbol UIC_CURRENT_WINDOW
window spec to refer to the current window
iterator pathSeq() const
iterative access to the path sequence section
PathArray(IndexSeq< prefix... >, IndexSeq< rest... >, ARGS &&...args)
bool isExtendedBelow(UICoord const &parent) const
Check if this coordinate spec can be seen as an extension of the given parent coordinates and thus re...
Lumiera error handling (C++ interface).
Builder && view(Literal viewID)
augment UI coordinates to indicate a specific view to be used
static Builder window(Literal windowID)
Builder: start definition of UI-Coordinates rooted in given window.
bool isIncomplete() const
void setContent(Literal *pos, const char *val)
Builder && prepend(Literal elmID)
augment partially defined UI coordinates by extending them towards the root
Foundation abstraction to implement path-like component sequences.
const Symbol UIC_FIRST_WINDOW
window spec to refer to the first window of the application
UICoord const & uiCoord()
size_t indexOf(Literal const &content) const
reverse lookup of actual path content
void setTailSequence(size_t idx, Literal newContent)
replace / overwrite existing content starting at given index.
static Builder firstWindow()
Builder: start definition of UI-Coordinates rooted in the firstWindow
Adapter for building an implementation of the »Lumiera Forward Iterator« concept. ...
static Builder currentWindow()
Builder: start definition of UI-Coordinates rooted in the currentWindow
Builder && tab(uint tabIdx)
augment UI coordinates to indicate a tab specified by index number