|
| virtual | ~Positionable () |
| void | anchorBottomInWindow (float margin=0.f) |
| void | anchorLeftInWindow (float margin=0.f) |
| void | anchorRightInWindow (float margin=0.f) |
| void | anchorTopInWindow (float margin=0.f) |
| Animate & | animate () |
| | Access this object's animation controller.
|
| template<class T> |
| void | center (T &obj) |
| | Center this object within obj (both axes).
|
| template<class T> |
| void | centerHorizonally (T &obj) |
| | Center this object horizontally within obj.
|
| void | centerInWindow () |
| | Center this object within the window (retained; re-solves on resize).
|
| void | centerText (sf::Text &obj) |
| | Center an sf::Text object within this object's bounds.
|
| template<class T> |
| void | centerVertically (T &obj) |
| | Center this object vertically within obj.
|
| void | centerXInWindow (float offset=0.f) |
| | Center this object horizontally within the window, plus offset px (retained).
|
| void | centerYInWindow (float offset=0.f) |
| | Center this object vertically within the window, plus offset px (retained).
|
| virtual sf::FloatRect | getGlobalBounds () const |
| | Return the axis-aligned bounding box in world space.
|
| virtual sf::Vector2f | getPosition () const |
| | Return the current world-space position.
|
| template<class T> |
| void | setAbove (T &obj, float spacing=0) |
| | Position this object immediately above obj.
|
| template<class T> |
| void | setBelow (T &obj, float spacing=0) |
| | Position this object immediately below obj.
|
| template<class T> |
| void | setLeftOf (T &obj, float spacing=0) |
| | Position this object immediately to the left of obj.
|
| virtual void | setPosition (const sf::Vector2f &position) |
| | Set the world-space position immediately (no animation).
|
| template<class T> |
| void | setRightOf (T &obj, float spacing=0) |
| | Position this object immediately to the right of obj.
|
| void | unanchored () |
| | Drop every retained anchor on this object, freezing its current place.
|
Trait that provides position, bounds, and animated movement.
Positionable is one of the three core traits on every ml::Core object. It serves two purposes:
- Spatial contract — declares the pure virtual
setPosition, getPosition, and getGlobalBounds methods that the rest of the framework (hit-testing, layout, drag) depend on.
- Animated movement — provides
moveTo and moveDistance for tweened position animation, with support for axis locking, easing curves, and a configurable framerate target.
Immediate positioning
myRect.setPosition({100.f, 200.f});
Vector2< float > Vector2f
Animated movement
myRect.moveTo({400.f, 300.f}, 0.5f);
myRect.moveDistance({50.f, 0.f});
if (myRect.isScrolling()) { ... }
Relative layout helpers
labelB.setRightOf(labelA, 10.f);
button.setBelow(header, 20.f);
icon.center(panel);
icon.centerHorizonally(panel);
- See also
- Draggable, CoreAdapter, Component
Definition at line 66 of file Positionable.h.
| virtual sf::FloatRect ml::Positionable::getGlobalBounds |
( |
| ) |
const |
|
inlinevirtual |
Return the axis-aligned bounding box in world space.
Used by AppManager for hit-testing (click, hover) and by layout helpers for relative placement. Returns a zero-size rect by default, opting the component out of event routing.
- Returns
- Bounding rectangle in world coordinates.
Reimplemented in ml::ColorButton, ml::ColorPicker, ml::ContextMenu, ml::CoreAdapter, ml::DrawableWrapper< ENTITY >, ml::GradientColorPicker, ml::Graphic< T >, ml::Graphic< ml::RoundedRectangle >, ml::Graphic< sf::CircleShape >, ml::Graphic< sf::ConvexShape >, ml::Graphic< sf::RectangleShape >, ml::Graphic< sf::Sprite >, ml::Graphic< sf::Text >, ml::Grid, and ml::InfoButton.
Definition at line 136 of file Positionable.h.