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

#include <Popup.hpp>

Inheritance diagram for psychic_ui::Popup:
psychic_ui::Div psychic_ui::Observer psychic_ui::Dialog psychic_ui::Menu psychic_ui::ToastStack psychic_ui::Tooltip

Public Member Functions

template<class Self>
Self & anchor (this Self &self, Div &anchor)
template<class Self>
Self & anchor (this Self &self, int x, int y)
Div * anchorDiv () const
bool anchored () const
Side side () const
template<class Self>
Self & side (this Self &self, Side side)
PopupAlign alignment () const
template<class Self>
Self & alignment (this Self &self, PopupAlign align)
template<class Self>
Self & sideOffset (this Self &self, detail::FloatArg offset)
template<class Self>
Self & alignOffset (this Self &self, detail::FloatArg offset)
template<class Self>
Self & collisionPadding (this Self &self, detail::FloatArg padding)
Side placedSide () const
const SkRect & anchorRect () const
bool modal () const
template<class Self>
Self & modal (this Self &self, detail::BoolArg modal)
bool dismissOnOutsidePress () const
template<class Self>
Self & dismissOnOutsidePress (this Self &self, detail::BoolArg dismiss)
bool passesContextPress () const
template<class Self>
Self & passesContextPress (this Self &self, detail::BoolArg passes)
bool dismissOnEscape () const
template<class Self>
Self & dismissOnEscape (this Self &self, detail::BoolArg dismiss)
bool trapFocus () const
template<class Self>
Self & trapFocus (this Self &self, detail::BoolArg trap)
bool restoreFocus () const
template<class Self>
Self & restoreFocus (this Self &self, detail::BoolArg restore)
template<class Self>
Self & passThrough (this Self &self, Div &div)
Popup * owner () const
template<class Self>
Self & owner (this Self &self, Popup &owner)
Div & surface ()
const Div & surface () const
bool isOpen () const
void close ()
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 MouseEventStatus handleMouseMove (const MouseEvent &event, bool handled)
virtual bool handleMouseExit (const MouseEvent &event)
virtual MouseEventStatus handleMouseButtonChange (const MouseEvent &event)
virtual MouseEventStatus handleMousePress (const MouseEvent &event)
virtual MouseEventStatus handleMouseRelease (const MouseEvent &event)
virtual MouseEventStatus handleClick (const MouseEvent &event)
virtual MouseEventStatus handleDoubleClick (const MouseEvent &event)
virtual MouseEventStatus handleMouseScroll (const MouseEvent &event)
virtual MouseEventStatus handleContextMenuRequest (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

Public Attributes

Signal closed {}
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 {}

Protected Member Functions

void updateAnchor (Div *anchor, int x, int y)
void placed (Side side)
virtual void opened ()
virtual void laidOut ()
virtual void update (std::chrono::nanoseconds)
virtual std::optional< std::chrono::nanoseconds > nextUpdate () const
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 ()
virtual void childAdded (Div &child)
virtual void childRemoved (Div &child)
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)

Protected Attributes

std::weak_ptr< Div > _anchor {}
bool _anchored {false}
bool _anchorIsDiv {false}
int _anchorX {0}
int _anchorY {0}
Side _side {Side::Bottom}
PopupAlign _align {PopupAlign::Start}
float _sideOffset {0}
float _alignOffset {0}
float _collisionPadding {12}
Side _placedSide {Side::Bottom}
SkRect _anchorRect {}
bool _modal {false}
bool _dismissOnOutsidePress {true}
bool _dismissOnEscape {true}
bool _passesContextPress {false}
bool _trapFocus {false}
bool _restoreFocus {true}
std::vector< std::weak_ptr< Div > > _passThrough {}
Overlay * _overlay {nullptr}
Popup * _owner {nullptr}
Div * _surface {nullptr}
std::weak_ptr< Div > _focusBefore {}
bool _laidOut {false}
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 Overlay

Additional Inherited Members

Static Public Attributes inherited from psychic_ui::Div
static bool debugLayout {false}
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)
Static Protected Attributes inherited from psychic_ui::Div
static int idCounter = 0

Detailed Description

