1.9
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
ScrolledView Class Reference

A scrollable view. More...

Inheritance diagram for ScrolledView:
Inheritance graph
[legend]

Public Types

enum class  Policy { never , always , as_needed }
 Scrollbar policy. More...
 
- Public Types inherited from Widget
enum class  Flag : uint32_t {
  plane_window = detail::bit(0) , window = detail::bit(1) , frame = detail::bit(2) , disabled = detail::bit(3) ,
  readonly = detail::bit(4) , active = detail::bit(5) , invisible = detail::bit(6) , grab_mouse = detail::bit(7) ,
  no_clip = detail::bit(8) , no_layout = detail::bit(9) , no_autoresize = detail::bit(10) , checked = detail::bit(11) ,
  component = detail::bit(12) , user_drag = detail::bit(13) , user_track_drag = detail::bit(14)
}
 Common flags used for various widget properties. More...
 
using Flags = egt::Flags< Widget::Flag >
 Widget flags. More...
 
using WalkCallback = std::function< bool(Widget *widget, int level)>
 Callback definition used by walk(). More...
 
using WidgetId = uint64_t
 Type used to identify a unique Widget ID. More...
 
- Public Types inherited from Object
using EventCallback = std::function< void(Event &event)>
 Event handler callback function. More...
 
using FilterFlags = FlagsBase< EventId >
 Event handler EventId filter. More...
 
using RegisterHandle = uint64_t
 Handle type. More...
 

Public Member Functions

 ScrolledView (const Rect &rect, Policy horizontal_policy=Policy::as_needed, Policy vertical_policy=Policy::as_needed) noexcept
 
 ScrolledView (Frame &parent, const Rect &rect, Policy horizontal_policy=Policy::as_needed, Policy vertical_policy=Policy::as_needed) noexcept
 
 ScrolledView (Frame &parent, Policy horizontal_policy=Policy::as_needed, Policy vertical_policy=Policy::as_needed) noexcept
 
 ScrolledView (Policy horizontal_policy=Policy::as_needed, Policy vertical_policy=Policy::as_needed) noexcept
 
 ScrolledView (Serializer::Properties &props) noexcept
 
void draw (Painter &painter, const Rect &rect) override
 Draw the widget. More...
 
void handle (Event &event) override
 Handle an event. More...
 
int hoffset () const
 Get the horizontal offset. More...
 
void hoffset (int offset)
 Set the horizontal offset. More...
 
EGT_NODISCARD Policy hpolicy () const
 Get the horizontal policy. More...
 
void hpolicy (Policy policy)
 Set the horizontal policy. More...
 
void layout () override
 Perform layout of the Widget. More...
 
EGT_NODISCARD Point offset () const
 Get the current offset. More...
 
void offset (Point offset)
 Set the position. More...
 
EGT_NODISCARD Point offset_max () const
 Get the maximum offset currently possible. More...
 
EGT_NODISCARD Point offset_min () const
 Get the minimum offset currently possible. More...
 
EGT_NODISCARD const Rectoffset_range () const
 Get the offset range currently possible. More...
 
void post_deserialize (Serializer::Properties &props) override
 Resume deserializing of the widget after its children have been deserialized. More...
 
void resize (const Size &size) override
 Resize the widget. More...
 
void serialize (Serializer &serializer) const override
 Serialize the widget to the specified serializer. More...
 
EGT_NODISCARD DefaultDim slider_dim () const
 Get the slider dimension. More...
 
void slider_dim (DefaultDim dim)
 Set the slider dimension. More...
 
int voffset () const
 Get the vertical offset. More...
 
void voffset (int offset)
 Set the vertical offset. More...
 
EGT_NODISCARD Policy vpolicy () const
 Get the vertical policy. More...
 
void vpolicy (Policy policy)
 Set the vertical policy. More...
 
- Public Member Functions inherited from Frame
 Frame (const Frame &)=delete
 
 Frame (const Rect &rect={}, const Flags &flags={}) noexcept
 
 Frame (Frame &&) noexcept=default
 
 Frame (Frame &parent, const Rect &rect, const Flags &flags={}) noexcept
 
 Frame (Serializer::Properties &props) noexcept
 
 ~Frame () noexcept override
 
template<class T >
void add (const std::shared_ptr< T > &widget)
 Utility wrapper around add() More...
 
virtual void add (const std::shared_ptr< Widget > &widget)
 Add a child widget. More...
 
void add (Widget &widget)
 Add a child widget. More...
 
EGT_NODISCARD std::shared_ptr< Widgetchild_at (size_t index) const
 Get a child widget at a specific index. More...
 
EGT_NODISCARD detail::Range< SubordinatesArray > & children ()
 Return the array of child widgets. More...
 
EGT_NODISCARD const detail::Range< SubordinatesArray > & children () const
 Return the array of child widgets. More...
 
