73 #ifndef STAGE_INTERACT_UI_COORD_H 74 #define STAGE_INTERACT_UI_COORD_H 143 template<
typename...ARGS>
177 Builder tab (uint tabIdx)
const;
190 Literal getWindow()
const {
return accesComponent (UIC_WINDOW);}
191 Literal getPersp()
const {
return accesComponent (UIC_PERSP); }
192 Literal getPanel()
const {
return accesComponent (UIC_PANEL); }
193 Literal getView()
const {
return accesComponent (UIC_VIEW); }
194 Literal getTab()
const {
return accesComponent (UIC_TAB); }
209 and isnil (getWindow());
216 and not isnil (getWindow());
228 and not util::contains (*
this, Symbol::ANY);
233 isPresent (
size_t idx)
const 235 Literal* elm = unConst(
this)->getPosition(idx);
236 return not isnil(elm)
237 and *elm != Symbol::ANY;
242 isWildcard (
size_t idx)
const 244 Literal* elm = unConst(
this)->getPosition(idx);
246 and *elm == Symbol::ANY;
264 size_t subSiz = this->size(),
265 parSiz = parent.size(),
268 if (parSiz >= subSiz)
272 and ( (*
this)[idx]== parent[idx]
273 or Symbol::ANY == parent[idx]
274 or isnil (parent[idx])))
277 ENSURE (idx < subSiz);
278 return idx == parSiz;
286 operator string()
const 291 string component = getComp();
292 string path = getPath();
294 if (isnil (component))
295 return "UI:?/" +
path;
298 return "UI:" + component;
300 return "UI:" + component +
"/" +
path;
306 if (empty())
return "";
308 size_t end = min (size(), UIC_PATH);
320 for ( ; pos<end; ++pos )
326 buff +=
"["+getPersp()+
"]";
329 buff +=
"-"+getPanel();
332 buff +=
"."+getView();
335 if (UIC_ELIDED != getTab())
336 buff +=
"."+getTab();
339 NOTREACHED (
"component index numbering broken");
352 buff.reserve (10 * (siz - UIC_PATH));
365 size_t len = buff.length();
375 return size()<= UIC_PATH? end()
376 :
iterator{
this, unConst(
this)->getPosition(UIC_PATH)};
387 REQUIRE (not empty());
392 accesComponent (UIPathElm idx)
const 394 Literal* elm = unConst(
this)->getPosition(idx);
395 return elm? *elm : Symbol::EMPTY;
399 setComponent (
size_t idx,
Literal newContent)
416 std::vector<Literal> elms;
417 if (not isnil (newContent))
419 if (not std::strchr (newContent,
'/'))
423 elms.emplace_back (newContent);
429 string sequence{newContent};
432 while (string::npos != (last = sequence.find (
'/', pos)))
434 elms.emplace_back (
Symbol{sequence.substr(pos, last - pos)});
437 sequence = sequence.substr(pos);
438 if (not isnil (sequence))
439 elms.emplace_back (
Symbol{sequence});
456 size_t cnt = pathElms.size();
458 for (
size_t i=0 ; i < cnt; ++i)
461 for (
size_t i = idx+cnt; i<end; ++i)
471 return static_cast<PathArray const&
> (l) == static_cast<PathArray const&> (r);
480 friend bool operator> (
UICoord const& l,
UICoord const& r) {
return (r < l); }
481 friend bool operator<= (
UICoord const& l,
UICoord const& r) {
return (l < r) or (l == r); }
482 friend bool operator>= (
UICoord const& l,
UICoord const& r) {
return (r < l) or (l == r); }
483 friend bool operator!= (
UICoord const& l,
UICoord const& r) {
return not (l == r); }
500 template<
typename...ARGS>
502 Builder (ARGS&& ...args) : uic_{std::forward<ARGS> (args)...} { }
513 size_t size()
const {
return uic_.size(); }
514 bool empty()
const {
return uic_.empty();}
532 uic_.setComponent (UIC_WINDOW, windowID);
533 return std::move (*
this);
540 uic_.setComponent (UIC_PERSP, perspectiveID);
541 return std::move (*
this);
548 uic_.setComponent (UIC_PANEL, panelID);
549 return std::move (*
this);
556 uic_.setComponent (UIC_VIEW, viewID);
557 return std::move (*
this);
564 uic_.setComponent (UIC_TAB, tabID);
565 return std::move (*
this);
572 uic_.setComponent (UIC_TAB,
Symbol{
"#"+util::toString (tabIdx)});
573 return std::move (*
this);
581 uic_.setComponent (UIC_TAB, UIC_ELIDED);
582 return std::move (*
this);
595 return std::move (*
this);
604 +
" to the complete rooted path "+
string(uic_));
606 uic_.setComponent (uic_.findStartIdx() - 1, elmID);
607 return std::move (*
this);
619 return std::move (*
this);
626 uic_.truncateTo (depth);
627 return std::move (*
this);
639 return std::move (*
this);
643 overwrite (
size_t depth,
Literal newSpec)
647 return std::move (*
this);
659 :
UICoord{std::move (builder.uic_)}
661 PathArray::normalise();
671 return window (UIC_CURRENT_WINDOW);
677 return window (UIC_FIRST_WINDOW);
697 return Builder(*this).persp (perspectiveID);
701 UICoord::panel (
Literal panelID)
const 703 return Builder(*this).panel (panelID);
707 UICoord::view (
Literal viewID)
const 709 return Builder(*this).view (viewID);
713 UICoord::tab (
Literal tabID)
const 715 return Builder(*this).tab (tabID);
719 UICoord::tab (uint tabIdx)
const 721 return Builder(*this).tab (tabIdx);
725 UICoord::noTab ()
const 738 return Builder(*this).path (pathDefinition);
742 UICoord::append (
Literal elmID)
const 744 return Builder(*this).append (elmID);
748 UICoord::prepend (
Literal elmID)
const 750 return Builder(*this).prepend (elmID);
754 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