A layer of the window's overlay (Window::overlay()), drawn above the content: a menu, a select's list, a tooltip, a dialog, the toasts. Open one with overlay.open<T>(args...); it stays until close().

  • Placed beside an anchor (anchor(div), or anchor(x, y) for a point in window coordinates) on a side (side, alignment, sideOffset, alignOffset), flipping to the other side and shifting along it to stay collisionPadding inside the window, every frame (it follows its anchor); placedSide() is where it went. Without an anchor it stays where its style puts it in the window-sized overlay.
  • modal(true): the content under it (and the popups under it) get no mouse input, except its pass-through divs (passThrough(div), like a menu bar while one of its menus is open).
  • Dismissed by a press outside its surface (dismissOnOutsidePress, the default) and by Escape (dismissOnEscape, the default); a press that dismisses a modal popup goes no further, except a right press outside a popup that passesContextPress (a menu), which goes on, so that another context menu opens there, as on macOS and Windows.
  • trapFocus(true): Tab stays among its divs. When it closes with the focus inside it, the focus goes back to what had it when it opened (restoreFocus, the default).
  • A popup opened from another (owner(popup), a submenu) closes with it.
  • It enters and leaves with transitions: it has the entering class for its first style (Div::startingClass), so that its rules' transitions start from there, and its placed side as a class (side-bottom, side-top, side-right, side-left) with its transform origin at its anchor once anchored. close() gives it the exiting class (Div::exit): it is closed at once (not isOpen, not modal, no mouse, no focus, closed emitted) but stays in the overlay until its and its descendants' transitions end; opening it again meanwhile brings it back from where it is. With reduced motion it is removed at once.

Its surface (surface(), itself by default) is the part that counts as inside: a dialog's panel, not its backdrop.

Member Function Documentation

◆ alignOffset()

template<class Self>
Self & psychic_ui::Popup::alignOffset ( this Self & self,
detail::FloatArg offset )
inline

How far along the anchor's side from where alignment puts it (negative: before the anchor's start)

◆ anchor() [1/2]

template<class Self>
Self & psychic_ui::Popup::anchor ( this Self & self,
Div & anchor )
inline

Place it beside a div (held weakly: the popup closes when the div leaves the window)

◆ anchor() [2/2]

template<class Self>
Self & psychic_ui::Popup::anchor ( this Self & self,
int x,
int y )
inline

Place it at a point, in window coordinates (a context menu)

◆ anchorRect()

const SkRect & psychic_ui::Popup::anchorRect ( ) const
inline

Where its anchor was at its last placement, in the overlay's coordinates

◆ close()

void psychic_ui::Popup::close ( )

Close it, the popups it owns first; a no-op when it is closed (or leaving). It leaves the overlay once its exit transitions end (at once with reduced motion): keep a shared_ptr to reuse it.

◆ collisionPadding()

template<class Self>
Self & psychic_ui::Popup::collisionPadding ( this Self & self,
detail::FloatArg padding )
inline

How far from the window's edges it stays

◆ isOpen()

bool psychic_ui::Popup::isOpen ( ) const

Whether it is in an overlay and not leaving it

◆ laidOut()

virtual void psychic_ui::Popup::laidOut ( )
inlineprotectedvirtual

Called once, after the first layout since it opened (Overlay::place), when what was added to it after open is styled and laid out: a dialog focuses its first field

Reimplemented in psychic_ui::Dialog.

◆ modal()

bool psychic_ui::Popup::modal ( ) const
inline

Whether it takes the mouse from what is under it: while it is open, not while it leaves

◆ nextUpdate()

virtual std::optional< std::chrono::nanoseconds > psychic_ui::Popup::nextUpdate ( ) const
inlineprotectedvirtual

When update has something to do next (a toast's timeout), on the same clock; nullopt when nothing waits

Reimplemented in psychic_ui::ToastStack.

◆ opened()

virtual void psychic_ui::Popup::opened ( )
inlineprotectedvirtual

Called by the overlay once it is in it, after the focus it had was noted: take the focus (opened)

Reimplemented in psychic_ui::Dialog, and psychic_ui::Menu.

◆ owner()

Popup * psychic_ui::Popup::owner ( ) const
inline

The popup it was opened from, which closes it when it closes

◆ passesContextPress()

bool psychic_ui::Popup::passesContextPress ( ) const
inline

Whether a right press outside it that closes it goes on to what is under it (false), so that a context menu opens there: a menu's (true)

◆ passThrough()

template<class Self>
Self & psychic_ui::Popup::passThrough ( this Self & self,
Div & div )
inline

A div under it that still gets the mouse while it is open (held weakly)

◆ placed()

void psychic_ui::Popup::placed ( Side side)
protected

It went on this side: placedSide(), and its class (side-bottom...)

◆ placedSide()

Side psychic_ui::Popup::placedSide ( ) const
inline

The side it went on at its last placement, after flipping

◆ sideOffset()

template<class Self>
Self & psychic_ui::Popup::sideOffset ( this Self & self,
detail::FloatArg offset )
inline

How far from the anchor, away from it

◆ surface()

Div & psychic_ui::Popup::surface ( )
inline

The part that counts as inside it (itself unless a subclass says otherwise)

◆ update()

virtual void psychic_ui::Popup::update ( std::chrono::nanoseconds )
inlineprotectedvirtual

Advance what goes on with time (a toast's timer), every frame from Window::updatePopups

Reimplemented in psychic_ui::ToastStack.

Member Data Documentation

◆ closed

Signal psychic_ui::Popup::closed {}

When it closed (and the focus went back), as its exit starts: it may stay in the overlay a moment longer, fading out (its removed() is when it leaves)


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