A grid of captioned image thumbnails from which exactly one is selectable — a Zoom-style "what do you want to share?" picker. More...
#include <Malena/Graphics/Controls/ThumbnailPicker.h>
Public Types | |
| using | Flag = ThumbnailPickerManifest::Flag |
Public Member Functions | |
| ThumbnailPicker (const sf::Font &font=FontManager<>::getDefault()) | |
| ThumbnailPicker (const ThumbnailPicker &)=delete | |
| void | addThumbnail (const sf::Image &image, const std::string &caption) |
| void | clear () |
| int | count () const |
| sf::FloatRect | getGlobalBounds () const override |
| sf::Vector2f | getPosition () const override |
| int | getSelectedIndex () const |
| void | onSelectionChanged (std::function< void(int)> cb) |
| ThumbnailPicker & | operator= (const ThumbnailPicker &)=delete |
| void | setActive (bool active) |
| void | setColumns (int columns) |
| void | setPosition (const sf::Vector2f &position) override |
| void | setSelectedIndex (int index) |
| void | setTileSize (float w, float h) |
Protected Member Functions | |
| void | draw (sf::RenderTarget &target, sf::RenderStates states) const override |
A grid of captioned image thumbnails from which exactly one is selectable — a Zoom-style "what do you want to share?" picker.
Self-contained: it owns each thumbnail's sf::Texture, lays the tiles out in a grid, draws them with a caption and a highlight on the selected tile, and resolves clicks itself by hit-testing the tile rectangles against the mouse (the same approach Modal uses), so it needs no child components.
Designed to be handed to a Modal as its content (it is window-centred and drawn by the modal). Call setActive(true) while the modal is up so clicks are interpreted, and read getSelectedIndex() on confirm.
Definition at line 52 of file ThumbnailPicker.h.
Definition at line 55 of file ThumbnailPicker.h.
|
explicit |
|
delete |
| void ml::ThumbnailPicker::addThumbnail | ( | const sf::Image & | image, |
| const std::string & | caption ) |
| void ml::ThumbnailPicker::clear | ( | ) |
|
nodiscard |
|
overrideprotected |
|
override |
|
override |
|
nodiscard |
| void ml::ThumbnailPicker::onSelectionChanged | ( | std::function< void(int)> | cb | ) |
|
delete |
| void ml::ThumbnailPicker::setActive | ( | bool | active | ) |
While active the picker hit-tests clicks; set false when not shown.
| void ml::ThumbnailPicker::setColumns | ( | int | columns | ) |
|
override |
| void ml::ThumbnailPicker::setSelectedIndex | ( | int | index | ) |
| void ml::ThumbnailPicker::setTileSize | ( | float | w, |
| float | h ) |