EGT_NODISCARD size_t count_children () const
 Get the number of children widgets. More...
 
void deserialize_children (const Deserializer &deserializer) override
 Deserialize the children of this widget. More...
 
template<class T >
std::shared_ptr< T > find_child (const std::string &name)
 Find a child Widget in the entire tree by name. More...
 
Widgethit_test (const DisplayPoint &point)
 Get the widget under the given DisplayPoint. More...
 
bool is_child (Widget *widget) const
 Returns true if the child exists. More...
 
void on_screen_resized () override
 Overridden to be called recursively on all children. More...
 
Frameoperator= (const Frame &)=delete
 
Frameoperator= (Frame &&) noexcept=default
 
void paint_children_to_file ()
 Paint individual children to file. More...
 
void paint_to_file (const std::string &filename={}) override
 Save the entire frame surface to a file. More...
 
virtual void remove (Widget *widget)
 Remove a child widget. More...
 
void remove_all ()
 Remove all child widgets. More...
 
void serialize_children (Serializer &serializer) const override
 Serialize the widget's children to the specified serializer. More...
 
void show () override
 Show the Widget. More...
 
template<typename T , typename... Args>
std::shared_ptr< T > spawn (Args &&... args)
 Create a child widget of the specified type. More...
 
EGT_NODISCARD ChildDrawCallback special_child_draw_callback () const
 Get the special child draw callback. More...
 
void special_child_draw_callback (ChildDrawCallback func)
 Set the special child draw callback. More...
 
EGT_NODISCARD ChildDrawCallback special_child_draw_callback (Widget *parent) const
 Get the child draw callback of the parent. More...
 
virtual EGT_NODISCARD Point to_child (const Point &p) const
 
EGT_NODISCARD Rect to_child (Rect rect) const
 
EGT_NODISCARD bool top_level () const override
 Return true if this is a top level frame, with no parent. More...
 
void walk (const WalkCallback &callback, int level=0) override
 Walk the Widget tree and call callback with each Widget. More...
 
virtual EGT_NODISCARD size_t zorder () const
 Get the zorder of the widget. More...
 
size_t zorder (const Widget *widget) const
 Get the zorder of the widget. More...
 
void zorder (const Widget *widget, size_t rank)
 Set the zorder of the widget. More...
 
virtual void zorder (size_t rank)
 Set the zorder of the widget. More...
 
virtual void zorder_bottom ()
 Move the widget to the bottom. More...
 
void zorder_bottom (const Widget *widget)
 Move the specified widget zorder to the bottom of the current list of widgets with the same parent. More...
 
virtual void zorder_down ()
 Move this widgets zorder down relative to other widgets with the same parent. More...
 
void zorder_down (const Widget *widget)
 Move the specified widget zorder down relative to other widgets with the same parent. More...
 
virtual void zorder_top ()
 Move the widget to the top. More...
 
void zorder_top (const Widget *widget)
 Move the specified widget zorder to the top of the current list of widgets with the same parent. More...
 
virtual void zorder_up ()
 Move this widgets zorder up relative to other widgets with the same parent. More...
 
void zorder_up (const Widget *widget)
 Move the specified widget zorder up relative to other widgets with the same parent. More...
 
- Public Member Functions inherited from Widget
 Widget (const Rect &rect={}, const Widget::Flags &flags={}) noexcept
 
 Widget (const Widget &)=delete
 
 Widget (Frame &parent, const Rect &rect={}, const Widget::Flags &flags={}) noexcept
 
 Widget (Serializer::Properties &props) noexcept
 
 Widget (Widget &&) noexcept=default
 
 ~Widget () noexcept override
 
EGT_NODISCARD bool active () const
 Get the active state. More...
 
void active (bool value)
 Set the active state. More...
 
AlignFlagsalign ()
 Get the alignment. More...
 
EGT_NODISCARD const AlignFlagsalign () const
 Get the alignment. More...
 
void align (const AlignFlags &a)
 Align the widget. More...
 
EGT_NODISCARD float alpha () const
 Get the alpha property. More...
 
void alpha (float alpha)
 Set the alpha property. More...
 
EGT_NODISCARD bool autoresize () const
 Return the autoresize state of the widget. More...
 
void autoresize (bool value)
 Set the autoresize state. More...
 
EGT_NODISCARD Imagebackground (bool allow_fallback=false) const
 Get the background image, if any, for the current group. More...
 
void background (const Image &image, Palette::GroupId group=Palette::GroupId::normal)
 Add an image background to the widget's box. More...
 
EGT_NODISCARD Imagebackground (Palette::GroupId group, bool allow_fallback=false) const
 Get the background image, if any, for the given group. More...
 
EGT_NODISCARD DefaultDim border () const
 Get the border width. More...
 
