psychic-ui 0.0.0
Loading...
Searching...
No Matches
psychic_ui::Overlay Class Reference

#include <Overlay.hpp>

Inheritance diagram for psychic_ui::Overlay:
psychic_ui::Div psychic_ui::Observer

Public Member Functions

 Overlay (const Overlay &)=delete
Overlay & operator= (const Overlay &)=delete
 Overlay (Overlay &&)=delete
Overlay & operator= (Overlay &&)=delete
template<class T, typename... Args>
T & open (Args &&... args)
Popup & open (const std::shared_ptr< Popup > &popup)
std::vector< Popup * > popups () const
const std::vector< std::shared_ptr< Popup > > & allPopups () const
template<class T>
T * top () const
template<class T>
void closeAll ()
bool place ()
bool pressOutside (int x, int y, bool contextPress=false)
bool dismissTop ()
bool modal () const
Popup * focusScope () const
Popup * popupAt (int x, int y) const
void update (std::chrono::nanoseconds now)
std::optional< std::chrono::nanoseconds > nextUpdate () const
MouseEventStatus handleMouseMove (const MouseEvent &event, bool handled) override
MouseEventStatus handleMouseButtonChange (const MouseEvent &event) override
MouseEventStatus handleMousePress (const MouseEvent &event) override
MouseEventStatus handleClick (const MouseEvent &event) override
MouseEventStatus handleDoubleClick (const MouseEvent &event) override
MouseEventStatus handleMouseScroll (const MouseEvent &event) override
MouseEventStatus handleContextMenuRequest (const MouseEvent &event) override
Public Member Functions inherited from psychic_ui::Div
 Div (const Div &)=delete
Div & operator= (const Div &)=delete
 Div (Div &&)=delete
Div & operator= (Div &&)=delete
std::string toString () const
virtual Window * window ()
virtual const Window * window () const
Div * parent ()
const Div * parent () const
int depth () const
unsigned int childCount () const
const std::vector< std::shared_ptr< Div > > & children () const
template<class T, class... Args>
requires (std::derived_from<T, Div> && std::constructible_from<T, Args...>)
T & add (Args &&... args)
template<class T>
requires std::derived_from<T, Div>
T & add (unsigned int index, std::shared_ptr< T > child)
template<class T>
requires std::derived_from<T, Div>
T & add (std::shared_ptr< T > child)
void remove (unsigned int index)
void remove (const std::shared_ptr< Div > &child)
void remove (const Div &child)
void removeAll ()
const Div * at (unsigned int index) const
Div * at (unsigned int index)
int childIndex (const std::shared_ptr< Div > &child) const
int childIndex (const Div *child) const
template<class Self>
Self & transition (this Self &self, Property property, const Timing &timing)
template<class Self>
Self & transition (this Self &self, std::initializer_list< Property > properties, const Timing &timing)
template<class Self>
Self & row (this Self &self)
template<class Self>
Self & column (this Self &self)
template<class Self>
Self & size (this Self &self, Length width, Length height)
template<class Self>
Self & style (this Self &self, const Style &style)
const Style & style () const
const Style & computedStyle () const
Style targetStyle () const
bool transitioning () const
bool transitioning (Property property) const
void animate (float from, float to, const Timing &timing, std::function< void(float)> update)
template<class Self>
Self & startingClass (this Self &self, detail::StringArg className)
const std::string & startingClass () const
bool starting () const
void exit (const std::string &className, std::function< void()> done)
bool exiting () const
void cancelExit ()
bool subtreeTransitioning () const
float layoutOffsetX () const
float layoutOffsetY () const
bool layoutSliding () const
bool visible () const
bool enabled () const
template<class Self>
Self & enabled (this Self &self, detail::BoolArg enabled)
virtual bool active () const
bool focusEnabled () const
template<class Self>
Self & focusEnabled (this Self &self, detail::BoolArg focusEnabled)
bool hasFocus () const
virtual bool takesEscape () const
void setFocused (bool focused)
const std::string & tooltip () const
template<class Self>
Self & tooltip (this Self &self, const std::string &text)
const std::vector< std::shared_ptr< MenuItem > > & contextMenu () const
template<class Self>
Self & contextMenu (this Self &self, std::vector< std::shared_ptr< MenuItem > > items)
void localToGlobal (int &gx, int &gy, int x=0, int y=0) const
void globalToLocal (int &lx, int &ly, int x=0, int y=0) const
int x () const
int y () const
int getWidth () const
int getHeight () const
int boundsLeft () const
int boundsTop () const
int boundsRight () const
int boundsBottom () const
int contentWidth () const
int contentHeight () const
int scrollX () const
template<class Self>
Self & scrollX (this Self &self, int scrollX)
int scrollY () const
template<class Self>
Self & scrollY (this Self &self, int scrollY)
void scroll (double scrollX, double scrollY)
bool scrollBy (int deltaX, int deltaY)
void scrollIntoView (const SkRect &rect)
StyleManager * styleManager () const
void setStyleManager (std::shared_ptr< StyleManager > styleManager)
void updateStyle ()
void updateStyleRecursive ()
void updateDirtyStyles ()
bool styleDirty () const
const std::vector< std::string > & tags () const
const std::string & internalId () const
const std::string & id () const
template<class Self>
Self & id (this Self &self, std::string id)
const std::unordered_set< std::string > & classNames () const
template<class Self>
Self & classNames (this Self &self, const std::unordered_set< std::string > &classNames)
template<class Self>
Self & addClassName (this Self &self, std::string className)
template<class Self>
Self & removeClassName (this Self &self, std::string className)
virtual const PropertyMask & inheritedProperties () const
bool mouseChildren () const
template<class Self>
Self & mouseChildren (this Self &self, detail::BoolArg mouseChildren)
bool mouseEnabled () const
template<class Self>
Self & mouseEnabled (this Self &self, detail::BoolArg mouseEnabled)
bool mouseOver () const
void setMouseOver (bool over)
bool getMouseDown () const
void setMouseDown (bool down)
bool contains (float x, float y) const
bool boundsContains (float x, float y) const
virtual bool handleMouseExit (const MouseEvent &event)
virtual MouseEventStatus handleMouseRelease (const MouseEvent &event)
MouseEvent mouseEventAtCenter ()
MouseEvent localMouseEvent (const MouseEvent &event) const
Public Member Functions inherited from psychic_ui::Observer
 Observer (const Observer &)=delete
