diff --git a/samples/pom.xml b/samples/pom.xml
index 0301d78..3346d16 100644
--- a/samples/pom.xml
+++ b/samples/pom.xml
@@ -50,6 +50,12 @@
logback-classic
1.5.18
+
+ ch.qos.logback
+ logback-classic
+ 1.5.18
+ test
+
xerces
xercesImpl
diff --git a/samples/src/main/sample/atriasoft/ewol/simpleWindowsWithBox/MainWindows.java b/samples/src/main/sample/atriasoft/ewol/simpleWindowsWithBox/MainWindows.java
index b52dd90..d7805fb 100644
--- a/samples/src/main/sample/atriasoft/ewol/simpleWindowsWithBox/MainWindows.java
+++ b/samples/src/main/sample/atriasoft/ewol/simpleWindowsWithBox/MainWindows.java
@@ -3,31 +3,34 @@ package sample.atriasoft.ewol.simpleWindowsWithBox;
import org.atriasoft.etk.Color;
import org.atriasoft.etk.Dimension1f;
import org.atriasoft.etk.Dimension2f;
+import org.atriasoft.etk.Dimension3f;
import org.atriasoft.etk.math.Vector2f;
import org.atriasoft.etk.math.Vector3b;
+import org.atriasoft.etk.math.Vector3f;
import org.atriasoft.ewol.widget.Box;
+import org.atriasoft.ewol.widget.Box2;
import sample.atriasoft.ewol.BasicWindows;
public class MainWindows extends BasicWindows {
-
- Box testWidget;
-
+
+ Box2 testWidget;
+
public MainWindows() {
//! [ewol_sample_HW_windows_title]
setPropertyTitle("Simple CheckBox");
-
+
final Box innerWidget = new Box();
//this.testWidget.setPropertySource(new Uri("DATA", "mireA.png"));
innerWidget.setPropertyExpand(Vector3b.FALSE);
innerWidget.setPropertyExpandIfFree(Vector3b.TRUE);
innerWidget.setPropertyFill(Vector3b.TRUE);
innerWidget.setPropertyColor(Color.PINK);
-
- this.testWidget = new Box(innerWidget);
- //this.testWidget.setPropertySource(new Uri("DATA", "mireA.png"));
- this.testWidget.setPropertyExpand(Vector3b.TRUE);
- this.testWidget.setPropertyFill(Vector3b.TRUE);
+ innerWidget.setPropertyMinSize(new Dimension3f(new Vector3f(50, 80, 15)));
+
+ this.testWidget = new Box2(innerWidget);
+ this.testWidget.setPropertyExpand(Vector3b.FALSE);
+ this.testWidget.setPropertyFill(Vector3b.FALSE);
this.testWidget.setPropertyBorderWidth(new Dimension1f(10));
this.testWidget.setPropertyBorderRadius(new Dimension1f(25));
this.testWidget.setPropertyBorderColor(Color.BLACK);
diff --git a/samples/src/resources/logback.xml b/samples/src/resources/logback.xml
index af419ee..83ccb8b 100644
--- a/samples/src/resources/logback.xml
+++ b/samples/src/resources/logback.xml
@@ -15,7 +15,7 @@
-
+
diff --git a/src/main/org/atriasoft/ewol/compositing/CompositingSVG.java b/src/main/org/atriasoft/ewol/compositing/CompositingSVG.java
index 413b2a0..f54b319 100644
--- a/src/main/org/atriasoft/ewol/compositing/CompositingSVG.java
+++ b/src/main/org/atriasoft/ewol/compositing/CompositingSVG.java
@@ -333,7 +333,7 @@ public class CompositingSVG extends Compositing {
}
/**
- * set position for the next text writen
+ * set position for the next text written
* @param pos Position of the text (in 3D)
*/
public void setPos(final Vector3f pos) {
@@ -345,8 +345,8 @@ public class CompositingSVG extends Compositing {
}
/**
- * set relative position for the next text writen
- * @param pos ofset apply of the text (in 3D)
+ * set relative position for the next text written
+ * @param pos offset apply of the text (in 3D)
*/
public void setRelPos(final Vector3f pos) {
this.position = this.position.add(pos);
@@ -374,6 +374,10 @@ public class CompositingSVG extends Compositing {
// }
public void setSource(final String data, final Vector2i size) {
+ if (data == null) {
+ LOGGER.error("try to set NULL data in svg");
+ return;
+ }
if (this.svgDoc == null && this.svgData.equals(data) && this.requestSize.x() == size.x()
&& this.requestSize.y() == size.y()) {
// Nothing to do ...
@@ -383,6 +387,7 @@ public class CompositingSVG extends Compositing {
this.svgDoc = null;
final EsvgDocument doc = new EsvgDocument();
doc.parse(data);
+ LOGGER.error("render size = {}", size);
final ImageByte tmp = ToolImage.convertImageByte(doc.renderImageFloatRGBA(size));
if (tmp == null) {
LOGGER.error("Can not load the Raw SVG ... ");
diff --git a/src/main/org/atriasoft/ewol/widget/Box.java b/src/main/org/atriasoft/ewol/widget/Box.java
index af7a791..b6bc04d 100644
--- a/src/main/org/atriasoft/ewol/widget/Box.java
+++ b/src/main/org/atriasoft/ewol/widget/Box.java
@@ -1,41 +1,24 @@
package org.atriasoft.ewol.widget;
-import java.io.IOException;
-
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.aknot.exception.AknotException;
-import org.atriasoft.ejson.JsonMapper;
-import org.atriasoft.ejson.exception.EjsonException;
import org.atriasoft.etk.Color;
import org.atriasoft.etk.Dimension1f;
import org.atriasoft.etk.Dimension2f;
-import org.atriasoft.etk.Uri;
import org.atriasoft.etk.math.Vector2f;
import org.atriasoft.etk.math.Vector2i;
-import org.atriasoft.etk.math.Vector3b;
import org.atriasoft.etk.math.Vector3f;
import org.atriasoft.ewol.compositing.CompositingSVG;
import org.atriasoft.ewol.event.EventTime;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-/**
- * @ingroup ewolWidgetGroup
- * Entry box display :
- *
- * ~~~~~~~~~~~~~~~~~~~~~~
- * -------------
- * | Content |
- * -------------
- * ~~~~~~~~~~~~~~~~~~~~~~
- */
public class Box extends Container {
private static final Logger LOGGER = LoggerFactory.getLogger(Box.class);
protected CompositingSVG compositing = new CompositingSVG();
-
+
public static class BoxParameter {
public Float margin;
public Float padding;
@@ -44,7 +27,7 @@ public class Box extends Container {
public String borderColor;
public String color;
}
-
+
/**
* Periodic call to update grapgic display
* @param event Time generic event
@@ -53,47 +36,31 @@ public class Box extends Container {
LOGGER.trace("Periodic call on Entry(" + event + ")");
self.markToRedraw();
}
-
- private final Uri propertyConfig = new Uri("THEME", "shape/Button.json", "ewol");
Vector2i startPosition = Vector2i.ZERO;
Vector2i endPosition = Vector2i.ZERO;
-
+
public boolean isInside(final Vector3f value) {
return value.x() > this.startPosition.x() //
&& value.y() > this.startPosition.y() //
&& value.x() < this.endPosition.x() //
&& value.y() < this.endPosition.y();
}
-
+
/**
* Constructor
*/
- public Box() {
- updateBasicConfig();
- }
-
+ public Box() {}
+
/**
* Constructor with his subWidget
*/
public Box(final Widget subWidget) {
super(subWidget);
- updateBasicConfig();
}
-
- private void updateBasicConfig() {
-
- final JsonMapper mapper = new JsonMapper();
- try {
- final BoxParameter parameters = mapper.read(BoxParameter.class, this.propertyConfig);
- // TODO ...
- } catch (EjsonException | AknotException | IOException e) {
- e.printStackTrace();
- }
- }
-
- protected Dimension1f propertyBorderWidth = Dimension1f.ZERO;
+ protected Dimension1f propertyBorderWidth = Dimension1f.ZERO;
+
@AknotManaged
@AknotAttribute
@AknotName(value = "border-width")
@@ -101,7 +68,7 @@ public class Box extends Container {
public Dimension1f getPropertyBorderWidth() {
return this.propertyBorderWidth;
}
-
+
public void setPropertyBorderWidth(final Dimension1f propertyBorder) {
if (this.propertyBorderWidth.equals(propertyBorder)) {
return;
@@ -110,9 +77,9 @@ public class Box extends Container {
markToRedraw();
requestUpdateSize();
}
-
+
protected Dimension1f propertyBorderRadius = new Dimension1f(0);
-
+
@AknotManaged
@AknotAttribute
@AknotName(value = "border-radius")
@@ -120,7 +87,7 @@ public class Box extends Container {
public Dimension1f getPropertyBorderRadius() {
return this.propertyBorderRadius;
}
-
+
public void setPropertyBorderRadius(final Dimension1f propertyBorderRadius) {
if (this.propertyBorderRadius.equals(propertyBorderRadius)) {
return;
@@ -129,9 +96,9 @@ public class Box extends Container {
markToRedraw();
requestUpdateSize();
}
-
- protected Color propertyBorderColor = Color.NONE;
+ protected Color propertyBorderColor = Color.NONE;
+
@AknotManaged
@AknotAttribute
@AknotName(value = "border-color")
@@ -139,7 +106,7 @@ public class Box extends Container {
public Color getPropertyBorderColor() {
return this.propertyBorderColor;
}
-
+
public void setPropertyBorderColor(final Color propertyBorderColor) {
if (this.propertyBorderColor.equals(propertyBorderColor)) {
return;
@@ -148,9 +115,9 @@ public class Box extends Container {
markToRedraw();
requestUpdateSize();
}
-
+
protected Color propertyColor = Color.NONE;
-
+
@AknotManaged
@AknotAttribute
@AknotName(value = "color")
@@ -158,7 +125,7 @@ public class Box extends Container {
public Color getPropertyColor() {
return this.propertyColor;
}
-
+
public void setPropertyColor(final Color propertyColor) {
if (this.propertyColor.equals(propertyColor)) {
return;
@@ -167,9 +134,9 @@ public class Box extends Container {
markToRedraw();
requestUpdateSize();
}
-
- protected Dimension2f propertyMargin = Dimension2f.ZERO;
+ protected Dimension2f propertyMargin = Dimension2f.ZERO;
+
@AknotManaged
@AknotAttribute
@AknotName(value = "margin")
@@ -177,7 +144,7 @@ public class Box extends Container {
public Dimension2f getPropertyMargin() {
return this.propertyMargin;
}
-
+
public void setPropertyMargin(final Dimension2f propertyMargin) {
if (this.propertyMargin.equals(propertyMargin)) {
return;
@@ -186,9 +153,9 @@ public class Box extends Container {
markToRedraw();
requestUpdateSize();
}
-
- protected Dimension2f propertyPadding = Dimension2f.ZERO;
+ protected Dimension2f propertyPadding = Dimension2f.ZERO;
+
@AknotManaged
@AknotAttribute
@AknotName(value = "padding")
@@ -196,7 +163,7 @@ public class Box extends Container {
public Dimension2f getPropertyPadding() {
return this.propertyPadding;
}
-
+
public void setPropertyPadding(final Dimension2f propertyPadding) {
if (this.propertyPadding.equals(propertyPadding)) {
return;
@@ -206,6 +173,23 @@ public class Box extends Container {
requestUpdateSize();
}
+ @Override
+ public void calculateMinMaxSize() {
+ super.calculateMinMaxSize();
+ 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 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);
+
+ this.minSize = new Vector3f(calculatedBoxMinSize.x(), calculatedBoxMinSize.y(), 0);
+ this.maxSize = Vector3f.max(this.minSize, this.propertyMaxSize.size());
+ markToRedraw();
+ }
+
@Override
public void onChangeSize() {
markToRedraw();
@@ -231,29 +215,37 @@ public class Box extends Container {
} else {
subWidgetSize = subWidgetSize.withY(this.minSize.y());
}
- if (this.subWidget.canExpand().z() && this.propertyFill.z()) {
- subWidgetSize = subWidgetSize.withZ(this.size.z());
- } else {
- subWidgetSize = subWidgetSize.withZ(this.minSize.z());
- }
- subWidgetSize = subWidgetSize.less(offsetSubWidget.x(), offsetSubWidget.y(), 0);
+ subWidgetSize = subWidgetSize.less(offsetSubWidget.x() * 2, offsetSubWidget.y() * 2, 0);
subWidgetSize = subWidgetSize.clipInteger();
-
- // set config to the Sub-widget
- //Vector3f subWidgetOrigin = this.origin.add(this.size.less(subWidgetSize).multiply(0.5f));
- Vector3f subWidgetOrigin = this.origin
- .add(this.propertyGravity.gravityGenerateDelta(this.size.less(subWidgetSize))).add(50);
- // NOTE le add 150 est pour un pb de test ==> a nlever en prod ...
+
+ final Vector3f freeSizeWithoutWidget = this.size
+ .less(new Vector3f(offsetSubWidget.x() * 2, offsetSubWidget.y() * 2, 0)).less(subWidgetSize);
+ Vector3f subWidgetOrigin = this.origin.add(this.propertyGravity.gravityGenerateDelta(freeSizeWithoutWidget));
+ subWidgetOrigin = subWidgetOrigin.add(new Vector3f(offsetSubWidget.x(), offsetSubWidget.y(), 0));
subWidgetOrigin = subWidgetOrigin.clipInteger();
-
this.subWidget.setOrigin(subWidgetOrigin);
this.subWidget.setSize(subWidgetSize);
this.subWidget.onChangeSize();
}
-
+
protected Vector2i renderOrigin;
protected Vector2i renderSize;
-
+
+ private Vector3f calculateOriginRendering(final Vector3f renderSize) {
+ return this.propertyGravity.gravityGenerateDelta(this.size.less(renderSize));
+ }
+
+ private Vector3f calculateSizeRendering() {
+ Vector3f tmpRenderSize = this.minSize;
+ if (this.propertyFill.x()) {
+ tmpRenderSize = tmpRenderSize.withX(this.size.x());
+ }
+ if (this.propertyFill.y()) {
+ tmpRenderSize = tmpRenderSize.withY(this.size.y());
+ }
+ return tmpRenderSize;
+ }
+
@Override
public void onRegenerateDisplay() {
super.onRegenerateDisplay();
@@ -261,39 +253,26 @@ public class Box extends Container {
//return;
}
final Vector2f localMargin = this.propertyMargin.size();
-
- final Vector3f minSizeWithoutMargin = this.minSize.less(localMargin.x() * 2, localMargin.y() * 2, 0);
- Vector3f tmpRenderSize = minSizeWithoutMargin;
- Vector3f tmpRenderOrigin = this.propertyGravity.gravityGenerateDelta(this.size.less(minSizeWithoutMargin));
- if (this.propertyFill.x()) {
- tmpRenderSize = tmpRenderSize.withX(this.size.x());
- tmpRenderOrigin = tmpRenderOrigin.withX(0.0f);
- }
- if (this.propertyFill.y()) {
- tmpRenderSize = tmpRenderSize.withY(this.size.y());
- tmpRenderOrigin = tmpRenderOrigin.withY(0.0f);
- }
- if (this.propertyFill.z()) {
- tmpRenderSize = tmpRenderSize.withZ(this.size.y());
- tmpRenderOrigin = tmpRenderOrigin.withZ(0.0f);
- }
+
+ Vector3f tmpRenderSize = calculateSizeRendering();
+ Vector3f tmpRenderOrigin = calculateOriginRendering(tmpRenderSize);
+
+ tmpRenderOrigin = tmpRenderOrigin.add(localMargin.x(), localMargin.y(), 0);
+ tmpRenderSize = tmpRenderSize.less(localMargin.x() * 2, localMargin.y() * 2, 0);
// not sure this is needed...
tmpRenderSize = tmpRenderSize.clipInteger();
tmpRenderOrigin = tmpRenderOrigin.clipInteger();
-
+
this.renderOrigin = new Vector2i((int) tmpRenderOrigin.x(), (int) tmpRenderOrigin.y());
this.renderSize = new Vector2i((int) tmpRenderSize.x(), (int) tmpRenderSize.y());
+ //System.out.println("renderSize: " + this.renderSize);
// remove data of the previous composition :
this.compositing.clear();
final int borderSize = (int) this.propertyBorderWidth.size();
final int paddingCompensateBorder = Math.round(borderSize * 0.5f);
-
- // this.renderSize = new Vector2i((int) (this.size.x() - this.propertyMargin.size().x() * 2),
- // (int) (this.size.y() - this.propertyMargin.size().y() * 2));
- // Bug intéressant: la parsing de la couleur est foireux, black et #000000FF ne rend pas la même chose ==> pour ètre plus précs le rendu avec alpha est foireux...
if (borderSize > 0.0f) {
this.compositing.setSource("""
-