Rose
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
rose::ScrollArea Class Reference

class ScrollArea brief A Container that provides scrolling to a single child. More...

#include <ScrollArea.h>

Inheritance diagram for rose::ScrollArea:
Inheritance graph
[legend]
Collaboration diagram for rose::ScrollArea:
Collaboration graph
[legend]

Public Member Functions

 ScrollArea ()
 Constructor.
 
void scrollIndicatorsOff ()
 Timer callback to turn scroll indicators off.
 
void draw (sdl::Renderer &renderer, Rectangle parentRect) override
 See Widget::draw.
 
Rectangle widgetLayout (sdl::Renderer &renderer, Rectangle available, uint layoutStage) override
 Determine the desired size of the child widgets. More...
 
void setScrollOffset (Position scrollOffset)
 Set the scroll offset of the ScrollArea. More...
 
std::shared_ptr< WidgetfindWidget (const Position &pos) override
 Find the Widget which uniquely contains the position. More...
 
Position getScrollOffset () const
 Get the current scroll offset of the ScrollArea. More...
 
bool mouseEnterEvent (const Position &p, bool enter) override
 Handle a mouse enter event.
 
bool mouseButtonEvent (const Position &mousePos, int button, bool down, int modifiers) override
 Handle a mouse button event (default implementation: propagate to children)
 
bool mouseMotionEvent (const Position &cursorPosition, const Position &rel, int button, int modifiers) override
 Handle a mouse motion event (default implementation: propagate to children)
 
bool mouseDragEvent (const Position &mousePos, const Position &rel, int button, int modifiers) override
 Handle a mouse drag event (default implementation: do nothing)
 
bool scrollEvent (const Position &mousePos, int32_t x, int32_t y) override
 Handle a mouse scroll event (default implementation: propagate to children)
 
bool keyboardCharacterEvent (unsigned int codepoint) override
 Handle text input (UTF-32 format) (default implementation: do nothing)
 

Static Public Member Functions

static Uint32 TimerCallbackStub (Uint32 interval, void *param)
 The SDL_Timer callback. More...
 

Protected Member Functions

sdl::Texture generateScrollIndicator (sdl::Renderer &renderer, Size indicatorSize)
 Generate a scroll indicator.
 
void startTimer ()
 Start the time to hid the scroll indicators.
 

Protected Attributes

std::optional< SDL_TimerID > sdlTimerId {}
 Timer to turn off scroll indicators.
 
int mIndWidth {10}
 The width of the indicator bars.
 
Position mScrollOffset
 The current scroll offset.
 
uint32_t mLastScrollTick
 Used to track how fast the scroll wheel is turning.
 
sdl::Texture mHorizontalInd {}
 An indicator of the position of the Horizontal Scroll.
 
sdl::Texture mVerticalInd {}
 An indicator of the position of the Vertical Scroll.
 
Size mHorIndSize {}
 The size of the horizontal indicator.
 
Size mVerIndSize {}
 The size of the vertical indicator.
 
float mRatioX {}
 The horizontal ratio.
 
float mRatioY {}
 The vertical ratio.
 
bool mShowHorInd {}
 If True, display the horizontal scroll indicator.
 
bool mShowVerInd {}
 If True, display the vertical scroll indicator.
 

Static Protected Attributes

static constexpr int MaximumChildSize = 4096
 The maximum width and height of a widget behind a ScrollArea.
 

Detailed Description

class ScrollArea brief A Container that provides scrolling to a single child.

Member Function Documentation

◆ findWidget()

std::shared_ptr< Widget > rose::ScrollArea::findWidget ( const Position pos)
override

Find the Widget which uniquely contains the position.

This version translates positions across scrolled boundaries.

Parameters
posthe position the Widget must contain.
Returns
A reference to the Widget found, if any.

◆ getScrollOffset()

Position rose::ScrollArea::getScrollOffset ( ) const
inline

Get the current scroll offset of the ScrollArea.

Returns
the scroll offset position.

◆ setScrollOffset()

void rose::ScrollArea::setScrollOffset ( Position  scrollOffset)
inline

Set the scroll offset of the ScrollArea.

Parameters
scrollOffsetthe offset position.

◆ TimerCallbackStub()

static Uint32 rose::ScrollArea::TimerCallbackStub ( Uint32  interval,
void *  param 
)
inlinestatic

The SDL_Timer callback.

Parameters
intervalThe timer interval in milliseconds.
paramA pointer to the ScrollArea
Returns
the interval.

◆ widgetLayout()

Rectangle rose::ScrollArea::widgetLayout ( sdl::Renderer renderer,
Rectangle  available,
uint  layoutStage 
)
override

Determine the desired size of the child widgets.

If not overridden the default is to call widgetLayout() for each child and return the current value of mSize of the Container.

Parameters
rendererThe Renderer to use
availableThe Rectangle available to layout in.
Returns

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