mirror of
https://github.com/AngelAuraMC/Amethyst-Android.git
synced 2025-09-17 08:35:37 -04:00
Added margins when snapping
This commit is contained in:
parent
4a48cbd249
commit
4eb3350865
@ -402,9 +402,9 @@ public class ControlButton extends androidx.appcompat.widget.AppCompatButton imp
|
|||||||
|
|
||||||
//Step 3: For each axis, we try to snap to the nearest
|
//Step 3: For each axis, we try to snap to the nearest
|
||||||
if(Math.abs(top - button_bottom) < MIN_DISTANCE){ // Bottom snap
|
if(Math.abs(top - button_bottom) < MIN_DISTANCE){ // Bottom snap
|
||||||
dynamicY = applySize(button.getProperties().dynamicY, button) + applySize(" + ${height}", button) ;
|
dynamicY = applySize(button.getProperties().dynamicY, button) + applySize(" + ${height}", button) + " + ${margin}" ;
|
||||||
}else if(Math.abs(button_top - bottom) < MIN_DISTANCE){ //Top snap
|
}else if(Math.abs(button_top - bottom) < MIN_DISTANCE){ //Top snap
|
||||||
dynamicY = applySize(button.getProperties().dynamicY, button) + " - ${height}";
|
dynamicY = applySize(button.getProperties().dynamicY, button) + " - ${height} - ${margin}";
|
||||||
}
|
}
|
||||||
if(!dynamicY.equals(generateDynamicY(getY()))){ //If we snapped
|
if(!dynamicY.equals(generateDynamicY(getY()))){ //If we snapped
|
||||||
if(Math.abs(button_left - left) < MIN_DISTANCE){ //Left align snap
|
if(Math.abs(button_left - left) < MIN_DISTANCE){ //Left align snap
|
||||||
@ -415,9 +415,9 @@ public class ControlButton extends androidx.appcompat.widget.AppCompatButton imp
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(Math.abs(button_left - right) < MIN_DISTANCE){ //Left snap
|
if(Math.abs(button_left - right) < MIN_DISTANCE){ //Left snap
|
||||||
dynamicX = applySize(button.getProperties().dynamicX, button) + " - ${width}";
|
dynamicX = applySize(button.getProperties().dynamicX, button) + " - ${width} - ${margin}";
|
||||||
}else if(Math.abs(left - button_right) < MIN_DISTANCE){ //Right snap
|
}else if(Math.abs(left - button_right) < MIN_DISTANCE){ //Right snap
|
||||||
dynamicX = applySize(button.getProperties().dynamicX, button) + applySize(" + ${width}", button);
|
dynamicX = applySize(button.getProperties().dynamicX, button) + applySize(" + ${width}", button) + " + ${margin}";
|
||||||
}
|
}
|
||||||
if(!dynamicX.equals(generateDynamicX(getX()))){ //If we snapped
|
if(!dynamicX.equals(generateDynamicX(getX()))){ //If we snapped
|
||||||
if(Math.abs(button_top - top) < MIN_DISTANCE){ //Top align snap
|
if(Math.abs(button_top - top) < MIN_DISTANCE){ //Top align snap
|
||||||
@ -434,10 +434,13 @@ public class ControlButton extends androidx.appcompat.widget.AppCompatButton imp
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Do a pre-conversion of an equation using values from a button,
|
||||||
|
* so the variables can be used for another button
|
||||||
*
|
*
|
||||||
* @param equation
|
* Internal use only.
|
||||||
* @param button
|
* @param equation The dynamic position as a String
|
||||||
* @return
|
* @param button The button to get the values from.
|
||||||
|
* @return The pre-processed equation as a String.
|
||||||
*/
|
*/
|
||||||
private static String applySize(String equation, ControlButton button){
|
private static String applySize(String equation, ControlButton button){
|
||||||
return equation
|
return equation
|
||||||
|
Loading…
x
Reference in New Issue
Block a user