void border (DefaultDim border)
 Set the border width. More...
 
EGT_NODISCARD Theme::BorderFlags border_flags () const
 Get the border flags. More...
 
void border_flags (const Theme::BorderFlags &flags)
 Set the border flags. More...
 
EGT_NODISCARD float border_radius () const
 Get the border radius. More...
 
void border_radius (float radius)
 Set the border radius. More...
 
EGT_NODISCARD const Rectbox () const
 Bounding box for the Widget. More...
 
void box (const Rect &rect)
 Change the bounding box of the widget. More...
 
bool can_handle_event () const
 Returns true if the widget is capable of handling an event. More...
 
EGT_NODISCARD Point center () const
 Get the center point of the widget's box(). More...
 
EGT_NODISCARD bool checked () const
 Get the boolean checked state of the a widget. More...
 
virtual void checked (bool value)
 Set the checked state of the widget. More...
 
EGT_NODISCARD bool clip () const
 Return the clip state of the widget. More...
 
EGT_NODISCARD const Patterncolor (Palette::ColorId id) const
 Get a Widget color. More...
 
void color (Palette::ColorId id, const Pattern &color, Palette::GroupId group=Palette::GroupId::normal)
 Add a color to the widget's instance palette. More...
 
EGT_NODISCARD const Patterncolor (Palette::ColorId id, Palette::GroupId group) const
 Get a Widget color. More...
 
virtual EGT_NODISCARD Rect content_area () const
 Return the area that content is allowed to be positioned into. More...
 
void continue_drag (Event &event)
 Handle 'pointer_drag' and 'pointer_drag_stop' events. More...
 
virtual void damage ()
 Damage the box() of the widget and cause a redraw. More...
 
virtual void damage (const Rect &rect)
 Mark the specified rect as a damaged area of the widget. More...
 
void detach ()
 Detach this widget from its parent. More...
 
void disable ()
 Set the disabled state to true. More...
 
void disable_toggle ()
 Toggle the disabled state. More...
 
EGT_NODISCARD bool disabled () const
 Return the disabled state of the widget. More...
 
void disabled (bool value)
 Set the disabled state. More...
 
DisplayPoint display_origin ()
 Get the display origin of the Widget. More...
 
virtual Point display_to_local (const DisplayPoint &p) const
 Convert a display point to a local point. More...
 
void draw_box (Painter &painter, Palette::ColorId bg, Palette::ColorId border) const
 Helper function to draw this widget's box using the appropriate theme. More...
 
void draw_circle (Painter &painter, Palette::ColorId bg, Palette::ColorId border) const
 Helper function to draw this widget's circle using the appropriate theme. More...
 
void enable ()
 Set the disabled state to false. More...
 
Theme::FillFlagsfill_flags ()
 Get a modifiable fill flags reference. More...
 
EGT_NODISCARD const Theme::FillFlagsfill_flags () const
 Get the fill flags. More...
 
void fill_flags (const Theme::FillFlags &flags)
 Set the fill flags. More...
 
EGT_NODISCARD bool focus () const
 Get the current focus state. More...
 
void focus (bool value)
 Set the focus state. More...
 
EGT_NODISCARD const Fontfont () const
 Get the widget Font. More...
 
void font (const Font &font)
 Set the widget Font. More...
 
EGT_NODISCARD bool frame () const
 Return the frame state of the widget. More...
 
EGT_NODISCARD bool grab_mouse () const
 Return the grab_mouse state of the widget. More...
 
void grab_mouse (bool value)
 Set the grab_mouse state. More...
 
EGT_NODISCARD Palette::GroupId group () const
 Get the current Palette::GroupId depending on the widget's state. More...
 
bool has_font () const
 Check whether the widget has a custom Font. More...
 
EGT_NODISCARD bool has_palette () const
 Check whether the widget has a custom palette. More...
 
virtual EGT_NODISCARD bool has_screen () const
 Does this Widget have a screen? More...
 
EGT_NODISCARD DefaultDim height () const
 Height of the widget's box(). More...
 
void height (DefaultDim h)
 Change the height. More...
 
virtual void hide ()
 Hide the Widget. More...
 
EGT_NODISCARD bool hit (const DisplayPoint &point) const
 Returns true if the DisplayPoint is within the widget box. More...
 
EGT_NODISCARD DefaultDim horizontal_ratio () const
 Get the horizontal ratio relative to parent. More...
 
void horizontal_ratio (DefaultDim horizontal)
 Set the horizontal ratio relative to parent. More...
 
EGT_NODISCARD bool in_layout () const
 Indicate if the Widget is computing the layout or not. More...
 
DisplayPoint local_to_display (const Point &p) const
 Convert a local point to a display point. More...
 
EGT_NODISCARD DefaultDim margin () const
 Get the margin width. More...
 
