UI: Allow negative left/right for anchor layouts.

This commit is contained in:
Unknown W. Brackets 2017-12-10 14:08:20 -08:00
parent 6783394ae1
commit 753e59c027
2 changed files with 8 additions and 9 deletions

View File

@ -994,10 +994,10 @@ void AnchorLayout::Measure(const UIContext &dc, MeasureSpec horiz, MeasureSpec v
height = params->height;
if (!params->center) {
if (params->left >= 0 && params->right >= 0) {
if (params->left > NONE && params->right > NONE) {
width = measuredWidth_ - params->left - params->right;
}
if (params->top >= 0 && params->bottom >= 0) {
if (params->top > NONE && params->bottom > NONE) {
height = measuredHeight_ - params->top - params->bottom;
}
}
@ -1034,22 +1034,22 @@ void AnchorLayout::Layout() {
center = params->center;
}
if (left >= 0) {
if (left > NONE) {
vBounds.x = bounds_.x + left;
if (center)
vBounds.x -= vBounds.w * 0.5f;
} else if (right >= 0) {
} else if (right > NONE) {
vBounds.x = bounds_.x2() - right - vBounds.w;
if (center) {
vBounds.x += vBounds.w * 0.5f;
}
}
if (top >= 0) {
if (top > NONE) {
vBounds.y = bounds_.y + top;
if (center)
vBounds.y -= vBounds.h * 0.5f;
} else if (bottom >= 0) {
} else if (bottom > NONE) {
vBounds.y = bounds_.y2() - bottom - vBounds.h;
if (center)
vBounds.y += vBounds.h * 0.5f;

View File

@ -1,5 +1,6 @@
#pragma once
#include <cfloat>
#include <vector>
#include <set>
#include <mutex>
@ -95,9 +96,7 @@ public:
void Layout() override;
};
enum {
NONE = -1,
};
const float NONE = -FLT_MAX;
class AnchorLayoutParams : public LayoutParams {
public: