Skip to content
This repository was archived by the owner on Dec 27, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ public class ConstraintWidget {
private boolean OPTIMIZE_WRAP = false;
private boolean OPTIMIZE_WRAP_ON_RESOLVED = true;

private int mWidthOverride = -1;
private int mHeightOverride = -1;

public WidgetRun getRun(int orientation) {
if (orientation == HORIZONTAL) {
return horizontalRun;
Expand Down Expand Up @@ -513,6 +516,8 @@ public void reset() {
mMeasureRequested = true;
mResolvedMatchConstraintDefault[HORIZONTAL] = 0;
mResolvedMatchConstraintDefault[VERTICAL] = 0;
mWidthOverride = -1;
mHeightOverride = -1;
}

public int horizontalGroup = -1;
Expand All @@ -533,6 +538,10 @@ public boolean oppositeDimensionsTied() {
&& mListDimensionBehaviors[VERTICAL] == MATCH_CONSTRAINT);
}

public boolean hasDimensionOverride() {
return mWidthOverride != -1 || mHeightOverride != -1;
}

/*-----------------------------------------------------------------------*/
// Creation
/*-----------------------------------------------------------------------*/
Expand Down Expand Up @@ -1435,6 +1444,18 @@ public void setFrame(int left, int top, int right, int bottom) {
if (mWidth < mMinWidth) {
mWidth = mMinWidth;
}
if (mMatchConstraintMaxWidth > 0 && mListDimensionBehaviors[HORIZONTAL] == MATCH_CONSTRAINT) {
mWidth = Math.min(mWidth, mMatchConstraintMaxWidth);
}
if (mMatchConstraintMaxHeight > 0 && mListDimensionBehaviors[VERTICAL] == MATCH_CONSTRAINT) {
mHeight = Math.min(mHeight, mMatchConstraintMaxHeight);
}
if (w != mWidth) {
mWidthOverride = mWidth;
}
if (h != mHeight) {
mHeightOverride = mHeight;
}

if (LinearSystem.FULL_DEBUG) {
System.out.println("update from solver " + mDebugName + " " + mX + ":" + mY + " - " + mWidth + " x " + mHeight);
Expand Down Expand Up @@ -2694,6 +2715,24 @@ private void applyConstraints(LinearSystem system, boolean isHorizontal,
break;
}


if (mWidthOverride != -1 && isHorizontal) {
if (FULL_DEBUG) {
System.out.println("OVERRIDE WIDTH to " + mWidthOverride);
}
variableSize = false;
dimension = mWidthOverride;
mWidthOverride = -1;
}
if (mHeightOverride != -1 && !isHorizontal) {
if (FULL_DEBUG) {
System.out.println("OVERRIDE HEIGHT to " + mHeightOverride);
}
variableSize = false;
dimension = mHeightOverride;
mHeightOverride = -1;
}

if (mVisibility == ConstraintWidget.GONE) {
dimension = 0;
variableSize = false;
Expand Down Expand Up @@ -2783,7 +2822,9 @@ private void applyConstraints(LinearSystem system, boolean isHorizontal,
percentEnd = system.createObjectVariable(mParent.getAnchor(ConstraintAnchor.Type.RIGHT));
}
system.addConstraint(system.createRow().createRowDimensionRatio(end, begin, percentEnd, percentBegin, matchPercentDimension));
variableSize = false;
if (parentWrapContent) {
variableSize = false;
}
} else {
isTerminal = true;
}
Expand Down Expand Up @@ -2884,6 +2925,15 @@ private void applyConstraints(LinearSystem system, boolean isHorizontal,
if (beginWidget instanceof Barrier || endWidget instanceof Barrier) {
boundsCheckStrength = SolverVariable.STRENGTH_HIGHEST;
}
} else if (matchConstraintDefault == MATCH_CONSTRAINT_PERCENT) {
applyCentering = true;
rangeCheckStrength = SolverVariable.STRENGTH_EQUALITY;
boundsCheckStrength = SolverVariable.STRENGTH_EQUALITY;
applyBoundsCheck = true;
applyRangeCheck = true;
if (beginWidget instanceof Barrier || endWidget instanceof Barrier) {
boundsCheckStrength = SolverVariable.STRENGTH_HIGHEST;
}
} else if (matchConstraintDefault == MATCH_CONSTRAINT_WRAP) {
applyCentering = true;
applyRangeCheck = true;
Expand Down Expand Up @@ -2975,6 +3025,7 @@ private void applyConstraints(LinearSystem system, boolean isHorizontal,
applyBoundsCheck = false;
parentWrapContent = false;
}

system.addCentering(begin, beginTarget, beginAnchor.getMargin(),
bias, endTarget, end, endAnchor.getMargin(), centeringStrength);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -419,15 +419,20 @@ public boolean addChildrenToSolver(LinearSystem system) {
*
* @param system the solver we get the values from.
*/
public void updateChildrenFromSolver(LinearSystem system, boolean flags[]) {
public boolean updateChildrenFromSolver(LinearSystem system, boolean flags[]) {
flags[Optimizer.FLAG_RECOMPUTE_BOUNDS] = false;
boolean optimize = optimizeFor(Optimizer.OPTIMIZATION_GRAPH);
updateFromSolver(system, optimize);
final int count = mChildren.size();
boolean hasOverride = false;
for (int i = 0; i < count; i++) {
ConstraintWidget widget = mChildren.get(i);
widget.updateFromSolver(system, optimize);
if (widget.hasDimensionOverride()) {
hasOverride = true;
}
}
return hasOverride;
}

@Override
Expand Down Expand Up @@ -802,15 +807,15 @@ public void layout() {
System.out.println("EXCEPTION : " + e);
}
if (needsSolving) {
updateChildrenFromSolver(mSystem, Optimizer.flags);
needsSolving = updateChildrenFromSolver(mSystem, Optimizer.flags);
} else {
updateFromSolver(mSystem, optimize);
for (int i = 0; i < count; i++) {
ConstraintWidget widget = mChildren.get(i);
widget.updateFromSolver(mSystem, optimize);
}
needsSolving = false;
}
needsSolving = false;

if (hasWrapContent && countSolve < MAX_ITERATIONS
&& Optimizer.flags[Optimizer.FLAG_RECOMPUTE_BOUNDS]) {
Expand Down
23 changes: 23 additions & 0 deletions desktop/ValidationTool/references/check_417_MATCH_MATCH.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"duration": "128000",
"layout": {
"children": [{
"bounds": {
"top": "648",
"left": "315",
"bottom": "889",
"right": "765"
},
"id": "textview1",
"class": "MaterialTextView"
}],
"bounds": {
"top": "0",
"left": "0",
"bottom": "1536",
"right": "1080"
},
"id": "root",
"class": "ConstraintLayout"
}
}
23 changes: 23 additions & 0 deletions desktop/ValidationTool/references/check_417_MATCH_WRAP.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"duration": "178000",
"layout": {
"children": [{
"bounds": {
"top": "0",
"left": "315",
"bottom": "241",
"right": "765"
},
"id": "textview1",
"class": "MaterialTextView"
}],
"bounds": {
"top": "0",
"left": "0",
"bottom": "241",
"right": "1080"
},
"id": "root",
"class": "ConstraintLayout"
}
}
23 changes: 23 additions & 0 deletions desktop/ValidationTool/references/check_417_WRAP_MATCH.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"duration": "176000",
"layout": {
"children": [{
"bounds": {
"top": "88",
"left": "0",
"bottom": "1449",
"right": "0"
},
"id": "textview1",
"class": "MaterialTextView"
}],
"bounds": {
"top": "0",
"left": "0",
"bottom": "1536",
"right": "0"
},
"id": "root",
"class": "ConstraintLayout"
}
}
23 changes: 23 additions & 0 deletions desktop/ValidationTool/references/check_417_WRAP_WRAP.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"duration": "221000",
"layout": {
"children": [{
"bounds": {
"top": "0",
"left": "0",
"bottom": "1361",
"right": "0"
},
"id": "textview1",
"class": "MaterialTextView"
}],
"bounds": {
"top": "0",
"left": "0",
"bottom": "1361",
"right": "0"
},
"id": "root",
"class": "ConstraintLayout"
}
}
35 changes: 35 additions & 0 deletions desktop/ValidationTool/references/check_418_MATCH_MATCH.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"duration": "255000",
"layout": {
"children": [
{
"bounds": {
"top": "591",
"left": "500",
"bottom": "648",
"right": "581"
},
"id": "title",
"class": "MaterialTextView"
},
{
"bounds": {
"top": "648",
"left": "315",
"bottom": "889",
"right": "765"
},
"id": "text",
"class": "MaterialTextView"
}
],
"bounds": {
"top": "0",
"left": "0",
"bottom": "1536",
"right": "1080"
},
"id": "root",
"class": "ConstraintLayout"
}
}
35 changes: 35 additions & 0 deletions desktop/ValidationTool/references/check_418_MATCH_WRAP.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"duration": "760500",
"layout": {
"children": [
{
"bounds": {
"top": "0",
"left": "500",
"bottom": "57",
"right": "581"
},
"id": "title",
"class": "MaterialTextView"
},
{
"bounds": {
"top": "57",
"left": "315",
"bottom": "298",
"right": "765"
},
"id": "text",
"class": "MaterialTextView"
}
],
"bounds": {
"top": "0",
"left": "0",
"bottom": "355",
"right": "1080"
},
"id": "root",
"class": "ConstraintLayout"
}
}
35 changes: 35 additions & 0 deletions desktop/ValidationTool/references/check_418_WRAP_MATCH.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"duration": "603000",
"layout": {
"children": [
{
"bounds": {
"top": "199",
"left": "41",
"bottom": "256",
"right": "122"
},
"id": "title",
"class": "MaterialTextView"
},
{
"bounds": {
"top": "256",
"left": "41",
"bottom": "1281",
"right": "122"
},
"id": "text",
"class": "MaterialTextView"
}
],
"bounds": {
"top": "0",
"left": "0",
"bottom": "1536",
"right": "162"
},
"id": "root",
"class": "ConstraintLayout"
}
}
35 changes: 35 additions & 0 deletions desktop/ValidationTool/references/check_418_WRAP_WRAP.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"duration": "577500",
"layout": {
"children": [
{
"bounds": {
"top": "0",
"left": "41",
"bottom": "57",
"right": "122"
},
"id": "title",
"class": "MaterialTextView"
},
{
"bounds": {
"top": "57",
"left": "41",
"bottom": "1082",
"right": "122"
},
"id": "text",
"class": "MaterialTextView"
}
],
"bounds": {
"top": "0",
"left": "0",
"bottom": "1139",
"right": "162"
},
"id": "root",
"class": "ConstraintLayout"
}
}
Loading