void margin (DefaultDim margin)
 Set the margin width. More...
 
virtual EGT_NODISCARD Size min_size_hint () const
 Get a minimum size hint for the Widget. More...
 
void min_size_hint (const Size &size)
 Set the minimum size hint for the Widget. More...
 
EGT_NODISCARD size_t moat () const
 Get the sum of the margin(), padding(), and border() around the content of the widget. More...
 
virtual void move (const Point &point)
 Move the Widget to a new position. More...
 
void move_to_center ()
 Move the widget to the center of its parent. More...
 
void move_to_center (const Point &point)
 Move the widget to the specified center point. More...
 
EGT_NODISCARD bool no_layout () const
 Return the no_layout state of the widget. More...
 
void no_layout (bool value)
 Set the no_layout state. More...
 
Widgetoperator= (const Widget &)=delete
 
Widgetoperator= (Widget &&) noexcept=default
 
EGT_NODISCARD DefaultDim padding () const
 Return the padding width. More...
 
void padding (DefaultDim padding)
 Set the padding width. More...
 
virtual void paint (Painter &painter)
 Paint the Widget using a Painter. More...
 
EGT_NODISCARD const Palettepalette () const
 Get the widget palette. More...
 
void palette (const Palette &palette)
 Set the widget instance Palette. More...
 
Widgetparent ()
 Get a pointer to the parent Widget, or nullptr if none exists. More...
 
EGT_NODISCARD const Widgetparent () const
 Get a pointer to the parent Widget, or nullptr if none exists. More...
 
EGT_NODISCARD bool plane_window () const
 Return the plane_window state of the widget. More...
 
EGT_NODISCARD const Pointpoint () const
 Get the origin of the widget's box(). More...
 
void ratio (DefaultDim horizontal, DefaultDim vertical)
 Set the size ratio relative to parent. More...
 
void ratio (DefaultDim ratio)
 Set the size ratio relative to parent. More...
 
EGT_NODISCARD bool readonly () const
 Get the readonly state of the widget. More...
 
void readonly (bool value)
 Set the readonly state of the widget. More...
 
void readonly_toggle ()
 Toggle the readonly state. More...
 
void reset_background (Palette::GroupId group=Palette::GroupId::normal)
 Remove an image background from the widget's box. More...
 
void reset_font ()
 Reset the widget's Font. More...
 
void reset_palette ()
 Clear the widget instance palette. More...
 
void resize_by_ratio (DefaultDim hratio, DefaultDim vratio)
 Scale the current size of the Widget given the ratio. More...
 
void resize_by_ratio (DefaultDim ratio)
 Scale the current size of the Widget given the ratio. More...
 
virtual void scale (float hscale, float vscale)
 Set the scale of the widget. More...
 
void scale (float scale)
 Set the scale of the widget. More...
 
virtual EGT_NODISCARD Screenscreen () const
 Get a pointer to the Screen instance, using using a parent as necessary. More...
 
EGT_NODISCARD const Sizesize () const
 Get the size of the widget's box(). More...
 
EGT_NODISCARD const Themetheme () const
 Get the Widget Theme. More...
 
EGT_NODISCARD Point to_parent (const Point &r) const
 Convert a point with a local origin to a parent origin. More...
 
EGT_NODISCARD Rect to_parent (const Rect &r) const
 Convert a point in a rect a local origin to a parent origin. More...
 
virtual EGT_NODISCARD std::string type () const
 Returns a string representation of the type of this widget. More...
 
EGT_NODISCARD bool user_drag () const
 
void user_drag (bool value)
 
EGT_NODISCARD const Rectuser_requested_box () const
 Get the box corresponding to the user requested one, not the actual one. More...
 
EGT_NODISCARD bool user_track_drag () const
 
void user_track_drag (bool value)
 
EGT_NODISCARD DefaultDim vertical_ratio () const
 Get the vertical ratio relative to parent. More...
 
void vertical_ratio (DefaultDim vertical)
 Set the vertical ratio relative to parent. More...
 
EGT_NODISCARD bool visible () const
 Get the visible state of the widget. More...
 
void visible (bool value)
 Set the visible state. More...
 
void visible_toggle ()
 Toggle the visibility state. More...
 
EGT_NODISCARD WidgetId widgetid () const
 Get the unique id of the widget. More...
 
EGT_NODISCARD DefaultDim width () const
 Width of the widget's box(). More...
 
void width (DefaultDim w)
 Change the width. More...
 
EGT_NODISCARD DefaultDim x () const
 X coordinate of the widget's box(). More...
 
void x (DefaultDim x)
 Set the X coordinate of the box. More...
 
EGT_NODISCARD DefaultDim xratio () const
 Get the X position ratio relative to parent. More...
 
void xratio (DefaultDim xratio)
 Set the X position ratio relative to parent. More...
 
EGT_NODISCARD DefaultDim y () const
 Y coordinate of the widget's box(). More...
 
void y (DefaultDim y)
 Set the Y coordinate of the box. More...
 
EGT_NODISCARD DefaultDim yratio () const
 Get the Y position ratio relative to parent. More...
 
void yratio (DefaultDim yratio)
 Set the Y position ratio relative to parent. More...
 
virtual EGT_NODISCARD size_t zorder () const
 Get the zorder of the widget. More...
 
virtual void zorder (size_t rank)
 Set the zorder of the widget. More...
 
- Public Member Functions inherited from Object
 Object () noexcept=default
 
 Object (const Object &)=delete
 
 Object (Object &&)=default
 
virtual ~Object () noexcept=default
 
void clear_handlers ()
 Clear all registered event handlers. More...
 
void invoke_handlers (Event &event)
 Invoke all handlers with the specified event. More...
 
void invoke_handlers (EventId event)
 Invoke all handlers with the specified EventId. More...
 
EGT_NODISCARD const std::string & name () const
 Get the name of the Object. More...
 
void name (const std::string &name)
 Set the name of the Object. More...
 
RegisterHandle on_event (const EventCallback &handler, const FilterFlags &mask={})
 Add an event handler to be called when the widget generates an event. More...
 
Objectoperator= (const Object &)=delete
 
Objectoperator= (Object &&)=default
 
void remove_handler (RegisterHandle handle)
 Remove an event handler. More...
 

Static Public Member Functions

static std::string policy2str (Policy policy)
 
static Policy str2policy (const std::string &str)
 

Protected Member Functions

 ScrolledView (Serializer::Properties &props, bool is_derived) noexcept
 
void damage_from_subordinate (const Rect &rect) override
 Special variation of damage() that is to be called explicitly by subordinate widgets. More...
 
void deserialize (Serializer::Properties &props)
 Deserialize ScrolledView properties. More...
 
EGT_NODISCARD bool hscrollable () const
 Horizontal scrollable. More...
 
void init_sliders ()
 Initialize the sliders properties. More...
 
bool internal_drag () const override
 
Point point_from_subordinate (const Widget &subordinate) const override
 
void resize_sliders ()
 Resize the sliders whenever the size of these changes. More...
 
EGT_NODISCARD Rect super_rect () const
 Return the super rectangle that includes all of the child widgets. More...
 
void update_scrollable ()
 Update scrollable settings based on current size. More...
 
void update_sliders ()
 Update properties of the sliders. More...
 
EGT_NODISCARD bool vscrollable () const
 Vertical scrollable. More...
 
- Protected Member Functions inherited from Frame
 Frame (Serializer::Properties &props, bool is_derived) noexcept
 
- Protected Member Functions inherited from Widget
 Widget (Serializer::Properties &props, bool is_derived) noexcept
 
bool accept_drag () const
 Tell the start_drag() method whether the widget accepts 'pointer_drag*' events. More...
 
void add_component (Widget &widget)
 Add a component. More...
 
void add_damage (const Rect &rect)
 Add damage to the damage array. More...
 
virtual void begin_draw ()
 Cause the widget to draw itself and all of its children. More...
 
void begin_draw (Widget *parent)
 Call the begin_draw() method of the parent. More...
 
EGT_NODISCARD detail::Range< SubordinatesArray > & children ()
 Return the array of child widgets. More...
 
EGT_NODISCARD const detail::Range< SubordinatesArray > & children () const
 Return the array of child widgets. More...
 
EGT_NODISCARD bool component () const
 Get the component status. More...
 
void component (bool value)
 Set the component flag. More...
 
EGT_NODISCARD detail::Range< SubordinatesArray > & components ()
 Return the array of components widgets. More...
 
EGT_NODISCARD const detail::Range< SubordinatesArray > & components () const
 Return the array of components widgets. More...
 
void deserialize_leaf (Serializer::Properties &props)
 Deserialize widget properties that require to call overridden methods. More...
 
Widgetfind_screen ()
 Starting from this Widget, find the Widget that has a Screen. More...
 
EGT_NODISCARD const Widgetfind_screen () const
 Starting from this Widget, find the Widget that has a Screen. More...
 
Widget::Flagsflags ()
 Get a modifiable ref of the flags. More...
 
EGT_NODISCARD const Widget::Flagsflags () const
 Get a const ref of the flags. More...
 
virtual bool internal_track_drag () const
 
EGT_NODISCARD Rect local_box () const
 Get the local box which is the same size as box(), but with the origin zeroed. More...
 
EGT_NODISCARD bool parent_in_layout ()
 Indicate if our parent is computing the layout. More...
 
void parent_layout ()
 Call our parent to do a layout. More...
 
