A scrollable list of UI buttons.
More...
#include <ScrollList.h>
|
| ScrollList (float width, float height, float buttonWidth, float buttonHeight) |
| Constructs a ScrollList with specified dimensions and button sizes.
|
|
| ScrollList (const ScrollList &)=delete |
|
ScrollList & | operator= (const ScrollList &)=delete |
|
void | AddButton (const std::string &label, UICommand *onPressCommand) |
| Adds a button to the scroll list.
|
|
Button * | GetButton (size_t index) const |
| Gets the specified button.
|
|
size_t | GetButtonCount () const |
| Gets the number of buttons in the scroll list.
|
|
void | SetPosition (float x, float y) |
| Sets the position of the scroll list.
|
|
void | Scroll (float offset) |
| Scrolls the list by a given offset (typically in response to mouse wheel input).
|
|
void | SetScrollSpeed (float speed) |
| Sets the scroll speed for the list.
|
|
virtual | ~UIComponent ()=default |
| Virtual destructor.
|
|
int | GetLayer () const |
| Gets the rendering layer of the component.
|
|
virtual void | SetLayer (int layer) |
| Sets the rendering layer of the component.
|
|
UIComponentType | GetType () const |
| Gets the type of the UI component.
|
|
bool | IsEnabled () const |
| Returns whether the component is enabled or not.
|
|
void | SetEnabled (bool enabled) |
| Sets the enabled state of the component.
|
|
void | SetOwningCanvas (Canvas *canvas) |
| Gets the owning canvas of the component.
|
|
|
void | Render () override |
| Renders the scroll list and its buttons.
|
|
void | OnPress () override |
| Handles press events on the scroll list (not typically used).
|
|
bool | IsMouseOver (float x, float y) override |
| Checks if the mouse is over the scroll list.
|
|
void | UpdateButtonPositions () |
| Updates the positions of the buttons based on the current scroll offset.
|
|
|
SUNENGINESprite * | pSprite |
| Background sprite for the scroll list.
|
|
std::vector< Button * > | buttons |
| List of buttons in the scroll list.
|
|
float | width |
| Width of the scroll list.
|
|
float | height |
| Height of the scroll list.
|
|
float | buttonWidth |
| Width of each button.
|
|
float | buttonHeight |
| Height of each button.
|
|
float | scrollOffset |
| Current scroll offset.
|
|
float | posX |
| X-coordinate of the scroll list's position.
|
|
float | posY |
| Y-coordinate of the scroll list's position.
|
|
float | scrollSpeed |
| Speed of scrolling (multiplier for scroll offset)
|
|
|
bool | Enabled = true |
| Indicates if the component is enabled or not.
|
|
int | Layer = 0 |
| Rendering layer in.
|
|
UIComponentType | Type = UIComponentType::None |
| Type of the UI component.
|
|
Canvas * | pOwningCanvas = nullptr |
| Pointer to the owning canvas, if any.
|
|
A scrollable list of UI buttons.
The ScrollList class provides a vertical list of buttons that can be scrolled if the content exceeds the visible area. It is useful for displaying selectable options, menus, or lists within a UI. Each button can have its own label and command. The ScrollList handles rendering only the visible buttons and manages their positions as the user scrolls.
Example usage:
list->
AddButton(
"Option 1",
new MyCommand());
canvas->AddComponent(list);
- See also
- Button, Canvas, UICommand
◆ ScrollList()
ScrollList::ScrollList |
( |
float | width, |
|
|
float | height, |
|
|
float | buttonWidth, |
|
|
float | buttonHeight ) |
Constructs a ScrollList with specified dimensions and button sizes.
- Parameters
-
width | The width of the scroll list in pixels. |
height | The height of the scroll list in pixels. |
buttonWidth | The width of each button in pixels. |
buttonHeight | The height of each button in pixels. |
◆ AddButton()
void ScrollList::AddButton |
( |
const std::string & | label, |
|
|
UICommand * | onPressCommand ) |
Adds a button to the scroll list.
- Parameters
-
label | The label for the button. |
onPressCommand | The command to execute when the button is pressed. |
◆ GetButton()
Button * ScrollList::GetButton |
( |
size_t | index | ) |
const |
Gets the specified button.
- Returns
- The button at the given index.
◆ GetButtonCount()
size_t ScrollList::GetButtonCount |
( |
| ) |
const |
Gets the number of buttons in the scroll list.
- Returns
- The count of buttons in the scroll list.
◆ IsMouseOver()
bool ScrollList::IsMouseOver |
( |
float | x, |
|
|
float | y ) |
|
overrideprivatevirtual |
Checks if the mouse is over the scroll list.
- Parameters
-
x | The x-coordinate of the mouse position. |
y | The y-coordinate of the mouse position. |
- Returns
- True if the mouse is over the scroll list, false otherwise.
Implements UIComponent.
◆ OnPress()
void ScrollList::OnPress |
( |
| ) |
|
|
overrideprivatevirtual |
Handles press events on the scroll list (not typically used).
Implements UIComponent.
◆ Render()
void ScrollList::Render |
( |
| ) |
|
|
overrideprivatevirtual |
Renders the scroll list and its buttons.
Implements UIComponent.
◆ Scroll()
void ScrollList::Scroll |
( |
float | offset | ) |
|
Scrolls the list by a given offset (typically in response to mouse wheel input).
- Parameters
-
offset | The scroll offset; positive or negative to scroll up or down. |
◆ SetPosition()
void ScrollList::SetPosition |
( |
float | x, |
|
|
float | y ) |
Sets the position of the scroll list.
- Parameters
-
x | The x-coordinate of the scroll list's position. |
y | The y-coordinate of the scroll list's position. |
◆ SetScrollSpeed()
void ScrollList::SetScrollSpeed |
( |
float | speed | ) |
|
Sets the scroll speed for the list.
- Parameters
-
speed | The scroll speed multiplier. |
The documentation for this class was generated from the following files: