ZenitUI
Retained-mode C++20 UI framework
Loading...
Searching...
No Matches
ZenitUI::UI::Popup Class Reference

A floating, anchored panel. More...

#include <Popup.hpp>

Inheritance diagram for ZenitUI::UI::Popup:
[legend]

Public Member Functions

void setContent (std::shared_ptr< Layout > content)
 Set the popup's content.
void openBelow (std::shared_ptr< Layout > anchor)
 Open the popup just below anchor.
void openAbove (std::shared_ptr< Layout > anchor)
 Open the popup just above anchor (auto-flips below if clipped).
void openAt (Vec2 screenPos)
 Open the popup at an absolute screen position.
void close ()
 Close the popup if open, fading out and firing onClose.
bool isOpen () const
 true while the popup is visible.
void arrange (Rect) override
 No-op: the popup owns its rect via onUpdate.
Public Member Functions inherited from ZenitUI::TLayout< Popup, Panel >
 TLayout (Args &&...args)
 Forward constructor arguments to Base.
std::shared_ptr< Popup > cls (const std::string &name)
 Fluent addClass; returns typed shared_ptr<Derived>.
std::shared_ptr< Popup > id (const std::string &node_id)
 Fluent setId; returns typed shared_ptr<Derived>.
std::shared_ptr< Popup > withRef (const std::string &r)
 Fluent setRef; returns typed shared_ptr<Derived>.
std::shared_ptr< Popup > size (Value w, Value h)
 Fluent setSize; returns typed shared_ptr<Derived>.
std::shared_ptr< Popup > passThrough (bool p=true)
 Fluent setPassThrough; returns typed shared_ptr<Derived>.
std::shared_ptr< Popup > with (std::shared_ptr< Layout > c)
 Fluent addChild; returns typed shared_ptr<Derived>.
std::shared_ptr< Popup > self ()
 Return shared_from_this() statically cast to Derived.

Public Attributes

bool closeOnClickOutside {true}
 Close on any button press outside the popup.
bool closeOnEscape {true}
 Close on Escape.
float offsetBelow {4.0f}
 Gap between the anchor and the popup.
std::function< void()> onOpen
 Fired after open*.
std::function< void()> onClose
 Fired after close.

Protected Member Functions

void onBuild () override
 Hook: called once after create() finishes constructing the object.
void onUpdate (float dt) override

Additional Inherited Members

Static Public Member Functions inherited from ZenitUI::TLayout< Popup, Panel >
static std::shared_ptr< Popup > create (Args &&...args)
 Construct a shared_ptr<Derived> and call onBuild().

Detailed Description

A floating, anchored panel.

Style tag: "Popup". Portal by default. Content is whatever you pass to setContent.

Member Function Documentation

◆ onBuild()

void ZenitUI::UI::Popup::onBuild ( )
overrideprotectedvirtual

Hook: called once after create() finishes constructing the object.

Reimplemented from ZenitUI::TLayout< Popup, Panel >.

◆ setContent()

void ZenitUI::UI::Popup::setContent ( std::shared_ptr< Layout > content)

Set the popup's content.

Replaces any previous content.


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