EGT_NODISCARD detail::Range< SubordinatesArray > & range_from_widget (const Widget &widget)
 Return either components() or children() depending on widget.component() More...
 
EGT_NODISCARD const detail::Range< SubordinatesArray > & range_from_widget (const Widget &widget) const
 Return either components() or children() depending on widget.component() More...
 
void remove_component (Widget *widget)
 Remove a component. More...
 
virtual void set_parent (Widget *parent)
 Set this widget's parent. More...
 
void special_child_draw (Painter &painter, Widget *widget)
 Special draw function that can be invoked when drawing each child. More...
 
EGT_NODISCARD ChildDrawCallback special_child_draw_callback () const
 Get the special child draw callback. More...
 
void special_child_draw_callback (ChildDrawCallback func)
 Set the special child draw callback. More...
 
EGT_NODISCARD ChildDrawCallback special_child_draw_callback (Widget *parent) const
 Get the child draw callback of the parent. More...
 
void start_drag (Event &event)
 Handle 'pointer_drag_start' events and decide whether they are caught by this widget. More...
 
virtual Point to_panel (const Point &p)
 Convert a local point to the coordinate system of the current panel. More...
 
virtual EGT_NODISCARD Point to_subordinate (const Point &p) const
 Convert a point with an origin of the current widget to subordinate origin. More...
 
EGT_NODISCARD Rect to_subordinate (Rect rect) const
 
bool track_drag () const
 Tell the continue_drag() method whether the widget tracks 'pointer_drag*' events once they have crossed out the widget boundaries. More...
 
void update_subordinates_ranges ()
 Update the 'm_children' and 'm_components' members. More...
 
size_t zorder (const Widget *widget) const
 Get the zorder of the widget. More...
 
void zorder (const Widget *widget, size_t rank)
 Set the zorder of the widget. More...
 
void zorder_bottom (const Widget *widget)
 Move the specified widget zorder to the bottom of the current list of widgets with the same parent. More...
 
void zorder_down (const Widget *widget)
 Move the specified widget zorder down relative to other widgets with the same parent. More...
 
void zorder_top (const Widget *widget)
 Move the specified widget zorder to the top of the current list of widgets with the same parent. More...
 
void zorder_up (const Widget *widget)
 Move the specified widget zorder up relative to other widgets with the same parent. More...
 

Protected Attributes

Policy m_horizontal_policy {Policy::as_needed}
 Horizontal scrollbar policy. More...
 
bool m_hscrollable {false}
 Horizontal scrollable. More...
 
Slider m_hslider
 Horizontal slider shown when scrollable. More...
 
Point m_offset
 Current offset of the view. More...
 
Rect m_offset_range
 Current offset range. More...
 
DefaultDim m_slider_dim {8}
 Width/height of the slider when shown. More...
 
Point m_start_offset
 Starting offset for the drag. More...
 
Policy m_vertical_policy {Policy::as_needed}
 Vertical scrollbar policy. More...
 
bool m_vscrollable {false}
 Vertical scrollable. More...
 
Slider m_vslider
 Vertical slider shown when scrollable. More...
 
- Protected Attributes inherited from Widget
Rect m_box
 Bounding box. More...
 
detail::Range< SubordinatesArraym_children
 Array of child widgets in the order they were added. More...
 
detail::Range< SubordinatesArraym_components
 Array of component widgets in the order they were added. More...
 
SubordinatesArray::iterator m_components_begin
 Iterator for the beginning of components which are positionned after children in the subordinates array. More...
 
Screen::DamageArray m_damage
 The damage array for this widget. More...
 
bool m_in_draw {false}
 Status for whether this widget is currently drawing. More...
 
bool m_in_layout {false}
 Status for whether this widget is currently performing layout. More...
 
Size m_min_size
 Minimum size of the widget when not an empty value. More...
 
Widgetm_parent {nullptr}
 Pointer to this widget's parent. More...
 
ChildDrawCallback m_special_child_draw_callback
 Used internally for calling the special child draw function. More...
 
SubordinatesArray m_subordinates
 Array of subordinates widgets split in child widgets and component widgets. More...
 
Rect m_user_requested_box
 Keep track of the box requested by the user. More...
 
WidgetId m_widgetid {0}
 Unique ID of this widget. More...
 
- Protected Attributes inherited from Object
detail::CopyOnWriteAllocate< CallbackArraym_callbacks
 Array of callbacks. More...
 
RegisterHandle m_handle_counter {0}
 Counter used to generate unique handles for each callback registration. More...
 
std::string m_name
 A user defined name for the Object. More...
 

Additional Inherited Members

- Public Attributes inherited from Widget
Signal on_checked_changed
 Event signal. More...
 
Signal on_gain_focus
 Invoked when the widget gains focus. More...
 
Signal on_lost_focus
 Invoked when the widget loses focus. More...
 