Observer & operator= (const Observer &)=delete
 Observer (Observer &&)=delete
Observer & operator= (Observer &&)=delete

Protected Member Functions

void close (Popup &popup)
void childAdded (Div &child) override
void childRemoved (Div &child) override
void raise (Popup &popup)
template<class F>
MouseEventStatus dispatch (const MouseEvent &event, const F &handler)
Protected Member Functions inherited from psychic_ui::Div
void updateContextMenu (std::vector< std::shared_ptr< MenuItem > > items)
void setParent (Div *parent)
virtual void added ()
virtual void removed ()
template<class T>
requires std::derived_from<T, Div>
T * trackChild (std::vector< std::shared_ptr< T > > &list, Div &child) const
virtual void addedToRender ()
virtual void removedFromRender ()
std::vector< std::shared_ptr< Div > > childrenTopmostFirst () const
void invalidateEndChildrenStyle ()
void insertChild (unsigned int index, std::shared_ptr< Div > child)
void updateEnabled (bool enabled)
void updateId (std::string id)
void updateClassNames (const std::unordered_set< std::string > &classNames)
void updateClassName (std::string className, bool present)
void scrollTo (int scrollX, int scrollY)
virtual void enabledChanged ()
template<class Self>
Self & tag (this Self &self, std::string tag)
void addTag (std::string tag)
void updateLayoutSlides (const SlideWalk &walk)
void updateSlidingClass ()
void releaseStartingClass ()
void finishExit ()
void updateTransitions (Style &computed)
bool advanceTransitions (std::chrono::nanoseconds now)
void finishTransitions ()
void cancelTransitions ()
void transitionsChanged (const PropertyMask &changed)
void invalidateStyle ()
void updateRuntimeStyles ()
virtual void createStyles ()
virtual void styleUpdated ()
void setMeasurable ()
void updateLayout (const PropertyMask &changed)
virtual void layoutUpdated ()
void invalidate ()
bool isValid () const
virtual Size measure (Constraint width, Constraint height)
virtual void render (SkCanvas *canvas)
void clip (SkCanvas *canvas)
virtual void draw (SkCanvas *canvas)
void drawShadow (SkCanvas *canvas)
void drawDotGrid (SkCanvas *canvas)
void drawOutline (SkCanvas *canvas)
Protected Member Functions inherited from psychic_ui::Observer
template<class... T, class F>
std::shared_ptr< Slot< T... > > subscribeTo (Signal< T... > &signal, F &&callback)

Static Protected Member Functions

static bool surfaceContains (const Popup &popup, int x, int y)
Static Protected Member Functions inherited from psychic_ui::Div
template<class T>
requires std::derived_from<T, Div>
static T * untrackChild (std::vector< std::shared_ptr< T > > &list, const Div &child)

Protected Attributes

