[FEAT] manage a good display of the rectangle ==> next step is corecting the box
This commit is contained in:
parent
29ef90c1a3
commit
3bbe3afe23
@ -1155,7 +1155,7 @@ public class ModelWidget extends Container {
|
||||
final var simpleLabel = new Label("bottom-left");
|
||||
simpleLabel.setPropertyExpand(Vector2b.FALSE);
|
||||
simpleLabel.setPropertyFill(Vector2b.TRUE);
|
||||
simpleLabel.setPropertyMinSize(new Dimension2f(Vector2f.VALUE_16, Distance.PIXEL));
|
||||
simpleLabel.setPropertyMinSize(new Dimension2f(new Vector2f(100, 0), Distance.PIXEL));
|
||||
simpleLabel.setPropertyGravity(Gravity.LEFT);
|
||||
lineSizer.subWidgetAdd(simpleLabel);
|
||||
|
||||
@ -1164,6 +1164,9 @@ public class ModelWidget extends Container {
|
||||
spin.setPropertyFill(Vector2b.TRUE);
|
||||
spin.setPropertyValue((int) value.size().bottomLeft());
|
||||
lineSizer.subWidgetAdd(spin);
|
||||
final var spacer = new Spacer();
|
||||
spacer.setPropertyMinSize(new Dimension2f(new Vector2f(5, 0), Distance.PIXEL));
|
||||
lineSizer.subWidgetAdd(spacer);
|
||||
final var con = spin.signalValue.connect(newValue -> {
|
||||
try {
|
||||
final var oldValue = pojo.getValue(widget);
|
||||
@ -1188,7 +1191,7 @@ public class ModelWidget extends Container {
|
||||
final var simpleLabel = new Label("bottom-right");
|
||||
simpleLabel.setPropertyExpand(Vector2b.FALSE);
|
||||
simpleLabel.setPropertyFill(Vector2b.TRUE);
|
||||
simpleLabel.setPropertyMinSize(new Dimension2f(Vector2f.VALUE_16, Distance.PIXEL));
|
||||
simpleLabel.setPropertyMinSize(new Dimension2f(new Vector2f(100, 0), Distance.PIXEL));
|
||||
simpleLabel.setPropertyGravity(Gravity.LEFT);
|
||||
lineSizer.subWidgetAdd(simpleLabel);
|
||||
|
||||
@ -1197,6 +1200,9 @@ public class ModelWidget extends Container {
|
||||
spin.setPropertyFill(Vector2b.TRUE);
|
||||
spin.setPropertyValue((int) value.size().bottomRight());
|
||||
lineSizer.subWidgetAdd(spin);
|
||||
final var spacer = new Spacer();
|
||||
spacer.setPropertyMinSize(new Dimension2f(new Vector2f(5, 0), Distance.PIXEL));
|
||||
lineSizer.subWidgetAdd(spacer);
|
||||
final var con = spin.signalValue.connect(newValue -> {
|
||||
try {
|
||||
final var oldValue = pojo.getValue(widget);
|
||||
@ -1221,7 +1227,7 @@ public class ModelWidget extends Container {
|
||||
final var simpleLabel = new Label("top-right");
|
||||
simpleLabel.setPropertyExpand(Vector2b.FALSE);
|
||||
simpleLabel.setPropertyFill(Vector2b.TRUE);
|
||||
simpleLabel.setPropertyMinSize(new Dimension2f(Vector2f.VALUE_16, Distance.PIXEL));
|
||||
simpleLabel.setPropertyMinSize(new Dimension2f(new Vector2f(100, 0), Distance.PIXEL));
|
||||
simpleLabel.setPropertyGravity(Gravity.LEFT);
|
||||
lineSizer.subWidgetAdd(simpleLabel);
|
||||
|
||||
@ -1230,6 +1236,9 @@ public class ModelWidget extends Container {
|
||||
spin.setPropertyFill(Vector2b.TRUE);
|
||||
spin.setPropertyValue((int) value.size().topRight());
|
||||
lineSizer.subWidgetAdd(spin);
|
||||
final var spacer = new Spacer();
|
||||
spacer.setPropertyMinSize(new Dimension2f(new Vector2f(5, 0), Distance.PIXEL));
|
||||
lineSizer.subWidgetAdd(spacer);
|
||||
final var con = spin.signalValue.connect(newValue -> {
|
||||
try {
|
||||
final var oldValue = pojo.getValue(widget);
|
||||
@ -1254,7 +1263,7 @@ public class ModelWidget extends Container {
|
||||
final var simpleLabel = new Label("top-left");
|
||||
simpleLabel.setPropertyExpand(Vector2b.FALSE);
|
||||
simpleLabel.setPropertyFill(Vector2b.TRUE);
|
||||
simpleLabel.setPropertyMinSize(new Dimension2f(Vector2f.VALUE_16, Distance.PIXEL));
|
||||
simpleLabel.setPropertyMinSize(new Dimension2f(new Vector2f(100, 0), Distance.PIXEL));
|
||||
simpleLabel.setPropertyGravity(Gravity.LEFT);
|
||||
lineSizer.subWidgetAdd(simpleLabel);
|
||||
|
||||
@ -1263,6 +1272,9 @@ public class ModelWidget extends Container {
|
||||
spin.setPropertyFill(Vector2b.TRUE);
|
||||
spin.setPropertyValue((int) value.size().topLeft());
|
||||
lineSizer.subWidgetAdd(spin);
|
||||
final var spacer = new Spacer();
|
||||
spacer.setPropertyMinSize(new Dimension2f(new Vector2f(5, 0), Distance.PIXEL));
|
||||
lineSizer.subWidgetAdd(spacer);
|
||||
final var con = spin.signalValue.connect(newValue -> {
|
||||
try {
|
||||
final var oldValue = pojo.getValue(widget);
|
||||
@ -1299,7 +1311,7 @@ public class ModelWidget extends Container {
|
||||
final var simpleLabel = new Label("left");
|
||||
simpleLabel.setPropertyExpand(Vector2b.FALSE);
|
||||
simpleLabel.setPropertyFill(Vector2b.TRUE);
|
||||
simpleLabel.setPropertyMinSize(new Dimension2f(Vector2f.VALUE_16, Distance.PIXEL));
|
||||
simpleLabel.setPropertyMinSize(new Dimension2f(new Vector2f(100, 0), Distance.PIXEL));
|
||||
simpleLabel.setPropertyGravity(Gravity.LEFT);
|
||||
lineSizer.subWidgetAdd(simpleLabel);
|
||||
|
||||
@ -1308,6 +1320,9 @@ public class ModelWidget extends Container {
|
||||
spin.setPropertyFill(Vector2b.TRUE);
|
||||
spin.setPropertyValue((int) value.size().left());
|
||||
lineSizer.subWidgetAdd(spin);
|
||||
final var spacer = new Spacer();
|
||||
spacer.setPropertyMinSize(new Dimension2f(new Vector2f(5, 0), Distance.PIXEL));
|
||||
lineSizer.subWidgetAdd(spacer);
|
||||
final var con = spin.signalValue.connect(newValue -> {
|
||||
try {
|
||||
final var oldValue = pojo.getValue(widget);
|
||||
@ -1332,7 +1347,7 @@ public class ModelWidget extends Container {
|
||||
final var simpleLabel = new Label("bottom");
|
||||
simpleLabel.setPropertyExpand(Vector2b.FALSE);
|
||||
simpleLabel.setPropertyFill(Vector2b.TRUE);
|
||||
simpleLabel.setPropertyMinSize(new Dimension2f(Vector2f.VALUE_16, Distance.PIXEL));
|
||||
simpleLabel.setPropertyMinSize(new Dimension2f(new Vector2f(100, 0), Distance.PIXEL));
|
||||
simpleLabel.setPropertyGravity(Gravity.LEFT);
|
||||
lineSizer.subWidgetAdd(simpleLabel);
|
||||
|
||||
@ -1341,6 +1356,9 @@ public class ModelWidget extends Container {
|
||||
spin.setPropertyFill(Vector2b.TRUE);
|
||||
spin.setPropertyValue((int) value.size().bottom());
|
||||
lineSizer.subWidgetAdd(spin);
|
||||
final var spacer = new Spacer();
|
||||
spacer.setPropertyMinSize(new Dimension2f(new Vector2f(5, 0), Distance.PIXEL));
|
||||
lineSizer.subWidgetAdd(spacer);
|
||||
final var con = spin.signalValue.connect(newValue -> {
|
||||
try {
|
||||
final var oldValue = pojo.getValue(widget);
|
||||
@ -1365,7 +1383,7 @@ public class ModelWidget extends Container {
|
||||
final var simpleLabel = new Label("right");
|
||||
simpleLabel.setPropertyExpand(Vector2b.FALSE);
|
||||
simpleLabel.setPropertyFill(Vector2b.TRUE);
|
||||
simpleLabel.setPropertyMinSize(new Dimension2f(Vector2f.VALUE_16, Distance.PIXEL));
|
||||
simpleLabel.setPropertyMinSize(new Dimension2f(new Vector2f(100, 0), Distance.PIXEL));
|
||||
simpleLabel.setPropertyGravity(Gravity.LEFT);
|
||||
lineSizer.subWidgetAdd(simpleLabel);
|
||||
|
||||
@ -1374,6 +1392,9 @@ public class ModelWidget extends Container {
|
||||
spin.setPropertyFill(Vector2b.TRUE);
|
||||
spin.setPropertyValue((int) value.size().right());
|
||||
lineSizer.subWidgetAdd(spin);
|
||||
final var spacer = new Spacer();
|
||||
spacer.setPropertyMinSize(new Dimension2f(new Vector2f(5, 0), Distance.PIXEL));
|
||||
lineSizer.subWidgetAdd(spacer);
|
||||
final var con = spin.signalValue.connect(newValue -> {
|
||||
try {
|
||||
final var oldValue = pojo.getValue(widget);
|
||||
@ -1398,7 +1419,7 @@ public class ModelWidget extends Container {
|
||||
final var simpleLabel = new Label("top");
|
||||
simpleLabel.setPropertyExpand(Vector2b.FALSE);
|
||||
simpleLabel.setPropertyFill(Vector2b.TRUE);
|
||||
simpleLabel.setPropertyMinSize(new Dimension2f(Vector2f.VALUE_16, Distance.PIXEL));
|
||||
simpleLabel.setPropertyMinSize(new Dimension2f(new Vector2f(100, 0), Distance.PIXEL));
|
||||
simpleLabel.setPropertyGravity(Gravity.LEFT);
|
||||
lineSizer.subWidgetAdd(simpleLabel);
|
||||
|
||||
@ -1407,6 +1428,9 @@ public class ModelWidget extends Container {
|
||||
spin.setPropertyFill(Vector2b.TRUE);
|
||||
spin.setPropertyValue((int) value.size().top());
|
||||
lineSizer.subWidgetAdd(spin);
|
||||
final var spacer = new Spacer();
|
||||
spacer.setPropertyMinSize(new Dimension2f(new Vector2f(5, 0), Distance.PIXEL));
|
||||
lineSizer.subWidgetAdd(spacer);
|
||||
final var con = spin.signalValue.connect(newValue -> {
|
||||
try {
|
||||
final var oldValue = pojo.getValue(widget);
|
||||
|
@ -104,18 +104,32 @@ public abstract class CompositingDrawing extends CompositingDraw {
|
||||
public void circleBorderRaw(
|
||||
final Vector3f centerPos,
|
||||
final float radius,
|
||||
final float thicknessStart,
|
||||
final float thicknessStop,
|
||||
float thicknessStart,
|
||||
float thicknessStop,
|
||||
final float angleStart,
|
||||
final float angleStop) {
|
||||
resetCount();
|
||||
if (thicknessStart < 0.001 && thicknessStop < 0.001) {
|
||||
return;
|
||||
}
|
||||
if (radius < 0.001) {
|
||||
return;
|
||||
}
|
||||
if (thicknessStart > radius) {
|
||||
thicknessStart = radius;
|
||||
}
|
||||
if (thicknessStop > radius) {
|
||||
thicknessStop = radius;
|
||||
}
|
||||
int nbOcurence = (int) radius;
|
||||
if (nbOcurence < 10) {
|
||||
nbOcurence = 10;
|
||||
}
|
||||
for (int iii = 0; iii < nbOcurence; iii++) {
|
||||
final float thickness = thicknessStart + ((thicknessStop - thicknessStart) * iii / nbOcurence);
|
||||
final float angleOne = angleStart + (angleStop * iii / nbOcurence);
|
||||
final float ratio = (float) iii / (float) nbOcurence;
|
||||
final float thickness = thicknessStart + ((thicknessStop - thicknessStart) * ratio);
|
||||
//final float thickness = thicknessStart * FMath.cos(ratio * FMath.PI * 0.5f) + thicknessStop * FMath.sin(ratio * FMath.PI * 0.5f);
|
||||
final float angleOne = angleStart + (angleStop * ratio);
|
||||
final float offsetExty = FMath.sin(angleOne) * (radius);
|
||||
final float offsetExtx = FMath.cos(angleOne) * (radius);
|
||||
final float offsetInty = FMath.sin(angleOne) * (radius - thickness);
|
||||
@ -144,6 +158,9 @@ public abstract class CompositingDrawing extends CompositingDraw {
|
||||
final float radiusStop,
|
||||
final float angleStart,
|
||||
final float angleStop) {
|
||||
if (radiusStart < 0.001 && radiusStop < 0.001) {
|
||||
return;
|
||||
}
|
||||
resetCount();
|
||||
int nbOcurence = (int) FMath.max(radiusStart, radiusStop);
|
||||
if (nbOcurence < 10) {
|
||||
@ -596,7 +613,7 @@ public abstract class CompositingDrawing extends CompositingDraw {
|
||||
|
||||
public void rectangleRadius(final Vector3f dest, final float radius) {
|
||||
internalSetColor(this.color);
|
||||
final boolean showConstruct = true;
|
||||
final boolean showConstruct = false;
|
||||
|
||||
rectangleRaw(this.position.add(new Vector3f(radius, 0, 0)), dest.less(new Vector3f(radius, 0, 0)));
|
||||
if (showConstruct) {
|
||||
@ -630,7 +647,7 @@ public abstract class CompositingDrawing extends CompositingDraw {
|
||||
|
||||
public void rectangleRadius(final Vector2f dest, final Insets thickness, final BorderRadius radius) {
|
||||
internalSetColor(this.color);
|
||||
final boolean showConstruct = true;
|
||||
final boolean showConstruct = false;
|
||||
|
||||
if (showConstruct) {
|
||||
internalSetColor(Color.DARK_KHAKI);
|
||||
@ -705,7 +722,7 @@ public abstract class CompositingDrawing extends CompositingDraw {
|
||||
final Insets thickness,
|
||||
final BorderRadius radius) {
|
||||
internalSetColor(this.colorBg);
|
||||
final boolean showConstruct = true;
|
||||
final boolean showConstruct = false;
|
||||
|
||||
if (showConstruct) {
|
||||
internalSetColor(Color.KHAKI);
|
||||
@ -735,7 +752,7 @@ public abstract class CompositingDrawing extends CompositingDraw {
|
||||
// top-left
|
||||
final Vector3f centerTopLeft = new Vector3f(this.position.x() + radius.topLeft(), dest.y() - radius.topLeft(),
|
||||
0);
|
||||
circleBorderRaw(centerTopLeft, radius.topLeft(), thickness.left(), thickness.top(), FMath.PI * 0.5f,
|
||||
circleBorderRaw(centerTopLeft, radius.topLeft(), thickness.top(), thickness.left(), FMath.PI * 0.5f,
|
||||
FMath.PI * 0.5f);
|
||||
|
||||
// buttom area:
|
||||
|
@ -66,17 +66,12 @@ public class CompositingGC extends CompositingDrawing {
|
||||
final Vector2f size,
|
||||
final Insets thickness,
|
||||
final BorderRadius radius) {
|
||||
if (radius == null || radius.isZero()) {
|
||||
//addRectangle(position, size);
|
||||
//throw new RuntimeException("Not implemented ...");
|
||||
} else {
|
||||
setPos(position);
|
||||
rectangleRadius(position.add(size), thickness, radius);
|
||||
if (!thickness.isZero()) {
|
||||
rectangleBorderRadius(position.add(size), thickness, radius);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCircle(final Vector2f position, final float radius) {
|
||||
|
@ -182,13 +182,13 @@ public class Box extends Container {
|
||||
LOGGER.debug("calculate min size: border=" + this.propertyBorderWidth);
|
||||
final Insets borderSize = this.propertyBorderWidth.getPixel();
|
||||
|
||||
final Vector2f padding = this.propertyPadding.size().multiply(2);
|
||||
final Vector2f margin = this.propertyMargin.size().multiply(2);
|
||||
final Vector2f padding = this.propertyPadding.getPixel().multiply(2);
|
||||
final Vector2f margin = this.propertyMargin.getPixel().multiply(2);
|
||||
|
||||
final Vector2f calculatedBoxMinSize = childMinSize.add(margin).add(padding).add(borderSize.toVector2f());
|
||||
|
||||
this.minSize = calculatedBoxMinSize;
|
||||
this.maxSize = Vector2f.max(this.minSize, this.propertyMaxSize.size());
|
||||
this.maxSize = Vector2f.max(this.minSize, this.propertyMaxSize.getPixel());
|
||||
markToRedraw();
|
||||
}
|
||||
|
||||
@ -201,8 +201,8 @@ public class Box extends Container {
|
||||
if (this.subWidget == null) {
|
||||
return;
|
||||
}
|
||||
final Vector2f localPadding = this.propertyPadding.size();
|
||||
final Vector2f localMargin = this.propertyMargin.size();
|
||||
final Vector2f localPadding = this.propertyPadding.getPixel();
|
||||
final Vector2f localMargin = this.propertyMargin.getPixel();
|
||||
final Insets localBorderSize = this.propertyBorderWidth.getPixel();
|
||||
final Vector2f offsetSubWidget = localPadding.add(localMargin).add(localBorderSize.toVector2f());
|
||||
|
||||
@ -220,6 +220,7 @@ public class Box extends Container {
|
||||
subWidgetSize = subWidgetSize.less(offsetSubWidget.multiply(2));
|
||||
subWidgetSize = subWidgetSize.clipInteger();
|
||||
|
||||
on a un pb ici car on double les margin, ce qui est normal, mai on redouble les border size
|
||||
final Vector2f freeSizeWithoutWidget = this.size.less(offsetSubWidget.multiply(2)).less(subWidgetSize);
|
||||
Vector2f subWidgetOrigin = this.origin.add(this.propertyGravity.gravityGenerateDelta(freeSizeWithoutWidget));
|
||||
subWidgetOrigin = subWidgetOrigin.add(offsetSubWidget);
|
||||
@ -266,8 +267,7 @@ public class Box extends Container {
|
||||
this.startPosition = renderOrigin.toVector2i();
|
||||
this.endPosition = renderSize.toVector2i();
|
||||
|
||||
//System.out.println("renderSize: " + this.renderSize);
|
||||
// remove data of the previous composition :
|
||||
// remove data of the previous composition:
|
||||
this.vectorialDraw.clear();
|
||||
this.vectorialDraw.setPaintFillColor(this.propertyColor);
|
||||
this.vectorialDraw.setPaintStrokeColor(this.propertyBorderColor);
|
||||
|
@ -4,6 +4,8 @@ import org.atriasoft.aknot.annotation.AknotAttribute;
|
||||
import org.atriasoft.aknot.annotation.AknotDescription;
|
||||
import org.atriasoft.aknot.annotation.AknotManaged;
|
||||
import org.atriasoft.aknot.annotation.AknotName;
|
||||
import org.atriasoft.etk.DimensionBorderRadius;
|
||||
import org.atriasoft.etk.DimensionInsets;
|
||||
import org.atriasoft.etk.Uri;
|
||||
import org.atriasoft.etk.math.Vector2b;
|
||||
import org.atriasoft.ewol.Gravity;
|
||||
@ -121,6 +123,7 @@ public class SpinBase extends Sizer {
|
||||
}
|
||||
if (this.widgetButtonDown == null) {
|
||||
this.widgetButtonDown = new Button();
|
||||
this.widgetButtonDown.setPropertyBorderWidth(new DimensionInsets(2f, 1f, 2f, 1f));
|
||||
if (this.config != null) {
|
||||
final String shaper = this.config.getString(this.confIdDownShaper);
|
||||
LOGGER.trace("shaper button DOWN : " + shaper);
|
||||
@ -137,6 +140,8 @@ public class SpinBase extends Sizer {
|
||||
}
|
||||
if (this.widgetButtonUp == null) {
|
||||
this.widgetButtonUp = new Button();
|
||||
this.widgetButtonUp.setPropertyBorderWidth(new DimensionInsets(2, 2, 2, 1));
|
||||
this.widgetButtonUp.setPropertyBorderRadius(new DimensionBorderRadius(0, 8, 8, 0));
|
||||
if (this.config != null) {
|
||||
final String shaper = this.config.getString(this.confIdUpShaper);
|
||||
LOGGER.trace("shaper button UP : " + shaper);
|
||||
|
Loading…
x
Reference in New Issue
Block a user