mirror of
https://github.com/rive-app/rive-cpp.git
synced 2026-01-18 21:21:17 +01:00
First steps towards supporting artboard resizing in our runtimes. This PR includes: - New Fit type `autoResizeArtboard`. After a bit of back and forth, I think this keeps the API simple. - ScaleFactor which represents a scale value to scale the artboard by in addition to resizing (only applies with `autoResizeArtboard`). This may be useful because an artboard is created at a specific width/height, but it may be deployed to platforms where it is rendered to a much smaller or larger surface/texture. Currently the default is 1.0 (no scale), however, an alternative is to have it default to something like textureSize / artboardSize so we sort of auto normalize it. - Implemented on iOS. Once this is finalzed, we can work with DevRels to implement across all runtimes. - TODO : Bubble up an event when the artboard size is changed internally by the .riv https://github.com/user-attachments/assets/20e9fdda-5c3e-4f3f-b2f5-104ff0291fbe Diffs= e71b4cc081 feat: add runtime layout fit type for ios, android, web (#8341) Co-authored-by: CI <pggordonhayes@gmail.com> Co-authored-by: David Skuza <david@rive.app> Co-authored-by: Philip Chung <philterdesign@gmail.com>
41 lines
804 B
C++
41 lines
804 B
C++
#ifndef _RIVE_LAYOUT_HPP_
|
|
#define _RIVE_LAYOUT_HPP_
|
|
namespace rive
|
|
{
|
|
enum class Fit : unsigned char
|
|
{
|
|
fill,
|
|
contain,
|
|
cover,
|
|
fitWidth,
|
|
fitHeight,
|
|
none,
|
|
scaleDown,
|
|
layout
|
|
};
|
|
|
|
class Alignment
|
|
{
|
|
public:
|
|
Alignment(float x, float y) : m_x(x), m_y(y) {}
|
|
Alignment() : m_x(0.0f), m_y(0.0f) {}
|
|
|
|
float x() const { return m_x; }
|
|
float y() const { return m_y; }
|
|
|
|
static const Alignment topLeft;
|
|
static const Alignment topCenter;
|
|
static const Alignment topRight;
|
|
static const Alignment centerLeft;
|
|
static const Alignment center;
|
|
static const Alignment centerRight;
|
|
static const Alignment bottomLeft;
|
|
static const Alignment bottomCenter;
|
|
static const Alignment bottomRight;
|
|
|
|
private:
|
|
float m_x, m_y;
|
|
};
|
|
|
|
} // namespace rive
|
|
#endif |