[FEAT] continue refacto to manage distinct width in rectangle border
This commit is contained in:
parent
ec4b1a1875
commit
55664d759e
@ -15,6 +15,8 @@ import org.atriasoft.etk.Color;
|
||||
import org.atriasoft.etk.Dimension1f;
|
||||
import org.atriasoft.etk.Dimension2f;
|
||||
import org.atriasoft.etk.Dimension3f;
|
||||
import org.atriasoft.etk.DimensionBorderRadius;
|
||||
import org.atriasoft.etk.DimensionInsets;
|
||||
import org.atriasoft.etk.Distance;
|
||||
import org.atriasoft.etk.Uri;
|
||||
import org.atriasoft.etk.math.Vector2b;
|
||||
@ -1135,6 +1137,294 @@ public class ModelWidget extends Container {
|
||||
}
|
||||
}
|
||||
|
||||
public void addMenuDimensionBorderRadius(final Widget widget, final IntrospectionProperty pojo) {
|
||||
Object valueRaw = null;
|
||||
try {
|
||||
valueRaw = pojo.getValue(widget);
|
||||
} catch (final AknotException e) {
|
||||
e.printStackTrace();
|
||||
return;
|
||||
}
|
||||
if (valueRaw instanceof final DimensionBorderRadius value) {
|
||||
{
|
||||
final var lineSizer = new Sizer(DisplayMode.HORIZONTAL);
|
||||
lineSizer.setPropertyExpand(Vector2b.TRUE_FALSE);
|
||||
lineSizer.setPropertyFill(Vector2b.TRUE);
|
||||
this.sizerMenu.subWidgetAdd(lineSizer);
|
||||
|
||||
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.setPropertyGravity(Gravity.LEFT);
|
||||
lineSizer.subWidgetAdd(simpleLabel);
|
||||
|
||||
final var spin = new Spin();
|
||||
spin.setPropertyExpand(Vector2b.TRUE_FALSE);
|
||||
spin.setPropertyFill(Vector2b.TRUE);
|
||||
spin.setPropertyValue((int) value.size().bottomLeft());
|
||||
lineSizer.subWidgetAdd(spin);
|
||||
final var con = spin.signalValue.connect(newValue -> {
|
||||
try {
|
||||
final var oldValue = pojo.getValue(widget);
|
||||
if (oldValue instanceof DimensionBorderRadius castedValue) {
|
||||
castedValue = castedValue.withSize(castedValue.size().withBottomLeft(newValue));
|
||||
LOGGER.warn("Set new value: {}", castedValue);
|
||||
pojo.setExistingValue(widget, castedValue);
|
||||
}
|
||||
} catch (final AknotException e) {
|
||||
e.printStackTrace();
|
||||
return;
|
||||
}
|
||||
});
|
||||
this.conections.add(con);
|
||||
}
|
||||
{
|
||||
final var lineSizer = new Sizer(DisplayMode.HORIZONTAL);
|
||||
lineSizer.setPropertyExpand(Vector2b.TRUE_FALSE);
|
||||
lineSizer.setPropertyFill(Vector2b.TRUE);
|
||||
this.sizerMenu.subWidgetAdd(lineSizer);
|
||||
|
||||
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.setPropertyGravity(Gravity.LEFT);
|
||||
lineSizer.subWidgetAdd(simpleLabel);
|
||||
|
||||
final var spin = new Spin();
|
||||
spin.setPropertyExpand(Vector2b.TRUE_FALSE);
|
||||
spin.setPropertyFill(Vector2b.TRUE);
|
||||
spin.setPropertyValue((int) value.size().bottomRight());
|
||||
lineSizer.subWidgetAdd(spin);
|
||||
final var con = spin.signalValue.connect(newValue -> {
|
||||
try {
|
||||
final var oldValue = pojo.getValue(widget);
|
||||
if (oldValue instanceof DimensionBorderRadius castedValue) {
|
||||
castedValue = castedValue.withSize(castedValue.size().withBottomRight(newValue));
|
||||
LOGGER.warn("Set new value: {}", castedValue);
|
||||
pojo.setExistingValue(widget, castedValue);
|
||||
}
|
||||
} catch (final AknotException e) {
|
||||
e.printStackTrace();
|
||||
return;
|
||||
}
|
||||
});
|
||||
this.conections.add(con);
|
||||
}
|
||||
{
|
||||
final var lineSizer = new Sizer(DisplayMode.HORIZONTAL);
|
||||
lineSizer.setPropertyExpand(Vector2b.TRUE_FALSE);
|
||||
lineSizer.setPropertyFill(Vector2b.TRUE);
|
||||
this.sizerMenu.subWidgetAdd(lineSizer);
|
||||
|
||||
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.setPropertyGravity(Gravity.LEFT);
|
||||
lineSizer.subWidgetAdd(simpleLabel);
|
||||
|
||||
final var spin = new Spin();
|
||||
spin.setPropertyExpand(Vector2b.TRUE_FALSE);
|
||||
spin.setPropertyFill(Vector2b.TRUE);
|
||||
spin.setPropertyValue((int) value.size().topRight());
|
||||
lineSizer.subWidgetAdd(spin);
|
||||
final var con = spin.signalValue.connect(newValue -> {
|
||||
try {
|
||||
final var oldValue = pojo.getValue(widget);
|
||||
if (oldValue instanceof DimensionBorderRadius castedValue) {
|
||||
castedValue = castedValue.withSize(castedValue.size().withTopRight(newValue));
|
||||
LOGGER.warn("Set new value: {}", castedValue);
|
||||
pojo.setExistingValue(widget, castedValue);
|
||||
}
|
||||
} catch (final AknotException e) {
|
||||
e.printStackTrace();
|
||||
return;
|
||||
}
|
||||
});
|
||||
this.conections.add(con);
|
||||
}
|
||||
{
|
||||
final var lineSizer = new Sizer(DisplayMode.HORIZONTAL);
|
||||
lineSizer.setPropertyExpand(Vector2b.TRUE_FALSE);
|
||||
lineSizer.setPropertyFill(Vector2b.TRUE);
|
||||
this.sizerMenu.subWidgetAdd(lineSizer);
|
||||
|
||||
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.setPropertyGravity(Gravity.LEFT);
|
||||
lineSizer.subWidgetAdd(simpleLabel);
|
||||
|
||||
final var spin = new Spin();
|
||||
spin.setPropertyExpand(Vector2b.TRUE_FALSE);
|
||||
spin.setPropertyFill(Vector2b.TRUE);
|
||||
spin.setPropertyValue((int) value.size().topLeft());
|
||||
lineSizer.subWidgetAdd(spin);
|
||||
final var con = spin.signalValue.connect(newValue -> {
|
||||
try {
|
||||
final var oldValue = pojo.getValue(widget);
|
||||
if (oldValue instanceof DimensionBorderRadius castedValue) {
|
||||
castedValue = castedValue.withSize(castedValue.size().withTopLeft(newValue));
|
||||
LOGGER.warn("Set new value: {}", castedValue);
|
||||
pojo.setExistingValue(widget, castedValue);
|
||||
}
|
||||
} catch (final AknotException e) {
|
||||
e.printStackTrace();
|
||||
return;
|
||||
}
|
||||
});
|
||||
this.conections.add(con);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void addMenuDimensionInsets(final Widget widget, final IntrospectionProperty pojo) {
|
||||
Object valueRaw = null;
|
||||
try {
|
||||
valueRaw = pojo.getValue(widget);
|
||||
} catch (final AknotException e) {
|
||||
e.printStackTrace();
|
||||
return;
|
||||
}
|
||||
if (valueRaw instanceof final DimensionInsets value) {
|
||||
{
|
||||
final var lineSizer = new Sizer(DisplayMode.HORIZONTAL);
|
||||
lineSizer.setPropertyExpand(Vector2b.TRUE_FALSE);
|
||||
lineSizer.setPropertyFill(Vector2b.TRUE);
|
||||
this.sizerMenu.subWidgetAdd(lineSizer);
|
||||
|
||||
final var simpleLabel = new Label("left");
|
||||
simpleLabel.setPropertyExpand(Vector2b.FALSE);
|
||||
simpleLabel.setPropertyFill(Vector2b.TRUE);
|
||||
simpleLabel.setPropertyMinSize(new Dimension2f(Vector2f.VALUE_16, Distance.PIXEL));
|
||||
simpleLabel.setPropertyGravity(Gravity.LEFT);
|
||||
lineSizer.subWidgetAdd(simpleLabel);
|
||||
|
||||
final var spin = new Spin();
|
||||
spin.setPropertyExpand(Vector2b.TRUE_FALSE);
|
||||
spin.setPropertyFill(Vector2b.TRUE);
|
||||
spin.setPropertyValue((int) value.size().left());
|
||||
lineSizer.subWidgetAdd(spin);
|
||||
final var con = spin.signalValue.connect(newValue -> {
|
||||
try {
|
||||
final var oldValue = pojo.getValue(widget);
|
||||
if (oldValue instanceof DimensionInsets castedValue) {
|
||||
castedValue = castedValue.withSize(castedValue.size().withLeft(newValue));
|
||||
LOGGER.warn("Set new value: {}", castedValue);
|
||||
pojo.setExistingValue(widget, castedValue);
|
||||
}
|
||||
} catch (final AknotException e) {
|
||||
e.printStackTrace();
|
||||
return;
|
||||
}
|
||||
});
|
||||
this.conections.add(con);
|
||||
}
|
||||
{
|
||||
final var lineSizer = new Sizer(DisplayMode.HORIZONTAL);
|
||||
lineSizer.setPropertyExpand(Vector2b.TRUE_FALSE);
|
||||
lineSizer.setPropertyFill(Vector2b.TRUE);
|
||||
this.sizerMenu.subWidgetAdd(lineSizer);
|
||||
|
||||
final var simpleLabel = new Label("bottom");
|
||||
simpleLabel.setPropertyExpand(Vector2b.FALSE);
|
||||
simpleLabel.setPropertyFill(Vector2b.TRUE);
|
||||
simpleLabel.setPropertyMinSize(new Dimension2f(Vector2f.VALUE_16, Distance.PIXEL));
|
||||
simpleLabel.setPropertyGravity(Gravity.LEFT);
|
||||
lineSizer.subWidgetAdd(simpleLabel);
|
||||
|
||||
final var spin = new Spin();
|
||||
spin.setPropertyExpand(Vector2b.TRUE_FALSE);
|
||||
spin.setPropertyFill(Vector2b.TRUE);
|
||||
spin.setPropertyValue((int) value.size().bottom());
|
||||
lineSizer.subWidgetAdd(spin);
|
||||
final var con = spin.signalValue.connect(newValue -> {
|
||||
try {
|
||||
final var oldValue = pojo.getValue(widget);
|
||||
if (oldValue instanceof DimensionInsets castedValue) {
|
||||
castedValue = castedValue.withSize(castedValue.size().withBottom(newValue));
|
||||
LOGGER.warn("Set new value: {}", castedValue);
|
||||
pojo.setExistingValue(widget, castedValue);
|
||||
}
|
||||
} catch (final AknotException e) {
|
||||
e.printStackTrace();
|
||||
return;
|
||||
}
|
||||
});
|
||||
this.conections.add(con);
|
||||
}
|
||||
{
|
||||
final var lineSizer = new Sizer(DisplayMode.HORIZONTAL);
|
||||
lineSizer.setPropertyExpand(Vector2b.TRUE_FALSE);
|
||||
lineSizer.setPropertyFill(Vector2b.TRUE);
|
||||
this.sizerMenu.subWidgetAdd(lineSizer);
|
||||
|
||||
final var simpleLabel = new Label("right");
|
||||
simpleLabel.setPropertyExpand(Vector2b.FALSE);
|
||||
simpleLabel.setPropertyFill(Vector2b.TRUE);
|
||||
simpleLabel.setPropertyMinSize(new Dimension2f(Vector2f.VALUE_16, Distance.PIXEL));
|
||||
simpleLabel.setPropertyGravity(Gravity.LEFT);
|
||||
lineSizer.subWidgetAdd(simpleLabel);
|
||||
|
||||
final var spin = new Spin();
|
||||
spin.setPropertyExpand(Vector2b.TRUE_FALSE);
|
||||
spin.setPropertyFill(Vector2b.TRUE);
|
||||
spin.setPropertyValue((int) value.size().right());
|
||||
lineSizer.subWidgetAdd(spin);
|
||||
final var con = spin.signalValue.connect(newValue -> {
|
||||
try {
|
||||
final var oldValue = pojo.getValue(widget);
|
||||
if (oldValue instanceof DimensionInsets castedValue) {
|
||||
castedValue = castedValue.withSize(castedValue.size().withRight(newValue));
|
||||
LOGGER.warn("Set new value: {}", castedValue);
|
||||
pojo.setExistingValue(widget, castedValue);
|
||||
}
|
||||
} catch (final AknotException e) {
|
||||
e.printStackTrace();
|
||||
return;
|
||||
}
|
||||
});
|
||||
this.conections.add(con);
|
||||
}
|
||||
{
|
||||
final var lineSizer = new Sizer(DisplayMode.HORIZONTAL);
|
||||
lineSizer.setPropertyExpand(Vector2b.TRUE_FALSE);
|
||||
lineSizer.setPropertyFill(Vector2b.TRUE);
|
||||
this.sizerMenu.subWidgetAdd(lineSizer);
|
||||
|
||||
final var simpleLabel = new Label("top");
|
||||
simpleLabel.setPropertyExpand(Vector2b.FALSE);
|
||||
simpleLabel.setPropertyFill(Vector2b.TRUE);
|
||||
simpleLabel.setPropertyMinSize(new Dimension2f(Vector2f.VALUE_16, Distance.PIXEL));
|
||||
simpleLabel.setPropertyGravity(Gravity.LEFT);
|
||||
lineSizer.subWidgetAdd(simpleLabel);
|
||||
|
||||
final var spin = new Spin();
|
||||
spin.setPropertyExpand(Vector2b.TRUE_FALSE);
|
||||
spin.setPropertyFill(Vector2b.TRUE);
|
||||
spin.setPropertyValue((int) value.size().top());
|
||||
lineSizer.subWidgetAdd(spin);
|
||||
final var con = spin.signalValue.connect(newValue -> {
|
||||
try {
|
||||
final var oldValue = pojo.getValue(widget);
|
||||
if (oldValue instanceof DimensionInsets castedValue) {
|
||||
castedValue = castedValue.withSize(castedValue.size().withTop(newValue));
|
||||
LOGGER.warn("Set new value: {}", castedValue);
|
||||
pojo.setExistingValue(widget, castedValue);
|
||||
}
|
||||
} catch (final AknotException e) {
|
||||
e.printStackTrace();
|
||||
return;
|
||||
}
|
||||
});
|
||||
this.conections.add(con);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void displayAllPropertyWithType(final Widget widget, final IntrospectionModel modelPojo) throws Exception {
|
||||
LOGGER.warn("Connect all property(ies) on '{}'", widget.getName());
|
||||
final var atributes = modelPojo.getAttributes();
|
||||
@ -1175,6 +1465,10 @@ public class ModelWidget extends Container {
|
||||
addMenuDimension2f(widget, pojo);
|
||||
} else if (pojo.getType() == Dimension1f.class) {
|
||||
addMenuDimension1f(widget, pojo);
|
||||
} else if (pojo.getType() == DimensionBorderRadius.class) {
|
||||
addMenuDimensionBorderRadius(widget, pojo);
|
||||
} else if (pojo.getType() == DimensionInsets.class) {
|
||||
addMenuDimensionInsets(widget, pojo);
|
||||
} else if (pojo.getType() == DisplayMode.class) {
|
||||
LOGGER.error(" ==> plop");
|
||||
} else if (pojo.getType() == Uri.class) {
|
||||
|
@ -1,8 +1,9 @@
|
||||
package sample.atriasoft.ewol;
|
||||
|
||||
import org.atriasoft.etk.Color;
|
||||
import org.atriasoft.etk.Dimension1f;
|
||||
import org.atriasoft.etk.Dimension2f;
|
||||
import org.atriasoft.etk.DimensionBorderRadius;
|
||||
import org.atriasoft.etk.DimensionInsets;
|
||||
import org.atriasoft.etk.math.Vector2b;
|
||||
import org.atriasoft.etk.math.Vector2f;
|
||||
import org.atriasoft.ewol.widget.Box;
|
||||
@ -22,8 +23,8 @@ public class TestWidgetBox implements TestWidgetInterface {
|
||||
final var testWidget = new Box(innerWidget);
|
||||
testWidget.setPropertyExpand(Vector2b.FALSE);
|
||||
testWidget.setPropertyFill(Vector2b.FALSE);
|
||||
testWidget.setPropertyBorderWidth(new Dimension1f(10));
|
||||
testWidget.setPropertyBorderRadius(new Dimension1f(25));
|
||||
testWidget.setPropertyBorderWidth(new DimensionInsets(10));
|
||||
testWidget.setPropertyBorderRadius(new DimensionBorderRadius(25));
|
||||
testWidget.setPropertyBorderColor(Color.BLACK);
|
||||
testWidget.setPropertyColor(Color.GREEN_YELLOW);
|
||||
testWidget.setPropertyPadding(new Dimension2f(new Vector2f(15, 15)));
|
||||
|
@ -5,7 +5,9 @@
|
||||
*/
|
||||
package org.atriasoft.ewol.compositing;
|
||||
|
||||
import org.atriasoft.etk.BorderRadius;
|
||||
import org.atriasoft.etk.Color;
|
||||
import org.atriasoft.etk.Insets;
|
||||
import org.atriasoft.etk.math.Vector2f;
|
||||
|
||||
public interface CompositingDrawInterface {
|
||||
@ -29,4 +31,6 @@ public interface CompositingDrawInterface {
|
||||
|
||||
void addEllipse(final Vector2f center, final Vector2f radius);
|
||||
|
||||
void addRectangle(Vector2f position, Vector2f size, Insets thickness, BorderRadius radius);
|
||||
|
||||
}
|
||||
|
@ -8,7 +8,9 @@ package org.atriasoft.ewol.compositing;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.atriasoft.etk.BorderRadius;
|
||||
import org.atriasoft.etk.Color;
|
||||
import org.atriasoft.etk.Insets;
|
||||
import org.atriasoft.etk.Uri;
|
||||
import org.atriasoft.etk.math.FMath;
|
||||
import org.atriasoft.etk.math.Matrix4f;
|
||||
@ -96,12 +98,23 @@ public abstract class CompositingDrawing extends CompositingDraw {
|
||||
final float thickness,
|
||||
final float angleStart,
|
||||
final float angleStop) {
|
||||
circleBorderRaw(centerPos, radius, thickness, thickness, angleStart, angleStop);
|
||||
}
|
||||
|
||||
public void circleBorderRaw(
|
||||
final Vector3f centerPos,
|
||||
final float radius,
|
||||
final float thicknessStart,
|
||||
final float thicknessStop,
|
||||
final float angleStart,
|
||||
final float angleStop) {
|
||||
resetCount();
|
||||
int nbOcurence = (int) radius;
|
||||
if (nbOcurence < 10) {
|
||||
nbOcurence = 10;
|
||||
}
|
||||
for (int iii = 0; iii < nbOcurence; iii++) {
|
||||
final float thickness = thicknessStart + ((thicknessStart - thicknessStop) * iii / nbOcurence);
|
||||
final float angleOne = angleStart + (angleStop * iii / nbOcurence);
|
||||
final float offsetExty = FMath.sin(angleOne) * (radius + thickness / 2);
|
||||
final float offsetExtx = FMath.cos(angleOne) * (radius + thickness / 2);
|
||||
@ -119,25 +132,35 @@ public abstract class CompositingDrawing extends CompositingDraw {
|
||||
setPoint(new Vector3f(centerPos.x() + offsetInt2x, centerPos.y() + offsetInt2y, 0));
|
||||
setPoint(new Vector3f(centerPos.x() + offsetIntx, centerPos.y() + offsetInty, 0));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void circleRaw(final Vector3f centerPos, final float radius, final float angleStart, final float angleStop) {
|
||||
circleRaw(centerPos, radius, radius, angleStart, angleStop);
|
||||
}
|
||||
|
||||
public void circleRaw(
|
||||
final Vector3f centerPos,
|
||||
final float radiusStart,
|
||||
final float radiusStop,
|
||||
final float angleStart,
|
||||
final float angleStop) {
|
||||
resetCount();
|
||||
int nbOcurence = (int) radius;
|
||||
int nbOcurence = (int) FMath.max(radiusStart, radiusStop);
|
||||
if (nbOcurence < 10) {
|
||||
nbOcurence = 10;
|
||||
}
|
||||
final float invertOccurence = 1.0f / nbOcurence;
|
||||
for (int iii = 0; iii < nbOcurence; iii++) {
|
||||
final float radius = radiusStart + ((radiusStart - radiusStop) * iii * invertOccurence);
|
||||
setPoint(new Vector3f(centerPos.x(), centerPos.y(), 0));
|
||||
|
||||
final float angleOne = angleStart + (angleStop * iii / nbOcurence);
|
||||
final float angleOne = angleStart + (angleStop * iii * invertOccurence);
|
||||
float offsety = FMath.sin(angleOne) * radius;
|
||||
float offsetx = FMath.cos(angleOne) * radius;
|
||||
|
||||
setPoint(new Vector3f(centerPos.x() + offsetx, centerPos.y() + offsety, 0));
|
||||
|
||||
final float angleTwo = angleStart + (angleStop * (iii + 1) / nbOcurence);
|
||||
final float angleTwo = angleStart + (angleStop * (iii + 1) * invertOccurence);
|
||||
offsety = FMath.sin(angleTwo) * radius;
|
||||
offsetx = FMath.cos(angleTwo) * radius;
|
||||
|
||||
@ -562,7 +585,7 @@ public abstract class CompositingDrawing extends CompositingDraw {
|
||||
|
||||
public void rectangleRadius(final Vector3f dest, final float radius) {
|
||||
internalSetColor(this.color);
|
||||
final boolean showConstruct = false;
|
||||
final boolean showConstruct = true;
|
||||
|
||||
rectangleRaw(this.position.add(new Vector3f(radius, 0, 0)), dest.less(new Vector3f(radius, 0, 0)));
|
||||
if (showConstruct) {
|
||||
@ -594,13 +617,55 @@ 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;
|
||||
|
||||
// center rectangle
|
||||
rectangleRaw(this.position.add(new Vector3f(thickness.top(), thickness.top(), 0)),
|
||||
dest.toVector3f().less(new Vector3f(thickness.top(), thickness.top(), 0)));
|
||||
// top & bottom rectangle ==> refacto ..
|
||||
// rectangleRaw(this.position.add(new Vector3f(thickness.top(), 0, 0)),
|
||||
// dest.toVector3f().less(new Vector3f(radius.topLeft(), 0, 0)));
|
||||
// if (showConstruct) {
|
||||
// internalSetColor(Color.ORANGE);
|
||||
// }
|
||||
// // left rectangle
|
||||
// rectangleRaw(this.position.add(new Vector3f(0, radius.topLeft(), 0)),
|
||||
// new Vector3f(this.position.x() + radius.topLeft(), dest.y() - radius.topLeft(), 0));
|
||||
// if (showConstruct) {
|
||||
// internalSetColor(Color.GRAY);
|
||||
// }
|
||||
// // right rectangle
|
||||
// rectangleRaw(new Vector3f(dest.x() - radius.topLeft(), this.position.y() + radius.topLeft(), 0),
|
||||
// new Vector3f(dest.x(), dest.y() - radius.topLeft(), 0));
|
||||
|
||||
if (showConstruct) {
|
||||
internalSetColor(Color.AQUA_MARINE);
|
||||
}
|
||||
circleRaw(this.position.add(radius.topLeft(), radius.topLeft(), 0), radius.topLeft(), FMath.PI,
|
||||
FMath.PI * 0.5f);
|
||||
circleRaw(dest.toVector3f().less(radius.topLeft(), radius.topLeft(), 0), radius.topLeft(), 0, FMath.PI * 0.5f);
|
||||
circleRaw(new Vector3f(dest.x() - radius.topLeft(), this.position.y() + radius.topLeft(), 0), radius.topLeft(),
|
||||
FMath.PI * 1.5f, FMath.PI * 0.5f);
|
||||
circleRaw(new Vector3f(this.position.x() + radius.topLeft(), dest.y() - radius.topLeft(), 0), radius.topLeft(),
|
||||
FMath.PI * 0.5f, FMath.PI * 0.5f);
|
||||
|
||||
if (showConstruct) {
|
||||
internalSetColor(Color.BLACK);
|
||||
rectangleRaw(this.position, this.position.add(10));
|
||||
internalSetColor(Color.RED);
|
||||
rectangleRaw(dest.toVector3f().less(10), dest.toVector3f());
|
||||
}
|
||||
}
|
||||
|
||||
public void rectangleBorderRadius(final Vector2f dest, final float thickness, final float radius) {
|
||||
rectangleBorderRadius(dest.toVector3f(), thickness, radius);
|
||||
}
|
||||
|
||||
public void rectangleBorderRadius(final Vector3f dest, final float thickness, final float radius) {
|
||||
internalSetColor(this.color);
|
||||
final boolean showConstruct = true;
|
||||
internalSetColor(this.colorBg);
|
||||
final boolean showConstruct = false;
|
||||
if (showConstruct) {
|
||||
internalSetColor(Color.ANTIQUE_WHITE);
|
||||
}
|
||||
@ -635,6 +700,47 @@ public abstract class CompositingDrawing extends CompositingDraw {
|
||||
}
|
||||
}
|
||||
|
||||
public void rectangleBorderRadius(
|
||||
//final Vector2f pos,
|
||||
final Vector2f dest,
|
||||
final Insets thickness,
|
||||
final BorderRadius radius) {
|
||||
internalSetColor(this.color);
|
||||
final boolean showConstruct = true;
|
||||
if (showConstruct) {
|
||||
internalSetColor(Color.ANTIQUE_WHITE);
|
||||
}
|
||||
// // Bottom
|
||||
// rectangleRaw(new Vector3f(this.position.x() + radius, this.position.y() - thickness * 0.5f, 0),
|
||||
// new Vector3f(dest.x() - radius, this.position.y() + thickness * 0.5f, 0));
|
||||
// // top
|
||||
// rectangleRaw(new Vector3f(this.position.x() + radius, dest.y() - thickness * 0.5f, 0),
|
||||
// new Vector3f(dest.x() - radius, dest.y() + thickness * 0.5f, 0));
|
||||
// // left
|
||||
// rectangleRaw(new Vector3f(this.position.x() - thickness * 0.5f, this.position.y() + radius, 0),
|
||||
// new Vector3f(this.position.x() + thickness * 0.5f, dest.y() - radius, 0));
|
||||
// // right
|
||||
// rectangleRaw(new Vector3f(dest.x() - thickness * 0.5f, this.position.y() + radius, 0),
|
||||
// new Vector3f(dest.x() + thickness * 0.5f, dest.y() - radius, 0));
|
||||
//
|
||||
// if (showConstruct) {
|
||||
// internalSetColor(Color.DARK_RED);
|
||||
// }
|
||||
// circleBorderRaw(this.position.add(radius, radius, 0), radius, thickness, FMath.PI, FMath.PI * 0.5f);
|
||||
// circleBorderRaw(dest.less(radius, radius, 0), radius, thickness, 0, FMath.PI * 0.5f);
|
||||
// circleBorderRaw(new Vector3f(dest.x() - radius, this.position.y() + radius, 0), radius, thickness,
|
||||
// FMath.PI * 1.5f, FMath.PI * 0.5f);
|
||||
// circleBorderRaw(new Vector3f(this.position.x() + radius, dest.y() - radius, 0), radius, thickness,
|
||||
// FMath.PI * 0.5f, FMath.PI * 0.5f);
|
||||
//
|
||||
// if (showConstruct) {
|
||||
// internalSetColor(Color.BLACK);
|
||||
// rectangleRaw(this.position, this.position.add(10));
|
||||
// internalSetColor(Color.RED);
|
||||
// rectangleRaw(dest.less(10), dest);
|
||||
// }
|
||||
}
|
||||
|
||||
public void rectangleWidth(final float xxx, final float yyy) {
|
||||
rectangleWidth(new Vector3f(xxx, yyy, 0));
|
||||
}
|
||||
|
@ -5,7 +5,9 @@
|
||||
*/
|
||||
package org.atriasoft.ewol.compositing;
|
||||
|
||||
import org.atriasoft.etk.BorderRadius;
|
||||
import org.atriasoft.etk.Color;
|
||||
import org.atriasoft.etk.Insets;
|
||||
import org.atriasoft.etk.math.Vector2f;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@ -58,6 +60,24 @@ public class CompositingGC extends CompositingDrawing {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addRectangle(
|
||||
final Vector2f position,
|
||||
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 (this.strokeSize > 0) {
|
||||
rectangleBorderRadius(position.add(size), thickness, radius);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCircle(final Vector2f position, final float radius) {
|
||||
setPos(position);
|
||||
|
@ -16,7 +16,9 @@ import org.atriasoft.esvg.JoinMode;
|
||||
import org.atriasoft.esvg.Line;
|
||||
import org.atriasoft.esvg.PaintState;
|
||||
import org.atriasoft.esvg.Rectangle;
|
||||
import org.atriasoft.etk.BorderRadius;
|
||||
import org.atriasoft.etk.Color;
|
||||
import org.atriasoft.etk.Insets;
|
||||
import org.atriasoft.etk.Uri;
|
||||
import org.atriasoft.etk.math.Matrix4f;
|
||||
import org.atriasoft.etk.math.Vector2f;
|
||||
@ -550,4 +552,14 @@ public class CompositingSVG extends CompositingDraw {
|
||||
new Vector2f(borderRadius, borderRadius));
|
||||
flush();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addRectangle(
|
||||
final Vector2f position,
|
||||
final Vector2f size,
|
||||
final Insets thickness,
|
||||
final BorderRadius radius) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -5,8 +5,10 @@ import org.atriasoft.aknot.annotation.AknotDescription;
|
||||
import org.atriasoft.aknot.annotation.AknotManaged;
|
||||
import org.atriasoft.aknot.annotation.AknotName;
|
||||
import org.atriasoft.etk.Color;
|
||||
import org.atriasoft.etk.Dimension1f;
|
||||
import org.atriasoft.etk.Dimension2f;
|
||||
import org.atriasoft.etk.DimensionBorderRadius;
|
||||
import org.atriasoft.etk.DimensionInsets;
|
||||
import org.atriasoft.etk.Insets;
|
||||
import org.atriasoft.etk.math.Vector2f;
|
||||
import org.atriasoft.etk.math.Vector2i;
|
||||
import org.atriasoft.ewol.compositing.CompositingGC;
|
||||
@ -58,17 +60,17 @@ public class Box extends Container {
|
||||
super(subWidget);
|
||||
}
|
||||
|
||||
protected Dimension1f propertyBorderWidth = Dimension1f.ZERO;
|
||||
protected DimensionInsets propertyBorderWidth = DimensionInsets.ZERO;
|
||||
|
||||
@AknotManaged
|
||||
@AknotAttribute
|
||||
@AknotName(value = "border-width")
|
||||
@AknotDescription(value = "Border of the box")
|
||||
public Dimension1f getPropertyBorderWidth() {
|
||||
public DimensionInsets getPropertyBorderWidth() {
|
||||
return this.propertyBorderWidth;
|
||||
}
|
||||
|
||||
public void setPropertyBorderWidth(final Dimension1f propertyBorder) {
|
||||
public void setPropertyBorderWidth(final DimensionInsets propertyBorder) {
|
||||
if (this.propertyBorderWidth.equals(propertyBorder)) {
|
||||
return;
|
||||
}
|
||||
@ -77,17 +79,17 @@ public class Box extends Container {
|
||||
requestUpdateSize();
|
||||
}
|
||||
|
||||
protected Dimension1f propertyBorderRadius = new Dimension1f(0);
|
||||
protected DimensionBorderRadius propertyBorderRadius = DimensionBorderRadius.ZERO;
|
||||
|
||||
@AknotManaged
|
||||
@AknotAttribute
|
||||
@AknotName(value = "border-radius")
|
||||
@AknotDescription(value = "Border radius of the box")
|
||||
public Dimension1f getPropertyBorderRadius() {
|
||||
public DimensionBorderRadius getPropertyBorderRadius() {
|
||||
return this.propertyBorderRadius;
|
||||
}
|
||||
|
||||
public void setPropertyBorderRadius(final Dimension1f propertyBorderRadius) {
|
||||
public void setPropertyBorderRadius(final DimensionBorderRadius propertyBorderRadius) {
|
||||
if (this.propertyBorderRadius.equals(propertyBorderRadius)) {
|
||||
return;
|
||||
}
|
||||
@ -178,11 +180,12 @@ public class Box extends Container {
|
||||
final Vector2f childMinSize = new Vector2f(this.minSize.x(), this.minSize.y());
|
||||
|
||||
LOGGER.debug("calculate min size: border=" + this.propertyBorderWidth);
|
||||
final Vector2f borderSize = new Vector2f(this.propertyBorderWidth.size() * 2.0f,
|
||||
this.propertyBorderWidth.size() * 2.0f);
|
||||
final Insets borderSize = this.propertyBorderWidth.getPixel();
|
||||
|
||||
final Vector2f padding = this.propertyPadding.size().multiply(2);
|
||||
final Vector2f margin = this.propertyMargin.size().multiply(2);
|
||||
final Vector2f calculatedBoxMinSize = childMinSize.add(margin).add(padding).add(borderSize);
|
||||
|
||||
final Vector2f calculatedBoxMinSize = childMinSize.add(margin).add(padding).add(borderSize.toVector2f());
|
||||
|
||||
this.minSize = calculatedBoxMinSize;
|
||||
this.maxSize = Vector2f.max(this.minSize, this.propertyMaxSize.size());
|
||||
@ -200,8 +203,8 @@ public class Box extends Container {
|
||||
}
|
||||
final Vector2f localPadding = this.propertyPadding.size();
|
||||
final Vector2f localMargin = this.propertyMargin.size();
|
||||
final float localBorderSize = this.propertyBorderWidth.size();
|
||||
final Vector2f offsetSubWidget = localPadding.add(localMargin).add(localBorderSize);
|
||||
final Insets localBorderSize = this.propertyBorderWidth.getPixel();
|
||||
final Vector2f offsetSubWidget = localPadding.add(localMargin).add(localBorderSize.toVector2f());
|
||||
|
||||
Vector2f subWidgetSize = this.subWidget.getCalculateMinSize();
|
||||
if (this.subWidget.canExpand().x() && this.propertyFill.x()) {
|
||||
@ -266,12 +269,11 @@ public class Box extends Container {
|
||||
//System.out.println("renderSize: " + this.renderSize);
|
||||
// remove data of the previous composition :
|
||||
this.vectorialDraw.clear();
|
||||
final int borderSize = (int) this.propertyBorderWidth.size();
|
||||
this.vectorialDraw.setPaintFillColor(this.propertyColor);
|
||||
this.vectorialDraw.setPaintStrokeColor(this.propertyBorderColor);
|
||||
this.vectorialDraw.setPaintStrokeWidth(borderSize);
|
||||
this.vectorialDraw.addRectangle(renderOrigin, renderSize,
|
||||
new Vector2f(this.propertyBorderRadius.size(), this.propertyBorderRadius.size()));
|
||||
//this.vectorialDraw.setPaintStrokeWidth(borderSize);
|
||||
this.vectorialDraw.addRectangle(renderOrigin, renderSize, this.propertyBorderWidth.getPixel(),
|
||||
this.propertyBorderRadius.getPixel());
|
||||
this.vectorialDraw.flush();
|
||||
}
|
||||
|
||||
|
@ -8,8 +8,8 @@ import org.atriasoft.aknot.annotation.AknotSignal;
|
||||
import org.atriasoft.esignal.Connection;
|
||||
import org.atriasoft.esignal.SignalEmpty;
|
||||
import org.atriasoft.etk.Color;
|
||||
import org.atriasoft.etk.Dimension1f;
|
||||
import org.atriasoft.etk.Dimension2f;
|
||||
import org.atriasoft.etk.DimensionInsets;
|
||||
import org.atriasoft.etk.Uri;
|
||||
import org.atriasoft.etk.math.Vector2b;
|
||||
import org.atriasoft.etk.math.Vector2f;
|
||||
@ -98,7 +98,7 @@ public class Button extends Box {
|
||||
setMouseLimit(1);
|
||||
setPropertyExpand(Vector2b.TRUE);
|
||||
setPropertyFill(Vector2b.TRUE);
|
||||
setPropertyBorderWidth(new Dimension1f(4));
|
||||
setPropertyBorderWidth(new DimensionInsets(4));
|
||||
//setPropertyBorderRadius(new Dimension1f(15));
|
||||
setPropertyBorderColor(Color.BLACK);
|
||||
setPropertyColor(Color.WHITE);
|
||||
|
@ -9,8 +9,8 @@ import org.atriasoft.esignal.Connection;
|
||||
import org.atriasoft.esignal.Signal;
|
||||
import org.atriasoft.esignal.SignalEmpty;
|
||||
import org.atriasoft.etk.Color;
|
||||
import org.atriasoft.etk.Dimension1f;
|
||||
import org.atriasoft.etk.Dimension2f;
|
||||
import org.atriasoft.etk.DimensionInsets;
|
||||
import org.atriasoft.etk.Uri;
|
||||
import org.atriasoft.etk.math.Vector2b;
|
||||
import org.atriasoft.etk.math.Vector2f;
|
||||
@ -91,7 +91,7 @@ public class Tick extends Box {
|
||||
setPropertyExpand(Vector2b.FALSE);
|
||||
setPropertyFill(Vector2b.TRUE);
|
||||
setPropertyMinSize(new Dimension2f(new Vector2f(32f, 32f)));
|
||||
setPropertyBorderWidth(new Dimension1f(4));
|
||||
setPropertyBorderWidth(new DimensionInsets(4));
|
||||
//setPropertyBorderRadius(new Dimension1f(15));
|
||||
setPropertyBorderColor(Color.BLACK);
|
||||
setPropertyColor(Color.WHITE);
|
||||
|
Loading…
x
Reference in New Issue
Block a user