Signal on_show
 Invoked when a widget is shown. More...
 
Signal on_hide
 Invoked when a widget is hidden. More...
 
- Protected Types inherited from Widget
using ChildDrawCallback = std::function< void(Painter &painter, Widget *widget)>
 Helper type that defines the special draw child callback. More...
 
using SubordinatesArray = std::list< std::shared_ptr< Widget > >
 Helper type for an array of subordinate widgets. More...
 
- Protected Types inherited from Object
using CallbackArray = std::vector< CallbackMeta >
 Helper type for an array of callbacks. More...
 

Detailed Description

A scrollable view.

A ScrolledView is a sort of kitchen window. You can have a large surface area on the other side of the window, but you only see a small portion of it through the window. The surface can be scrolled, or panned, in a single Orientation to see the rest.

This is used internally by Widgets, but can also be used directly.

Member Enumeration Documentation

◆ Policy

enum Policy
strong

Scrollbar policy.

Enumerator
never 
always 
as_needed 

Constructor & Destructor Documentation

◆ ScrolledView() [1/6]

ScrolledView ( Policy  horizontal_policy = Policy::as_needed,
Policy  vertical_policy = Policy::as_needed 
)
explicitnoexcept
Parameters
[in]horizontal_policyHorizontal slider policy.
[in]vertical_policyVertical slider policy.

◆ ScrolledView() [2/6]

ScrolledView ( const Rect rect,
Policy  horizontal_policy = Policy::as_needed,
Policy  vertical_policy = Policy::as_needed 
)
explicitnoexcept
Parameters
[in]rectInitial rectangle of the widget.
[in]horizontal_policyHorizontal slider policy.
[in]vertical_policyVertical slider policy.

◆ ScrolledView() [3/6]

ScrolledView ( Frame parent,
const Rect rect,
Policy  horizontal_policy = Policy::as_needed,
Policy  vertical_policy = Policy::as_needed 
)
explicitnoexcept
Parameters
[in]parentThe parent Frame.
[in]rectInitial rectangle of the widget.
[in]horizontal_policyHorizontal slider policy.
[in]vertical_policyVertical slider policy.

◆ ScrolledView() [4/6]

ScrolledView ( Frame parent,
Policy  horizontal_policy = Policy::as_needed,
Policy  vertical_policy = Policy::as_needed 
)
explicitnoexcept
Parameters
[in]parentThe parent Frame.
[in]horizontal_policyHorizontal slider policy.
[in]vertical_policyVertical slider policy.

◆ ScrolledView() [5/6]

ScrolledView ( Serializer::Properties props)
inlineexplicitnoexcept
Parameters
[in]propslist of widget argument and its properties.

◆ ScrolledView() [6/6]

ScrolledView ( Serializer::Properties props,
bool  is_derived 
)
explicitprotectednoexcept

Member Function Documentation

◆ damage_from_subordinate()

void damage_from_subordinate ( const Rect rect)
inlineoverrideprotectedvirtual

Special variation of damage() that is to be called explicitly by subordinate widgets.

Reimplemented from Widget.

◆ deserialize()

void deserialize ( Serializer::Properties props)
protected

Deserialize ScrolledView properties.

◆ draw()

void draw ( Painter painter,
const Rect rect 
)
overridevirtual

Draw the widget.

To change how a widget is drawn, this function can be overloaded and changed in a derived class, or it can be changed dynamically with the Theme.

To optimize drawing, a Widget may use the Rect parameter to limit what needs to be redrawn, which may be smaller than the widget's box(), but will never be outside the widget's box().

Painter will always be supplied in a default state to this function, so there is no need to do any cleanup or state saving inside this draw() function.

Warning
Normally this should not be called directly and instead the EventLoop will call this function with an already established Painter when the Widget needs to be drawn.
See also
Color, Palette, and Theme and Drawing
Parameters
[in]painterInstance of the Painter for the Screen.
[in]rectThe rectangle to draw.

Reimplemented from Widget.

◆ handle()

void handle ( Event event)
overridevirtual

Handle an event.

This handles global events that usually do not originate at the widget. For example, a pointer event. All events are defined by egt::EventId.

The default implementation in the Widget class, will dispatch the event to any third party handlers that have been registered with on_event(). What this means is if you expect other handlers to receive the events then this must be called from derived classes. Or, manually call invoke_handlers().

Override this function in a derived class to handle events.

See also
Events
Parameters
eventThe Event that occurred.

Reimplemented from Widget.

◆ hoffset() [1/2]

int hoffset ( ) const
inline

Get the horizontal offset.

◆ hoffset() [2/2]

void hoffset ( int  offset)
inline

Set the horizontal offset.

Note
The offset moves in the negative direction from zero.

◆ hpolicy() [1/2]

