diff --git a/samples/pom.xml b/samples/pom.xml
index 7452ac2..f25ceb8 100644
--- a/samples/pom.xml
+++ b/samples/pom.xml
@@ -44,17 +44,17 @@
ewol
0.1.0
+
+
+ org.slf4j
+ jul-to-slf4j
+ 2.0.9
+
ch.qos.logback
logback-classic
- 1.5.18
-
-
- ch.qos.logback
- logback-classic
- 1.5.18
- test
+ 1.4.11
xerces
diff --git a/samples/src/main/sample/atriasoft/ewol/BasicWindows.java b/samples/src/main/sample/atriasoft/ewol/BasicWindows.java
index 1990a21..4488c80 100644
--- a/samples/src/main/sample/atriasoft/ewol/BasicWindows.java
+++ b/samples/src/main/sample/atriasoft/ewol/BasicWindows.java
@@ -18,20 +18,20 @@ import org.slf4j.LoggerFactory;
public class BasicWindows extends Windows {
private static final Logger LOGGER = LoggerFactory.getLogger(BasicWindows.class);
-
+
private int index = -1;
private final List testedElement = new ArrayList<>();
private Container container = null;
private Label title = null;
-
+
public static void staticRequestNext(final BasicWindows self) {
self.requestNext();
}
-
+
public static void staticRequestPrevious(final BasicWindows self) {
self.requestPrevious();
}
-
+
public void requestNext() {
LOGGER.info("Request Next");
this.index++;
@@ -40,7 +40,7 @@ public class BasicWindows extends Windows {
}
updateDisplay();
}
-
+
public void requestPrevious() {
LOGGER.info("Request Previous");
this.index--;
@@ -49,7 +49,7 @@ public class BasicWindows extends Windows {
}
updateDisplay();
}
-
+
public void updateDisplay() {
final var test = this.testedElement.get(this.index);
final var titlegenerated = "[" + (this.index + 1) + "/" + this.testedElement.size() + "] " + test.getTitle()
@@ -58,14 +58,14 @@ public class BasicWindows extends Windows {
setPropertyTitle(titlegenerated);
this.container.setSubWidget(new ModelWidget(test));
}
-
+
public BasicWindows() {
-
+
final var sizerMain = new Sizer(DisplayMode.VERTICAL);
sizerMain.setPropertyExpand(Vector2b.TRUE);
sizerMain.setPropertyFill(Vector2b.TRUE);
setSubWidget(sizerMain);
-
+
final var menu = new Sizer(DisplayMode.HORIZONTAL);
menu.setPropertyExpand(Vector2b.TRUE_FALSE);
menu.setPropertyExpandIfFree(Vector2b.TRUE_FALSE);
@@ -73,40 +73,40 @@ public class BasicWindows extends Windows {
menu.setPropertyLockExpand(Vector2b.TRUE);
menu.setPropertyMaxSize(new Dimension2f(new Vector2f(9999, 3), Distance.CENTIMETER));
sizerMain.subWidgetAdd(menu);
-
+
this.container = new Container();
this.container.setPropertyExpand(Vector2b.TRUE);
this.container.setPropertyFill(Vector2b.TRUE);
sizerMain.subWidgetAdd(this.container);
-
+
final var next = Button.createLabelButton("<< Previous");
next.setPropertyMaxSize(new Dimension2f(new Vector2f(9999, 2), Distance.CENTIMETER));
menu.subWidgetAdd(next);
next.signalClick.connectAuto(this, BasicWindows::staticRequestNext);
-
+
this.title = new Label("unknown");
this.title.setPropertyFill(Vector2b.FALSE);
this.title.setPropertyExpand(Vector2b.TRUE);
menu.subWidgetAdd(this.title);
-
+
final var previous = Button.createLabelButton("Next >>");
previous.setPropertyMaxSize(new Dimension2f(new Vector2f(9999, 2), Distance.CENTIMETER));
menu.subWidgetAdd(previous);
previous.signalClick.connectAuto(this, BasicWindows::staticRequestPrevious);
-
+
this.container.setPropertyExpand(Vector2b.TRUE);
this.container.setPropertyFill(Vector2b.TRUE);
this.container.setPropertyExpandIfFree(Vector2b.TRUE);
-
+
+ this.testedElement.add(new TestWidgetBox());
this.testedElement.add(new TestWidgetSlider());
this.testedElement.add(new TestWidgetEntry());
- this.testedElement.add(new TestWidgetBox());
this.testedElement.add(new TestWidgetButton());
this.testedElement.add(new TestWidgetButtonToggle());
this.testedElement.add(new TestWidgetCheckBox());
this.testedElement.add(new TestWidgetImage());
this.testedElement.add(new TestWidgetLabel());
requestNext();
-
+
}
}
diff --git a/samples/src/main/sample/atriasoft/ewol/MainApplicaitionStarter.java b/samples/src/main/sample/atriasoft/ewol/MainApplicaitionStarter.java
index afded41..b54efcf 100644
--- a/samples/src/main/sample/atriasoft/ewol/MainApplicaitionStarter.java
+++ b/samples/src/main/sample/atriasoft/ewol/MainApplicaitionStarter.java
@@ -1,15 +1,20 @@
package sample.atriasoft.ewol;
+import java.util.logging.LogManager;
+
import org.atriasoft.etk.Uri;
import org.atriasoft.ewol.Ewol;
+import org.slf4j.bridge.SLF4JBridgeHandler;
public class MainApplicaitionStarter {
public static void main(final String[] args) {
+ // Loop-back of logger JDK logging API to SLF4J
+ LogManager.getLogManager().reset();
+ SLF4JBridgeHandler.install();
Ewol.init();
Uri.setApplication(MainApplicaitionStarter.class, "test-ewol/");
Ewol.run(new Appl(), args);
}
-
- private MainApplicaitionStarter() {
- }
+
+ private MainApplicaitionStarter() {}
}
diff --git a/src/main/org/atriasoft/ewol/compositing/CompositingDraw.java b/src/main/org/atriasoft/ewol/compositing/CompositingDraw.java
new file mode 100644
index 0000000..36cb64e
--- /dev/null
+++ b/src/main/org/atriasoft/ewol/compositing/CompositingDraw.java
@@ -0,0 +1,15 @@
+package org.atriasoft.ewol.compositing;
+
+/** @file
+ * @author Edouard DUPIN
+ * @copyright 2025, Edouard DUPIN, all right reserved
+ * @license MPL v2.0 (see license file)
+ */
+
+public abstract class CompositingDraw extends Compositing implements CompositingDrawInterface {
+
+ public static final CompositingDraw createGC() {
+ return new CompositingGC();
+ }
+
+}
diff --git a/src/main/org/atriasoft/ewol/compositing/CompositingDrawInterface.java b/src/main/org/atriasoft/ewol/compositing/CompositingDrawInterface.java
new file mode 100644
index 0000000..5af5930
--- /dev/null
+++ b/src/main/org/atriasoft/ewol/compositing/CompositingDrawInterface.java
@@ -0,0 +1,32 @@
+/** @file
+ * @author Edouard DUPIN
+ * @copyright 2025, Edouard DUPIN, all right reserved
+ * @license MPL v2.0 (see license file)
+ */
+package org.atriasoft.ewol.compositing;
+
+import org.atriasoft.etk.Color;
+import org.atriasoft.etk.math.Vector2f;
+
+public interface CompositingDrawInterface {
+ void clear();
+
+ void flush();
+
+ void setPaintFillColor(final Color color);
+
+ void setPaintStrokeColor(final Color color);
+
+ void setPaintStrokeWidth(final float width);
+
+ void addLine(final Vector2f startPos, final Vector2f stopPos);
+
+ void addRectangle(final Vector2f position, final Vector2f size);
+
+ void addRectangle(final Vector2f position, final Vector2f size, final Vector2f roundedCorner);
+
+ void addCircle(final Vector2f position, final float radius);
+
+ void addEllipse(final Vector2f center, final Vector2f radius);
+
+}
diff --git a/src/main/org/atriasoft/ewol/compositing/CompositingDrawing.java b/src/main/org/atriasoft/ewol/compositing/CompositingDrawing.java
index 6dcb943..bd636e7 100644
--- a/src/main/org/atriasoft/ewol/compositing/CompositingDrawing.java
+++ b/src/main/org/atriasoft/ewol/compositing/CompositingDrawing.java
@@ -20,9 +20,9 @@ import org.atriasoft.gale.resource.ResourceVirtualArrayObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class CompositingDrawing extends Compositing {
+public abstract class CompositingDrawing extends CompositingDraw {
private static final Logger LOGGER = LoggerFactory.getLogger(CompositingDrawing.class);
-
+
protected static int vboIdColor = 1;
protected static int vboIdCoord = 0;
private boolean clippingEnable = false; // !< true if the clipping must be activated
@@ -38,19 +38,19 @@ public class CompositingDrawing extends Compositing {
private ResourceProgram oGLprogram; // !< pointer on the opengl display program
private final List outColors = new ArrayList<>();
private final List outTriangles = new ArrayList<>();
-
+
private Vector3f position = new Vector3f(0, 0, 0); // !< The current position to draw
-
+
private float thickness = 0; // !< when drawing line and other things
-
+
private final Vector3f[] triangle = new Vector3f[3]; // !< Register every system with a combinaison of tiangle
-
+
private final Color[] tricolor = new Color[3]; // !< Register every the associated color foreground
-
+
private int triElement = 0; // !< special counter of the single dot generated
//protected ResourceVirtualBufferObject vbo;
protected ResourceVirtualArrayObject vbo;
-
+
// internal API for the generation abstraction of triangles
/**
* Basic ructor
@@ -66,7 +66,7 @@ public class CompositingDrawing extends Compositing {
// TO facilitate some debugs we add a name of the VBO:
this.vbo.setName("[VBO] of ewol::compositing::Area");
}
-
+
/**
* add a point reference at the current position (this is a vertex
* reference at the current position
@@ -75,7 +75,7 @@ public class CompositingDrawing extends Compositing {
internalSetColor(this.color);
setPoint(this.position);
}
-
+
/**
* draw a 2D circle with the specify rafdius parameter.
* @param radius Distence to the dorder
@@ -85,75 +85,90 @@ public class CompositingDrawing extends Compositing {
public void circle(final float radius) {
circle(radius, 0);
}
-
+
public void circle(final float radius, final float angleStart) {
circle(radius, angleStart, 2.0f * FMath.PI);
}
- public void circle(float radius, final float angleStart, float angleStop) {
+ public void circleBorderRaw(
+ final Vector3f centerPos,
+ final float radius,
+ final float thickness,
+ final float angleStart,
+ final float angleStop) {
resetCount();
-
- if (radius < 0) {
- radius *= -1;
- }
- angleStop = angleStop - angleStart;
-
int nbOcurence = (int) radius;
if (nbOcurence < 10) {
nbOcurence = 10;
}
+ for (int iii = 0; iii < nbOcurence; iii++) {
+ 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);
+ final float offsetInty = FMath.sin(angleOne) * (radius - thickness / 2);
+ final float offsetIntx = FMath.cos(angleOne) * (radius - thickness / 2);
+ final float angleTwo = angleStart + (angleStop * (iii + 1) / nbOcurence);
+ final float offsetExt2y = FMath.sin(angleTwo) * (radius + thickness / 2);
+ final float offsetExt2x = FMath.cos(angleTwo) * (radius + thickness / 2);
+ final float offsetInt2y = FMath.sin(angleTwo) * (radius - thickness / 2);
+ final float offsetInt2x = FMath.cos(angleTwo) * (radius - thickness / 2);
+ setPoint(new Vector3f(centerPos.x() + offsetIntx, centerPos.y() + offsetInty, 0));
+ setPoint(new Vector3f(centerPos.x() + offsetExtx, centerPos.y() + offsetExty, 0));
+ setPoint(new Vector3f(centerPos.x() + offsetExt2x, centerPos.y() + offsetExt2y, 0));
+ setPoint(new Vector3f(centerPos.x() + offsetExt2x, centerPos.y() + offsetExt2y, 0));
+ 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) {
+ resetCount();
+ int nbOcurence = (int) radius;
+ if (nbOcurence < 10) {
+ nbOcurence = 10;
+ }
+ for (int iii = 0; iii < nbOcurence; iii++) {
+ setPoint(new Vector3f(centerPos.x(), centerPos.y(), 0));
+
+ final float angleOne = angleStart + (angleStop * iii / nbOcurence);
+ 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);
+ offsety = FMath.sin(angleTwo) * radius;
+ offsetx = FMath.cos(angleTwo) * radius;
+
+ setPoint(new Vector3f(centerPos.x() + offsetx, centerPos.y() + offsety, 0));
+ }
+ }
+
+ public void circle(float radius, final float angleStart, float angleStop) {
+ resetCount();
+
+ if (radius < 0) {
+ radius *= -1;
+ }
+ angleStop = angleStop - angleStart;
+
// display background :
if (this.colorBg.a() != 0) {
internalSetColor(this.colorBg);
- for (int iii = 0; iii < nbOcurence; iii++) {
- setPoint(new Vector3f(this.position.x(), this.position.y(), 0));
-
- final float angleOne = angleStart + (angleStop * iii / nbOcurence);
- float offsety = FMath.sin(angleOne) * radius;
- float offsetx = FMath.cos(angleOne) * radius;
-
- setPoint(new Vector3f(this.position.x() + offsetx, this.position.y() + offsety, 0));
-
- final float angleTwo = angleStart + (angleStop * (iii + 1) / nbOcurence);
- offsety = FMath.sin(angleTwo) * radius;
- offsetx = FMath.cos(angleTwo) * radius;
-
- setPoint(new Vector3f(this.position.x() + offsetx, this.position.y() + offsety, 0));
- }
+ circleRaw(this.position, radius, angleStart, angleStop);
}
-
+
// show if we have a border :
if (this.thickness == 0 || this.color.a() == 0) {
return;
}
internalSetColor(this.color);
- for (int iii = 0; iii < nbOcurence; iii++) {
-
- final float angleOne = angleStart + (angleStop * iii / nbOcurence);
- final float offsetExty = FMath.sin(angleOne) * (radius + this.thickness / 2);
- final float offsetExtx = FMath.cos(angleOne) * (radius + this.thickness / 2);
- final float offsetInty = FMath.sin(angleOne) * (radius - this.thickness / 2);
- final float offsetIntx = FMath.cos(angleOne) * (radius - this.thickness / 2);
-
- final float angleTwo = angleStart + (angleStop * (iii + 1) / nbOcurence);
- final float offsetExt2y = FMath.sin(angleTwo) * (radius + this.thickness / 2);
- final float offsetExt2x = FMath.cos(angleTwo) * (radius + this.thickness / 2);
- final float offsetInt2y = FMath.sin(angleTwo) * (radius - this.thickness / 2);
- final float offsetInt2x = FMath.cos(angleTwo) * (radius - this.thickness / 2);
-
- setPoint(new Vector3f(this.position.x() + offsetIntx, this.position.y() + offsetInty, 0));
- setPoint(new Vector3f(this.position.x() + offsetExtx, this.position.y() + offsetExty, 0));
- setPoint(new Vector3f(this.position.x() + offsetExt2x, this.position.y() + offsetExt2y, 0));
-
- setPoint(new Vector3f(this.position.x() + offsetExt2x, this.position.y() + offsetExt2y, 0));
- setPoint(new Vector3f(this.position.x() + offsetInt2x, this.position.y() + offsetInt2y, 0));
- setPoint(new Vector3f(this.position.x() + offsetIntx, this.position.y() + offsetInty, 0));
- }
+ circleBorderRaw(this.position, radius, this.thickness, angleStart, angleStop);
}
-
+
/**
- * clear alll tre registered element in the current element
+ * clear all the registered element in the current element
*/
@Override
public void clear() {
@@ -163,23 +178,23 @@ public class CompositingDrawing extends Compositing {
this.vbo.clear();
this.outTriangles.clear();
this.outColors.clear();
-
+
// reset temporal variables :
this.position = Vector3f.ZERO;
-
+
this.clippingPosStart = Vector3f.ZERO;
this.clippingPosStop = Vector3f.ZERO;
this.clippingEnable = false;
-
+
this.color = Color.BLACK;
this.colorBg = Color.NONE;
-
+
for (int iii = 0; iii < 3; iii++) {
this.triangle[iii] = this.position;
this.tricolor[iii] = this.color;
}
}
-
+
/**
* draw All the refistered text in the current element on openGL
*/
@@ -202,7 +217,7 @@ public class CompositingDrawing extends Compositing {
this.vbo.unBindForRendering();
this.oGLprogram.unUse();
}
-
+
@Override
public void flush() {
// push data on the VBO
@@ -210,7 +225,7 @@ public class CompositingDrawing extends Compositing {
this.vbo.setColors(this.outColors.toArray(Color[]::new));
this.vbo.setVertexCount(this.outTriangles.size());
}
-
+
/**
* Lunch the generation of triangle
*/
@@ -223,7 +238,7 @@ public class CompositingDrawing extends Compositing {
this.outColors.add(this.tricolor[1]);
this.outColors.add(this.tricolor[2]);
}
-
+
/**
* Get the foreground color of the font.
* @return Foreground color.
@@ -231,7 +246,7 @@ public class CompositingDrawing extends Compositing {
public Color getColor() {
return this.color;
}
-
+
/**
* Get the background color of the font.
* @return Background color.
@@ -239,7 +254,7 @@ public class CompositingDrawing extends Compositing {
public Color getColorBg() {
return this.colorBg;
}
-
+
/**
* get the current display position (sometime needed in the gui control)
* @return the current position.
@@ -247,7 +262,7 @@ public class CompositingDrawing extends Compositing {
public Vector3f getPos() {
return this.position;
}
-
+
/**
* set the Color of the current triangle drawing
* @param color Color to current dots generated
@@ -263,7 +278,7 @@ public class CompositingDrawing extends Compositing {
this.tricolor[2] = color;
}
}
-
+
/**
* Relative drawing a line (special vector)
* @param vect Vector of the current line.
@@ -271,31 +286,31 @@ public class CompositingDrawing extends Compositing {
public void lineRel(final float xxx, final float yyy) {
lineTo(this.position.add(new Vector3f(xxx, yyy, 0)));
}
-
+
public void lineRel(final float xxx, final float yyy, final float zzz) {
lineTo(this.position.add(new Vector3f(xxx, yyy, zzz)));
}
-
+
public void lineRel(final Vector2f vect) {
lineRel(new Vector3f(vect.x(), vect.y(), 0));
}
-
+
public void lineRel(final Vector3f vect) {
lineTo(this.position.add(vect));
}
-
+
public void lineTo(final float xxx, final float yyy) {
lineTo(new Vector3f(xxx, yyy, 0));
}
-
+
public void lineTo(final float xxx, final float yyy, final float zzz) {
lineTo(new Vector3f(xxx, yyy, zzz));
}
-
+
public void lineTo(final Vector2f dest) {
lineTo(new Vector3f(dest.x(), dest.y(), 0));
}
-
+
/**
* draw a line to a specific position
* @param dest Position of the end of the line.
@@ -326,14 +341,14 @@ public class CompositingDrawing extends Compositing {
setPoint(new Vector3f(this.position.x() - offsetx, this.position.y() - offsety, this.position.z()));
setPoint(new Vector3f(this.position.x() + offsetx, this.position.y() + offsety, this.position.z()));
setPoint(new Vector3f(dest.x() + offsetx, dest.y() + offsety, this.position.z()));
-
+
setPoint(new Vector3f(dest.x() + offsetx, dest.y() + offsety, dest.z()));
setPoint(new Vector3f(dest.x() - offsetx, dest.y() - offsety, dest.z()));
setPoint(new Vector3f(this.position.x() - offsetx, this.position.y() - offsety, dest.z()));
// update the system position :
this.position = dest;
}
-
+
/**
* load the openGL program and get all the ID needed
*/
@@ -352,39 +367,47 @@ public class CompositingDrawing extends Compositing {
this.oGLMatrixView = this.oGLprogram.getUniform("in_matrixView");
}
}
-
+
public void rectangle(final float xxx, final float yyy) {
rectangle(new Vector3f(xxx, yyy, 0));
}
-
+
public void rectangle(final float xxx, final float yyy, final float zzz) {
rectangle(new Vector3f(xxx, yyy, zzz));
}
-
+
public void rectangle(final Vector2f dest) {
- rectangle(new Vector3f(dest.x(), dest.y(), 0));
+ rectangle(dest.toVector3f());
}
-
+
/**
* draw a 2D rectangle to the position requested.
* @param dest Position the the end of the rectangle
*/
public void rectangle(final Vector3f dest) {
- resetCount();
internalSetColor(this.color);
+ rectangleRaw(this.position, dest);
+ }
+
+ public void rectangleRaw(final Vector3f startPos, final Vector3f endPos) {
+ resetCount();
/*
- * Bitmap position xA xB yC *------* | | | | yD *------*
+ * Bitmap position xA xB
+ * yC *------*
+ * | |
+ * | |
+ * yD *------*
*/
- float dxA = this.position.x();
- float dxB = dest.x();
+ float dxA = startPos.x();
+ float dxB = endPos.x();
if (dxA > dxB) {
// inverse order :
final float tmp = dxA;
dxA = dxB;
dxB = tmp;
}
- float dyC = this.position.y();
- float dyD = dest.y();
+ float dyC = startPos.y();
+ float dyD = endPos.y();
if (dyC > dyD) {
// inverse order :
final float tmp = dyC;
@@ -411,24 +434,219 @@ public class CompositingDrawing extends Compositing {
setPoint(new Vector3f(dxA, dyD, 0));
setPoint(new Vector3f(dxA, dyC, 0));
setPoint(new Vector3f(dxB, dyC, 0));
-
+
setPoint(new Vector3f(dxB, dyC, 0));
setPoint(new Vector3f(dxB, dyD, 0));
setPoint(new Vector3f(dxA, dyD, 0));
}
+ public void rectangleBorder(final Vector2f dest, final float borderWidth) {
+ rectangleBorder(dest.toVector3f(), borderWidth);
+ }
+
+ public void rectangleBorder(final Vector3f dest, final float borderWidth) {
+ /*
+ * Bitmap position xA xB
+ * yC *--------------* buttom
+ * | |
+ * | xpA xpB |
+ * ypC | *------* |
+ * | | | |
+ * | | | |
+ * Left | | | |
+ * | | | |
+ * ypD | *------* |
+ * | |
+ * | |
+ * yD *--------------* Top
+ */
+ resetCount();
+ internalSetColor(this.colorBg);
+ float dxA = this.position.x();
+ float dxB = dest.x();
+ if (dxA > dxB) {
+ // inverse order :
+ final float tmp = dxA;
+ dxA = dxB;
+ dxB = tmp;
+ }
+ float dyC = this.position.y();
+ float dyD = dest.y();
+ if (dyC > dyD) {
+ // inverse order :
+ final float tmp = dyC;
+ dyC = dyD;
+ dyD = tmp;
+ }
+ float dxpA = dxA + borderWidth * 0.5f;
+ float dxpB = dxB - borderWidth * 0.5f;
+ float dypC = dyC + borderWidth * 0.5f;
+ float dypD = dyD - borderWidth * 0.5f;
+ dxA = dxA - borderWidth * 0.5f;
+ dxB = dxB + borderWidth * 0.5f;
+ dyC = dyC - borderWidth * 0.5f;
+ dyD = dyD + borderWidth * 0.5f;
+ if (this.clippingEnable) {
+ if (dxA < this.clippingPosStart.x()) {
+ dxA = this.clippingPosStart.x();
+ }
+ if (dxB > this.clippingPosStop.x()) {
+ dxB = this.clippingPosStop.x();
+ }
+ if (dyC < this.clippingPosStart.y()) {
+ dyC = this.clippingPosStart.y();
+ }
+ if (dyD > this.clippingPosStop.y()) {
+ dyD = this.clippingPosStop.y();
+ }
+ if (dxpA < this.clippingPosStart.x()) {
+ dxpA = this.clippingPosStart.x();
+ }
+ if (dxpB > this.clippingPosStop.x()) {
+ dxpB = this.clippingPosStop.x();
+ }
+ if (dypC < this.clippingPosStart.y()) {
+ dypC = this.clippingPosStart.y();
+ }
+ if (dypD > this.clippingPosStop.y()) {
+ dypD = this.clippingPosStop.y();
+ }
+ }
+ if (dyC >= dyD || dxA >= dxB) {
+ return;
+ }
+ // Buttom border:
+ setPoint(new Vector3f(dxA, dyC, 0));
+ setPoint(new Vector3f(dxB, dyC, 0));
+ setPoint(new Vector3f(dxpA, dypC, 0));
+
+ setPoint(new Vector3f(dxB, dyC, 0));
+ setPoint(new Vector3f(dxpA, dypC, 0));
+ setPoint(new Vector3f(dxpB, dypC, 0));
+
+ // Right border:
+ setPoint(new Vector3f(dxpB, dypC, 0));
+ setPoint(new Vector3f(dxB, dyC, 0));
+ setPoint(new Vector3f(dxB, dyD, 0));
+
+ setPoint(new Vector3f(dxpB, dypC, 0));
+ setPoint(new Vector3f(dxB, dyD, 0));
+ setPoint(new Vector3f(dxpB, dypD, 0));
+
+ // Top border:
+ setPoint(new Vector3f(dxpB, dypD, 0));
+ setPoint(new Vector3f(dxB, dyD, 0));
+ setPoint(new Vector3f(dxA, dyD, 0));
+
+ setPoint(new Vector3f(dxpB, dypD, 0));
+ setPoint(new Vector3f(dxA, dyD, 0));
+ setPoint(new Vector3f(dxpA, dypD, 0));
+
+ // Left border:
+ setPoint(new Vector3f(dxpA, dypD, 0));
+ setPoint(new Vector3f(dxA, dyD, 0));
+ setPoint(new Vector3f(dxpA, dypC, 0));
+
+ setPoint(new Vector3f(dxA, dyD, 0));
+ setPoint(new Vector3f(dxpA, dypC, 0));
+ setPoint(new Vector3f(dxA, dyC, 0));
+ }
+
+ /**
+ * draw a 2D rectangle to the position requested.
+ * @param dest Position the the end of the rectangle
+ */
+ public void rectangleRadius(final Vector2f dest, final float radius) {
+ rectangleRadius(dest.toVector3f(), radius);
+ }
+
+ public void rectangleRadius(final Vector3f dest, final float radius) {
+ internalSetColor(this.color);
+ final boolean showConstruct = false;
+
+ rectangleRaw(this.position.add(new Vector3f(radius, 0, 0)), dest.less(new Vector3f(radius, 0, 0)));
+ if (showConstruct) {
+ internalSetColor(Color.ORANGE);
+ }
+ rectangleRaw(this.position.add(new Vector3f(0, radius, 0)),
+ new Vector3f(this.position.x() + radius, dest.y() - radius, 0));
+ if (showConstruct) {
+ internalSetColor(Color.GRAY);
+ }
+ rectangleRaw(new Vector3f(dest.x() - radius, this.position.y() + radius, 0),
+ new Vector3f(dest.x(), dest.y() - radius, 0));
+
+ if (showConstruct) {
+ internalSetColor(Color.AQUA_MARINE);
+ }
+ circleRaw(this.position.add(radius, radius, 0), radius, FMath.PI, FMath.PI * 0.5f);
+ circleRaw(dest.less(radius, radius, 0), radius, 0, FMath.PI * 0.5f);
+ circleRaw(new Vector3f(dest.x() - radius, this.position.y() + radius, 0), radius, FMath.PI * 1.5f,
+ FMath.PI * 0.5f);
+ circleRaw(new Vector3f(this.position.x() + radius, dest.y() - radius, 0), radius, 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 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;
+ 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));
}
-
+
public void rectangleWidth(final float xxx, final float yyy, final float zzz) {
rectangleWidth(new Vector3f(xxx, yyy, zzz));
}
-
+
public void rectangleWidth(final Vector2f size) {
rectangleWidth(new Vector3f(size.x(), size.y(), 0));
}
-
+
/**
* draw a 2D rectangle to the requested size.
* @param size size of the rectangle
@@ -436,18 +654,18 @@ public class CompositingDrawing extends Compositing {
public void rectangleWidth(final Vector3f size) {
rectangle(this.position.add(size));
}
-
+
/**
* in case of some error the count can be reset
*/
private void resetCount() {
this.triElement = 0;
}
-
+
public void setClipping(final Vector2f pos, final Vector2f posEnd) {
setClipping(new Vector3f(pos.x(), pos.y(), -1), new Vector3f(posEnd.x(), posEnd.y(), 1));
}
-
+
/**
* Request a clipping area for the text (next draw only)
* @param pos Start position of the clipping
@@ -460,7 +678,7 @@ public class CompositingDrawing extends Compositing {
this.clippingPosStart = Vector3f.min(pos, posEnd);
this.clippingEnable = true;
}
-
+
/**
* enable/Disable the clipping (without lose the current clipping
* position)
@@ -469,11 +687,11 @@ public class CompositingDrawing extends Compositing {
public void setClippingMode(final boolean newMode) {
this.clippingEnable = newMode;
}
-
+
public void setClippingWidth(final Vector2f pos, final Vector2f width) {
setClippingWidth(new Vector3f(pos.x(), pos.y(), -1), new Vector3f(width.x(), width.y(), 2));
}
-
+
/**
* Request a clipping area for the text (next draw only)
* @param pos Start position of the clipping
@@ -482,7 +700,7 @@ public class CompositingDrawing extends Compositing {
public void setClippingWidth(final Vector3f pos, final Vector3f width) {
setClipping(pos, pos.add(width));
}
-
+
/**
* set the Color of the current foreground font
* @param color Color to set on foreground (for next print)
@@ -490,7 +708,7 @@ public class CompositingDrawing extends Compositing {
public void setColor(final Color color) {
this.color = color;
}
-
+
/**
* set the background color of the font (for selected Text (not the
* global BG))
@@ -499,7 +717,7 @@ public class CompositingDrawing extends Compositing {
public void setColorBg(final Color color) {
this.colorBg = color;
}
-
+
/**
* internal add of the specific point
* @param point The requeste dpoint to add
@@ -512,19 +730,19 @@ public class CompositingDrawing extends Compositing {
}
this.vbo.flush();
}
-
+
public void setPos(final float xxx, final float yyy) {
setPos(new Vector3f(xxx, yyy, 0));
}
-
+
public void setPos(final float xxx, final float yyy, final float zzz) {
setPos(new Vector3f(xxx, yyy, zzz));
}
-
+
public void setPos(final Vector2f pos) {
setPos(new Vector3f(pos.x(), pos.y(), 0));
}
-
+
/**
* set position for the next text written
* @param pos Position of the text (in 3D)
@@ -532,11 +750,11 @@ public class CompositingDrawing extends Compositing {
public void setPos(final Vector3f pos) {
this.position = pos;
}
-
+
public void setRelPos(final float xxx, final float yyy) {
this.position = this.position.add(xxx, yyy, 0);
}
-
+
/**
* set relative position for the next text writen
* @param pos ofset apply of the text (in 3D)
@@ -544,15 +762,15 @@ public class CompositingDrawing extends Compositing {
public void setRelPos(final float xxx, final float yyy, final float zzz) {
this.position = this.position.add(xxx, yyy, zzz);
}
-
+
public void setRelPos(final Vector2f pos) {
setRelPos(new Vector3f(pos.x(), pos.y(), 0));
}
-
+
public void setRelPos(final Vector3f pos) {
this.position = this.position.add(pos);
}
-
+
/**
* Specify the line thickness for the next elements
* @param thickness The thickness desired for the next print
@@ -564,12 +782,12 @@ public class CompositingDrawing extends Compositing {
this.thickness *= -1;
}
}
-
+
/**
* Un-Load the openGL program and get all the ID needed
*/
private void unLoadProgram() {
this.oGLprogram = null;
}
-
+
}
\ No newline at end of file
diff --git a/src/main/org/atriasoft/ewol/compositing/CompositingGC.java b/src/main/org/atriasoft/ewol/compositing/CompositingGC.java
new file mode 100644
index 0000000..b90d29c
--- /dev/null
+++ b/src/main/org/atriasoft/ewol/compositing/CompositingGC.java
@@ -0,0 +1,73 @@
+/** @file
+ * @author Edouard DUPIN
+ * @copyright 2011, Edouard DUPIN, all right reserved
+ * @license MPL v2.0 (see license file)
+ */
+package org.atriasoft.ewol.compositing;
+
+import org.atriasoft.etk.Color;
+import org.atriasoft.etk.math.Vector2f;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class CompositingGC extends CompositingDrawing {
+ private static final Logger LOGGER = LoggerFactory.getLogger(CompositingGC.class);
+
+ @Override
+ public void setPaintFillColor(final Color color) {
+ setColor(color);
+ }
+
+ @Override
+ public void setPaintStrokeColor(final Color color) {
+ setColorBg(color);
+ }
+
+ float strokeSize = 0;
+
+ @Override
+ public void setPaintStrokeWidth(final float width) {
+ this.strokeSize = width;
+ }
+
+ @Override
+ public void addLine(final Vector2f startPos, final Vector2f stopPos) {
+ setPos(startPos);
+ lineTo(stopPos);
+ }
+
+ @Override
+ public void addRectangle(final Vector2f position, final Vector2f size) {
+ setPos(position);
+ rectangle(position.add(size));
+ if (this.strokeSize > 0) {
+ rectangleBorder(position.add(size), this.strokeSize);
+ }
+ }
+
+ @Override
+ public void addRectangle(final Vector2f position, final Vector2f size, final Vector2f roundedCorner) {
+ if (roundedCorner == null || roundedCorner.x() <= 0) {
+ addRectangle(position, size);
+ } else {
+ setPos(position);
+ rectangleRadius(position.add(size), roundedCorner.x());
+ if (this.strokeSize > 0) {
+ rectangleBorderRadius(position.add(size), this.strokeSize, roundedCorner.x());
+ }
+ }
+ }
+
+ @Override
+ public void addCircle(final Vector2f position, final float radius) {
+ setPos(position);
+ circle(radius);
+
+ }
+
+ @Override
+ public void addEllipse(final Vector2f center, final Vector2f radius) {
+ // TODO Auto-generated method stub
+
+ }
+}
\ No newline at end of file
diff --git a/src/main/org/atriasoft/ewol/compositing/CompositingGraphicContext.java b/src/main/org/atriasoft/ewol/compositing/CompositingGraphicContext.java
deleted file mode 100644
index 152895d..0000000
--- a/src/main/org/atriasoft/ewol/compositing/CompositingGraphicContext.java
+++ /dev/null
@@ -1,269 +0,0 @@
-/** @file
- * @author Edouard DUPIN
- * @copyright 2011, Edouard DUPIN, all right reserved
- * @license MPL v2.0 (see license file)
- */
-package org.atriasoft.ewol.compositing;
-
-import org.atriasoft.egami.ImageByte;
-import org.atriasoft.esvg.CapMode;
-import org.atriasoft.esvg.GraphicContext;
-import org.atriasoft.esvg.JoinMode;
-import org.atriasoft.etk.Color;
-import org.atriasoft.etk.math.Vector2f;
-import org.atriasoft.etk.math.Vector2i;
-import org.atriasoft.gale.resource.ResourceTexture2;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class CompositingGraphicContext extends Compositing {
- private static final Logger LOGGER = LoggerFactory.getLogger(CompositingGraphicContext.class);
- GraphicContext context = new GraphicContext();
- private final ResourceTexture2 texture = new ResourceTexture2();
-
- public CompositingGraphicContext() {
-
- }
-
- public Vector2i calculateTextSize(final String data) {
- return this.context.calculateTextSize(data);
- }
-
- public void circle(final Vector2f position, final float radius) {
- this.context.circle(position, radius);
- }
-
- /**
- * clear alll tre registered element in the current element
- */
- @Override
- public void clear() {
- // call upper class
- super.clear();
- // reset Buffer :
- this.context.clear();
- }
-
- /**
- * Clear the fill color (disable fill ==> better that set it transparent)
- */
- public void clearColorFill() {
- this.context.clearColorFill();
- }
-
- /**
- * Clear the Stroke color (disable stroke)
- */
- public void clearColorStroke() {
- this.context.clearColorStroke();
- }
-
- @Override
- public void draw(final boolean disableDepthTest) {
- // TODO Auto-generated method stub
-
- }
-
- public void ellipse(final Vector2f center, final Vector2f radius) {
- this.context.ellipse(center, radius);
- }
-
- @Override
- public void flush() {
- if (this.texture == null) {
- LOGGER.warn("texture is null");
- return;
- }
- final ImageByte img = this.context.render();
- //IOgami.storePNG(new Uri("/home/heero/000000000aaaaplopppp222.png"), img);
- this.texture.set(img);
- this.texture.flush();
- }
-
- /**
- * Get the fill color.
- * @return fill color.
- */
- public Color getColorFill() {
- return this.context.getColorFill();
- }
-
- /**
- * Get the stroke color.
- * @return Stroke color.
- */
- public Color getColorStroke() {
- return this.context.getColorStroke();
- }
-
- public CapMode getLineCap() {
- return this.context.getLineCap();
- }
-
- public JoinMode getLineJoin() {
- return this.context.getLineJoin();
- }
-
- public float getMiterLimit() {
- return this.context.getMiterLimit();
- }
-
- public float getOpacity() {
- return this.context.getOpacity();
- }
-
- /**
- * get the source image registered size in the file (<0 when multiple size image)
- * @return tre image registered size
- */
- public Vector2i getRealSize() {
- return this.texture.get().getSize();
- }
-
- public int getRendererId() {
- return this.texture.getRendererId();
- }
-
- public ResourceTexture2 getResourceTexture() {
- return this.texture;
- }
-
- public float getStrokeWidth() {
- return this.context.getStrokeWidth();
- }
-
- public int getTextHeight() {
- return this.context.getTextHeight();
- }
-
- public float getTextSize() {
- return this.context.getTextSize();
- }
-
- /**
- * Sometimes the user declare an image but not allocate the ressources all the time, this is to know it ..
- * @return the validity od the resources.
- */
- public boolean hasSources() {
- return true;
- }
-
- public void line(final Vector2f origin, final Vector2f destination) {
- this.context.line(origin, destination);
- }
-
- public void lineRel(final Vector2f origin, final Vector2f relativeDestination) {
- this.context.lineRel(origin, relativeDestination);
- }
-
- public void pathLine(final Vector2f pos) {
- this.context.pathLine(pos);
- }
-
- public void pathLineTo(final Vector2f pos) {
- this.context.pathLineTo(pos);
-
- }
-
- public void pathMove(final Vector2f pos) {
- this.context.pathMove(pos);
- }
-
- public void pathMoveTo(final Vector2f pos) {
- this.context.pathMoveTo(pos);
- }
-
- public void pathStart() {
- this.context.pathStart();
- }
-
- public void pathStop() {
- this.context.pathStop();
- }
-
- public void pathStopLinked() {
- this.context.pathStopLinked();
- }
-
- public void rectangle(final Vector2f position, final Vector2f destination) {
- this.context.rectangle(position, destination);
- }
-
- public void rectangleRounded(final Vector2f position, final Vector2f destination, final Vector2f ruound) {
- this.context.rectangleRounded(position, destination, ruound);
- }
-
- public void rectangleRoundedWidth(final Vector2f position, final Vector2f width, final Vector2f ruound) {
- this.context.rectangleRoundedWidth(position, width, ruound);
- }
-
- public void rectangleWidth(final Vector2f position, final Vector2f width) {
- this.context.rectangleWidth(position, width);
- }
-
- /**
- * set the fill color
- * @param color Color to set on fill
- * @apiNote use clearFill() if you want to remove drawing of fill
- */
- public void setColorFill(final Color color) {
- this.context.setColorFill(color);
- }
-
- /**
- * set the stroke color
- * @param color Color to set on stroke
- * @apiNote use clearStroke() if you want to remove drawing of stroke
- */
- public void setColorStroke(final Color color) {
- this.context.setColorStroke(color);
- }
-
- public void setLineCap(final CapMode lineCap) {
- this.context.setLineCap(lineCap);
- }
-
- public void setLineJoin(final JoinMode lineJoin) {
- this.context.setLineJoin(lineJoin);
- }
-
- public void setMiterLimit(final float miterLimit) {
- this.context.setMiterLimit(miterLimit);
- }
-
- public void setOpacity(final float opacity) {
- this.context.setOpacity(opacity);
- }
-
- /**
- * Set global size of the Graphic context (output render size)
- * @param xxx Width of the image
- * @param yyy Height of the image
- * @apiNote It will clear the current context.
- */
- public void setSize(final int xxx, final int yyy) {
- this.context.setSize(xxx, yyy);
- }
-
- /**
- * Set global size of the Graphic contexct (output render size)
- * @param vector2i New size of the image
- * @apiNote It will clear the current context.
- */
- public void setSize(final Vector2i size) {
- this.context.setSize(size.x(), size.y());
- }
-
- public void setStrokeWidth(final float strokeWidth) {
- this.context.setStrokeWidth(strokeWidth);
- }
-
- public void text(final Vector2f position, final float height, final String data) {
- this.context.text(position, height, data);
- }
-
- public void text(final Vector2f position, final String data) {
- this.context.text(position, data);
- }
-
-}
diff --git a/src/main/org/atriasoft/ewol/compositing/CompositingSVG.java b/src/main/org/atriasoft/ewol/compositing/CompositingSVG.java
index a7b2a4c..68dfc0b 100644
--- a/src/main/org/atriasoft/ewol/compositing/CompositingSVG.java
+++ b/src/main/org/atriasoft/ewol/compositing/CompositingSVG.java
@@ -8,13 +8,21 @@ package org.atriasoft.ewol.compositing;
import org.atriasoft.egami.ImageByte;
import org.atriasoft.egami.ImageByteRGBA;
import org.atriasoft.egami.ToolImage;
+import org.atriasoft.esvg.CapMode;
+import org.atriasoft.esvg.Circle;
+import org.atriasoft.esvg.Ellipse;
import org.atriasoft.esvg.EsvgDocument;
+import org.atriasoft.esvg.JoinMode;
+import org.atriasoft.esvg.Line;
+import org.atriasoft.esvg.PaintState;
+import org.atriasoft.esvg.Rectangle;
import org.atriasoft.etk.Color;
import org.atriasoft.etk.Uri;
import org.atriasoft.etk.math.Matrix4f;
import org.atriasoft.etk.math.Vector2f;
import org.atriasoft.etk.math.Vector2i;
import org.atriasoft.etk.math.Vector3f;
+import org.atriasoft.etk.util.Pair;
import org.atriasoft.gale.backend3d.OpenGL;
import org.atriasoft.gale.backend3d.OpenGL.RenderMode;
import org.atriasoft.gale.resource.ResourceProgram;
@@ -23,7 +31,7 @@ import org.atriasoft.gale.resource.ResourceVirtualArrayObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class CompositingSVG extends Compositing {
+public class CompositingSVG extends CompositingDraw {
private static final Logger LOGGER = LoggerFactory.getLogger(CompositingSVG.class);
public static final int NB_VBO = 3;
public static final int SIZE_AUTO = 0;
@@ -126,11 +134,14 @@ public class CompositingSVG extends Compositing {
@Override
public void flush() {
- this.vbo.setPosition(this.vboDataCoords);
- this.vbo.setTextureCoordinate(this.vboDataCoordsTex);
- this.vbo.setColors(this.vboDataColors);
- this.vbo.setVertexCount(this.vboDataCoords.length);
- this.vbo.flush();
+ generate();
+ if (this.vboDataCoords != null) {
+ this.vbo.setPosition(this.vboDataCoords);
+ this.vbo.setTextureCoordinate(this.vboDataCoordsTex);
+ this.vbo.setColors(this.vboDataColors);
+ this.vbo.setVertexCount(this.vboDataCoords.length);
+ this.vbo.flush();
+ }
}
/**
@@ -407,39 +418,120 @@ public class CompositingSVG extends Compositing {
// Nothing to do ...
return;
}
- this.svgData = null;
clear();
- final ImageByte tmp = ToolImage.convertImageByte(data.renderImageFloatRGBA(size));
- if (tmp == null) {
- LOGGER.error("Can not load the Raw SVG ... ");
- return;
- }
- if (this.resource == null) {
- this.resource = new ResourceTexture2();
- }
- this.resource.set(tmp);
this.svgDoc = data;
this.requestSize = size;
+ generate();
+ }
+
+ protected void generate() {
+ final Vector2i size = this.requestSize;
+ if (this.svgDoc != null) {
+ final ImageByte tmp = ToolImage.convertImageByte(this.svgDoc.renderImageFloatRGBA(size));
+ if (tmp == null) {
+ LOGGER.error("Can not load the Raw SVG ... ");
+ return;
+ }
+ if (this.resource == null) {
+ this.resource = new ResourceTexture2();
+ }
+ this.resource.set(tmp);
+ }
+ }
+
+ PaintState paint = new PaintState();
+
+ public void clearPaint() {
+ this.paint.clear();
+ }
+
+ public void createSize(final Vector2i size) {
+ clear();
+ this.paint.clear();
+ if (this.svgDoc == null) {
+ this.svgDoc = new EsvgDocument(size);
+ }
+ this.requestSize = size;
}
- public void setRectangleAsSource(final int sizeX, final int sizeY, final Color color) {
- setSource("""
- """.formatted( //
- sizeX, sizeY, //
- 0, 0, //
- sizeX, sizeY, //
- color.toStringSharp() //
- ), new Vector2i(sizeX, sizeY));
+ @Override
+ public void setPaintFillColor(final Color color) {
+ this.paint.fill = new Pair<>(color, "");
}
+ @Override
+ public void setPaintStrokeColor(final Color color) {
+ this.paint.stroke = new Pair<>(color, "");
+ }
+
+ @Override
+ public void setPaintStrokeWidth(final float width) {
+ this.paint.strokeWidth = width;
+ }
+
+ public void setPaintLineJoin(final JoinMode lineJoin) {
+ this.paint.lineJoin = lineJoin;
+ }
+
+ public void setPaintLineCap(final CapMode lineCap) {
+ this.paint.lineCap = lineCap;
+ }
+
+ public void setPaintMiterLimit(final float miterLimit) {
+ this.paint.miterLimit = miterLimit;
+ }
+
+ public void setPaintOpacity(final float opacity) {
+ this.paint.opacity = opacity;
+ }
+
+ @Override
+ public void addLine(final Vector2f startPos, final Vector2f stopPos) {
+ if (this.svgDoc == null) {
+ this.svgDoc = new EsvgDocument();
+ }
+ this.svgDoc.addElement(new Line(startPos, stopPos, this.paint));
+ }
+
+ @Override
+ public void addRectangle(final Vector2f position, final Vector2f size) {
+ if (this.svgDoc == null) {
+ this.svgDoc = new EsvgDocument();
+ }
+ this.svgDoc.addElement(new Rectangle(position, size, this.paint));
+ }
+
+ @Override
+ public void addRectangle(final Vector2f position, final Vector2f size, final Vector2f roundedCorner) {
+ if (this.svgDoc == null) {
+ this.svgDoc = new EsvgDocument();
+ }
+ this.svgDoc.addElement(new Rectangle(position, size, roundedCorner, this.paint));
+ }
+
+ @Override
+ public void addCircle(final Vector2f position, final float radius) {
+ if (this.svgDoc == null) {
+ this.svgDoc = new EsvgDocument();
+ }
+ this.svgDoc.addElement(new Circle(position, radius, this.paint));
+ }
+
+ @Override
+ public void addEllipse(final Vector2f center, final Vector2f radius) {
+ if (this.svgDoc == null) {
+ this.svgDoc = new EsvgDocument();
+ }
+ this.svgDoc.addElement(new Ellipse(center, radius, this.paint));
+ }
+
+ public void setRectangleAsSource(final int sizeX, final int sizeY, final Color color) {
+ createSize(new Vector2i(sizeX, sizeY)); // specific for SVG
+ setPaintFillColor(color);
+ addRectangle(Vector2f.ZERO, new Vector2f(sizeX, sizeY));
+ flush();
+ }
+
public void setRectangleBorderAsSource(
final int sizeX,
final int sizeY,
@@ -447,30 +539,15 @@ public class CompositingSVG extends Compositing {
final int borderSize,
final int borderRadius,
final Color borderColor) {
-
+
final int paddingCompensateBorder = Math.round(borderSize * 0.5f);
- setSource("""
- """.formatted( //
- sizeX, sizeY, //
- paddingCompensateBorder, paddingCompensateBorder, //
- sizeX - 2 * paddingCompensateBorder, sizeY - 2 * paddingCompensateBorder, //
- borderRadius, //
- borderRadius, //
- color.toStringSharp(), //
- borderColor.toStringSharp(), //
- borderSize //
- ), new Vector2i(sizeX, sizeY));
+ createSize(new Vector2i(sizeX, sizeY)); // specific for SVG
+ setPaintFillColor(color);
+ setPaintStrokeColor(borderColor);
+ setPaintStrokeWidth(borderSize);
+ addRectangle(new Vector2f(paddingCompensateBorder, paddingCompensateBorder), //
+ new Vector2f(sizeX - 2 * paddingCompensateBorder, sizeY - 2 * paddingCompensateBorder), //
+ new Vector2f(borderRadius, borderRadius));
+ flush();
}
}
diff --git a/src/main/org/atriasoft/ewol/compositing/TextBase.java b/src/main/org/atriasoft/ewol/compositing/TextBase.java
index 57e730b..a1b70c7 100644
--- a/src/main/org/atriasoft/ewol/compositing/TextBase.java
+++ b/src/main/org/atriasoft/ewol/compositing/TextBase.java
@@ -13,7 +13,6 @@ import org.atriasoft.etk.Color;
import org.atriasoft.etk.Uri;
import org.atriasoft.etk.math.Matrix4f;
import org.atriasoft.etk.math.Vector2f;
-import org.atriasoft.etk.math.Vector2f;
import org.atriasoft.etk.util.Dynamic;
import org.atriasoft.ewol.compositing.tools.TextDecoration;
import org.atriasoft.ewol.resource.font.FontMode;
@@ -47,7 +46,7 @@ public abstract class TextBase extends Compositing {
protected Color defaultColorFg = Color.BLACK; // !< The text foreground color
// this section is reserved for HTML parsing and display:
public String htmlCurrentLine = ""; // !< current line for HTML display
-
+
public List htmlDecoration = new ArrayList<>(); // !< current decoration for the HTML display
public TextDecoration htmlDecoTmp = new TextDecoration(); // !< current decoration
protected boolean kerning = true; // !< Kerning enable or disable on the next elements displayed
@@ -70,19 +69,19 @@ public abstract class TextBase extends Compositing {
// position)
protected float stopTextPos = 0; // !< end of the alignment (when a string is too height it cut at the word
protected ResourceVirtualArrayObject vbo = null;
- protected CompositingDrawing vectorialDraw = new CompositingDrawing();
-
+ protected CompositingDrawing vectorialDraw = new CompositingGC();
+
/**
* generic constructor
*/
public TextBase() {
this(new Uri("DATA", "text.vert", "ewol"), new Uri("DATA", "text.frag", "ewol"));
}
-
+
public TextBase(final Uri vertexShader, final Uri fragmentShader) {
this(vertexShader, fragmentShader, true);
}
-
+
public TextBase(final Uri vertexShader, final Uri fragmentShader, final boolean loadProgram) {
if (loadProgram) {
loadProgram(vertexShader, fragmentShader);
@@ -92,7 +91,7 @@ public abstract class TextBase extends Compositing {
// TO facilitate some debugs we add a name of the VBO:
this.vbo.setName("[VBO] of super.TextBase");
}
-
+
/**
* calculate a theoric charcode size
* @param charcode The Unicode value to calculate dimention.
@@ -101,7 +100,7 @@ public abstract class TextBase extends Compositing {
public Vector2f calculateSize(final Character charcode) {
return calculateSizeChar(charcode);
}
-
+
/**
* calculate a theoric text size
* @param text The string to calculate dimention.
@@ -118,10 +117,10 @@ public abstract class TextBase extends Compositing {
}
return outputSize;
}
-
+
// ! @previous
public abstract Vector2f calculateSizeChar(Character charcode);
-
+
/**
* calculate a theoric text size
* @param text The string to calculate dimention.
@@ -131,13 +130,13 @@ public abstract class TextBase extends Compositing {
if (text.length() == 0) {
return Vector2f.ZERO;
}
-
+
final StringBuilder tmpData = new StringBuilder("\n");
tmpData.append(text);
tmpData.append("\n\n");
return calculateSizeHTML(tmpData.toString());
}
-
+
/**
* calculate a theoric text size
* @param text The string to calculate dimention.
@@ -149,27 +148,27 @@ public abstract class TextBase extends Compositing {
// LOGGER.debug(" 0 size for=\n" + text);
// disable display system
this.needDisplay = false;
-
+
setPos(Vector2f.ZERO);
// same as print without the end display ...
printHTML(text);
//LOGGER.error(" ]]]] position={}", this.position);
//LOGGER.error(" ]]]] sizeDisplayStart={}", this.sizeDisplayStart);
//LOGGER.error(" ]]]] sizeDisplayStop={}", this.sizeDisplayStop);
-
+
// get the last elements
this.sizeDisplayStop = Vector2f.max(this.position, this.sizeDisplayStop);
this.sizeDisplayStart = Vector2f.min(this.position, this.sizeDisplayStart);
-
+
// LOGGER.debug(" 2 Start pos=" + this.sizeDisplayStart);
// LOGGER.debug(" 2 Stop pos=" + this.sizeDisplayStop);
// set back the display system
this.needDisplay = true;
-
+
return new Vector2f(this.sizeDisplayStop.x() - this.sizeDisplayStart.x(),
this.sizeDisplayStop.y() - this.sizeDisplayStart.y());
}
-
+
/**
* clear all the registered element in the current element
*/
@@ -184,14 +183,14 @@ public abstract class TextBase extends Compositing {
// reset temporal variables:
reset();
}
-
+
/**
* disable the alignement system
*/
public void disableAlignement() {
this.alignment = AlignMode.DISABLE;
}
-
+
/**
* remove the cursor display
*/
@@ -199,7 +198,7 @@ public abstract class TextBase extends Compositing {
this.selectionStartPos = -100;
this.cursorPos = -100;
}
-
+
/**
* draw All the registered text in the current element on openGL
*/
@@ -207,20 +206,20 @@ public abstract class TextBase extends Compositing {
public void draw(final boolean disableDepthTest) {
drawD(disableDepthTest);
}
-
+
// ! @previous
public void draw(final Matrix4f transformationMatrix, final boolean enableDepthTest) {
drawMT(transformationMatrix, enableDepthTest);
}
-
+
/**
* draw All the refistered text in the current element on openGL
*/
public abstract void drawD(final boolean disableDepthTest);
-
+
// ! @previous
public abstract void drawMT(final Matrix4f transformationMatrix, final boolean enableDepthTest);
-
+
/**
* calculate the element number that is the first out the alignment
* range (start at the specify ID, and use start pos with current one)
@@ -241,21 +240,21 @@ public abstract class TextBase extends Compositing {
final Dynamic freeSpace) {
// store previous :
final Character storePrevious = this.previousCharcode;
-
+
stop.value = text.length();
space.value = 0;
-
+
int lastSpacePosition = start;
int lastSpacefreeSize = 0;
-
+
float endPos = this.position.x();
boolean endOfLine = false;
-
+
float stopPosition = this.stopTextPos;
if (!this.needDisplay || this.stopTextPos == this.startTextPos) {
stopPosition = this.startTextPos + 3999999999.0f;
}
-
+
for (int iii = start; iii < text.length(); iii++) {
final Vector2f tmpSize = calculateSize(text.charAt(iii));
// check overflow :
@@ -293,12 +292,12 @@ public abstract class TextBase extends Compositing {
freeSpace.value = lastSpacefreeSize;
return false;
}
-
+
@Override
public void flush() {
this.vectorialDraw.flush();
}
-
+
/**
* This generate the line return == > it return to the alignment
* position start and at the correct line position ==> it might be use to
@@ -308,7 +307,7 @@ public abstract class TextBase extends Compositing {
// reset position :
setPos(new Vector2f(this.startTextPos, this.position.y() - getHeight()));
}
-
+
/**
* get the current alignment property
* @return the current alignment type
@@ -316,12 +315,12 @@ public abstract class TextBase extends Compositing {
public AlignMode getAlignment() {
return this.alignment;
}
-
+
// This is used to draw background selection and other things ...
public CompositingDrawing getDrawing() {
return this.vectorialDraw;
}
-
+
/**
* get the current font mode
* @return The font mode applied
@@ -329,11 +328,11 @@ public abstract class TextBase extends Compositing {
public FontMode getFontMode() {
return this.mode;
}
-
+
public abstract GlyphProperty getGlyphPointer(Character charcode);
-
+
public abstract float getHeight();
-
+
/**
* get the current display position (sometime needed in the gui control)
* @return the current position.
@@ -341,9 +340,9 @@ public abstract class TextBase extends Compositing {
public Vector2f getPos() {
return this.position;
}
-
+
public abstract float getSize();
-
+
/**
* add a line with the current this.htmlDecoTmp decoration
* @param data The cuurent data to add.
@@ -365,7 +364,7 @@ public abstract class TextBase extends Compositing {
this.htmlDecoration.add(this.htmlDecoTmp);
}
}
-
+
/**
* draw the current line
*/
@@ -376,7 +375,7 @@ public abstract class TextBase extends Compositing {
this.htmlCurrentLine = "";
this.htmlDecoration.clear();
}
-
+
/**
* load the openGL program and get all the ID needed
*/
@@ -396,7 +395,7 @@ public abstract class TextBase extends Compositing {
old = null;
}
}
-
+
/**
* This parse a tinyXML node (void pointer to permit to hide tiny XML in
* include).
@@ -509,11 +508,11 @@ public abstract class TextBase extends Compositing {
} else {
LOGGER.error("node not suported type: " + elem.getType() + " val='" + elem.getValue() + "'");
}
-
+
//LOGGER.error("Add data elems... @pos=", this.position);
}
}
-
+
/**
* display a compleat string in the current element.
* @param text The string to display.
@@ -522,7 +521,7 @@ public abstract class TextBase extends Compositing {
final List decorationEmpty = new ArrayList<>();
print(text, decorationEmpty);
}
-
+
/**
* display a compleat string in the current element whith specific
* decorations (advence mode).
@@ -702,14 +701,14 @@ public abstract class TextBase extends Compositing {
+ this.sizeDisplayStop + " pos=" + this.position);
}
}
-
+
/**
* display the current char in the current element (note that the kerning
* is availlable if the position is not changed)
* @param charcode Char that might be dispalyed
*/
public abstract void printChar(Character charcode);
-
+
/**
* draw a cursor at the specify position
* @param isInsertMode True if the insert mode is activated
@@ -717,7 +716,7 @@ public abstract class TextBase extends Compositing {
public void printCursor(final boolean isInsertMode) {
printCursor(isInsertMode, 20.0f);
}
-
+
public void printCursor(final boolean isInsertMode, final float cursorSize) {
final int fontHeigh = (int) getHeight();
if (isInsertMode) {
@@ -728,7 +727,7 @@ public abstract class TextBase extends Compositing {
this.vectorialDraw.setThickness(0);
}
}
-
+
/**
* display a compleat string in the current element with the generic
* decoration specification. (basic html data)
@@ -764,7 +763,7 @@ public abstract class TextBase extends Compositing {
// LOGGER.debug("plop : " + tmpData);
printHTML(tmpData.toString());
}
-
+
/**
* display a compleat string in the current element with the generic
* decoration specification. (basic html data)
@@ -804,7 +803,7 @@ public abstract class TextBase extends Compositing {
return;
}
final XmlElement root = (XmlElement) doc.getNode("html");
-
+
if (!root.existNode("body")) {
LOGGER.error("can not load XML: main node not find: 'body'");
return;
@@ -826,7 +825,7 @@ public abstract class TextBase extends Compositing {
e.printStackTrace();
}
}
-
+
/**
* clear all the intermediate result detween 2 prints
*/
@@ -852,19 +851,19 @@ public abstract class TextBase extends Compositing {
this.needDisplay = true;
this.nbCharDisplayed = 0;
}
-
+
@Override
public void rotate(final Vector2f vect, final float angle) {
super.rotate(vect, angle);
this.vectorialDraw.rotate(vect, angle);
}
-
+
@Override
public void scale(final Vector2f vect) {
super.scale(vect);
this.vectorialDraw.scale(vect);
}
-
+
/**
* Request a clipping area for the text (next draw only)
* @param pos Start position of the clipping
@@ -878,7 +877,7 @@ public abstract class TextBase extends Compositing {
this.clippingEnable = true;
this.vectorialDraw.setClipping(this.clippingPosStart, this.clippingPosStop);
}
-
+
/**
* enable/Disable the clipping (without lose the current clipping
* position)
@@ -890,7 +889,6 @@ public abstract class TextBase extends Compositing {
this.vectorialDraw.setClippingMode(this.clippingEnable);
}
-
/**
* Request a clipping area for the text (next draw only)
* @param pos Start position of the clipping
@@ -899,7 +897,7 @@ public abstract class TextBase extends Compositing {
public void setClippingWidth(final Vector2f pos, final Vector2f width) {
setClipping(pos, pos.add(width));
}
-
+
/**
* set the Color of the current foreground font
* @param color Color to set on foreground (for next print)
@@ -907,7 +905,7 @@ public abstract class TextBase extends Compositing {
public void setColor(final Color color) {
this.color = color;
}
-
+
/**
* set the background color of the font (for selected Text (not the
* global BG))
@@ -917,7 +915,7 @@ public abstract class TextBase extends Compositing {
this.colorBg = color;
this.vectorialDraw.setColor(color);
}
-
+
/**
* change the cursor color
* @param color New color for the Selection
@@ -925,7 +923,7 @@ public abstract class TextBase extends Compositing {
public void setCursorColor(final Color color) {
this.colorCursor = color;
}
-
+
/**
* set a cursor at a specific position:
* @param cursorPos id of the cursor position
@@ -934,7 +932,7 @@ public abstract class TextBase extends Compositing {
this.selectionStartPos = cursorPos;
this.cursorPos = cursorPos;
}
-
+
/**
* set a cursor at a specific position with his associated selection:
* @param cursorPos id of the cursor position
@@ -944,7 +942,7 @@ public abstract class TextBase extends Compositing {
this.selectionStartPos = selectionStartPos;
this.cursorPos = cursorPos;
}
-
+
/**
* set the default background color of the font (when reset, set this
* value ...)
@@ -953,7 +951,7 @@ public abstract class TextBase extends Compositing {
public void setDefaultColorBg(final Color color) {
this.defaultColorBg = color;
}
-
+
/**
* set the default Foreground color of the font (when reset, set this
* value ...)
@@ -962,7 +960,7 @@ public abstract class TextBase extends Compositing {
public void setDefaultColorFg(final Color color) {
this.defaultColorFg = color;
}
-
+
/**
* Specify the font property (this reset the internal element of the
* current text (system requirement)
@@ -970,7 +968,7 @@ public abstract class TextBase extends Compositing {
* @param fontSize New font size
*/
public abstract void setFont(final String fontName, final int fontSize);
-
+
/**
* enable or disable the bold mode
* @param status The new status for this display property
@@ -990,7 +988,7 @@ public abstract class TextBase extends Compositing {
setFontMode(FontMode.ITALIC);
}
}
-
+
/**
* enable or disable the italic mode
* @param status The new status for this display property
@@ -1010,27 +1008,27 @@ public abstract class TextBase extends Compositing {
setFontMode(FontMode.BOLD);
}
}
-
+
/**
* Specify the font mode for the next @ref print
* @param mode The font mode requested
*/
public abstract void setFontMode(FontMode mode);
-
+
/**
* Specify the font name (this reset the internal element of the current
* text (system requirement)
* @param fontName Current name of the selected font
*/
public abstract void setFontName(final String fontName);
-
+
/**
* Specify the font size (this reset the internal element of the current
* text (system requirement)
* @param fontSize New font size
*/
public abstract void setFontSize(final int fontSize);
-
+
/**
* set the activation of the Kerning for the display (if it existed)
* @param newMode enable/Diasable the kerning on this font.
@@ -1038,7 +1036,7 @@ public abstract class TextBase extends Compositing {
public void setKerningMode(final boolean newMode) {
this.kerning = newMode;
}
-
+
/**
* set position for the next text writen
* @param pos Position of the text (in 3D)
@@ -1066,7 +1064,7 @@ public abstract class TextBase extends Compositing {
//LOGGER.trace("update size 4 " + this.sizeDisplayStart + " " + this.sizeDisplayStop);
}
}
-
+
/**
* set relative position for the next text written
* @param pos offset apply of the text (in 3D)
@@ -1076,7 +1074,7 @@ public abstract class TextBase extends Compositing {
this.previousCharcode = 0;
this.vectorialDraw.setPos(this.position);
}
-
+
/**
* change the selection color
* @param color New color for the Selection
@@ -1084,7 +1082,7 @@ public abstract class TextBase extends Compositing {
public void setSelectionColor(final Color color) {
this.colorSelection = color;
}
-
+
/**
* This generate the possibility to generate the big text property
* @param startTextPos The x text start position of the display.
@@ -1095,7 +1093,7 @@ public abstract class TextBase extends Compositing {
public void setTextAlignment(final float startTextPos, final float stopTextPos) {
setTextAlignment(startTextPos, stopTextPos, AlignMode.DISABLE);
}
-
+
public void setTextAlignment(final float startTextPos, final float stopTextPos, final AlignMode alignement) {
this.startTextPos = startTextPos;
this.stopTextPos = stopTextPos + 1;
@@ -1105,11 +1103,11 @@ public abstract class TextBase extends Compositing {
LOGGER.trace("Request alignment with Borne position error : " + startTextPos + " => " + stopTextPos);
}
}
-
+
@Override
public void translate(final Vector2f vect) {
super.translate(vect);
this.vectorialDraw.translate(vect);
}
-
+
}
\ No newline at end of file
diff --git a/src/main/org/atriasoft/ewol/widget/Box.java b/src/main/org/atriasoft/ewol/widget/Box.java
index 952e405..2546214 100644
--- a/src/main/org/atriasoft/ewol/widget/Box.java
+++ b/src/main/org/atriasoft/ewol/widget/Box.java
@@ -9,15 +9,14 @@ import org.atriasoft.etk.Dimension1f;
import org.atriasoft.etk.Dimension2f;
import org.atriasoft.etk.math.Vector2f;
import org.atriasoft.etk.math.Vector2i;
-import org.atriasoft.etk.math.Vector2f;
-import org.atriasoft.ewol.compositing.CompositingSVG;
+import org.atriasoft.ewol.compositing.CompositingGC;
import org.atriasoft.ewol.event.EventTime;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class Box extends Container {
private static final Logger LOGGER = LoggerFactory.getLogger(Box.class);
- protected CompositingSVG compositing = new CompositingSVG();
+ protected CompositingGC vectorialDraw = new CompositingGC();
public static class BoxParameter {
public Float margin;
@@ -218,8 +217,7 @@ public class Box extends Container {
subWidgetSize = subWidgetSize.less(offsetSubWidget.multiply(2));
subWidgetSize = subWidgetSize.clipInteger();
- final Vector2f freeSizeWithoutWidget = this.size
- .less(offsetSubWidget.multiply(2)).less(subWidgetSize);
+ final Vector2f freeSizeWithoutWidget = this.size.less(offsetSubWidget.multiply(2)).less(subWidgetSize);
Vector2f subWidgetOrigin = this.origin.add(this.propertyGravity.gravityGenerateDelta(freeSizeWithoutWidget));
subWidgetOrigin = subWidgetOrigin.add(offsetSubWidget);
subWidgetOrigin = subWidgetOrigin.clipInteger();
@@ -228,9 +226,6 @@ public class Box extends Container {
this.subWidget.onChangeSize();
}
- protected Vector2i renderOrigin;
- protected Vector2i renderSize;
-
private Vector2f calculateOriginRendering(final Vector2f renderSize) {
return this.propertyGravity.gravityGenerateDelta(this.size.less(renderSize));
}
@@ -254,40 +249,36 @@ public class Box extends Container {
}
final Vector2f localMargin = this.propertyMargin.size();
- Vector2f tmpRenderSize = calculateSizeRendering();
- Vector2f tmpRenderOrigin = calculateOriginRendering(tmpRenderSize);
+ Vector2f renderSize = calculateSizeRendering();
+ Vector2f renderOrigin = calculateOriginRendering(renderSize);
- tmpRenderOrigin = tmpRenderOrigin.add(localMargin);
- tmpRenderSize = tmpRenderSize.less(localMargin.multiply(2));
+ renderOrigin = renderOrigin.add(localMargin);
+ renderSize = renderSize.less(localMargin.multiply(2));
// 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());
+ renderSize = renderSize.clipInteger();
+ renderOrigin = renderOrigin.clipInteger();
+
+ renderOrigin = renderOrigin.clipInteger();
+ renderSize = renderSize.clipInteger();
+ this.startPosition = renderOrigin.toVector2i();
+ this.endPosition = renderSize.toVector2i();
+
//System.out.println("renderSize: " + this.renderSize);
// remove data of the previous composition :
- this.compositing.clear();
+ this.vectorialDraw.clear();
final int borderSize = (int) this.propertyBorderWidth.size();
- final int paddingCompensateBorder = Math.round(borderSize * 0.5f);
- if (borderSize > 0.0f) {
- this.compositing.setRectangleBorderAsSource(this.renderSize.x(), this.renderSize.y(), this.propertyColor,
- borderSize, (int) this.propertyBorderRadius.size(), this.propertyBorderColor);
- } else {
- this.compositing.setRectangleAsSource(this.renderSize.x(), this.renderSize.y(), this.propertyColor);
- }
- this.compositing.setPos(this.renderOrigin);
- // For events:
- this.startPosition = this.renderOrigin;
- this.endPosition = this.renderOrigin.add(this.renderSize);
- this.compositing.print(this.renderSize);
- this.compositing.flush();
+ 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.flush();
}
@Override
protected void onDraw() {
- if (this.compositing != null) {
- this.compositing.draw(true);
+ if (this.vectorialDraw != null) {
+ this.vectorialDraw.draw(true);
}
super.onDraw();
}
diff --git a/src/main/org/atriasoft/ewol/widget/BoxSVG.java b/src/main/org/atriasoft/ewol/widget/BoxSVG.java
new file mode 100644
index 0000000..5433e3e
--- /dev/null
+++ b/src/main/org/atriasoft/ewol/widget/BoxSVG.java
@@ -0,0 +1,293 @@
+package org.atriasoft.ewol.widget;
+
+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.Color;
+import org.atriasoft.etk.Dimension1f;
+import org.atriasoft.etk.Dimension2f;
+import org.atriasoft.etk.math.Vector2f;
+import org.atriasoft.etk.math.Vector2i;
+import org.atriasoft.ewol.compositing.CompositingSVG;
+import org.atriasoft.ewol.event.EventTime;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class BoxSVG extends Container {
+ private static final Logger LOGGER = LoggerFactory.getLogger(BoxSVG.class);
+ protected CompositingSVG vectorialDraw = new CompositingSVG();
+
+ public static class BoxParameter {
+ public Float margin;
+ public Float padding;
+ public Float borderWidth;
+ public Float borderRadius;
+ public String borderColor;
+ public String color;
+ }
+
+ /**
+ * Periodic call to update grapgic display
+ * @param event Time generic event
+ */
+ protected static void periodicCall(final BoxSVG self, final EventTime event) {
+ LOGGER.trace("Periodic call on Entry(" + event + ")");
+ self.markToRedraw();
+ }
+
+ Vector2i startPosition = Vector2i.ZERO;
+ Vector2i endPosition = Vector2i.ZERO;
+
+ public boolean isInside(final Vector2f value) {
+ return value.x() > this.startPosition.x() //
+ && value.y() > this.startPosition.y() //
+ && value.x() < this.endPosition.x() //
+ && value.y() < this.endPosition.y();
+ }
+
+ /**
+ * Constructor
+ */
+ public BoxSVG() {}
+
+ /**
+ * Constructor with his subWidget
+ */
+ public BoxSVG(final Widget subWidget) {
+ super(subWidget);
+ }
+
+ protected Dimension1f propertyBorderWidth = Dimension1f.ZERO;
+
+ @AknotManaged
+ @AknotAttribute
+ @AknotName(value = "border-width")
+ @AknotDescription(value = "Border of the box")
+ public Dimension1f getPropertyBorderWidth() {
+ return this.propertyBorderWidth;
+ }
+
+ public void setPropertyBorderWidth(final Dimension1f propertyBorder) {
+ if (this.propertyBorderWidth.equals(propertyBorder)) {
+ return;
+ }
+ this.propertyBorderWidth = propertyBorder;
+ markToRedraw();
+ requestUpdateSize();
+ }
+
+ protected Dimension1f propertyBorderRadius = new Dimension1f(0);
+
+ @AknotManaged
+ @AknotAttribute
+ @AknotName(value = "border-radius")
+ @AknotDescription(value = "Border radius of the box")
+ public Dimension1f getPropertyBorderRadius() {
+ return this.propertyBorderRadius;
+ }
+
+ public void setPropertyBorderRadius(final Dimension1f propertyBorderRadius) {
+ if (this.propertyBorderRadius.equals(propertyBorderRadius)) {
+ return;
+ }
+ this.propertyBorderRadius = propertyBorderRadius;
+ markToRedraw();
+ requestUpdateSize();
+ }
+
+ protected Color propertyBorderColor = Color.NONE;
+
+ @AknotManaged
+ @AknotAttribute
+ @AknotName(value = "border-color")
+ @AknotDescription(value = "Border color of the box")
+ public Color getPropertyBorderColor() {
+ return this.propertyBorderColor;
+ }
+
+ public void setPropertyBorderColor(final Color propertyBorderColor) {
+ if (this.propertyBorderColor.equals(propertyBorderColor)) {
+ return;
+ }
+ this.propertyBorderColor = propertyBorderColor;
+ markToRedraw();
+ requestUpdateSize();
+ }
+
+ protected Color propertyColor = Color.NONE;
+
+ @AknotManaged
+ @AknotAttribute
+ @AknotName(value = "color")
+ @AknotDescription(value = "Border color of the box")
+ public Color getPropertyColor() {
+ return this.propertyColor;
+ }
+
+ public void setPropertyColor(final Color propertyColor) {
+ if (this.propertyColor.equals(propertyColor)) {
+ return;
+ }
+ this.propertyColor = propertyColor;
+ markToRedraw();
+ requestUpdateSize();
+ }
+
+ protected Dimension2f propertyMargin = Dimension2f.ZERO;
+
+ @AknotManaged
+ @AknotAttribute
+ @AknotName(value = "margin")
+ @AknotDescription(value = "margin of the box")
+ public Dimension2f getPropertyMargin() {
+ return this.propertyMargin;
+ }
+
+ public void setPropertyMargin(final Dimension2f propertyMargin) {
+ if (this.propertyMargin.equals(propertyMargin)) {
+ return;
+ }
+ this.propertyMargin = propertyMargin;
+ markToRedraw();
+ requestUpdateSize();
+ }
+
+ protected Dimension2f propertyPadding = Dimension2f.ZERO;
+
+ @AknotManaged
+ @AknotAttribute
+ @AknotName(value = "padding")
+ @AknotDescription(value = "Padding of the box")
+ public Dimension2f getPropertyPadding() {
+ return this.propertyPadding;
+ }
+
+ public void setPropertyPadding(final Dimension2f propertyPadding) {
+ if (this.propertyPadding.equals(propertyPadding)) {
+ return;
+ }
+ this.propertyPadding = propertyPadding;
+ markToRedraw();
+ 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 = calculatedBoxMinSize;
+ this.maxSize = Vector2f.max(this.minSize, this.propertyMaxSize.size());
+ markToRedraw();
+ }
+
+ @Override
+ public void onChangeSize() {
+ markToRedraw();
+ if (this.propertyHide) {
+ return;
+ }
+ if (this.subWidget == null) {
+ return;
+ }
+ 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);
+
+ Vector2f subWidgetSize = this.subWidget.getCalculateMinSize();
+ if (this.subWidget.canExpand().x() && this.propertyFill.x()) {
+ subWidgetSize = subWidgetSize.withX(this.size.x());
+ } else {
+ subWidgetSize = subWidgetSize.withX(this.minSize.x());
+ }
+ if (this.subWidget.canExpand().y() && this.propertyFill.y()) {
+ subWidgetSize = subWidgetSize.withY(this.size.y());
+ } else {
+ subWidgetSize = subWidgetSize.withY(this.minSize.y());
+ }
+ subWidgetSize = subWidgetSize.less(offsetSubWidget.multiply(2));
+ subWidgetSize = subWidgetSize.clipInteger();
+
+ final Vector2f freeSizeWithoutWidget = this.size.less(offsetSubWidget.multiply(2)).less(subWidgetSize);
+ Vector2f subWidgetOrigin = this.origin.add(this.propertyGravity.gravityGenerateDelta(freeSizeWithoutWidget));
+ subWidgetOrigin = subWidgetOrigin.add(offsetSubWidget);
+ subWidgetOrigin = subWidgetOrigin.clipInteger();
+ this.subWidget.setOrigin(subWidgetOrigin);
+ this.subWidget.setSize(subWidgetSize);
+ this.subWidget.onChangeSize();
+ }
+
+ protected Vector2i renderOrigin;
+ protected Vector2i renderSize;
+
+ private Vector2f calculateOriginRendering(final Vector2f renderSize) {
+ return this.propertyGravity.gravityGenerateDelta(this.size.less(renderSize));
+ }
+
+ private Vector2f calculateSizeRendering() {
+ Vector2f 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();
+ if (!needRedraw()) {
+ return;
+ }
+ final Vector2f localMargin = this.propertyMargin.size();
+
+ Vector2f tmpRenderSize = calculateSizeRendering();
+ Vector2f tmpRenderOrigin = calculateOriginRendering(tmpRenderSize);
+
+ tmpRenderOrigin = tmpRenderOrigin.add(localMargin);
+ tmpRenderSize = tmpRenderSize.less(localMargin.multiply(2));
+ // 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.vectorialDraw.clear();
+ final int borderSize = (int) this.propertyBorderWidth.size();
+ final int paddingCompensateBorder = Math.round(borderSize * 0.5f);
+ if (borderSize > 0.0f) {
+ this.vectorialDraw.setRectangleBorderAsSource(this.renderSize.x(), this.renderSize.y(), this.propertyColor,
+ borderSize, (int) this.propertyBorderRadius.size(), this.propertyBorderColor);
+ } else {
+ this.vectorialDraw.setRectangleAsSource(this.renderSize.x(), this.renderSize.y(), this.propertyColor);
+ }
+ this.vectorialDraw.setPos(this.renderOrigin);
+ // For events:
+ this.startPosition = this.renderOrigin;
+ this.endPosition = this.renderOrigin.add(this.renderSize);
+ this.vectorialDraw.print(this.renderSize);
+ this.vectorialDraw.flush();
+ }
+
+ @Override
+ protected void onDraw() {
+ if (this.vectorialDraw != null) {
+ this.vectorialDraw.draw(true);
+ }
+ super.onDraw();
+ }
+
+}
diff --git a/src/main/org/atriasoft/ewol/widget/Button.java b/src/main/org/atriasoft/ewol/widget/Button.java
index 348934f..1c33d8c 100644
--- a/src/main/org/atriasoft/ewol/widget/Button.java
+++ b/src/main/org/atriasoft/ewol/widget/Button.java
@@ -11,7 +11,6 @@ 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.Vector2b;
import org.atriasoft.etk.math.Vector2f;
import org.atriasoft.ewol.Gravity;
@@ -129,7 +128,7 @@ public class Button extends Box {
@Override
public boolean onEventInput(final EventInput event) {
final Vector2f relPos = relativePosition(event.pos());
- //LOGGER.warn("Event on Input ... " + event + " relPos = " + relPos);
+ //LOGGER.warn("Event on Input ... event={} relPos={}", event, relPos);
final boolean over = isInside(relPos);
//filter if outside the element...
if (event.status() == KeyStatus.leave) {
diff --git a/src/main/org/atriasoft/ewol/widget/Entry.java b/src/main/org/atriasoft/ewol/widget/Entry.java
index 7059898..d477d64 100644
--- a/src/main/org/atriasoft/ewol/widget/Entry.java
+++ b/src/main/org/atriasoft/ewol/widget/Entry.java
@@ -15,7 +15,6 @@ import org.atriasoft.etk.Uri;
import org.atriasoft.etk.math.FMath;
import org.atriasoft.etk.math.Vector2f;
import org.atriasoft.etk.math.Vector2i;
-import org.atriasoft.etk.math.Vector2f;
import org.atriasoft.ewol.Padding;
import org.atriasoft.ewol.compositing.CompositingSVG;
import org.atriasoft.ewol.compositing.CompositingText;
@@ -43,7 +42,7 @@ import org.slf4j.LoggerFactory;
*/
public class Entry extends Widget {
private static final Logger LOGGER = LoggerFactory.getLogger(Entry.class);
-
+
/**
* Periodic call to update graphic display
* @param _event Time generic event
@@ -55,7 +54,7 @@ public class Entry extends Widget {
// }
self.markToRedraw();
}
-
+
/// color property of the text foreground
private int colorIdTextFg;
/// Cursor must be display only when the widget has the focus
@@ -70,7 +69,7 @@ public class Entry extends Widget {
private int displayCursorPositionPixel = 0;
/// text display this.text
private final CompositingText text = new CompositingText();
- protected CompositingSVG compositing = new CompositingSVG();
+ protected CompositingSVG vectorialDraw = new CompositingSVG();
/// text position can have change
private boolean needUpdateTextPos = true;
/// Periodic call handle to remove it when needed
@@ -78,16 +77,16 @@ public class Entry extends Widget {
private Uri propertyConfig = new Uri("THEME", "shape/Entry.json", "ewol");
private int propertyMaxCharacter = Integer.MAX_VALUE; //!< number max of Character in the list
private boolean propertyPassword = false; //!< Disable display of the content of the entry
-
+
/// regular expression value
private String propertyRegex = ".*";
-
+
/// Text to display when nothing in in the entry (decorated text...)
private String propertyTextWhenNothing = null;
-
+
private String propertyValue = "Test Text..."; //!< string that must be displayed
private Pattern regex = null; //!< regular expression to check content
-
+
//.create()
@AknotSignal
@AknotName(value = "click")
@@ -97,16 +96,16 @@ public class Entry extends Widget {
@AknotName(value = "enter")
@AknotDescription("The cursor enter inside the button")
public Signal signalEnter = new Signal<>(); //!< Enter key is pressed
-
+
@AknotSignal
@AknotName(value = "modify")
@AknotDescription("Entry box value change")
public Signal signalModify = new Signal<>(); //!< data change
// element over:
Vector2f overPositionStart = Vector2f.ZERO;
-
+
Vector2f overPositionStop = Vector2f.ZERO;
-
+
/**
* Constructor
* @param _newData The USting that might be set in the Entry box (no event generation!!)
@@ -114,7 +113,7 @@ public class Entry extends Widget {
public Entry() {
this.propertyCanFocus = true;
//onChangePropertyShaper();
-
+
this.regex = Pattern.compile(this.propertyRegex);
if (this.regex == null) {
LOGGER.error("can not parse regex for : " + this.propertyRegex);
@@ -128,7 +127,7 @@ public class Entry extends Widget {
shortCutAdd("ctrl+shift+a", "select:none");
//TODO this.signalShortcut.connect(this, Entry::onCallbackShortCut);
}
-
+
@Override
public void calculateMinMaxSize() {
// call main class
@@ -136,7 +135,7 @@ public class Entry extends Widget {
// get generic padding
final Padding padding = Padding.ZERO;
final int minHeight = (int) this.text.getHeight();//calculateSize('A').y();
-
+
Vector2f minimumSizeBase = new Vector2f(20, minHeight);
// add padding :
minimumSizeBase = minimumSizeBase.add(padding.x(), padding.y());
@@ -145,7 +144,7 @@ public class Entry extends Widget {
checkMinSize();
//LOGGER.trace("min size = " + this.minSize);
}
-
+
protected void changeStatusIn(final GuiShapeMode newStatusId) {
// if (this.shape.changeStatusIn(newStatusId)) {
// if (!this.periodicConnectionHanble.isConnected()) {
@@ -156,7 +155,7 @@ public class Entry extends Widget {
// markToRedraw();
// }
}
-
+
/**
* Copy the selected data on the specify clipboard
* @param clipboardID Selected clipboard
@@ -176,48 +175,48 @@ public class Entry extends Widget {
final String tmpData = this.propertyValue.substring(pos1, pos2);
ClipBoard.set(clipboardID, tmpData);
}
-
+
public Uri getPropertyConfig() {
return this.propertyConfig;
}
-
+
public int getPropertyMaxCharacter() {
return this.propertyMaxCharacter;
}
-
+
public String getPropertyRegex() {
return this.propertyRegex;
}
-
+
public String getPropertyTextWhenNothing() {
return this.propertyTextWhenNothing;
}
-
+
public String getPropertyValue() {
return this.propertyValue;
}
-
+
public boolean isPropertyPassword() {
return this.propertyPassword;
}
-
+
/**
* informe the system thet the text change and the start position change
*/
protected void markToUpdateTextPosition() {
this.needUpdateTextPos = true;
}
-
+
private void onCallbackCopy() {
copySelectionToClipBoard(ClipboardList.CLIPBOARD_STD);
}
-
+
private void onCallbackCut() {
copySelectionToClipBoard(ClipboardList.CLIPBOARD_STD);
removeSelected();
this.signalModify.emit(this.propertyValue);
}
-
+
private void onCallbackEntryClean() {
this.propertyValue = "";
this.displayStartPosition = 0;
@@ -225,11 +224,11 @@ public class Entry extends Widget {
this.displayCursorPosSelection = this.displayCursorPos;
markToRedraw();
}
-
+
private void onCallbackPaste() {
ClipBoard.request(ClipboardList.CLIPBOARD_STD);
}
-
+
private void onCallbackSelect(final boolean all) {
if (all) {
this.displayCursorPosSelection = 0;
@@ -239,7 +238,7 @@ public class Entry extends Widget {
}
markToRedraw();
}
-
+
private void onCallbackShortCut(final String value) {
if (value.equals("clean")) {
onCallbackEntryClean();
@@ -258,15 +257,15 @@ public class Entry extends Widget {
LOGGER.warn("Unknow event from ShortCut : " + value);
}
}
-
+
protected void onChangePropertyMaxCharacter() {
// TODO : check number of char in the data
}
-
+
protected void onChangePropertyPassword() {
markToRedraw();
}
-
+
protected void onChangePropertyRegex() {
this.regex = Pattern.compile(this.propertyRegex);
if (this.regex != null) {
@@ -274,11 +273,11 @@ public class Entry extends Widget {
}
markToRedraw();
}
-
+
protected void onChangePropertyTextWhenNothing() {
markToRedraw();
}
-
+
protected void onChangePropertyValue() {
String newData = this.propertyValue;
if ((long) newData.length() > this.propertyMaxCharacter) {
@@ -294,15 +293,15 @@ public class Entry extends Widget {
}
markToRedraw();
}
-
+
@Override
protected void onDraw() {
- if (this.compositing != null) {
- this.compositing.draw(true);
+ if (this.vectorialDraw != null) {
+ this.vectorialDraw.draw(true);
}
this.text.draw();
}
-
+
@Override
public void onEventClipboard(final ClipboardList clipboardID) {
// remove curent selected data ...
@@ -326,7 +325,7 @@ public class Entry extends Widget {
}
this.signalModify.emit(this.propertyValue);
}
-
+
@Override
public boolean onEventEntry(final EventEntry event) {
LOGGER.trace("Event on Entry ... " + event);
@@ -402,7 +401,7 @@ public class Entry extends Widget {
}
return false;
}
-
+
@Override
public boolean onEventInput(final EventInput event) {
final Vector2f absolutePosition = event.pos();
@@ -505,7 +504,7 @@ public class Entry extends Widget {
}
return false;
}
-
+
@Override
protected void onGetFocus() {
this.displayCursor = true;
@@ -513,7 +512,7 @@ public class Entry extends Widget {
showKeyboard();
markToRedraw();
}
-
+
@Override
protected void onLostFocus() {
this.displayCursor = false;
@@ -521,14 +520,14 @@ public class Entry extends Widget {
hideKeyboard();
markToRedraw();
}
-
+
@Override
public void onRegenerateDisplay() {
if (!needRedraw()) {
- //return;
+ return;
}
//LOGGER.trace("Regenerate Display ==> is needed: '" + this.propertyValue + "'");
- this.compositing.clear();
+ this.vectorialDraw.clear();
this.text.clear();
if (this.colorIdTextFg >= 0) {
//this.text.setDefaultColorFg(this.shape.getColor(this.colorIdTextFg));
@@ -538,7 +537,7 @@ public class Entry extends Widget {
}
updateTextPosition();
final Padding padding = Padding.ZERO;
-
+
Vector2f tmpSizeShaper = this.minSize;
Vector2f delta = this.propertyGravity.gravityGenerateDelta(this.size.less(this.minSize));
if (this.propertyFill.x()) {
@@ -555,7 +554,7 @@ public class Entry extends Widget {
Vector2f tmpOriginText = tmpOriginShaper.add(padding.bottom(), padding.left()); //this.size.less(tmpSizeText).multiply(0.5f);
//Vector2f tmpOriginText = new Vector2f(0, this.text.getSize(), 0);
// sometimes, the user define an height bigger than the real size needed == > in this case we need to center the text in the shaper ...
-
+
final int minHeight = (int) this.text.getHeight();
if (tmpSizeText.y() > minHeight) {
tmpOriginText = tmpOriginText.add(0, (tmpSizeText.y() - minHeight) * 0.5f);
@@ -565,7 +564,7 @@ public class Entry extends Widget {
tmpOriginShaper = Vector2f.clipInt(tmpOriginShaper);
tmpSizeText = Vector2f.clipInt(tmpSizeText);
tmpOriginText = Vector2f.clipInt(tmpOriginText);
-
+
this.text.clear();
//this.text.setSize((int) tmpSizeText.x(), (int) tmpSizeText.y());
this.text.setClippingWidth(tmpOriginText, tmpSizeText);
@@ -579,7 +578,7 @@ public class Entry extends Widget {
if (this.propertyPassword) {
Arrays.fill(valueToDisplay, '*');
}
-
+
//final Vector2f plop = new Vector2f(tmpOriginText.x() + this.displayStartPosition, tmpOriginText.y());
if (valueToDisplay.length != 0) {
this.text.print(new String(valueToDisplay));
@@ -590,7 +589,7 @@ public class Entry extends Widget {
this.overPositionStart = tmpOriginShaper;
this.overPositionStop = tmpOriginShaper.add(tmpSizeShaper);
//this.shape.setShape(tmpOriginShaper, tmpSizeShaper, tmpOriginText, tmpSizeText);
- this.compositing.setSource("""
+ this.vectorialDraw.setSource("""