|
template<typename... _Args> |
static void | bubbleEvent (const bwEvent &event, const Node &from_node, HandlerFunc< _Args &&... > handler_func, _Args &&... __args) |
|
static auto | findHoveredNode (const bwEvent &event, Node &node) -> Node * |
|
static auto | painter_check_paint_engine () -> bool |
|
static auto | getRoundboxMinsize (const bwRectanglePixel &rect, unsigned int corners) -> unsigned int |
|
auto | operator* (const bwPoint &lhs, float factor) -> bwPoint |
|
auto | operator* (float factor, const bwPoint &rhs) -> bwPoint |
|
auto | operator+ (const bwPoint &lhs, const bwPoint &rhs) -> bwPoint |
|
auto | operator- (const bwPoint &lhs, const bwPoint &rhs) -> bwPoint |
|
auto | distance (bwPoint a, bwPoint b) -> float |
|
static auto | property_value_is_copyable (const bwStyleProperty &destination, const bwStyleProperty &source) -> bool |
|
template<typename _Type > |
static void | property_copy_value (bwStyleProperty &destination_property_base, const bwStyleProperty &source_property_base) |
|
static void | widget_base_style_checkbox_set (bwWidget &widget, bwWidgetBaseStyle &r_base_style) |
|
static void | widget_base_style_number_slider_set (bwWidget &widget, bwWidgetBaseStyle &r_base_style) |
|
static void | widget_base_style_push_button_set (bwWidget &widget, bwWidgetBaseStyle &r_base_style) |
|
static void | widget_base_style_radio_button_set (bwWidget &widget, bwWidgetBaseStyle &r_base_style) |
|
static void | widget_base_style_scroll_bar_set (bwWidget &widget, bwWidgetBaseStyle &r_base_style) |
|
static void | widget_base_style_text_box_set (bwWidget &widget, bwWidgetBaseStyle &r_base_style) |
|
static void | widget_base_style_panel_set (bwWidget &widget, bwWidgetBaseStyle &r_base_style) |
|
static void | widget_base_style_scrollview_set (bwWidget &, bwWidgetBaseStyle &r_base_style) |
|
static void | widget_style_properties_set_to_default (bwWidget &widget) |
|
static void | widget_base_style_set (bwWidget &widget, bwWidgetBaseStyle &r_base_style) |
|
static void | widget_base_style_checkbox_set (bwWidget &widget, bwWidgetBaseStyle &r_base_style) |
|
static void | widget_base_style_number_slider_set (bwWidget &widget, bwWidgetBaseStyle &r_base_style) |
|
static void | widget_base_style_push_button_set (bwWidget &widget, bwWidgetBaseStyle &r_base_style) |
|
static void | widget_base_style_radio_button_set (bwWidget &widget, bwWidgetBaseStyle &r_base_style) |
|
static void | widget_base_style_scroll_bar_set (bwWidget &widget, bwWidgetBaseStyle &r_base_style) |
|
static void | widget_base_style_text_box_set (bwWidget &widget, bwWidgetBaseStyle &r_base_style) |
|
static void | widget_base_style_panel_set (bwWidget &, bwWidgetBaseStyle &r_base_style) |
|
static void | widget_base_style_scrollview_set (bwWidget &, bwWidgetBaseStyle &r_base_style) |
|
static void | widget_style_properties_set_to_default (bwWidget &widget) |
|
static void | widget_base_style_set (bwWidget &widget, bwWidgetBaseStyle &r_base_style) |
|
static void | panel_draw_drag_dots (bwPainter &painter, const bwRectanglePixel &rectangle, const bwWidgetBaseStyle &base_style) |
|
static auto | getInnerRect (bwScrollBar &scrollbar) -> bwRectanglePixel |
|
template<typename... _Args> |
static void | forwardEventToNode (bwScreenGraph::Node &to_node, HandlerFunc< _Args &&... > handler_func, _Args &&... __args) |
|
template<typename... _Args> |
static auto | forwardEventToScrollbarIfInside (const bwScrollViewHandler &scrollview_handler, bwScreenGraph::Node &scrollbar_node, const class bwEvent &event, HandlerFunc< _Args &&... > handler_func, _Args &&... __args) -> bool |
|
template<class T , class _RawT = typename std::remove_pointer<T>::type> |
auto | widget_cast (bwWidget &widget) -> _RawT * |
|
template<class T , class _RawT = typename std::remove_pointer<typename std::remove_const<T>::type>::type> |
auto | widget_cast (const bwWidget &widget) -> const _RawT * |
|
template<class T , class _RawT = typename std::remove_pointer<T>::type> |
auto | widget_cast (bwWidget *widget) -> _RawT * |
|
template<class T , class _RawT = typename std::remove_pointer<typename std::remove_const<T>::type>::type> |
auto | widget_cast (const bwWidget *widget) -> const _RawT * |
|
|
template<typename _Type > |
static auto | properties_add_property (bwStyleProperties::PropertyList &properties, const std::string_view &name, _Type &reference) -> bwStyleProperty & |
|
template<typename _Type > |
static auto | properties_add_property (bwStyleProperties::PropertyList &properties, const std::string_view &name) -> bwStyleProperty & |
|
template<class T , class _RawT = typename std::remove_pointer<T>::type>
auto bWidgets::widget_cast |
( |
bwWidget & |
widget | ) |
-> _RawT*
|
|
inline |
Try to dynamically cast a widget from one widget type to another. Use-case is not just to perform the cast itself, but to also to check if a widget is of a specific type.
There are a couple of reasons why types are checked this way:
- Using bwWidget::identifier for this would imply string comparisons - which scale badly.
- The most practical alternative would probably be a type enum. To add a widget, the central enum definition would have to be extended. This makes it impossible to define a widget in a single file.
- Enums can't be modified from external code to define custom widget types (types not definied within bWidgets). So for these a "custom" enum item would be needed. If this is set, an alternative type check mechanism would be needed, likely the slower string comparison.
- Using enums leads to more verbose and less safe checks. If an enum value says the widget is of a certain type, the code will assume it was also constructed for this type. It typically performs a static cast, which may work fine in most cases, but is technically unsafe still. Using
dynamic_cast<>()
, the compiler ensures a type-safe operation.
Retains const-correctness and always returns a pointer. E.g. widget_cast<bwFoo>(const_object)
returns a const bwFoo*
type.
- Note
- By design, bWidgets should not need much type casting or type checking like this. Widget types, composed together with other custom objects (like widget specific event handlers) through the screen-graph node, should be able to define comprehensive custom behavior. Sometimes it's still necessary to customize behavior through type checks from outside the widget type definition though. At least for now.
- Returns
- The derived widget class of type
T*
or nullptr
if cast is not valid (whereby T is the "raw" type requested, without pointer).