EGT_NODISCARD Policy hpolicy ( ) const
inline

Get the horizontal policy.

◆ hpolicy() [2/2]

void hpolicy ( Policy  policy)
inline

Set the horizontal policy.

◆ hscrollable()

EGT_NODISCARD bool hscrollable ( ) const
inlineprotected

Horizontal scrollable.

◆ init_sliders()

void init_sliders ( )
protected

Initialize the sliders properties.

◆ internal_drag()

bool internal_drag ( ) const
inlineoverrideprotectedvirtual

Reimplemented from Widget.

◆ layout()

void layout ( )
overridevirtual

Perform layout of the Widget.

This will cause the widget to layout itself and any of its children. This can mean, for example, the widget will resize() itself to respect its min_size_hint().

Note
Remember that when overriding this function as a Frame, you must call layout on each child Frame to propagate the layout.

Reimplemented from Widget.

◆ offset() [1/2]

EGT_NODISCARD Point offset ( ) const
inline

Get the current offset.

Note
The offset moves in the negative direction.

◆ offset() [2/2]

void offset ( Point  offset)

Set the position.

Note
The offset moves in the negative direction.

◆ offset_max()

EGT_NODISCARD Point offset_max ( ) const
inline

Get the maximum offset currently possible.

Note
The offset moves in the negative direction.

◆ offset_min()

EGT_NODISCARD Point offset_min ( ) const
inline

Get the minimum offset currently possible.

Note
The offset moves in the negative direction.

◆ offset_range()

EGT_NODISCARD const Rect& offset_range ( ) const
inline

Get the offset range currently possible.

Note
The offset moves in the negative direction.

◆ point_from_subordinate()

Point point_from_subordinate ( const Widget subordinate) const
overrideprotectedvirtual

Reimplemented from Widget.

◆ policy2str()

static std::string policy2str ( Policy  policy)
static

◆ post_deserialize()

void post_deserialize ( Serializer::Properties props)
overridevirtual

Resume deserializing of the widget after its children have been deserialized.

Reimplemented from Widget.

◆ resize()

void resize ( const Size size)
overridevirtual

Resize the widget.

Changes the width and height of the Widget.

Parameters
[in]sizeThe new size of the Widget.
Note
This will cause a redraw of the Widget.

Reimplemented from Widget.

◆ resize_sliders()

void resize_sliders ( )
protected

Resize the sliders whenever the size of these changes.

◆ serialize()

void serialize ( Serializer serializer) const
overridevirtual

Serialize the widget to the specified serializer.

Reimplemented from Frame.

◆ slider_dim() [1/2]

EGT_NODISCARD DefaultDim slider_dim ( ) const
inline

Get the slider dimension.

◆ slider_dim() [2/2]

void slider_dim ( DefaultDim  dim)
inline

Set the slider dimension.

◆ str2policy()

static Policy str2policy ( const std::string &  str)
static

◆ super_rect()

EGT_NODISCARD Rect super_rect ( ) const
protected

Return the super rectangle that includes all of the child widgets.

◆ update_scrollable()

void update_scrollable ( )
inlineprotected

Update scrollable settings based on current size.

◆ update_sliders()

void update_sliders ( )
protected

Update properties of the sliders.

◆ voffset() [1/2]

int voffset ( ) const
inline

Get the vertical offset.

◆ voffset() [2/2]

void voffset ( int  offset)
inline

Set the vertical offset.

Note
The offset moves in the negative direction from zero.

◆ vpolicy() [1/2]

EGT_NODISCARD Policy vpolicy ( ) const
inline

Get the vertical policy.

◆ vpolicy() [2/2]

void vpolicy ( Policy  policy)
inline

Set the vertical policy.

◆ vscrollable()

EGT_NODISCARD bool vscrollable ( ) const
inlineprotected

Vertical scrollable.

Member Data Documentation

◆ m_horizontal_policy

Policy m_horizontal_policy {Policy::as_needed}
protected

Horizontal scrollbar policy.

◆ m_hscrollable

bool m_hscrollable {false}
protected

Horizontal scrollable.

◆ m_hslider

Slider m_hslider
protected

Horizontal slider shown when scrollable.

◆ m_offset

Point m_offset
protected

Current offset of the view.

◆ m_offset_range

Rect m_offset_range
protected

Current offset range.

◆ m_slider_dim

DefaultDim m_slider_dim {8}
protected

Width/height of the slider when shown.

◆ m_start_offset

Point m_start_offset
protected

Starting offset for the drag.

◆ m_vertical_policy

Policy m_vertical_policy {Policy::as_needed}
protected

Vertical scrollbar policy.

◆ m_vscrollable

bool m_vscrollable {false}
protected

Vertical scrollable.

◆ m_vslider

Slider m_vslider
protected

Vertical slider shown when scrollable.