mirror of
https://github.com/geode-sdk/geode.git
synced 2025-03-13 22:49:52 -04:00
add support for overriding cross axis line alignment on AxisLayout nodes
This commit is contained in:
parent
56839119f0
commit
6995e8d4c5
2 changed files with 22 additions and 1 deletions
|
@ -120,6 +120,7 @@ public:
|
|||
bool getBreakLine() const;
|
||||
bool getSameLine() const;
|
||||
int getScalePriority() const;
|
||||
std::optional<AxisAlignment> getCrossAxisAlignment() const;
|
||||
|
||||
/**
|
||||
* Set the maximum scale this node can be if it's contained in an
|
||||
|
@ -192,6 +193,11 @@ public:
|
|||
* each other with no gaps
|
||||
*/
|
||||
AxisLayoutOptions* setScalePriority(int priority);
|
||||
|
||||
/**
|
||||
* Override the cross axis alignment for this node in the layout
|
||||
*/
|
||||
AxisLayoutOptions* setCrossAxisAlignment(std::optional<AxisAlignment> alignment);
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -84,6 +84,13 @@ static float scaleByOpts(
|
|||
}
|
||||
}
|
||||
|
||||
static AxisAlignment optsCrossAxisAlign(AxisLayoutOptions const* opts, AxisAlignment def) {
|
||||
if (opts && opts->getCrossAxisAlignment()) {
|
||||
return *opts->getCrossAxisAlignment();
|
||||
}
|
||||
return def;
|
||||
}
|
||||
|
||||
struct AxisPosition {
|
||||
float axisLength;
|
||||
float axisAnchor;
|
||||
|
@ -671,7 +678,7 @@ public:
|
|||
row->axisEndsLength * row->scale * (1.f - row->squish) * 1.f / nodes->count();
|
||||
}
|
||||
float crossOffset;
|
||||
switch (m_crossLineAlignment) {
|
||||
switch (optsCrossAxisAlign(opts, m_crossLineAlignment)) {
|
||||
case AxisAlignment::Start: {
|
||||
crossOffset = pos.crossLength * pos.crossAnchor;
|
||||
} break;
|
||||
|
@ -931,6 +938,7 @@ public:
|
|||
bool m_breakLine = false;
|
||||
bool m_sameLine = false;
|
||||
int m_scalePriority = AXISLAYOUT_DEFAULT_PRIORITY;
|
||||
std::optional<AxisAlignment> m_crossAxisAlignment;
|
||||
};
|
||||
|
||||
AxisLayoutOptions* AxisLayoutOptions::create() {
|
||||
|
@ -978,6 +986,9 @@ bool AxisLayoutOptions::getSameLine() const {
|
|||
int AxisLayoutOptions::getScalePriority() const {
|
||||
return m_impl->m_scalePriority;
|
||||
}
|
||||
std::optional<AxisAlignment> AxisLayoutOptions::getCrossAxisAlignment() const {
|
||||
return m_impl->m_crossAxisAlignment;
|
||||
}
|
||||
|
||||
AxisLayoutOptions* AxisLayoutOptions::setMaxScale(float scale) {
|
||||
m_impl->m_scaleLimits.second = scale;
|
||||
|
@ -1023,3 +1034,7 @@ AxisLayoutOptions* AxisLayoutOptions::setScalePriority(int priority) {
|
|||
m_impl->m_scalePriority = priority;
|
||||
return this;
|
||||
}
|
||||
AxisLayoutOptions* AxisLayoutOptions::setCrossAxisAlignment(std::optional<AxisAlignment> alignment) {
|
||||
m_impl->m_crossAxisAlignment = alignment;
|
||||
return this;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue