Permalink
Browse files

UI: Allow negative left/right for anchor layouts.

  • Loading branch information...
unknownbrackets committed Dec 10, 2017
1 parent 6783394 commit 753e59c0273fdbbcf095518e81fd1f013f082712
Showing with 8 additions and 9 deletions.
  1. +6 −6 ext/native/ui/viewgroup.cpp
  2. +2 −3 ext/native/ui/viewgroup.h
@@ -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;
@@ -1,5 +1,6 @@
#pragma once
#include <cfloat>
#include <vector>
#include <set>
#include <mutex>
@@ -95,9 +96,7 @@ class FrameLayout : public ViewGroup {
void Layout() override;
};
enum {
NONE = -1,
};
const float NONE = -FLT_MAX;
class AnchorLayoutParams : public LayoutParams {
public:

0 comments on commit 753e59c

Please sign in to comment.