View¶
Abstract base class for all user interface elements.
Declaration¶
namespace bdn::ui {
class View : public std::enable_shared_from_this<View>
}
Properties¶
-
Property<Rect> geometry
Current geometry of the view on screen.
-
Property<bool> visible = true
Whether the view is visible.
-
Property<std::shared_ptr<json>> stylesheet
A stylesheet defining the styling and layout of the view.
-
Property<bool> isLayoutRoot = false
Whether the view is treated as a layout root. If set to true, the view's geometry will not be changed by the layout system. Children are not affected by this setting and will still be processed by the layout system. Defaults to
false
. -
const Property<std::weak_ptr<View>> &parentView
(read-only) The current parent view.
Stylesheet¶
-
{ "background-color" : Color }
Controls the background color of the view.
Layout¶
-
virtual Size sizeForSpace(Size availableSpace = Size::none()) const
Calculates the view's
Size
for the given space. -
std::shared_ptr<Layout> getLayout()
Returns the view's
Layout
. -
void setLayout(std::shared_ptr<Layout> layout)
Sets the view's
Layout
. -
void setFallbackLayout(std::shared_ptr<Layout> layout)
Sets the view's
Layout
fallback. A view that has no layout set (viasetLayout
) will use the givenlayout
.
View Core¶
-
std::shared_ptr<ViewCore> viewCore() const
Returns the view's
ViewCore
. -
std::shared_ptr<ViewCoreFactory> viewCoreFactory()
Returns the view's
ViewCoreFactory
. -
virtual void bindViewCore()
Called after a new
ViewCore
is created to connect it to the view's properties and notifiers -
virtual const std::type_info &typeInfoForCoreCreation() const
Returns the std::type_info that should be used to determine the
ViewCore
type. The default implementation returns typeid(*this). Override if you want to use a differentViewCore
.
View Hierarchy¶
-
virtual std::vector<std::shared_ptr<View>> childViews() const
Returns the view's child views.
Misc¶
-
std::shared_ptr<View> shared_from_this()
Returns an
std::shared_ptr
referencing the view.
Relationships¶
Inherits from std::enable_shared_from_this<View>
.