std::vector< std::shared_ptr< Popup > > _popups {}
Protected Attributes inherited from psychic_ui::Div
std::string _tooltip {}
std::vector< std::shared_ptr< MenuItem > > _contextMenu {}
ScopedSlot _contextMenuSlot {}
bool _enabled {true}
bool _visible {true}
int _x {0}
int _y {0}
int _width {0}
int _height {0}
int _boundsLeft {0}
int _boundsTop {0}
int _boundsRight {0}
int _boundsBottom {0}
bool _focusEnabled {false}
bool _focused {false}
int _depth {0}
Div * _parent {nullptr}
std::vector< std::shared_ptr< Div > > _children {}
std::vector< std::string > _tags {}
std::string _internalId {}
std::string _id {}
std::unordered_set< std::string > _classNames {}
std::shared_ptr< StyleManager > _styleManager {nullptr}
Style _defaultStyle
Style _inlineStyle
Style _computedStyle {}
bool _layoutInitialized {false}
bool _styleDirty {true}
bool _descendantStyleDirty {false}
Window * _styledIn {nullptr}
std::size_t _styledGeneration {0}
std::shared_ptr< detail::StyleTransitions > _transitions {}
std::vector< std::shared_ptr< Animation > > _animations {}
std::string _startingClass {}
bool _startingApplied {false}
std::unique_ptr< Exit > _exit {}
std::unique_ptr< LayoutSlide > _layoutSlide {}
YGNode * _yogaNode {nullptr}
SkRect _rect {}
SkRect _marginRect {}
float _marginLeft {0.0f}
float _marginRight {0.0f}
float _marginTop {0.0f}
float _marginBottom {0.0f}
SkRect _paddedRect {}
SkRRect _roundRect {}
SkRect _boundsRect {}
float _paintOutset {0.0f}
bool _ignoreInternalLayoutContraints {false}
bool layoutReady {false}
bool _drawBackground {false}
bool _drawBorder {false}
bool _drawComplexBorders {false}
bool _drawRoundRect {false}
bool _drawComplexRoundRect {false}
float _radiusTopLeft {0.0f}
float _radiusTopRight {0.0f}
float _radiusBottomLeft {0.0f}
float _radiusBottomRight {0.0f}
std::array< SkVector, 4 > _radii {}
float _borderLeft {0.0f}
float _borderRight {0.0f}
float _borderTop {0.0f}
float _borderBottom {0.0f}
int _scrollX {0}
int _scrollY {0}
bool _mouseEnabled {true}
bool _mouseChildren {true}
bool _mouseOver {false}
bool _mouseDown {false}
Protected Attributes inherited from psychic_ui::Observer
std::vector< ScopedSlot > slots {}

Friends

class Popup

Additional Inherited Members

Public Attributes inherited from psychic_ui::Div
Signal< int, int > scrolled {}
Signal< int, int > resized {}
bool dashed {false}
Signal< MouseEvent > mouseButtonChanged {}
Signal< MouseEvent > mousePressed {}
Signal< MouseEvent > mouseReleased {}
Signal< MouseEvent > mouseReleasedOutside {}
Signal< MouseEvent > mouseMoved {}
Signal< MouseEvent > mouseEntered {}
Signal< MouseEvent > mouseExited {}
Signal< MouseEvent > mouseScrolled {}
Signal< MouseEvent > clicked {}
Signal< MouseEvent > doubleClicked {}
Signal< MouseEvent > contextMenuRequested {}
Signal< Key, Mod > keyPressed {}
Signal< Key, Mod > keyRepeated {}
Signal< Key, Mod > keyReleased {}
Signal< icu::UnicodeString > typed {}
Signal focused {}
Signal blurred {}
Static Public Attributes inherited from psychic_ui::Div
static bool debugLayout {false}
Static Protected Attributes inherited from psychic_ui::Div
static int idCounter = 0

Detailed Description

Where the window's popups live: a child of the window above its content, filling it, whose children are the popups (Popup), the last on top. It only takes the mouse where a popup is, or everywhere under a modal popup. See Popup.

Member Function Documentation

◆ allPopups()

const std::vector< std::shared_ptr< Popup > > & psychic_ui::Overlay::allPopups ( ) const
inline

Every popup opened in it, bottom first, those leaving too: its children, typed

◆ childAdded()

void psychic_ui::Overlay::childAdded ( Div & child)
overrideprotectedvirtual

A child joined this div, by any path (add, or moved here from another parent): it is in the children, its parent is this one and its added() ran, before its first style. For a div that keeps a typed list of some of its children (the overlay's popups, the toast stack's toasts), so that the children owe it nothing.

Reimplemented from psychic_ui::Div.

◆ childRemoved()

void psychic_ui::Overlay::childRemoved ( Div & child)
overrideprotectedvirtual

A child left this div, by any path (remove, removeAll, added to another parent): it is out of the children and its removed() ran, before the focus it had moves (its parent() still answers this one until the call returns). The counterpart of childAdded.

Reimplemented from psychic_ui::Div.

◆ closeAll()

template<class T>
void psychic_ui::Overlay::closeAll ( )
inline

Close every popup that is a T

◆ dismissTop()

bool psychic_ui::Overlay::dismissTop ( )

Escape was pressed: close the topmost popup Escape dismisses

Returns
Whether one closed

◆ dispatch()

template<class F>
MouseEventStatus psychic_ui::Overlay::dispatch ( const MouseEvent & event,
const F & handler )
protected

Send a mouse event to the popups, topmost first, until one takes it; under a modal popup, to its pass-through divs and no further

◆ focusScope()

Popup * psychic_ui::Overlay::focusScope ( ) const

Where Tab moves the focus: the topmost popup that traps it, or nullptr

◆ handleClick()

MouseEventStatus psychic_ui::Overlay::handleClick ( const MouseEvent & event)
overridevirtual

Reimplemented from psychic_ui::Div.

◆ handleContextMenuRequest()

MouseEventStatus psychic_ui::Overlay::handleContextMenuRequest ( const MouseEvent & event)
overridevirtual

Reimplemented from psychic_ui::Div.

◆ handleDoubleClick()

MouseEventStatus psychic_ui::Overlay::handleDoubleClick ( const MouseEvent & event)
overridevirtual

Reimplemented from psychic_ui::Div.

◆ handleMouseButtonChange()

MouseEventStatus psychic_ui::Overlay::handleMouseButtonChange ( const MouseEvent & event)
overridevirtual

Reimplemented from psychic_ui::Div.

◆ handleMouseMove()

MouseEventStatus psychic_ui::Overlay::handleMouseMove ( const MouseEvent & event,
bool handled )
overridevirtual

Reimplemented from psychic_ui::Div.

◆ handleMousePress()

MouseEventStatus psychic_ui::Overlay::handleMousePress ( const MouseEvent & event)
overridevirtual

Reimplemented from psychic_ui::Div.

◆ handleMouseScroll()

MouseEventStatus psychic_ui::Overlay::handleMouseScroll ( const MouseEvent & event)
overridevirtual

Reimplemented from psychic_ui::Div.

◆ modal()

bool psychic_ui::Overlay::modal ( ) const

Whether a modal popup is open, which takes the mouse from what is under it

◆ nextUpdate()

std::optional< std::chrono::nanoseconds > psychic_ui::Overlay::nextUpdate ( ) const

The soonest of the popups' nextUpdate

◆ open() [1/2]

template<class T, typename... Args>
T & psychic_ui::Overlay::open ( Args &&... args)
inline

Open a popup: construct it, add it on top, then let it take the focus

◆ open() [2/2]

Popup & psychic_ui::Overlay::open ( const std::shared_ptr< Popup > & popup)

Open an existing popup (on top again if it was open; back from where it is if it was leaving)

◆ place()

bool psychic_ui::Overlay::place ( )

Place the anchored popups beside their anchors (closing those whose anchor left the window; those leaving stay where they are), then call laidOut on those laid out for the first time

Returns
Whether one moved, so that the layout must run again

◆ popupAt()

Popup * psychic_ui::Overlay::popupAt ( int x,
int y ) const

The topmost popup whose surface takes the mouse at this point (window coordinates), or nullptr

◆ popups()

std::vector< Popup * > psychic_ui::Overlay::popups ( ) const

The open popups, bottom first (not those leaving)

◆ pressOutside()

bool psychic_ui::Overlay::pressOutside ( int x,
int y,
bool contextPress = false )

A press at this point (window coordinates) is about to be dispatched: close the popups it is outside of that a press outside dismisses, topmost first, until one it is inside of, or a modal one that stays

Parameters
contextPressA right press: closing a popup that passesContextPress doesn't stop it
Returns
Whether it closed a modal popup without landing in another popup: the press goes no further

◆ raise()

void psychic_ui::Overlay::raise ( Popup & popup)
protected

Put an open popup on top without taking it out (it keeps its style and transitions)

◆ surfaceContains()

bool psychic_ui::Overlay::surfaceContains ( const Popup & popup,
int x,
int y )
staticprotected

Whether a point (window coordinates) is on a popup's surface

◆ top()

template<class T>
T * psychic_ui::Overlay::top ( ) const
inline

The topmost open popup that is a T, or nullptr

Member Data Documentation

◆ _popups

std::vector<std::shared_ptr<Popup> > psychic_ui::Overlay::_popups {}
protected

The popups in it, in its children's order, those leaving too: kept by childAdded and childRemoved, whatever adds or removes them


The documentation for this class was generated from the following files: