[FEAT] basic rework of generic Graphic context in full openGl

This commit is contained in:
Edouard DUPIN 2025-07-14 16:31:46 +02:00
parent 0fe0fa6629
commit ec4b1a1875
21 changed files with 1252 additions and 857 deletions

View File

@ -44,17 +44,17 @@
<artifactId>ewol</artifactId> <artifactId>ewol</artifactId>
<version>0.1.0</version> <version>0.1.0</version>
</dependency> </dependency>
<!-- Loopback of logger JDK logging API to SLF4J -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jul-to-slf4j</artifactId>
<version>2.0.9</version>
</dependency>
<!-- generic logger of SLF4J to console (in color) --> <!-- generic logger of SLF4J to console (in color) -->
<dependency> <dependency>
<groupId>ch.qos.logback</groupId> <groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId> <artifactId>logback-classic</artifactId>
<version>1.5.18</version> <version>1.4.11</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.5.18</version>
<scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>xerces</groupId> <groupId>xerces</groupId>

View File

@ -18,20 +18,20 @@ import org.slf4j.LoggerFactory;
public class BasicWindows extends Windows { public class BasicWindows extends Windows {
private static final Logger LOGGER = LoggerFactory.getLogger(BasicWindows.class); private static final Logger LOGGER = LoggerFactory.getLogger(BasicWindows.class);
private int index = -1; private int index = -1;
private final List<TestWidgetInterface> testedElement = new ArrayList<>(); private final List<TestWidgetInterface> testedElement = new ArrayList<>();
private Container container = null; private Container container = null;
private Label title = null; private Label title = null;
public static void staticRequestNext(final BasicWindows self) { public static void staticRequestNext(final BasicWindows self) {
self.requestNext(); self.requestNext();
} }
public static void staticRequestPrevious(final BasicWindows self) { public static void staticRequestPrevious(final BasicWindows self) {
self.requestPrevious(); self.requestPrevious();
} }
public void requestNext() { public void requestNext() {
LOGGER.info("Request Next"); LOGGER.info("Request Next");
this.index++; this.index++;
@ -40,7 +40,7 @@ public class BasicWindows extends Windows {
} }
updateDisplay(); updateDisplay();
} }
public void requestPrevious() { public void requestPrevious() {
LOGGER.info("Request Previous"); LOGGER.info("Request Previous");
this.index--; this.index--;
@ -49,7 +49,7 @@ public class BasicWindows extends Windows {
} }
updateDisplay(); updateDisplay();
} }
public void updateDisplay() { public void updateDisplay() {
final var test = this.testedElement.get(this.index); final var test = this.testedElement.get(this.index);
final var titlegenerated = "<b>[" + (this.index + 1) + "/" + this.testedElement.size() + "] " + test.getTitle() final var titlegenerated = "<b>[" + (this.index + 1) + "/" + this.testedElement.size() + "] " + test.getTitle()
@ -58,14 +58,14 @@ public class BasicWindows extends Windows {
setPropertyTitle(titlegenerated); setPropertyTitle(titlegenerated);
this.container.setSubWidget(new ModelWidget(test)); this.container.setSubWidget(new ModelWidget(test));
} }
public BasicWindows() { public BasicWindows() {
final var sizerMain = new Sizer(DisplayMode.VERTICAL); final var sizerMain = new Sizer(DisplayMode.VERTICAL);
sizerMain.setPropertyExpand(Vector2b.TRUE); sizerMain.setPropertyExpand(Vector2b.TRUE);
sizerMain.setPropertyFill(Vector2b.TRUE); sizerMain.setPropertyFill(Vector2b.TRUE);
setSubWidget(sizerMain); setSubWidget(sizerMain);
final var menu = new Sizer(DisplayMode.HORIZONTAL); final var menu = new Sizer(DisplayMode.HORIZONTAL);
menu.setPropertyExpand(Vector2b.TRUE_FALSE); menu.setPropertyExpand(Vector2b.TRUE_FALSE);
menu.setPropertyExpandIfFree(Vector2b.TRUE_FALSE); menu.setPropertyExpandIfFree(Vector2b.TRUE_FALSE);
@ -73,40 +73,40 @@ public class BasicWindows extends Windows {
menu.setPropertyLockExpand(Vector2b.TRUE); menu.setPropertyLockExpand(Vector2b.TRUE);
menu.setPropertyMaxSize(new Dimension2f(new Vector2f(9999, 3), Distance.CENTIMETER)); menu.setPropertyMaxSize(new Dimension2f(new Vector2f(9999, 3), Distance.CENTIMETER));
sizerMain.subWidgetAdd(menu); sizerMain.subWidgetAdd(menu);
this.container = new Container(); this.container = new Container();
this.container.setPropertyExpand(Vector2b.TRUE); this.container.setPropertyExpand(Vector2b.TRUE);
this.container.setPropertyFill(Vector2b.TRUE); this.container.setPropertyFill(Vector2b.TRUE);
sizerMain.subWidgetAdd(this.container); sizerMain.subWidgetAdd(this.container);
final var next = Button.createLabelButton("&lt;&lt; Previous"); final var next = Button.createLabelButton("&lt;&lt; Previous");
next.setPropertyMaxSize(new Dimension2f(new Vector2f(9999, 2), Distance.CENTIMETER)); next.setPropertyMaxSize(new Dimension2f(new Vector2f(9999, 2), Distance.CENTIMETER));
menu.subWidgetAdd(next); menu.subWidgetAdd(next);
next.signalClick.connectAuto(this, BasicWindows::staticRequestNext); next.signalClick.connectAuto(this, BasicWindows::staticRequestNext);
this.title = new Label("unknown"); this.title = new Label("unknown");
this.title.setPropertyFill(Vector2b.FALSE); this.title.setPropertyFill(Vector2b.FALSE);
this.title.setPropertyExpand(Vector2b.TRUE); this.title.setPropertyExpand(Vector2b.TRUE);
menu.subWidgetAdd(this.title); menu.subWidgetAdd(this.title);
final var previous = Button.createLabelButton("Next &gt;&gt;"); final var previous = Button.createLabelButton("Next &gt;&gt;");
previous.setPropertyMaxSize(new Dimension2f(new Vector2f(9999, 2), Distance.CENTIMETER)); previous.setPropertyMaxSize(new Dimension2f(new Vector2f(9999, 2), Distance.CENTIMETER));
menu.subWidgetAdd(previous); menu.subWidgetAdd(previous);
previous.signalClick.connectAuto(this, BasicWindows::staticRequestPrevious); previous.signalClick.connectAuto(this, BasicWindows::staticRequestPrevious);
this.container.setPropertyExpand(Vector2b.TRUE); this.container.setPropertyExpand(Vector2b.TRUE);
this.container.setPropertyFill(Vector2b.TRUE); this.container.setPropertyFill(Vector2b.TRUE);
this.container.setPropertyExpandIfFree(Vector2b.TRUE); this.container.setPropertyExpandIfFree(Vector2b.TRUE);
this.testedElement.add(new TestWidgetBox());
this.testedElement.add(new TestWidgetSlider()); this.testedElement.add(new TestWidgetSlider());
this.testedElement.add(new TestWidgetEntry()); this.testedElement.add(new TestWidgetEntry());
this.testedElement.add(new TestWidgetBox());
this.testedElement.add(new TestWidgetButton()); this.testedElement.add(new TestWidgetButton());
this.testedElement.add(new TestWidgetButtonToggle()); this.testedElement.add(new TestWidgetButtonToggle());
this.testedElement.add(new TestWidgetCheckBox()); this.testedElement.add(new TestWidgetCheckBox());
this.testedElement.add(new TestWidgetImage()); this.testedElement.add(new TestWidgetImage());
this.testedElement.add(new TestWidgetLabel()); this.testedElement.add(new TestWidgetLabel());
requestNext(); requestNext();
} }
} }

View File

@ -1,15 +1,20 @@
package sample.atriasoft.ewol; package sample.atriasoft.ewol;
import java.util.logging.LogManager;
import org.atriasoft.etk.Uri; import org.atriasoft.etk.Uri;
import org.atriasoft.ewol.Ewol; import org.atriasoft.ewol.Ewol;
import org.slf4j.bridge.SLF4JBridgeHandler;
public class MainApplicaitionStarter { public class MainApplicaitionStarter {
public static void main(final String[] args) { public static void main(final String[] args) {
// Loop-back of logger JDK logging API to SLF4J
LogManager.getLogManager().reset();
SLF4JBridgeHandler.install();
Ewol.init(); Ewol.init();
Uri.setApplication(MainApplicaitionStarter.class, "test-ewol/"); Uri.setApplication(MainApplicaitionStarter.class, "test-ewol/");
Ewol.run(new Appl(), args); Ewol.run(new Appl(), args);
} }
private MainApplicaitionStarter() { private MainApplicaitionStarter() {}
}
} }

View File

@ -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();
}
}

View File

@ -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);
}

View File

@ -20,9 +20,9 @@ import org.atriasoft.gale.resource.ResourceVirtualArrayObject;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
public class CompositingDrawing extends Compositing { public abstract class CompositingDrawing extends CompositingDraw {
private static final Logger LOGGER = LoggerFactory.getLogger(CompositingDrawing.class); private static final Logger LOGGER = LoggerFactory.getLogger(CompositingDrawing.class);
protected static int vboIdColor = 1; protected static int vboIdColor = 1;
protected static int vboIdCoord = 0; protected static int vboIdCoord = 0;
private boolean clippingEnable = false; // !< true if the clipping must be activated 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 ResourceProgram oGLprogram; // !< pointer on the opengl display program
private final List<Color> outColors = new ArrayList<>(); private final List<Color> outColors = new ArrayList<>();
private final List<Vector3f> outTriangles = new ArrayList<>(); private final List<Vector3f> outTriangles = new ArrayList<>();
private Vector3f position = new Vector3f(0, 0, 0); // !< The current position to draw private Vector3f position = new Vector3f(0, 0, 0); // !< The current position to draw
private float thickness = 0; // !< when drawing line and other things 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 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 final Color[] tricolor = new Color[3]; // !< Register every the associated color foreground
private int triElement = 0; // !< special counter of the single dot generated private int triElement = 0; // !< special counter of the single dot generated
//protected ResourceVirtualBufferObject vbo; //protected ResourceVirtualBufferObject vbo;
protected ResourceVirtualArrayObject vbo; protected ResourceVirtualArrayObject vbo;
// internal API for the generation abstraction of triangles // internal API for the generation abstraction of triangles
/** /**
* Basic ructor * Basic ructor
@ -66,7 +66,7 @@ public class CompositingDrawing extends Compositing {
// TO facilitate some debugs we add a name of the VBO: // TO facilitate some debugs we add a name of the VBO:
this.vbo.setName("[VBO] of ewol::compositing::Area"); this.vbo.setName("[VBO] of ewol::compositing::Area");
} }
/** /**
* add a point reference at the current position (this is a vertex * add a point reference at the current position (this is a vertex
* reference at the current position * reference at the current position
@ -75,7 +75,7 @@ public class CompositingDrawing extends Compositing {
internalSetColor(this.color); internalSetColor(this.color);
setPoint(this.position); setPoint(this.position);
} }
/** /**
* draw a 2D circle with the specify rafdius parameter. * draw a 2D circle with the specify rafdius parameter.
* @param radius Distence to the dorder * @param radius Distence to the dorder
@ -85,75 +85,90 @@ public class CompositingDrawing extends Compositing {
public void circle(final float radius) { public void circle(final float radius) {
circle(radius, 0); circle(radius, 0);
} }
public void circle(final float radius, final float angleStart) { public void circle(final float radius, final float angleStart) {
circle(radius, angleStart, 2.0f * FMath.PI); 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(); resetCount();
if (radius < 0) {
radius *= -1;
}
angleStop = angleStop - angleStart;
int nbOcurence = (int) radius; int nbOcurence = (int) radius;
if (nbOcurence < 10) { if (nbOcurence < 10) {
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 : // display background :
if (this.colorBg.a() != 0) { if (this.colorBg.a() != 0) {
internalSetColor(this.colorBg); internalSetColor(this.colorBg);
for (int iii = 0; iii < nbOcurence; iii++) { circleRaw(this.position, radius, angleStart, angleStop);
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));
}
} }
// show if we have a border : // show if we have a border :
if (this.thickness == 0 || this.color.a() == 0) { if (this.thickness == 0 || this.color.a() == 0) {
return; return;
} }
internalSetColor(this.color); internalSetColor(this.color);
for (int iii = 0; iii < nbOcurence; iii++) { circleBorderRaw(this.position, radius, this.thickness, angleStart, angleStop);
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));
}
} }
/** /**
* clear alll tre registered element in the current element * clear all the registered element in the current element
*/ */
@Override @Override
public void clear() { public void clear() {
@ -163,23 +178,23 @@ public class CompositingDrawing extends Compositing {
this.vbo.clear(); this.vbo.clear();
this.outTriangles.clear(); this.outTriangles.clear();
this.outColors.clear(); this.outColors.clear();
// reset temporal variables : // reset temporal variables :
this.position = Vector3f.ZERO; this.position = Vector3f.ZERO;
this.clippingPosStart = Vector3f.ZERO; this.clippingPosStart = Vector3f.ZERO;
this.clippingPosStop = Vector3f.ZERO; this.clippingPosStop = Vector3f.ZERO;
this.clippingEnable = false; this.clippingEnable = false;
this.color = Color.BLACK; this.color = Color.BLACK;
this.colorBg = Color.NONE; this.colorBg = Color.NONE;
for (int iii = 0; iii < 3; iii++) { for (int iii = 0; iii < 3; iii++) {
this.triangle[iii] = this.position; this.triangle[iii] = this.position;
this.tricolor[iii] = this.color; this.tricolor[iii] = this.color;
} }
} }
/** /**
* draw All the refistered text in the current element on openGL * draw All the refistered text in the current element on openGL
*/ */
@ -202,7 +217,7 @@ public class CompositingDrawing extends Compositing {
this.vbo.unBindForRendering(); this.vbo.unBindForRendering();
this.oGLprogram.unUse(); this.oGLprogram.unUse();
} }
@Override @Override
public void flush() { public void flush() {
// push data on the VBO // push data on the VBO
@ -210,7 +225,7 @@ public class CompositingDrawing extends Compositing {
this.vbo.setColors(this.outColors.toArray(Color[]::new)); this.vbo.setColors(this.outColors.toArray(Color[]::new));
this.vbo.setVertexCount(this.outTriangles.size()); this.vbo.setVertexCount(this.outTriangles.size());
} }
/** /**
* Lunch the generation of triangle * 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[1]);
this.outColors.add(this.tricolor[2]); this.outColors.add(this.tricolor[2]);
} }
/** /**
* Get the foreground color of the font. * Get the foreground color of the font.
* @return Foreground color. * @return Foreground color.
@ -231,7 +246,7 @@ public class CompositingDrawing extends Compositing {
public Color getColor() { public Color getColor() {
return this.color; return this.color;
} }
/** /**
* Get the background color of the font. * Get the background color of the font.
* @return Background color. * @return Background color.
@ -239,7 +254,7 @@ public class CompositingDrawing extends Compositing {
public Color getColorBg() { public Color getColorBg() {
return this.colorBg; return this.colorBg;
} }
/** /**
* get the current display position (sometime needed in the gui control) * get the current display position (sometime needed in the gui control)
* @return the current position. * @return the current position.
@ -247,7 +262,7 @@ public class CompositingDrawing extends Compositing {
public Vector3f getPos() { public Vector3f getPos() {
return this.position; return this.position;
} }
/** /**
* set the Color of the current triangle drawing * set the Color of the current triangle drawing
* @param color Color to current dots generated * @param color Color to current dots generated
@ -263,7 +278,7 @@ public class CompositingDrawing extends Compositing {
this.tricolor[2] = color; this.tricolor[2] = color;
} }
} }
/** /**
* Relative drawing a line (special vector) * Relative drawing a line (special vector)
* @param vect Vector of the current line. * @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) { public void lineRel(final float xxx, final float yyy) {
lineTo(this.position.add(new Vector3f(xxx, yyy, 0))); lineTo(this.position.add(new Vector3f(xxx, yyy, 0)));
} }
public void lineRel(final float xxx, final float yyy, final float zzz) { public void lineRel(final float xxx, final float yyy, final float zzz) {
lineTo(this.position.add(new Vector3f(xxx, yyy, zzz))); lineTo(this.position.add(new Vector3f(xxx, yyy, zzz)));
} }
public void lineRel(final Vector2f vect) { public void lineRel(final Vector2f vect) {
lineRel(new Vector3f(vect.x(), vect.y(), 0)); lineRel(new Vector3f(vect.x(), vect.y(), 0));
} }
public void lineRel(final Vector3f vect) { public void lineRel(final Vector3f vect) {
lineTo(this.position.add(vect)); lineTo(this.position.add(vect));
} }
public void lineTo(final float xxx, final float yyy) { public void lineTo(final float xxx, final float yyy) {
lineTo(new Vector3f(xxx, yyy, 0)); lineTo(new Vector3f(xxx, yyy, 0));
} }
public void lineTo(final float xxx, final float yyy, final float zzz) { public void lineTo(final float xxx, final float yyy, final float zzz) {
lineTo(new Vector3f(xxx, yyy, zzz)); lineTo(new Vector3f(xxx, yyy, zzz));
} }
public void lineTo(final Vector2f dest) { public void lineTo(final Vector2f dest) {
lineTo(new Vector3f(dest.x(), dest.y(), 0)); lineTo(new Vector3f(dest.x(), dest.y(), 0));
} }
/** /**
* draw a line to a specific position * draw a line to a specific position
* @param dest Position of the end of the line. * @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(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, 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(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())); setPoint(new Vector3f(this.position.x() - offsetx, this.position.y() - offsety, dest.z()));
// update the system position : // update the system position :
this.position = dest; this.position = dest;
} }
/** /**
* load the openGL program and get all the ID needed * 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"); this.oGLMatrixView = this.oGLprogram.getUniform("in_matrixView");
} }
} }
public void rectangle(final float xxx, final float yyy) { public void rectangle(final float xxx, final float yyy) {
rectangle(new Vector3f(xxx, yyy, 0)); rectangle(new Vector3f(xxx, yyy, 0));
} }
public void rectangle(final float xxx, final float yyy, final float zzz) { public void rectangle(final float xxx, final float yyy, final float zzz) {
rectangle(new Vector3f(xxx, yyy, zzz)); rectangle(new Vector3f(xxx, yyy, zzz));
} }
public void rectangle(final Vector2f dest) { 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. * draw a 2D rectangle to the position requested.
* @param dest Position the the end of the rectangle * @param dest Position the the end of the rectangle
*/ */
public void rectangle(final Vector3f dest) { public void rectangle(final Vector3f dest) {
resetCount();
internalSetColor(this.color); 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 dxA = startPos.x();
float dxB = dest.x(); float dxB = endPos.x();
if (dxA > dxB) { if (dxA > dxB) {
// inverse order : // inverse order :
final float tmp = dxA; final float tmp = dxA;
dxA = dxB; dxA = dxB;
dxB = tmp; dxB = tmp;
} }
float dyC = this.position.y(); float dyC = startPos.y();
float dyD = dest.y(); float dyD = endPos.y();
if (dyC > dyD) { if (dyC > dyD) {
// inverse order : // inverse order :
final float tmp = dyC; final float tmp = dyC;
@ -411,24 +434,219 @@ public class CompositingDrawing extends Compositing {
setPoint(new Vector3f(dxA, dyD, 0)); setPoint(new Vector3f(dxA, dyD, 0));
setPoint(new Vector3f(dxA, dyC, 0)); setPoint(new Vector3f(dxA, dyC, 0));
setPoint(new Vector3f(dxB, dyC, 0)); setPoint(new Vector3f(dxB, dyC, 0));
setPoint(new Vector3f(dxB, dyC, 0)); setPoint(new Vector3f(dxB, dyC, 0));
setPoint(new Vector3f(dxB, dyD, 0)); setPoint(new Vector3f(dxB, dyD, 0));
setPoint(new Vector3f(dxA, 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) { public void rectangleWidth(final float xxx, final float yyy) {
rectangleWidth(new Vector3f(xxx, yyy, 0)); rectangleWidth(new Vector3f(xxx, yyy, 0));
} }
public void rectangleWidth(final float xxx, final float yyy, final float zzz) { public void rectangleWidth(final float xxx, final float yyy, final float zzz) {
rectangleWidth(new Vector3f(xxx, yyy, zzz)); rectangleWidth(new Vector3f(xxx, yyy, zzz));
} }
public void rectangleWidth(final Vector2f size) { public void rectangleWidth(final Vector2f size) {
rectangleWidth(new Vector3f(size.x(), size.y(), 0)); rectangleWidth(new Vector3f(size.x(), size.y(), 0));
} }
/** /**
* draw a 2D rectangle to the requested size. * draw a 2D rectangle to the requested size.
* @param size size of the rectangle * @param size size of the rectangle
@ -436,18 +654,18 @@ public class CompositingDrawing extends Compositing {
public void rectangleWidth(final Vector3f size) { public void rectangleWidth(final Vector3f size) {
rectangle(this.position.add(size)); rectangle(this.position.add(size));
} }
/** /**
* in case of some error the count can be reset * in case of some error the count can be reset
*/ */
private void resetCount() { private void resetCount() {
this.triElement = 0; this.triElement = 0;
} }
public void setClipping(final Vector2f pos, final Vector2f posEnd) { public void setClipping(final Vector2f pos, final Vector2f posEnd) {
setClipping(new Vector3f(pos.x(), pos.y(), -1), new Vector3f(posEnd.x(), posEnd.y(), 1)); 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) * Request a clipping area for the text (next draw only)
* @param pos Start position of the clipping * @param pos Start position of the clipping
@ -460,7 +678,7 @@ public class CompositingDrawing extends Compositing {
this.clippingPosStart = Vector3f.min(pos, posEnd); this.clippingPosStart = Vector3f.min(pos, posEnd);
this.clippingEnable = true; this.clippingEnable = true;
} }
/** /**
* enable/Disable the clipping (without lose the current clipping * enable/Disable the clipping (without lose the current clipping
* position) * position)
@ -469,11 +687,11 @@ public class CompositingDrawing extends Compositing {
public void setClippingMode(final boolean newMode) { public void setClippingMode(final boolean newMode) {
this.clippingEnable = newMode; this.clippingEnable = newMode;
} }
public void setClippingWidth(final Vector2f pos, final Vector2f width) { public void setClippingWidth(final Vector2f pos, final Vector2f width) {
setClippingWidth(new Vector3f(pos.x(), pos.y(), -1), new Vector3f(width.x(), width.y(), 2)); 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) * Request a clipping area for the text (next draw only)
* @param pos Start position of the clipping * @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) { public void setClippingWidth(final Vector3f pos, final Vector3f width) {
setClipping(pos, pos.add(width)); setClipping(pos, pos.add(width));
} }
/** /**
* set the Color of the current foreground font * set the Color of the current foreground font
* @param color Color to set on foreground (for next print) * @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) { public void setColor(final Color color) {
this.color = color; this.color = color;
} }
/** /**
* set the background color of the font (for selected Text (not the * set the background color of the font (for selected Text (not the
* global BG)) * global BG))
@ -499,7 +717,7 @@ public class CompositingDrawing extends Compositing {
public void setColorBg(final Color color) { public void setColorBg(final Color color) {
this.colorBg = color; this.colorBg = color;
} }
/** /**
* internal add of the specific point * internal add of the specific point
* @param point The requeste dpoint to add * @param point The requeste dpoint to add
@ -512,19 +730,19 @@ public class CompositingDrawing extends Compositing {
} }
this.vbo.flush(); this.vbo.flush();
} }
public void setPos(final float xxx, final float yyy) { public void setPos(final float xxx, final float yyy) {
setPos(new Vector3f(xxx, yyy, 0)); setPos(new Vector3f(xxx, yyy, 0));
} }
public void setPos(final float xxx, final float yyy, final float zzz) { public void setPos(final float xxx, final float yyy, final float zzz) {
setPos(new Vector3f(xxx, yyy, zzz)); setPos(new Vector3f(xxx, yyy, zzz));
} }
public void setPos(final Vector2f pos) { public void setPos(final Vector2f pos) {
setPos(new Vector3f(pos.x(), pos.y(), 0)); setPos(new Vector3f(pos.x(), pos.y(), 0));
} }
/** /**
* set position for the next text written * set position for the next text written
* @param pos Position of the text (in 3D) * @param pos Position of the text (in 3D)
@ -532,11 +750,11 @@ public class CompositingDrawing extends Compositing {
public void setPos(final Vector3f pos) { public void setPos(final Vector3f pos) {
this.position = pos; this.position = pos;
} }
public void setRelPos(final float xxx, final float yyy) { public void setRelPos(final float xxx, final float yyy) {
this.position = this.position.add(xxx, yyy, 0); this.position = this.position.add(xxx, yyy, 0);
} }
/** /**
* set relative position for the next text writen * set relative position for the next text writen
* @param pos ofset apply of the text (in 3D) * @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) { public void setRelPos(final float xxx, final float yyy, final float zzz) {
this.position = this.position.add(xxx, yyy, zzz); this.position = this.position.add(xxx, yyy, zzz);
} }
public void setRelPos(final Vector2f pos) { public void setRelPos(final Vector2f pos) {
setRelPos(new Vector3f(pos.x(), pos.y(), 0)); setRelPos(new Vector3f(pos.x(), pos.y(), 0));
} }
public void setRelPos(final Vector3f pos) { public void setRelPos(final Vector3f pos) {
this.position = this.position.add(pos); this.position = this.position.add(pos);
} }
/** /**
* Specify the line thickness for the next elements * Specify the line thickness for the next elements
* @param thickness The thickness desired for the next print * @param thickness The thickness desired for the next print
@ -564,12 +782,12 @@ public class CompositingDrawing extends Compositing {
this.thickness *= -1; this.thickness *= -1;
} }
} }
/** /**
* Un-Load the openGL program and get all the ID needed * Un-Load the openGL program and get all the ID needed
*/ */
private void unLoadProgram() { private void unLoadProgram() {
this.oGLprogram = null; this.oGLprogram = null;
} }
} }

View File

@ -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
}
}

View File

@ -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);
}
}

View File

@ -8,13 +8,21 @@ package org.atriasoft.ewol.compositing;
import org.atriasoft.egami.ImageByte; import org.atriasoft.egami.ImageByte;
import org.atriasoft.egami.ImageByteRGBA; import org.atriasoft.egami.ImageByteRGBA;
import org.atriasoft.egami.ToolImage; 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.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.Color;
import org.atriasoft.etk.Uri; import org.atriasoft.etk.Uri;
import org.atriasoft.etk.math.Matrix4f; import org.atriasoft.etk.math.Matrix4f;
import org.atriasoft.etk.math.Vector2f; import org.atriasoft.etk.math.Vector2f;
import org.atriasoft.etk.math.Vector2i; import org.atriasoft.etk.math.Vector2i;
import org.atriasoft.etk.math.Vector3f; import org.atriasoft.etk.math.Vector3f;
import org.atriasoft.etk.util.Pair;
import org.atriasoft.gale.backend3d.OpenGL; import org.atriasoft.gale.backend3d.OpenGL;
import org.atriasoft.gale.backend3d.OpenGL.RenderMode; import org.atriasoft.gale.backend3d.OpenGL.RenderMode;
import org.atriasoft.gale.resource.ResourceProgram; import org.atriasoft.gale.resource.ResourceProgram;
@ -23,7 +31,7 @@ import org.atriasoft.gale.resource.ResourceVirtualArrayObject;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
public class CompositingSVG extends Compositing { public class CompositingSVG extends CompositingDraw {
private static final Logger LOGGER = LoggerFactory.getLogger(CompositingSVG.class); private static final Logger LOGGER = LoggerFactory.getLogger(CompositingSVG.class);
public static final int NB_VBO = 3; public static final int NB_VBO = 3;
public static final int SIZE_AUTO = 0; public static final int SIZE_AUTO = 0;
@ -126,11 +134,14 @@ public class CompositingSVG extends Compositing {
@Override @Override
public void flush() { public void flush() {
this.vbo.setPosition(this.vboDataCoords); generate();
this.vbo.setTextureCoordinate(this.vboDataCoordsTex); if (this.vboDataCoords != null) {
this.vbo.setColors(this.vboDataColors); this.vbo.setPosition(this.vboDataCoords);
this.vbo.setVertexCount(this.vboDataCoords.length); this.vbo.setTextureCoordinate(this.vboDataCoordsTex);
this.vbo.flush(); 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 ... // Nothing to do ...
return; return;
} }
this.svgData = null;
clear(); 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.svgDoc = data;
this.requestSize = size; 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) { @Override
setSource(""" public void setPaintFillColor(final Color color) {
<svg width="%d" height="%d"> this.paint.fill = new Pair<>(color, "");
<rect
x="%d"
y="%d"
width="%d"
height="%d"
fill="%s"
/>
</svg>""".formatted( //
sizeX, sizeY, //
0, 0, //
sizeX, sizeY, //
color.toStringSharp() //
), new Vector2i(sizeX, sizeY));
} }
@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( public void setRectangleBorderAsSource(
final int sizeX, final int sizeX,
final int sizeY, final int sizeY,
@ -447,30 +539,15 @@ public class CompositingSVG extends Compositing {
final int borderSize, final int borderSize,
final int borderRadius, final int borderRadius,
final Color borderColor) { final Color borderColor) {
final int paddingCompensateBorder = Math.round(borderSize * 0.5f); final int paddingCompensateBorder = Math.round(borderSize * 0.5f);
setSource(""" createSize(new Vector2i(sizeX, sizeY)); // specific for SVG
<svg width="%d" height="%d"> setPaintFillColor(color);
<rect setPaintStrokeColor(borderColor);
x="%d" setPaintStrokeWidth(borderSize);
y="%d" addRectangle(new Vector2f(paddingCompensateBorder, paddingCompensateBorder), //
width="%d" new Vector2f(sizeX - 2 * paddingCompensateBorder, sizeY - 2 * paddingCompensateBorder), //
height="%d" new Vector2f(borderRadius, borderRadius));
rx="%d" flush();
ry="%d"
fill="%s"
stroke="%s"
stroke-width="%d"
/>
</svg>""".formatted( //
sizeX, sizeY, //
paddingCompensateBorder, paddingCompensateBorder, //
sizeX - 2 * paddingCompensateBorder, sizeY - 2 * paddingCompensateBorder, //
borderRadius, //
borderRadius, //
color.toStringSharp(), //
borderColor.toStringSharp(), //
borderSize //
), new Vector2i(sizeX, sizeY));
} }
} }

View File

@ -13,7 +13,6 @@ import org.atriasoft.etk.Color;
import org.atriasoft.etk.Uri; import org.atriasoft.etk.Uri;
import org.atriasoft.etk.math.Matrix4f; import org.atriasoft.etk.math.Matrix4f;
import org.atriasoft.etk.math.Vector2f; import org.atriasoft.etk.math.Vector2f;
import org.atriasoft.etk.math.Vector2f;
import org.atriasoft.etk.util.Dynamic; import org.atriasoft.etk.util.Dynamic;
import org.atriasoft.ewol.compositing.tools.TextDecoration; import org.atriasoft.ewol.compositing.tools.TextDecoration;
import org.atriasoft.ewol.resource.font.FontMode; 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 protected Color defaultColorFg = Color.BLACK; // !< The text foreground color
// this section is reserved for HTML parsing and display: // this section is reserved for HTML parsing and display:
public String htmlCurrentLine = ""; // !< current line for HTML display public String htmlCurrentLine = ""; // !< current line for HTML display
public List<TextDecoration> htmlDecoration = new ArrayList<>(); // !< current decoration for the HTML display public List<TextDecoration> htmlDecoration = new ArrayList<>(); // !< current decoration for the HTML display
public TextDecoration htmlDecoTmp = new TextDecoration(); // !< current decoration public TextDecoration htmlDecoTmp = new TextDecoration(); // !< current decoration
protected boolean kerning = true; // !< Kerning enable or disable on the next elements displayed protected boolean kerning = true; // !< Kerning enable or disable on the next elements displayed
@ -70,19 +69,19 @@ public abstract class TextBase extends Compositing {
// position) // position)
protected float stopTextPos = 0; // !< end of the alignment (when a string is too height it cut at the word protected float stopTextPos = 0; // !< end of the alignment (when a string is too height it cut at the word
protected ResourceVirtualArrayObject vbo = null; protected ResourceVirtualArrayObject vbo = null;
protected CompositingDrawing vectorialDraw = new CompositingDrawing(); protected CompositingDrawing vectorialDraw = new CompositingGC();
/** /**
* generic constructor * generic constructor
*/ */
public TextBase() { public TextBase() {
this(new Uri("DATA", "text.vert", "ewol"), new Uri("DATA", "text.frag", "ewol")); this(new Uri("DATA", "text.vert", "ewol"), new Uri("DATA", "text.frag", "ewol"));
} }
public TextBase(final Uri vertexShader, final Uri fragmentShader) { public TextBase(final Uri vertexShader, final Uri fragmentShader) {
this(vertexShader, fragmentShader, true); this(vertexShader, fragmentShader, true);
} }
public TextBase(final Uri vertexShader, final Uri fragmentShader, final boolean loadProgram) { public TextBase(final Uri vertexShader, final Uri fragmentShader, final boolean loadProgram) {
if (loadProgram) { if (loadProgram) {
loadProgram(vertexShader, fragmentShader); loadProgram(vertexShader, fragmentShader);
@ -92,7 +91,7 @@ public abstract class TextBase extends Compositing {
// TO facilitate some debugs we add a name of the VBO: // TO facilitate some debugs we add a name of the VBO:
this.vbo.setName("[VBO] of super.TextBase"); this.vbo.setName("[VBO] of super.TextBase");
} }
/** /**
* calculate a theoric charcode size * calculate a theoric charcode size
* @param charcode The Unicode value to calculate dimention. * @param charcode The Unicode value to calculate dimention.
@ -101,7 +100,7 @@ public abstract class TextBase extends Compositing {
public Vector2f calculateSize(final Character charcode) { public Vector2f calculateSize(final Character charcode) {
return calculateSizeChar(charcode); return calculateSizeChar(charcode);
} }
/** /**
* calculate a theoric text size * calculate a theoric text size
* @param text The string to calculate dimention. * @param text The string to calculate dimention.
@ -118,10 +117,10 @@ public abstract class TextBase extends Compositing {
} }
return outputSize; return outputSize;
} }
// ! @previous // ! @previous
public abstract Vector2f calculateSizeChar(Character charcode); public abstract Vector2f calculateSizeChar(Character charcode);
/** /**
* calculate a theoric text size * calculate a theoric text size
* @param text The string to calculate dimention. * @param text The string to calculate dimention.
@ -131,13 +130,13 @@ public abstract class TextBase extends Compositing {
if (text.length() == 0) { if (text.length() == 0) {
return Vector2f.ZERO; return Vector2f.ZERO;
} }
final StringBuilder tmpData = new StringBuilder("<html><body>\n"); final StringBuilder tmpData = new StringBuilder("<html><body>\n");
tmpData.append(text); tmpData.append(text);
tmpData.append("\n</body></html>\n"); tmpData.append("\n</body></html>\n");
return calculateSizeHTML(tmpData.toString()); return calculateSizeHTML(tmpData.toString());
} }
/** /**
* calculate a theoric text size * calculate a theoric text size
* @param text The string to calculate dimention. * @param text The string to calculate dimention.
@ -149,27 +148,27 @@ public abstract class TextBase extends Compositing {
// LOGGER.debug(" 0 size for=\n" + text); // LOGGER.debug(" 0 size for=\n" + text);
// disable display system // disable display system
this.needDisplay = false; this.needDisplay = false;
setPos(Vector2f.ZERO); setPos(Vector2f.ZERO);
// same as print without the end display ... // same as print without the end display ...
printHTML(text); printHTML(text);
//LOGGER.error(" ]]]] position={}", this.position); //LOGGER.error(" ]]]] position={}", this.position);
//LOGGER.error(" ]]]] sizeDisplayStart={}", this.sizeDisplayStart); //LOGGER.error(" ]]]] sizeDisplayStart={}", this.sizeDisplayStart);
//LOGGER.error(" ]]]] sizeDisplayStop={}", this.sizeDisplayStop); //LOGGER.error(" ]]]] sizeDisplayStop={}", this.sizeDisplayStop);
// get the last elements // get the last elements
this.sizeDisplayStop = Vector2f.max(this.position, this.sizeDisplayStop); this.sizeDisplayStop = Vector2f.max(this.position, this.sizeDisplayStop);
this.sizeDisplayStart = Vector2f.min(this.position, this.sizeDisplayStart); this.sizeDisplayStart = Vector2f.min(this.position, this.sizeDisplayStart);
// LOGGER.debug(" 2 Start pos=" + this.sizeDisplayStart); // LOGGER.debug(" 2 Start pos=" + this.sizeDisplayStart);
// LOGGER.debug(" 2 Stop pos=" + this.sizeDisplayStop); // LOGGER.debug(" 2 Stop pos=" + this.sizeDisplayStop);
// set back the display system // set back the display system
this.needDisplay = true; this.needDisplay = true;
return new Vector2f(this.sizeDisplayStop.x() - this.sizeDisplayStart.x(), return new Vector2f(this.sizeDisplayStop.x() - this.sizeDisplayStart.x(),
this.sizeDisplayStop.y() - this.sizeDisplayStart.y()); this.sizeDisplayStop.y() - this.sizeDisplayStart.y());
} }
/** /**
* clear all the registered element in the current element * clear all the registered element in the current element
*/ */
@ -184,14 +183,14 @@ public abstract class TextBase extends Compositing {
// reset temporal variables: // reset temporal variables:
reset(); reset();
} }
/** /**
* disable the alignement system * disable the alignement system
*/ */
public void disableAlignement() { public void disableAlignement() {
this.alignment = AlignMode.DISABLE; this.alignment = AlignMode.DISABLE;
} }
/** /**
* remove the cursor display * remove the cursor display
*/ */
@ -199,7 +198,7 @@ public abstract class TextBase extends Compositing {
this.selectionStartPos = -100; this.selectionStartPos = -100;
this.cursorPos = -100; this.cursorPos = -100;
} }
/** /**
* draw All the registered text in the current element on openGL * 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) { public void draw(final boolean disableDepthTest) {
drawD(disableDepthTest); drawD(disableDepthTest);
} }
// ! @previous // ! @previous
public void draw(final Matrix4f transformationMatrix, final boolean enableDepthTest) { public void draw(final Matrix4f transformationMatrix, final boolean enableDepthTest) {
drawMT(transformationMatrix, enableDepthTest); drawMT(transformationMatrix, enableDepthTest);
} }
/** /**
* draw All the refistered text in the current element on openGL * draw All the refistered text in the current element on openGL
*/ */
public abstract void drawD(final boolean disableDepthTest); public abstract void drawD(final boolean disableDepthTest);
// ! @previous // ! @previous
public abstract void drawMT(final Matrix4f transformationMatrix, final boolean enableDepthTest); public abstract void drawMT(final Matrix4f transformationMatrix, final boolean enableDepthTest);
/** /**
* calculate the element number that is the first out the alignment * calculate the element number that is the first out the alignment
* range (start at the specify ID, and use start pos with current one) * 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<Integer> freeSpace) { final Dynamic<Integer> freeSpace) {
// store previous : // store previous :
final Character storePrevious = this.previousCharcode; final Character storePrevious = this.previousCharcode;
stop.value = text.length(); stop.value = text.length();
space.value = 0; space.value = 0;
int lastSpacePosition = start; int lastSpacePosition = start;
int lastSpacefreeSize = 0; int lastSpacefreeSize = 0;
float endPos = this.position.x(); float endPos = this.position.x();
boolean endOfLine = false; boolean endOfLine = false;
float stopPosition = this.stopTextPos; float stopPosition = this.stopTextPos;
if (!this.needDisplay || this.stopTextPos == this.startTextPos) { if (!this.needDisplay || this.stopTextPos == this.startTextPos) {
stopPosition = this.startTextPos + 3999999999.0f; stopPosition = this.startTextPos + 3999999999.0f;
} }
for (int iii = start; iii < text.length(); iii++) { for (int iii = start; iii < text.length(); iii++) {
final Vector2f tmpSize = calculateSize(text.charAt(iii)); final Vector2f tmpSize = calculateSize(text.charAt(iii));
// check overflow : // check overflow :
@ -293,12 +292,12 @@ public abstract class TextBase extends Compositing {
freeSpace.value = lastSpacefreeSize; freeSpace.value = lastSpacefreeSize;
return false; return false;
} }
@Override @Override
public void flush() { public void flush() {
this.vectorialDraw.flush(); this.vectorialDraw.flush();
} }
/** /**
* This generate the line return == > it return to the alignment * This generate the line return == > it return to the alignment
* position start and at the correct line position ==> it might be use to * 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 : // reset position :
setPos(new Vector2f(this.startTextPos, this.position.y() - getHeight())); setPos(new Vector2f(this.startTextPos, this.position.y() - getHeight()));
} }
/** /**
* get the current alignment property * get the current alignment property
* @return the current alignment type * @return the current alignment type
@ -316,12 +315,12 @@ public abstract class TextBase extends Compositing {
public AlignMode getAlignment() { public AlignMode getAlignment() {
return this.alignment; return this.alignment;
} }
// This is used to draw background selection and other things ... // This is used to draw background selection and other things ...
public CompositingDrawing getDrawing() { public CompositingDrawing getDrawing() {
return this.vectorialDraw; return this.vectorialDraw;
} }
/** /**
* get the current font mode * get the current font mode
* @return The font mode applied * @return The font mode applied
@ -329,11 +328,11 @@ public abstract class TextBase extends Compositing {
public FontMode getFontMode() { public FontMode getFontMode() {
return this.mode; return this.mode;
} }
public abstract GlyphProperty getGlyphPointer(Character charcode); public abstract GlyphProperty getGlyphPointer(Character charcode);
public abstract float getHeight(); public abstract float getHeight();
/** /**
* get the current display position (sometime needed in the gui control) * get the current display position (sometime needed in the gui control)
* @return the current position. * @return the current position.
@ -341,9 +340,9 @@ public abstract class TextBase extends Compositing {
public Vector2f getPos() { public Vector2f getPos() {
return this.position; return this.position;
} }
public abstract float getSize(); public abstract float getSize();
/** /**
* add a line with the current this.htmlDecoTmp decoration * add a line with the current this.htmlDecoTmp decoration
* @param data The cuurent data to add. * @param data The cuurent data to add.
@ -365,7 +364,7 @@ public abstract class TextBase extends Compositing {
this.htmlDecoration.add(this.htmlDecoTmp); this.htmlDecoration.add(this.htmlDecoTmp);
} }
} }
/** /**
* draw the current line * draw the current line
*/ */
@ -376,7 +375,7 @@ public abstract class TextBase extends Compositing {
this.htmlCurrentLine = ""; this.htmlCurrentLine = "";
this.htmlDecoration.clear(); this.htmlDecoration.clear();
} }
/** /**
* load the openGL program and get all the ID needed * load the openGL program and get all the ID needed
*/ */
@ -396,7 +395,7 @@ public abstract class TextBase extends Compositing {
old = null; old = null;
} }
} }
/** /**
* This parse a tinyXML node (void pointer to permit to hide tiny XML in * This parse a tinyXML node (void pointer to permit to hide tiny XML in
* include). * include).
@ -509,11 +508,11 @@ public abstract class TextBase extends Compositing {
} else { } else {
LOGGER.error("node not suported type: " + elem.getType() + " val='" + elem.getValue() + "'"); LOGGER.error("node not suported type: " + elem.getType() + " val='" + elem.getValue() + "'");
} }
//LOGGER.error("Add data elems... @pos=", this.position); //LOGGER.error("Add data elems... @pos=", this.position);
} }
} }
/** /**
* display a compleat string in the current element. * display a compleat string in the current element.
* @param text The string to display. * @param text The string to display.
@ -522,7 +521,7 @@ public abstract class TextBase extends Compositing {
final List<TextDecoration> decorationEmpty = new ArrayList<>(); final List<TextDecoration> decorationEmpty = new ArrayList<>();
print(text, decorationEmpty); print(text, decorationEmpty);
} }
/** /**
* display a compleat string in the current element whith specific * display a compleat string in the current element whith specific
* decorations (advence mode). * decorations (advence mode).
@ -702,14 +701,14 @@ public abstract class TextBase extends Compositing {
+ this.sizeDisplayStop + " pos=" + this.position); + this.sizeDisplayStop + " pos=" + this.position);
} }
} }
/** /**
* display the current char in the current element (note that the kerning * display the current char in the current element (note that the kerning
* is availlable if the position is not changed) * is availlable if the position is not changed)
* @param charcode Char that might be dispalyed * @param charcode Char that might be dispalyed
*/ */
public abstract void printChar(Character charcode); public abstract void printChar(Character charcode);
/** /**
* draw a cursor at the specify position * draw a cursor at the specify position
* @param isInsertMode True if the insert mode is activated * @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) { public void printCursor(final boolean isInsertMode) {
printCursor(isInsertMode, 20.0f); printCursor(isInsertMode, 20.0f);
} }
public void printCursor(final boolean isInsertMode, final float cursorSize) { public void printCursor(final boolean isInsertMode, final float cursorSize) {
final int fontHeigh = (int) getHeight(); final int fontHeigh = (int) getHeight();
if (isInsertMode) { if (isInsertMode) {
@ -728,7 +727,7 @@ public abstract class TextBase extends Compositing {
this.vectorialDraw.setThickness(0); this.vectorialDraw.setThickness(0);
} }
} }
/** /**
* display a compleat string in the current element with the generic * display a compleat string in the current element with the generic
* decoration specification. (basic html data) * decoration specification. (basic html data)
@ -764,7 +763,7 @@ public abstract class TextBase extends Compositing {
// LOGGER.debug("plop : " + tmpData); // LOGGER.debug("plop : " + tmpData);
printHTML(tmpData.toString()); printHTML(tmpData.toString());
} }
/** /**
* display a compleat string in the current element with the generic * display a compleat string in the current element with the generic
* decoration specification. (basic html data) * decoration specification. (basic html data)
@ -804,7 +803,7 @@ public abstract class TextBase extends Compositing {
return; return;
} }
final XmlElement root = (XmlElement) doc.getNode("html"); final XmlElement root = (XmlElement) doc.getNode("html");
if (!root.existNode("body")) { if (!root.existNode("body")) {
LOGGER.error("can not load XML: main node not find: 'body'"); LOGGER.error("can not load XML: main node not find: 'body'");
return; return;
@ -826,7 +825,7 @@ public abstract class TextBase extends Compositing {
e.printStackTrace(); e.printStackTrace();
} }
} }
/** /**
* clear all the intermediate result detween 2 prints * clear all the intermediate result detween 2 prints
*/ */
@ -852,19 +851,19 @@ public abstract class TextBase extends Compositing {
this.needDisplay = true; this.needDisplay = true;
this.nbCharDisplayed = 0; this.nbCharDisplayed = 0;
} }
@Override @Override
public void rotate(final Vector2f vect, final float angle) { public void rotate(final Vector2f vect, final float angle) {
super.rotate(vect, angle); super.rotate(vect, angle);
this.vectorialDraw.rotate(vect, angle); this.vectorialDraw.rotate(vect, angle);
} }
@Override @Override
public void scale(final Vector2f vect) { public void scale(final Vector2f vect) {
super.scale(vect); super.scale(vect);
this.vectorialDraw.scale(vect); this.vectorialDraw.scale(vect);
} }
/** /**
* Request a clipping area for the text (next draw only) * Request a clipping area for the text (next draw only)
* @param pos Start position of the clipping * @param pos Start position of the clipping
@ -878,7 +877,7 @@ public abstract class TextBase extends Compositing {
this.clippingEnable = true; this.clippingEnable = true;
this.vectorialDraw.setClipping(this.clippingPosStart, this.clippingPosStop); this.vectorialDraw.setClipping(this.clippingPosStart, this.clippingPosStop);
} }
/** /**
* enable/Disable the clipping (without lose the current clipping * enable/Disable the clipping (without lose the current clipping
* position) * position)
@ -890,7 +889,6 @@ public abstract class TextBase extends Compositing {
this.vectorialDraw.setClippingMode(this.clippingEnable); this.vectorialDraw.setClippingMode(this.clippingEnable);
} }
/** /**
* Request a clipping area for the text (next draw only) * Request a clipping area for the text (next draw only)
* @param pos Start position of the clipping * @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) { public void setClippingWidth(final Vector2f pos, final Vector2f width) {
setClipping(pos, pos.add(width)); setClipping(pos, pos.add(width));
} }
/** /**
* set the Color of the current foreground font * set the Color of the current foreground font
* @param color Color to set on foreground (for next print) * @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) { public void setColor(final Color color) {
this.color = color; this.color = color;
} }
/** /**
* set the background color of the font (for selected Text (not the * set the background color of the font (for selected Text (not the
* global BG)) * global BG))
@ -917,7 +915,7 @@ public abstract class TextBase extends Compositing {
this.colorBg = color; this.colorBg = color;
this.vectorialDraw.setColor(color); this.vectorialDraw.setColor(color);
} }
/** /**
* change the cursor color * change the cursor color
* @param color New color for the Selection * @param color New color for the Selection
@ -925,7 +923,7 @@ public abstract class TextBase extends Compositing {
public void setCursorColor(final Color color) { public void setCursorColor(final Color color) {
this.colorCursor = color; this.colorCursor = color;
} }
/** /**
* set a cursor at a specific position: * set a cursor at a specific position:
* @param cursorPos id of the cursor position * @param cursorPos id of the cursor position
@ -934,7 +932,7 @@ public abstract class TextBase extends Compositing {
this.selectionStartPos = cursorPos; this.selectionStartPos = cursorPos;
this.cursorPos = cursorPos; this.cursorPos = cursorPos;
} }
/** /**
* set a cursor at a specific position with his associated selection: * set a cursor at a specific position with his associated selection:
* @param cursorPos id of the cursor position * @param cursorPos id of the cursor position
@ -944,7 +942,7 @@ public abstract class TextBase extends Compositing {
this.selectionStartPos = selectionStartPos; this.selectionStartPos = selectionStartPos;
this.cursorPos = cursorPos; this.cursorPos = cursorPos;
} }
/** /**
* set the default background color of the font (when reset, set this * set the default background color of the font (when reset, set this
* value ...) * value ...)
@ -953,7 +951,7 @@ public abstract class TextBase extends Compositing {
public void setDefaultColorBg(final Color color) { public void setDefaultColorBg(final Color color) {
this.defaultColorBg = color; this.defaultColorBg = color;
} }
/** /**
* set the default Foreground color of the font (when reset, set this * set the default Foreground color of the font (when reset, set this
* value ...) * value ...)
@ -962,7 +960,7 @@ public abstract class TextBase extends Compositing {
public void setDefaultColorFg(final Color color) { public void setDefaultColorFg(final Color color) {
this.defaultColorFg = color; this.defaultColorFg = color;
} }
/** /**
* Specify the font property (this reset the internal element of the * Specify the font property (this reset the internal element of the
* current text (system requirement) * current text (system requirement)
@ -970,7 +968,7 @@ public abstract class TextBase extends Compositing {
* @param fontSize New font size * @param fontSize New font size
*/ */
public abstract void setFont(final String fontName, final int fontSize); public abstract void setFont(final String fontName, final int fontSize);
/** /**
* enable or disable the bold mode * enable or disable the bold mode
* @param status The new status for this display property * @param status The new status for this display property
@ -990,7 +988,7 @@ public abstract class TextBase extends Compositing {
setFontMode(FontMode.ITALIC); setFontMode(FontMode.ITALIC);
} }
} }
/** /**
* enable or disable the italic mode * enable or disable the italic mode
* @param status The new status for this display property * @param status The new status for this display property
@ -1010,27 +1008,27 @@ public abstract class TextBase extends Compositing {
setFontMode(FontMode.BOLD); setFontMode(FontMode.BOLD);
} }
} }
/** /**
* Specify the font mode for the next @ref print * Specify the font mode for the next @ref print
* @param mode The font mode requested * @param mode The font mode requested
*/ */
public abstract void setFontMode(FontMode mode); public abstract void setFontMode(FontMode mode);
/** /**
* Specify the font name (this reset the internal element of the current * Specify the font name (this reset the internal element of the current
* text (system requirement) * text (system requirement)
* @param fontName Current name of the selected font * @param fontName Current name of the selected font
*/ */
public abstract void setFontName(final String fontName); public abstract void setFontName(final String fontName);
/** /**
* Specify the font size (this reset the internal element of the current * Specify the font size (this reset the internal element of the current
* text (system requirement) * text (system requirement)
* @param fontSize New font size * @param fontSize New font size
*/ */
public abstract void setFontSize(final int fontSize); public abstract void setFontSize(final int fontSize);
/** /**
* set the activation of the Kerning for the display (if it existed) * set the activation of the Kerning for the display (if it existed)
* @param newMode enable/Diasable the kerning on this font. * @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) { public void setKerningMode(final boolean newMode) {
this.kerning = newMode; this.kerning = newMode;
} }
/** /**
* set position for the next text writen * set position for the next text writen
* @param pos Position of the text (in 3D) * @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); //LOGGER.trace("update size 4 " + this.sizeDisplayStart + " " + this.sizeDisplayStop);
} }
} }
/** /**
* set relative position for the next text written * set relative position for the next text written
* @param pos offset apply of the text (in 3D) * @param pos offset apply of the text (in 3D)
@ -1076,7 +1074,7 @@ public abstract class TextBase extends Compositing {
this.previousCharcode = 0; this.previousCharcode = 0;
this.vectorialDraw.setPos(this.position); this.vectorialDraw.setPos(this.position);
} }
/** /**
* change the selection color * change the selection color
* @param color New color for the Selection * @param color New color for the Selection
@ -1084,7 +1082,7 @@ public abstract class TextBase extends Compositing {
public void setSelectionColor(final Color color) { public void setSelectionColor(final Color color) {
this.colorSelection = color; this.colorSelection = color;
} }
/** /**
* This generate the possibility to generate the big text property * This generate the possibility to generate the big text property
* @param startTextPos The x text start position of the display. * @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) { public void setTextAlignment(final float startTextPos, final float stopTextPos) {
setTextAlignment(startTextPos, stopTextPos, AlignMode.DISABLE); setTextAlignment(startTextPos, stopTextPos, AlignMode.DISABLE);
} }
public void setTextAlignment(final float startTextPos, final float stopTextPos, final AlignMode alignement) { public void setTextAlignment(final float startTextPos, final float stopTextPos, final AlignMode alignement) {
this.startTextPos = startTextPos; this.startTextPos = startTextPos;
this.stopTextPos = stopTextPos + 1; this.stopTextPos = stopTextPos + 1;
@ -1105,11 +1103,11 @@ public abstract class TextBase extends Compositing {
LOGGER.trace("Request alignment with Borne position error : " + startTextPos + " => " + stopTextPos); LOGGER.trace("Request alignment with Borne position error : " + startTextPos + " => " + stopTextPos);
} }
} }
@Override @Override
public void translate(final Vector2f vect) { public void translate(final Vector2f vect) {
super.translate(vect); super.translate(vect);
this.vectorialDraw.translate(vect); this.vectorialDraw.translate(vect);
} }
} }

View File

@ -9,15 +9,14 @@ import org.atriasoft.etk.Dimension1f;
import org.atriasoft.etk.Dimension2f; import org.atriasoft.etk.Dimension2f;
import org.atriasoft.etk.math.Vector2f; import org.atriasoft.etk.math.Vector2f;
import org.atriasoft.etk.math.Vector2i; import org.atriasoft.etk.math.Vector2i;
import org.atriasoft.etk.math.Vector2f; import org.atriasoft.ewol.compositing.CompositingGC;
import org.atriasoft.ewol.compositing.CompositingSVG;
import org.atriasoft.ewol.event.EventTime; import org.atriasoft.ewol.event.EventTime;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
public class Box extends Container { public class Box extends Container {
private static final Logger LOGGER = LoggerFactory.getLogger(Box.class); private static final Logger LOGGER = LoggerFactory.getLogger(Box.class);
protected CompositingSVG compositing = new CompositingSVG(); protected CompositingGC vectorialDraw = new CompositingGC();
public static class BoxParameter { public static class BoxParameter {
public Float margin; public Float margin;
@ -218,8 +217,7 @@ public class Box extends Container {
subWidgetSize = subWidgetSize.less(offsetSubWidget.multiply(2)); subWidgetSize = subWidgetSize.less(offsetSubWidget.multiply(2));
subWidgetSize = subWidgetSize.clipInteger(); subWidgetSize = subWidgetSize.clipInteger();
final Vector2f freeSizeWithoutWidget = this.size final Vector2f freeSizeWithoutWidget = this.size.less(offsetSubWidget.multiply(2)).less(subWidgetSize);
.less(offsetSubWidget.multiply(2)).less(subWidgetSize);
Vector2f subWidgetOrigin = this.origin.add(this.propertyGravity.gravityGenerateDelta(freeSizeWithoutWidget)); Vector2f subWidgetOrigin = this.origin.add(this.propertyGravity.gravityGenerateDelta(freeSizeWithoutWidget));
subWidgetOrigin = subWidgetOrigin.add(offsetSubWidget); subWidgetOrigin = subWidgetOrigin.add(offsetSubWidget);
subWidgetOrigin = subWidgetOrigin.clipInteger(); subWidgetOrigin = subWidgetOrigin.clipInteger();
@ -228,9 +226,6 @@ public class Box extends Container {
this.subWidget.onChangeSize(); this.subWidget.onChangeSize();
} }
protected Vector2i renderOrigin;
protected Vector2i renderSize;
private Vector2f calculateOriginRendering(final Vector2f renderSize) { private Vector2f calculateOriginRendering(final Vector2f renderSize) {
return this.propertyGravity.gravityGenerateDelta(this.size.less(renderSize)); return this.propertyGravity.gravityGenerateDelta(this.size.less(renderSize));
} }
@ -254,40 +249,36 @@ public class Box extends Container {
} }
final Vector2f localMargin = this.propertyMargin.size(); final Vector2f localMargin = this.propertyMargin.size();
Vector2f tmpRenderSize = calculateSizeRendering(); Vector2f renderSize = calculateSizeRendering();
Vector2f tmpRenderOrigin = calculateOriginRendering(tmpRenderSize); Vector2f renderOrigin = calculateOriginRendering(renderSize);
tmpRenderOrigin = tmpRenderOrigin.add(localMargin); renderOrigin = renderOrigin.add(localMargin);
tmpRenderSize = tmpRenderSize.less(localMargin.multiply(2)); renderSize = renderSize.less(localMargin.multiply(2));
// not sure this is needed... // not sure this is needed...
tmpRenderSize = tmpRenderSize.clipInteger(); renderSize = renderSize.clipInteger();
tmpRenderOrigin = tmpRenderOrigin.clipInteger(); renderOrigin = renderOrigin.clipInteger();
this.renderOrigin = new Vector2i((int) tmpRenderOrigin.x(), (int) tmpRenderOrigin.y()); renderOrigin = renderOrigin.clipInteger();
this.renderSize = new Vector2i((int) tmpRenderSize.x(), (int) tmpRenderSize.y()); renderSize = renderSize.clipInteger();
this.startPosition = renderOrigin.toVector2i();
this.endPosition = renderSize.toVector2i();
//System.out.println("renderSize: " + this.renderSize); //System.out.println("renderSize: " + this.renderSize);
// remove data of the previous composition : // remove data of the previous composition :
this.compositing.clear(); this.vectorialDraw.clear();
final int borderSize = (int) this.propertyBorderWidth.size(); final int borderSize = (int) this.propertyBorderWidth.size();
final int paddingCompensateBorder = Math.round(borderSize * 0.5f); this.vectorialDraw.setPaintFillColor(this.propertyColor);
if (borderSize > 0.0f) { this.vectorialDraw.setPaintStrokeColor(this.propertyBorderColor);
this.compositing.setRectangleBorderAsSource(this.renderSize.x(), this.renderSize.y(), this.propertyColor, this.vectorialDraw.setPaintStrokeWidth(borderSize);
borderSize, (int) this.propertyBorderRadius.size(), this.propertyBorderColor); this.vectorialDraw.addRectangle(renderOrigin, renderSize,
} else { new Vector2f(this.propertyBorderRadius.size(), this.propertyBorderRadius.size()));
this.compositing.setRectangleAsSource(this.renderSize.x(), this.renderSize.y(), this.propertyColor); this.vectorialDraw.flush();
}
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();
} }
@Override @Override
protected void onDraw() { protected void onDraw() {
if (this.compositing != null) { if (this.vectorialDraw != null) {
this.compositing.draw(true); this.vectorialDraw.draw(true);
} }
super.onDraw(); super.onDraw();
} }

View File

@ -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();
}
}

View File

@ -11,7 +11,6 @@ import org.atriasoft.etk.Color;
import org.atriasoft.etk.Dimension1f; import org.atriasoft.etk.Dimension1f;
import org.atriasoft.etk.Dimension2f; import org.atriasoft.etk.Dimension2f;
import org.atriasoft.etk.Uri; import org.atriasoft.etk.Uri;
import org.atriasoft.etk.math.Vector2f;
import org.atriasoft.etk.math.Vector2b; import org.atriasoft.etk.math.Vector2b;
import org.atriasoft.etk.math.Vector2f; import org.atriasoft.etk.math.Vector2f;
import org.atriasoft.ewol.Gravity; import org.atriasoft.ewol.Gravity;
@ -129,7 +128,7 @@ public class Button extends Box {
@Override @Override
public boolean onEventInput(final EventInput event) { public boolean onEventInput(final EventInput event) {
final Vector2f relPos = relativePosition(event.pos()); 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); final boolean over = isInside(relPos);
//filter if outside the element... //filter if outside the element...
if (event.status() == KeyStatus.leave) { if (event.status() == KeyStatus.leave) {

View File

@ -15,7 +15,6 @@ import org.atriasoft.etk.Uri;
import org.atriasoft.etk.math.FMath; import org.atriasoft.etk.math.FMath;
import org.atriasoft.etk.math.Vector2f; import org.atriasoft.etk.math.Vector2f;
import org.atriasoft.etk.math.Vector2i; import org.atriasoft.etk.math.Vector2i;
import org.atriasoft.etk.math.Vector2f;
import org.atriasoft.ewol.Padding; import org.atriasoft.ewol.Padding;
import org.atriasoft.ewol.compositing.CompositingSVG; import org.atriasoft.ewol.compositing.CompositingSVG;
import org.atriasoft.ewol.compositing.CompositingText; import org.atriasoft.ewol.compositing.CompositingText;
@ -43,7 +42,7 @@ import org.slf4j.LoggerFactory;
*/ */
public class Entry extends Widget { public class Entry extends Widget {
private static final Logger LOGGER = LoggerFactory.getLogger(Entry.class); private static final Logger LOGGER = LoggerFactory.getLogger(Entry.class);
/** /**
* Periodic call to update graphic display * Periodic call to update graphic display
* @param _event Time generic event * @param _event Time generic event
@ -55,7 +54,7 @@ public class Entry extends Widget {
// } // }
self.markToRedraw(); self.markToRedraw();
} }
/// color property of the text foreground /// color property of the text foreground
private int colorIdTextFg; private int colorIdTextFg;
/// Cursor must be display only when the widget has the focus /// Cursor must be display only when the widget has the focus
@ -70,7 +69,7 @@ public class Entry extends Widget {
private int displayCursorPositionPixel = 0; private int displayCursorPositionPixel = 0;
/// text display this.text /// text display this.text
private final CompositingText text = new CompositingText(); private final CompositingText text = new CompositingText();
protected CompositingSVG compositing = new CompositingSVG(); protected CompositingSVG vectorialDraw = new CompositingSVG();
/// text position can have change /// text position can have change
private boolean needUpdateTextPos = true; private boolean needUpdateTextPos = true;
/// Periodic call handle to remove it when needed /// 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 Uri propertyConfig = new Uri("THEME", "shape/Entry.json", "ewol");
private int propertyMaxCharacter = Integer.MAX_VALUE; //!< number max of Character in the list 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 private boolean propertyPassword = false; //!< Disable display of the content of the entry
/// regular expression value /// regular expression value
private String propertyRegex = ".*"; private String propertyRegex = ".*";
/// Text to display when nothing in in the entry (decorated text...) /// Text to display when nothing in in the entry (decorated text...)
private String propertyTextWhenNothing = null; private String propertyTextWhenNothing = null;
private String propertyValue = "Test Text..."; //!< string that must be displayed private String propertyValue = "Test Text..."; //!< string that must be displayed
private Pattern regex = null; //!< regular expression to check content private Pattern regex = null; //!< regular expression to check content
//.create() //.create()
@AknotSignal @AknotSignal
@AknotName(value = "click") @AknotName(value = "click")
@ -97,16 +96,16 @@ public class Entry extends Widget {
@AknotName(value = "enter") @AknotName(value = "enter")
@AknotDescription("The cursor enter inside the button") @AknotDescription("The cursor enter inside the button")
public Signal<String> signalEnter = new Signal<>(); //!< Enter key is pressed public Signal<String> signalEnter = new Signal<>(); //!< Enter key is pressed
@AknotSignal @AknotSignal
@AknotName(value = "modify") @AknotName(value = "modify")
@AknotDescription("Entry box value change") @AknotDescription("Entry box value change")
public Signal<String> signalModify = new Signal<>(); //!< data change public Signal<String> signalModify = new Signal<>(); //!< data change
// element over: // element over:
Vector2f overPositionStart = Vector2f.ZERO; Vector2f overPositionStart = Vector2f.ZERO;
Vector2f overPositionStop = Vector2f.ZERO; Vector2f overPositionStop = Vector2f.ZERO;
/** /**
* Constructor * Constructor
* @param _newData The USting that might be set in the Entry box (no event generation!!) * @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() { public Entry() {
this.propertyCanFocus = true; this.propertyCanFocus = true;
//onChangePropertyShaper(); //onChangePropertyShaper();
this.regex = Pattern.compile(this.propertyRegex); this.regex = Pattern.compile(this.propertyRegex);
if (this.regex == null) { if (this.regex == null) {
LOGGER.error("can not parse regex for : " + this.propertyRegex); LOGGER.error("can not parse regex for : " + this.propertyRegex);
@ -128,7 +127,7 @@ public class Entry extends Widget {
shortCutAdd("ctrl+shift+a", "select:none"); shortCutAdd("ctrl+shift+a", "select:none");
//TODO this.signalShortcut.connect(this, Entry::onCallbackShortCut); //TODO this.signalShortcut.connect(this, Entry::onCallbackShortCut);
} }
@Override @Override
public void calculateMinMaxSize() { public void calculateMinMaxSize() {
// call main class // call main class
@ -136,7 +135,7 @@ public class Entry extends Widget {
// get generic padding // get generic padding
final Padding padding = Padding.ZERO; final Padding padding = Padding.ZERO;
final int minHeight = (int) this.text.getHeight();//calculateSize('A').y(); final int minHeight = (int) this.text.getHeight();//calculateSize('A').y();
Vector2f minimumSizeBase = new Vector2f(20, minHeight); Vector2f minimumSizeBase = new Vector2f(20, minHeight);
// add padding : // add padding :
minimumSizeBase = minimumSizeBase.add(padding.x(), padding.y()); minimumSizeBase = minimumSizeBase.add(padding.x(), padding.y());
@ -145,7 +144,7 @@ public class Entry extends Widget {
checkMinSize(); checkMinSize();
//LOGGER.trace("min size = " + this.minSize); //LOGGER.trace("min size = " + this.minSize);
} }
protected void changeStatusIn(final GuiShapeMode newStatusId) { protected void changeStatusIn(final GuiShapeMode newStatusId) {
// if (this.shape.changeStatusIn(newStatusId)) { // if (this.shape.changeStatusIn(newStatusId)) {
// if (!this.periodicConnectionHanble.isConnected()) { // if (!this.periodicConnectionHanble.isConnected()) {
@ -156,7 +155,7 @@ public class Entry extends Widget {
// markToRedraw(); // markToRedraw();
// } // }
} }
/** /**
* Copy the selected data on the specify clipboard * Copy the selected data on the specify clipboard
* @param clipboardID Selected clipboard * @param clipboardID Selected clipboard
@ -176,48 +175,48 @@ public class Entry extends Widget {
final String tmpData = this.propertyValue.substring(pos1, pos2); final String tmpData = this.propertyValue.substring(pos1, pos2);
ClipBoard.set(clipboardID, tmpData); ClipBoard.set(clipboardID, tmpData);
} }
public Uri getPropertyConfig() { public Uri getPropertyConfig() {
return this.propertyConfig; return this.propertyConfig;
} }
public int getPropertyMaxCharacter() { public int getPropertyMaxCharacter() {
return this.propertyMaxCharacter; return this.propertyMaxCharacter;
} }
public String getPropertyRegex() { public String getPropertyRegex() {
return this.propertyRegex; return this.propertyRegex;
} }
public String getPropertyTextWhenNothing() { public String getPropertyTextWhenNothing() {
return this.propertyTextWhenNothing; return this.propertyTextWhenNothing;
} }
public String getPropertyValue() { public String getPropertyValue() {
return this.propertyValue; return this.propertyValue;
} }
public boolean isPropertyPassword() { public boolean isPropertyPassword() {
return this.propertyPassword; return this.propertyPassword;
} }
/** /**
* informe the system thet the text change and the start position change * informe the system thet the text change and the start position change
*/ */
protected void markToUpdateTextPosition() { protected void markToUpdateTextPosition() {
this.needUpdateTextPos = true; this.needUpdateTextPos = true;
} }
private void onCallbackCopy() { private void onCallbackCopy() {
copySelectionToClipBoard(ClipboardList.CLIPBOARD_STD); copySelectionToClipBoard(ClipboardList.CLIPBOARD_STD);
} }
private void onCallbackCut() { private void onCallbackCut() {
copySelectionToClipBoard(ClipboardList.CLIPBOARD_STD); copySelectionToClipBoard(ClipboardList.CLIPBOARD_STD);
removeSelected(); removeSelected();
this.signalModify.emit(this.propertyValue); this.signalModify.emit(this.propertyValue);
} }
private void onCallbackEntryClean() { private void onCallbackEntryClean() {
this.propertyValue = ""; this.propertyValue = "";
this.displayStartPosition = 0; this.displayStartPosition = 0;
@ -225,11 +224,11 @@ public class Entry extends Widget {
this.displayCursorPosSelection = this.displayCursorPos; this.displayCursorPosSelection = this.displayCursorPos;
markToRedraw(); markToRedraw();
} }
private void onCallbackPaste() { private void onCallbackPaste() {
ClipBoard.request(ClipboardList.CLIPBOARD_STD); ClipBoard.request(ClipboardList.CLIPBOARD_STD);
} }
private void onCallbackSelect(final boolean all) { private void onCallbackSelect(final boolean all) {
if (all) { if (all) {
this.displayCursorPosSelection = 0; this.displayCursorPosSelection = 0;
@ -239,7 +238,7 @@ public class Entry extends Widget {
} }
markToRedraw(); markToRedraw();
} }
private void onCallbackShortCut(final String value) { private void onCallbackShortCut(final String value) {
if (value.equals("clean")) { if (value.equals("clean")) {
onCallbackEntryClean(); onCallbackEntryClean();
@ -258,15 +257,15 @@ public class Entry extends Widget {
LOGGER.warn("Unknow event from ShortCut : " + value); LOGGER.warn("Unknow event from ShortCut : " + value);
} }
} }
protected void onChangePropertyMaxCharacter() { protected void onChangePropertyMaxCharacter() {
// TODO : check number of char in the data // TODO : check number of char in the data
} }
protected void onChangePropertyPassword() { protected void onChangePropertyPassword() {
markToRedraw(); markToRedraw();
} }
protected void onChangePropertyRegex() { protected void onChangePropertyRegex() {
this.regex = Pattern.compile(this.propertyRegex); this.regex = Pattern.compile(this.propertyRegex);
if (this.regex != null) { if (this.regex != null) {
@ -274,11 +273,11 @@ public class Entry extends Widget {
} }
markToRedraw(); markToRedraw();
} }
protected void onChangePropertyTextWhenNothing() { protected void onChangePropertyTextWhenNothing() {
markToRedraw(); markToRedraw();
} }
protected void onChangePropertyValue() { protected void onChangePropertyValue() {
String newData = this.propertyValue; String newData = this.propertyValue;
if ((long) newData.length() > this.propertyMaxCharacter) { if ((long) newData.length() > this.propertyMaxCharacter) {
@ -294,15 +293,15 @@ public class Entry extends Widget {
} }
markToRedraw(); markToRedraw();
} }
@Override @Override
protected void onDraw() { protected void onDraw() {
if (this.compositing != null) { if (this.vectorialDraw != null) {
this.compositing.draw(true); this.vectorialDraw.draw(true);
} }
this.text.draw(); this.text.draw();
} }
@Override @Override
public void onEventClipboard(final ClipboardList clipboardID) { public void onEventClipboard(final ClipboardList clipboardID) {
// remove curent selected data ... // remove curent selected data ...
@ -326,7 +325,7 @@ public class Entry extends Widget {
} }
this.signalModify.emit(this.propertyValue); this.signalModify.emit(this.propertyValue);
} }
@Override @Override
public boolean onEventEntry(final EventEntry event) { public boolean onEventEntry(final EventEntry event) {
LOGGER.trace("Event on Entry ... " + event); LOGGER.trace("Event on Entry ... " + event);
@ -402,7 +401,7 @@ public class Entry extends Widget {
} }
return false; return false;
} }
@Override @Override
public boolean onEventInput(final EventInput event) { public boolean onEventInput(final EventInput event) {
final Vector2f absolutePosition = event.pos(); final Vector2f absolutePosition = event.pos();
@ -505,7 +504,7 @@ public class Entry extends Widget {
} }
return false; return false;
} }
@Override @Override
protected void onGetFocus() { protected void onGetFocus() {
this.displayCursor = true; this.displayCursor = true;
@ -513,7 +512,7 @@ public class Entry extends Widget {
showKeyboard(); showKeyboard();
markToRedraw(); markToRedraw();
} }
@Override @Override
protected void onLostFocus() { protected void onLostFocus() {
this.displayCursor = false; this.displayCursor = false;
@ -521,14 +520,14 @@ public class Entry extends Widget {
hideKeyboard(); hideKeyboard();
markToRedraw(); markToRedraw();
} }
@Override @Override
public void onRegenerateDisplay() { public void onRegenerateDisplay() {
if (!needRedraw()) { if (!needRedraw()) {
//return; return;
} }
//LOGGER.trace("Regenerate Display ==> is needed: '" + this.propertyValue + "'"); //LOGGER.trace("Regenerate Display ==> is needed: '" + this.propertyValue + "'");
this.compositing.clear(); this.vectorialDraw.clear();
this.text.clear(); this.text.clear();
if (this.colorIdTextFg >= 0) { if (this.colorIdTextFg >= 0) {
//this.text.setDefaultColorFg(this.shape.getColor(this.colorIdTextFg)); //this.text.setDefaultColorFg(this.shape.getColor(this.colorIdTextFg));
@ -538,7 +537,7 @@ public class Entry extends Widget {
} }
updateTextPosition(); updateTextPosition();
final Padding padding = Padding.ZERO; final Padding padding = Padding.ZERO;
Vector2f tmpSizeShaper = this.minSize; Vector2f tmpSizeShaper = this.minSize;
Vector2f delta = this.propertyGravity.gravityGenerateDelta(this.size.less(this.minSize)); Vector2f delta = this.propertyGravity.gravityGenerateDelta(this.size.less(this.minSize));
if (this.propertyFill.x()) { 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 = tmpOriginShaper.add(padding.bottom(), padding.left()); //this.size.less(tmpSizeText).multiply(0.5f);
//Vector2f tmpOriginText = new Vector2f(0, this.text.getSize(), 0); //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 ... // 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(); final int minHeight = (int) this.text.getHeight();
if (tmpSizeText.y() > minHeight) { if (tmpSizeText.y() > minHeight) {
tmpOriginText = tmpOriginText.add(0, (tmpSizeText.y() - minHeight) * 0.5f); tmpOriginText = tmpOriginText.add(0, (tmpSizeText.y() - minHeight) * 0.5f);
@ -565,7 +564,7 @@ public class Entry extends Widget {
tmpOriginShaper = Vector2f.clipInt(tmpOriginShaper); tmpOriginShaper = Vector2f.clipInt(tmpOriginShaper);
tmpSizeText = Vector2f.clipInt(tmpSizeText); tmpSizeText = Vector2f.clipInt(tmpSizeText);
tmpOriginText = Vector2f.clipInt(tmpOriginText); tmpOriginText = Vector2f.clipInt(tmpOriginText);
this.text.clear(); this.text.clear();
//this.text.setSize((int) tmpSizeText.x(), (int) tmpSizeText.y()); //this.text.setSize((int) tmpSizeText.x(), (int) tmpSizeText.y());
this.text.setClippingWidth(tmpOriginText, tmpSizeText); this.text.setClippingWidth(tmpOriginText, tmpSizeText);
@ -579,7 +578,7 @@ public class Entry extends Widget {
if (this.propertyPassword) { if (this.propertyPassword) {
Arrays.fill(valueToDisplay, '*'); Arrays.fill(valueToDisplay, '*');
} }
//final Vector2f plop = new Vector2f(tmpOriginText.x() + this.displayStartPosition, tmpOriginText.y()); //final Vector2f plop = new Vector2f(tmpOriginText.x() + this.displayStartPosition, tmpOriginText.y());
if (valueToDisplay.length != 0) { if (valueToDisplay.length != 0) {
this.text.print(new String(valueToDisplay)); this.text.print(new String(valueToDisplay));
@ -590,7 +589,7 @@ public class Entry extends Widget {
this.overPositionStart = tmpOriginShaper; this.overPositionStart = tmpOriginShaper;
this.overPositionStop = tmpOriginShaper.add(tmpSizeShaper); this.overPositionStop = tmpOriginShaper.add(tmpSizeShaper);
//this.shape.setShape(tmpOriginShaper, tmpSizeShaper, tmpOriginText, tmpSizeText); //this.shape.setShape(tmpOriginShaper, tmpSizeShaper, tmpOriginText, tmpSizeText);
this.compositing.setSource(""" this.vectorialDraw.setSource("""
<svg width="%d" height="%d"> <svg width="%d" height="%d">
<rect <rect
x="0.5" x="0.5"
@ -605,13 +604,13 @@ public class Entry extends Widget {
(int) tmpSizeShaper.x(), (int) tmpSizeShaper.y(), // (int) tmpSizeShaper.x(), (int) tmpSizeShaper.y(), //
tmpSizeShaper.x() - 0.5, tmpSizeShaper.y() - 0.5// tmpSizeShaper.x() - 0.5, tmpSizeShaper.y() - 0.5//
), new Vector2i((int) tmpSizeShaper.x(), (int) tmpSizeShaper.y())); ), new Vector2i((int) tmpSizeShaper.x(), (int) tmpSizeShaper.y()));
this.compositing.setPos(tmpOriginShaper); this.vectorialDraw.setPos(tmpOriginShaper);
this.compositing.print(new Vector2f(tmpSizeShaper.x(), tmpSizeShaper.y())); this.vectorialDraw.print(new Vector2f(tmpSizeShaper.x(), tmpSizeShaper.y()));
this.text.flush(); this.text.flush();
this.compositing.flush(); this.vectorialDraw.flush();
} }
/** /**
* remove the selected area * remove the selected area
* @note This request a regeneration of the display * @note This request a regeneration of the display
@ -639,7 +638,7 @@ public class Entry extends Widget {
this.propertyValue = tmp.toString(); this.propertyValue = tmp.toString();
markToRedraw(); markToRedraw();
} }
/** /**
* internal check the value with RegExp checking * internal check the value with RegExp checking
* @param newData The new string to display * @param newData The new string to display
@ -666,7 +665,7 @@ public class Entry extends Widget {
this.propertyValue = newData; this.propertyValue = newData;
markToRedraw(); markToRedraw();
} }
@AknotManaged @AknotManaged
@AknotAttribute @AknotAttribute
@AknotName(value = "config") @AknotName(value = "config")
@ -678,7 +677,7 @@ public class Entry extends Widget {
this.propertyConfig = propertyConfig; this.propertyConfig = propertyConfig;
//onChangePropertyShaper(); //onChangePropertyShaper();
} }
@AknotManaged @AknotManaged
@AknotAttribute @AknotAttribute
@AknotName(value = "max") @AknotName(value = "max")
@ -690,7 +689,7 @@ public class Entry extends Widget {
this.propertyMaxCharacter = propertyMaxCharacter; this.propertyMaxCharacter = propertyMaxCharacter;
onChangePropertyMaxCharacter(); onChangePropertyMaxCharacter();
} }
@AknotManaged @AknotManaged
@AknotAttribute @AknotAttribute
@AknotName(value = "password") @AknotName(value = "password")
@ -702,7 +701,7 @@ public class Entry extends Widget {
this.propertyPassword = propertyPassword; this.propertyPassword = propertyPassword;
onChangePropertyPassword(); onChangePropertyPassword();
} }
@AknotManaged @AknotManaged
@AknotAttribute @AknotAttribute
@AknotName(value = "regex") @AknotName(value = "regex")
@ -714,7 +713,7 @@ public class Entry extends Widget {
this.propertyRegex = propertyRegex; this.propertyRegex = propertyRegex;
onChangePropertyRegex(); onChangePropertyRegex();
} }
@AknotManaged @AknotManaged
@AknotAttribute @AknotAttribute
@AknotName(value = "empty-text") @AknotName(value = "empty-text")
@ -726,7 +725,7 @@ public class Entry extends Widget {
this.propertyTextWhenNothing = propertyTextWhenNothing; this.propertyTextWhenNothing = propertyTextWhenNothing;
onChangePropertyTextWhenNothing(); onChangePropertyTextWhenNothing();
} }
@AknotManaged @AknotManaged
@AknotAttribute @AknotAttribute
@AknotName(value = "value") @AknotName(value = "value")
@ -738,7 +737,7 @@ public class Entry extends Widget {
this.propertyValue = propertyValue; this.propertyValue = propertyValue;
onChangePropertyValue(); onChangePropertyValue();
} }
/** /**
* change the cursor position with the curent position requested on the display * change the cursor position with the curent position requested on the display
* @param pos Absolute position of the event * @param pos Absolute position of the event
@ -747,13 +746,13 @@ public class Entry extends Widget {
protected void updateCursorPosition(final Vector2f pos) { protected void updateCursorPosition(final Vector2f pos) {
updateCursorPosition(pos, false); updateCursorPosition(pos, false);
} }
protected void updateCursorPosition(final Vector2f pos, final boolean selection/*=false*/) { protected void updateCursorPosition(final Vector2f pos, final boolean selection/*=false*/) {
final Padding padding = Padding.ZERO; final Padding padding = Padding.ZERO;
final Vector2f relPos = relativePosition(pos).less(this.overPositionStart); final Vector2f relPos = relativePosition(pos).less(this.overPositionStart);
// reject when outside ... // reject when outside ...
// try to find the new cursor position : // try to find the new cursor position :
if (this.displayStartPosition > this.propertyValue.length()) { if (this.displayStartPosition > this.propertyValue.length()) {
this.displayStartPosition = this.propertyValue.length(); this.displayStartPosition = this.propertyValue.length();
@ -791,7 +790,7 @@ public class Entry extends Widget {
} }
markToUpdateTextPosition(); markToUpdateTextPosition();
} }
/** /**
* update the display position start == > depending of the position of the Cursor and the size of the Data inside * update the display position start == > depending of the position of the Cursor and the size of the Data inside
* @change this.displayStartPosition < == updated * @change this.displayStartPosition < == updated
@ -801,7 +800,7 @@ public class Entry extends Widget {
return; return;
} }
final Padding padding = Padding.ZERO; final Padding padding = Padding.ZERO;
int tmpSizeX = (int) this.minSize.x(); int tmpSizeX = (int) this.minSize.x();
if (this.propertyFill.x()) { if (this.propertyFill.x()) {
tmpSizeX = (int) this.size.x(); tmpSizeX = (int) this.size.x();
@ -831,5 +830,5 @@ public class Entry extends Widget {
//this.displayStartPosition = -totalWidth + tmpUserSize; //this.displayStartPosition = -totalWidth + tmpUserSize;
} }
} }
} }

View File

@ -13,8 +13,8 @@ import org.atriasoft.aknot.annotation.AknotSignal;
import org.atriasoft.esignal.SignalEmpty; import org.atriasoft.esignal.SignalEmpty;
import org.atriasoft.etk.Uri; import org.atriasoft.etk.Uri;
import org.atriasoft.etk.math.FMath; import org.atriasoft.etk.math.FMath;
import org.atriasoft.etk.math.Vector2i;
import org.atriasoft.etk.math.Vector2f; import org.atriasoft.etk.math.Vector2f;
import org.atriasoft.etk.math.Vector2i;
import org.atriasoft.etranslate.ETranslate; import org.atriasoft.etranslate.ETranslate;
import org.atriasoft.ewol.compositing.AlignMode; import org.atriasoft.ewol.compositing.AlignMode;
import org.atriasoft.ewol.compositing.CompositingText; import org.atriasoft.ewol.compositing.CompositingText;
@ -30,7 +30,7 @@ public class LabelOnSVG extends Widget {
protected int colorDefaultFgText = -1; //!< Default color of the text protected int colorDefaultFgText = -1; //!< Default color of the text
protected ResourceColorFile colorProperty; //!< theme color property protected ResourceColorFile colorProperty; //!< theme color property
protected boolean propertyAutoTranslate = true; //!< if at true the data is translate automaticaly translate. protected boolean propertyAutoTranslate = true; //!< if at true the data is translate automaticaly translate.
protected int propertyFontSize = 0; //!< default size of the font. protected int propertyFontSize = 0; //!< default size of the font.
protected String propertyValue = ""; //!< decorated text to display. protected String propertyValue = ""; //!< decorated text to display.
@AknotSignal @AknotSignal
@ -39,7 +39,7 @@ public class LabelOnSVG extends Widget {
public SignalEmpty signalPressed = new SignalEmpty(); public SignalEmpty signalPressed = new SignalEmpty();
protected CompositingText text = new CompositingText(); //!< Compositing text element. protected CompositingText text = new CompositingText(); //!< Compositing text element.
protected String value = ""; protected String value = "";
public LabelOnSVG() { public LabelOnSVG() {
this.colorProperty = ResourceColorFile.create(new Uri("THEME", "/color/Label.json", "ewol")); this.colorProperty = ResourceColorFile.create(new Uri("THEME", "/color/Label.json", "ewol"));
if (this.colorProperty != null) { if (this.colorProperty != null) {
@ -49,7 +49,7 @@ public class LabelOnSVG extends Widget {
setMouseLimit(1); setMouseLimit(1);
setPropertyCanFocus(false); setPropertyCanFocus(false);
} }
/** /**
* Constructor * Constructor
* @param newLabel The displayed decorated text. * @param newLabel The displayed decorated text.
@ -64,7 +64,7 @@ public class LabelOnSVG extends Widget {
setPropertyCanFocus(false); setPropertyCanFocus(false);
setPropertyValue(newLabel); setPropertyValue(newLabel);
} }
@Override @Override
public void calculateMinMaxSize() { public void calculateMinMaxSize() {
final Vector2f tmpMax = this.propertyMaxSize.getPixel(); final Vector2f tmpMax = this.propertyMaxSize.getPixel();
@ -76,30 +76,30 @@ public class LabelOnSVG extends Widget {
} }
final Vector2f minSize = this.text.calculateSizeDecorated(this.value); final Vector2f minSize = this.text.calculateSizeDecorated(this.value);
LOGGER.debug("[" + getId() + "] {" + getClass().getCanonicalName() + "} minSize : " + minSize); LOGGER.debug("[" + getId() + "] {" + getClass().getCanonicalName() + "} minSize : " + minSize);
this.minSize = new Vector2f(FMath.avg(tmpMin.x(), 4 + minSize.x(), tmpMax.x()), this.minSize = new Vector2f(FMath.avg(tmpMin.x(), 4 + minSize.x(), tmpMax.x()),
FMath.avg(tmpMin.y(), 4 + minSize.y(), tmpMax.y())); FMath.avg(tmpMin.y(), 4 + minSize.y(), tmpMax.y()));
LOGGER.trace("[" + getId() + "] {" + getClass().getCanonicalName() + "} Result min size : " + tmpMin + " < " LOGGER.trace("[" + getId() + "] {" + getClass().getCanonicalName() + "} Result min size : " + tmpMin + " < "
+ this.minSize + " < " + tmpMax); + this.minSize + " < " + tmpMax);
} }
public int getPropertyFontSize() { public int getPropertyFontSize() {
return this.propertyFontSize; return this.propertyFontSize;
} }
public String getPropertyValue() { public String getPropertyValue() {
return this.propertyValue; return this.propertyValue;
} }
public boolean isPropertyAutoTranslate() { public boolean isPropertyAutoTranslate() {
return this.propertyAutoTranslate; return this.propertyAutoTranslate;
} }
@Override @Override
protected void onDraw() { protected void onDraw() {
this.text.draw(); this.text.draw();
} }
@Override @Override
public boolean onEventInput(final EventInput event) { public boolean onEventInput(final EventInput event) {
//LOGGER.debug("Event on Label ..."); //LOGGER.debug("Event on Label ...");
@ -112,32 +112,32 @@ public class LabelOnSVG extends Widget {
} }
return false; return false;
} }
@Override @Override
public void onRegenerateDisplay() { public void onRegenerateDisplay() {
if (!needRedraw()) { if (!needRedraw()) {
//return; return;
} }
this.text.clear(); this.text.clear();
final int paddingSize = 2; final int paddingSize = 2;
final Vector2f tmpMax = this.propertyMaxSize.getPixel(); final Vector2f tmpMax = this.propertyMaxSize.getPixel();
// to know the size of one line : // to know the size of one line :
final Vector2f minSize = this.text.calculateSize('A'); final Vector2f minSize = this.text.calculateSize('A');
//minSize.setX(etk::max(minSize.x(), this.minSize.x())); //minSize.setX(etk::max(minSize.x(), this.minSize.x()));
//minSize.setY(etk::max(minSize.y(), this.minSize.y())); //minSize.setY(etk::max(minSize.y(), this.minSize.y()));
if (tmpMax.x() <= 999999) { if (tmpMax.x() <= 999999) {
this.text.setTextAlignment(0, tmpMax.x() - 2 * paddingSize, AlignMode.LEFT); this.text.setTextAlignment(0, tmpMax.x() - 2 * paddingSize, AlignMode.LEFT);
} }
final Vector2f currentTextSize = this.text.calculateSizeDecorated(this.value); final Vector2f currentTextSize = this.text.calculateSizeDecorated(this.value);
Vector2i localSize = new Vector2i((int) this.minSize.x(), (int) this.minSize.y()); Vector2i localSize = new Vector2i((int) this.minSize.x(), (int) this.minSize.y());
// no change for the text origin : // no change for the text origin :
Vector2f tmpTextOrigin = new Vector2f((this.size.x() - this.minSize.x()) / 2.0f, Vector2f tmpTextOrigin = new Vector2f((this.size.x() - this.minSize.x()) / 2.0f,
(this.size.y() - this.minSize.y()) / 2.0f); (this.size.y() - this.minSize.y()) / 2.0f);
if (this.propertyFill.x()) { if (this.propertyFill.x()) {
localSize = localSize.withX((int) this.size.x()); localSize = localSize.withX((int) this.size.x());
tmpTextOrigin = tmpTextOrigin.withX(0); tmpTextOrigin = tmpTextOrigin.withX(0);
@ -148,14 +148,14 @@ public class LabelOnSVG extends Widget {
} }
tmpTextOrigin = tmpTextOrigin.add(paddingSize, paddingSize); tmpTextOrigin = tmpTextOrigin.add(paddingSize, paddingSize);
localSize = localSize.less(2 * paddingSize, 2 * paddingSize); localSize = localSize.less(2 * paddingSize, 2 * paddingSize);
tmpTextOrigin = tmpTextOrigin.withY(tmpTextOrigin.y() + (this.minSize.y() - 2 * paddingSize) - minSize.y()); tmpTextOrigin = tmpTextOrigin.withY(tmpTextOrigin.y() + (this.minSize.y() - 2 * paddingSize) - minSize.y());
final Vector2f textPos = new Vector2f(tmpTextOrigin.x(), tmpTextOrigin.y()); final Vector2f textPos = new Vector2f(tmpTextOrigin.x(), tmpTextOrigin.y());
final Vector2f drawClippingPos = new Vector2f(paddingSize, paddingSize); final Vector2f drawClippingPos = new Vector2f(paddingSize, paddingSize);
final Vector2f drawClippingSize = new Vector2f((this.size.x() - paddingSize), (this.size.y() - paddingSize)); final Vector2f drawClippingSize = new Vector2f((this.size.x() - paddingSize), (this.size.y() - paddingSize));
// clean the element // clean the element
this.text.reset(); this.text.reset();
if (this.propertyFontSize != 0) { if (this.propertyFontSize != 0) {
@ -170,10 +170,10 @@ public class LabelOnSVG extends Widget {
this.text.setTextAlignment(tmpTextOrigin.x(), tmpTextOrigin.x() + localSize.x(), AlignMode.LEFT); this.text.setTextAlignment(tmpTextOrigin.x(), tmpTextOrigin.x() + localSize.x(), AlignMode.LEFT);
this.text.setClipping(drawClippingPos, drawClippingSize); this.text.setClipping(drawClippingPos, drawClippingSize);
this.text.printDecorated(this.value); this.text.printDecorated(this.value);
this.text.flush(); this.text.flush();
} }
@AknotManaged @AknotManaged
@AknotAttribute @AknotAttribute
@AknotName("auto-translate") @AknotName("auto-translate")
@ -191,7 +191,7 @@ public class LabelOnSVG extends Widget {
markToRedraw(); markToRedraw();
requestUpdateSize(); requestUpdateSize();
} }
@AknotManaged @AknotManaged
@AknotAttribute @AknotAttribute
@AknotName("font-size") @AknotName("font-size")
@ -204,7 +204,7 @@ public class LabelOnSVG extends Widget {
markToRedraw(); markToRedraw();
requestUpdateSize(); requestUpdateSize();
} }
@AknotManaged @AknotManaged
@AknotAttribute @AknotAttribute
@AknotName("value") @AknotName("value")
@ -222,5 +222,5 @@ public class LabelOnSVG extends Widget {
requestUpdateSize(); requestUpdateSize();
this.propertyValue = propertyValue; this.propertyValue = propertyValue;
} }
} }

View File

@ -12,27 +12,28 @@ import org.atriasoft.aknot.annotation.AknotName;
import org.atriasoft.etk.Color; import org.atriasoft.etk.Color;
import org.atriasoft.etk.math.Vector2f; import org.atriasoft.etk.math.Vector2f;
import org.atriasoft.ewol.compositing.CompositingDrawing; import org.atriasoft.ewol.compositing.CompositingDrawing;
import org.atriasoft.ewol.compositing.CompositingGC;
class ProgressBar extends Widget { class ProgressBar extends Widget {
private static final int DOT_RADIUS = 6; private static final int DOT_RADIUS = 6;
private final CompositingDrawing draw = new CompositingDrawing(); // basic drawing element private final CompositingDrawing vectorialDraw = new CompositingGC(); // basic drawing element
protected Color propertyTextColorBgOff = Color.NONE; protected Color propertyTextColorBgOff = Color.NONE;
protected Color propertyTextColorBgOn = Color.GREEN; protected Color propertyTextColorBgOn = Color.GREEN;
protected Color propertyTextColorFg = Color.BLACK; protected Color propertyTextColorFg = Color.BLACK;
protected float propertyValue = 0; protected float propertyValue = 0;
public ProgressBar() { public ProgressBar() {
setPropertyCanFocus(true); setPropertyCanFocus(true);
} }
@Override @Override
public void calculateMinMaxSize() { public void calculateMinMaxSize() {
final Vector2f tmpMin = this.propertyMinSize.getPixel(); final Vector2f tmpMin = this.propertyMinSize.getPixel();
this.minSize = new Vector2f(Math.max(tmpMin.x(), 40.0f), Math.max(tmpMin.y(), ProgressBar.DOT_RADIUS * 2.0f)); this.minSize = new Vector2f(Math.max(tmpMin.x(), 40.0f), Math.max(tmpMin.y(), ProgressBar.DOT_RADIUS * 2.0f));
markToRedraw(); markToRedraw();
} }
@AknotManaged @AknotManaged
@AknotAttribute @AknotAttribute
@AknotName(value = "color-off") @AknotName(value = "color-off")
@ -40,7 +41,7 @@ class ProgressBar extends Widget {
public Color getPropertyTextColorBgOff() { public Color getPropertyTextColorBgOff() {
return this.propertyTextColorBgOff; return this.propertyTextColorBgOff;
} }
@AknotManaged @AknotManaged
@AknotAttribute @AknotAttribute
@AknotName(value = "color-on") @AknotName(value = "color-on")
@ -48,7 +49,7 @@ class ProgressBar extends Widget {
public Color getPropertyTextColorBgOn() { public Color getPropertyTextColorBgOn() {
return this.propertyTextColorBgOn; return this.propertyTextColorBgOn;
} }
@AknotManaged @AknotManaged
@AknotAttribute @AknotAttribute
@AknotName(value = "color-bg") @AknotName(value = "color-bg")
@ -56,7 +57,7 @@ class ProgressBar extends Widget {
public Color getPropertyTextColorFg() { public Color getPropertyTextColorFg() {
return this.propertyTextColorFg; return this.propertyTextColorFg;
} }
@AknotManaged @AknotManaged
@AknotAttribute @AknotAttribute
@AknotName(value = "value") @AknotName(value = "value")
@ -64,38 +65,38 @@ class ProgressBar extends Widget {
public float getPropertyValue() { public float getPropertyValue() {
return this.propertyValue; return this.propertyValue;
} }
@Override @Override
protected void onDraw() { protected void onDraw() {
this.draw.draw(); this.vectorialDraw.draw();
} }
@Override @Override
public void onRegenerateDisplay() { public void onRegenerateDisplay() {
if (!needRedraw()) { if (!needRedraw()) {
return; return;
} }
// clean the object list ... // clean the object list ...
this.draw.clear(); this.vectorialDraw.clear();
this.draw.setColor(this.propertyTextColorFg); this.vectorialDraw.setColor(this.propertyTextColorFg);
final int tmpSizeX = (int) (this.size.x() - 10); final int tmpSizeX = (int) (this.size.x() - 10);
final int tmpSizeY = (int) (this.size.y() - 10); final int tmpSizeY = (int) (this.size.y() - 10);
final int tmpOriginX = 5; final int tmpOriginX = 5;
final int tmpOriginY = 5; final int tmpOriginY = 5;
this.draw.setColor(this.propertyTextColorBgOn); this.vectorialDraw.setColor(this.propertyTextColorBgOn);
this.draw.setPos(new Vector2f(tmpOriginX, tmpOriginY)); this.vectorialDraw.setPos(new Vector2f(tmpOriginX, tmpOriginY));
this.draw.rectangleWidth(new Vector2f(tmpSizeX * this.propertyValue, tmpSizeY)); this.vectorialDraw.rectangleWidth(new Vector2f(tmpSizeX * this.propertyValue, tmpSizeY));
this.draw.setColor(this.propertyTextColorBgOff); this.vectorialDraw.setColor(this.propertyTextColorBgOff);
this.draw.setPos(new Vector2f(tmpOriginX + tmpSizeX * this.propertyValue, tmpOriginY)); this.vectorialDraw.setPos(new Vector2f(tmpOriginX + tmpSizeX * this.propertyValue, tmpOriginY));
this.draw.rectangleWidth(new Vector2f(tmpSizeX * (1.0f - this.propertyValue), tmpSizeY)); this.vectorialDraw.rectangleWidth(new Vector2f(tmpSizeX * (1.0f - this.propertyValue), tmpSizeY));
// TODO : Create a better progress Bar ... // TODO : Create a better progress Bar ...
//this.draw.setColor(propertyTextColorFg); //this.draw.setColor(propertyTextColorFg);
//this.draw.rectangleBorder( tmpOriginX, tmpOriginY, tmpSizeX, tmpSizeY, 1); //this.draw.rectangleBorder( tmpOriginX, tmpOriginY, tmpSizeX, tmpSizeY, 1);
} }
public void setPropertyTextColorBgOff(final Color propertyTextColorBgOff) { public void setPropertyTextColorBgOff(final Color propertyTextColorBgOff) {
if (propertyTextColorBgOff.equals(this.propertyTextColorBgOff)) { if (propertyTextColorBgOff.equals(this.propertyTextColorBgOff)) {
return; return;
@ -103,7 +104,7 @@ class ProgressBar extends Widget {
this.propertyTextColorBgOff = propertyTextColorBgOff; this.propertyTextColorBgOff = propertyTextColorBgOff;
markToRedraw(); markToRedraw();
} }
public void setPropertyTextColorBgOn(final Color propertyTextColorBgOn) { public void setPropertyTextColorBgOn(final Color propertyTextColorBgOn) {
if (propertyTextColorBgOn.equals(this.propertyTextColorBgOn)) { if (propertyTextColorBgOn.equals(this.propertyTextColorBgOn)) {
return; return;
@ -111,7 +112,7 @@ class ProgressBar extends Widget {
this.propertyTextColorBgOn = propertyTextColorBgOn; this.propertyTextColorBgOn = propertyTextColorBgOn;
markToRedraw(); markToRedraw();
} }
public void setPropertyTextColorFg(final Color propertyTextColorFg) { public void setPropertyTextColorFg(final Color propertyTextColorFg) {
if (propertyTextColorFg.equals(this.propertyTextColorFg)) { if (propertyTextColorFg.equals(this.propertyTextColorFg)) {
return; return;
@ -119,7 +120,7 @@ class ProgressBar extends Widget {
this.propertyTextColorFg = propertyTextColorFg; this.propertyTextColorFg = propertyTextColorFg;
markToRedraw(); markToRedraw();
} }
public void setPropertyValue(final float propertyValue) { public void setPropertyValue(final float propertyValue) {
if (propertyValue == this.propertyValue) { if (propertyValue == this.propertyValue) {
return; return;

View File

@ -7,13 +7,11 @@ import org.atriasoft.aknot.annotation.AknotName;
import org.atriasoft.aknot.annotation.AknotSignal; import org.atriasoft.aknot.annotation.AknotSignal;
import org.atriasoft.esignal.Signal; import org.atriasoft.esignal.Signal;
import org.atriasoft.etk.Color; import org.atriasoft.etk.Color;
import org.atriasoft.etk.Uri;
import org.atriasoft.etk.math.FMath; import org.atriasoft.etk.math.FMath;
import org.atriasoft.etk.math.Vector2f; import org.atriasoft.etk.math.Vector2f;
import org.atriasoft.etk.math.Vector2f;
import org.atriasoft.etk.math.Vector2i; import org.atriasoft.etk.math.Vector2i;
import org.atriasoft.ewol.Padding; import org.atriasoft.ewol.Padding;
import org.atriasoft.ewol.compositing.CompositingDrawing; import org.atriasoft.ewol.compositing.CompositingGC;
import org.atriasoft.ewol.compositing.CompositingSVG; import org.atriasoft.ewol.compositing.CompositingSVG;
import org.atriasoft.ewol.event.EventInput; import org.atriasoft.ewol.event.EventInput;
import org.atriasoft.gale.key.KeyStatus; import org.atriasoft.gale.key.KeyStatus;
@ -32,8 +30,6 @@ import org.slf4j.LoggerFactory;
public class Slider extends Widget { public class Slider extends Widget {
private static final Logger LOGGER = LoggerFactory.getLogger(Slider.class); private static final Logger LOGGER = LoggerFactory.getLogger(Slider.class);
private Uri propertyConfig = new Uri("THEME", "shape/Slider.json", "ewol");
private Float propertyValue = 0.0f; //!< string that must be displayed private Float propertyValue = 0.0f; //!< string that must be displayed
protected CompositingSVG compositing = new CompositingSVG(); protected CompositingSVG compositing = new CompositingSVG();
@AknotSignal @AknotSignal
@ -59,11 +55,10 @@ public class Slider extends Widget {
private final Color textColorBg = Color.BLACK.withA(0x3F); //!< Background color private final Color textColorBg = Color.BLACK.withA(0x3F); //!< Background color
CompositingDrawing draw = new CompositingDrawing(); //!< drawing tool. CompositingGC vectorialDraw = new CompositingGC(); //!< drawing tool.
public Slider() { public Slider() {
this.propertyCanFocus = true; this.propertyCanFocus = true;
onChangePropertyShaper();
markToRedraw(); markToRedraw();
// Limit event at 1: // Limit event at 1:
setMouseLimit(1); setMouseLimit(1);
@ -92,14 +87,6 @@ public class Slider extends Widget {
&& relPos.x() < this.overPositionStop.x() && relPos.y() < this.overPositionStop.y(); && relPos.x() < this.overPositionStop.x() && relPos.y() < this.overPositionStop.y();
} }
@AknotManaged
@AknotAttribute
@AknotName("config")
@AknotDescription("configuration of the widget")
public Uri getPropertyConfig() {
return this.propertyConfig;
}
@AknotManaged @AknotManaged
@AknotAttribute @AknotAttribute
@AknotName("maximum") @AknotName("maximum")
@ -107,6 +94,15 @@ public class Slider extends Widget {
public Float getPropertyMaximum() { public Float getPropertyMaximum() {
return this.propertyMaximum; return this.propertyMaximum;
} }
public void setPropertyMaximum(final Float propertyMaximum) {
if (this.propertyMaximum == propertyMaximum) {
return;
}
this.propertyMaximum = propertyMaximum;
updateValue(this.propertyValue);
this.signalValue.emit(this.propertyValue);
}
@AknotManaged @AknotManaged
@AknotAttribute @AknotAttribute
@ -116,6 +112,15 @@ public class Slider extends Widget {
return this.propertyMinimum; return this.propertyMinimum;
} }
public void setPropertyMinimum(final Float propertyMinimum) {
if (this.propertyMinimum == propertyMinimum) {
return;
}
this.propertyMinimum = propertyMinimum;
updateValue(this.propertyValue);
this.signalValue.emit(this.propertyValue);
}
@AknotManaged @AknotManaged
@AknotAttribute @AknotAttribute
@AknotName("step") @AknotName("step")
@ -123,7 +128,16 @@ public class Slider extends Widget {
public Float getPropertyStep() { public Float getPropertyStep() {
return this.propertyStep; return this.propertyStep;
} }
public void setPropertyStep(final Float propertyStep) {
if (this.propertyStep == propertyStep) {
return;
}
this.propertyStep = propertyStep;
updateValue(this.propertyValue);
this.signalValue.emit(this.propertyValue);
}
@AknotManaged @AknotManaged
@AknotAttribute @AknotAttribute
@AknotName("value") @AknotName("value")
@ -131,13 +145,25 @@ public class Slider extends Widget {
public Float getPropertyValue() { public Float getPropertyValue() {
return this.propertyValue; return this.propertyValue;
} }
public void setPropertyValue(final Float propertyValue) {
if (this.propertyValue == propertyValue) {
return;
}
this.propertyValue = propertyValue;
updateValue(this.propertyValue);
this.signalValue.emit(this.propertyValue);
}
protected void onChangePropertyShaper() { protected void updateValue(float newValue) {
// if (this.shape == null) { newValue = FMath.max(FMath.min(newValue, this.propertyMaximum), this.propertyMinimum);
// this.shape = new GuiShape(this.propertyConfig); if (this.propertyStep == 0.0f) {
// } else { this.propertyValue = newValue;
// this.shape.setSource(this.propertyConfig); } else {
// } final float basicVal = (long) (newValue / this.propertyStep);
this.propertyValue = basicVal * this.propertyStep;
}
markToRedraw();
} }
@Override @Override
@ -208,7 +234,7 @@ public class Slider extends Widget {
@Override @Override
public void onRegenerateDisplay() { public void onRegenerateDisplay() {
if (!needRedraw()) { if (!needRedraw()) {
//return; return;
} }
//LOGGER.trace("Regenerate Display ==> is needed: '" + this.propertyValue + "'"); //LOGGER.trace("Regenerate Display ==> is needed: '" + this.propertyValue + "'");
this.compositing.clear(); this.compositing.clear();
@ -281,70 +307,15 @@ public class Slider extends Widget {
this.overCursorPositionStop = tmpOriginShaper.add(tmpSizeShaper); this.overCursorPositionStop = tmpOriginShaper.add(tmpSizeShaper);
//this.shape.setShape(1, tmpOriginShaper, tmpSizeShaper, tmpOriginInside, tmpSizeInside); //this.shape.setShape(1, tmpOriginShaper, tmpSizeShaper, tmpOriginInside, tmpSizeInside);
} }
LOGGER.error("REQUEST display an immage with size={}x{}", (int) this.overPositionSize.x(),
(int) this.overPositionSize.y());
this.compositing.setRectangleAsSource((int) this.overPositionSize.x(), (int) this.overPositionSize.y(), this.compositing.setRectangleAsSource((int) this.overPositionSize.x(), (int) this.overPositionSize.y(),
Color.GREEN); Color.GREEN);
// TODO: Refaire le design de cet affichage... // TODO: Refaire le design de cet affichage...
this.compositing.setPos(this.overPositionStart); this.compositing.setPos(this.overPositionStart);
this.compositing.print(new Vector2f(this.overPositionSize.x(), this.overPositionSize.y())); this.compositing.print(new Vector2f(this.overPositionSize.x(), this.overPositionSize.y()));
this.compositing.flush(); this.compositing.flush();
//this.gc.flush();
this.compositing.flush();
} }
public void setPropertyConfig(final Uri propertyConfig) {
if (this.propertyConfig.equals(propertyConfig)) {
return;
}
this.propertyConfig = propertyConfig;
onChangePropertyShaper();
}
public void setPropertyMaximum(final Float propertyMaximum) {
if (this.propertyMaximum == propertyMaximum) {
return;
}
this.propertyMaximum = propertyMaximum;
updateValue(this.propertyValue);
this.signalValue.emit(this.propertyValue);
}
public void setPropertyMinimum(final Float propertyMinimum) {
if (this.propertyMinimum == propertyMinimum) {
return;
}
this.propertyMinimum = propertyMinimum;
updateValue(this.propertyValue);
this.signalValue.emit(this.propertyValue);
}
public void setPropertyStep(final Float propertyStep) {
if (this.propertyStep == propertyStep) {
return;
}
this.propertyStep = propertyStep;
updateValue(this.propertyValue);
this.signalValue.emit(this.propertyValue);
}
public void setPropertyValue(final Float propertyValue) {
if (this.propertyValue == propertyValue) {
return;
}
this.propertyValue = propertyValue;
updateValue(this.propertyValue);
this.signalValue.emit(this.propertyValue);
}
protected void updateValue(float newValue) {
newValue = FMath.max(FMath.min(newValue, this.propertyMaximum), this.propertyMinimum);
if (this.propertyStep == 0.0f) {
this.propertyValue = newValue;
} else {
final float basicVal = (long) (newValue / this.propertyStep);
this.propertyValue = basicVal * this.propertyStep;
}
markToRedraw();
}
} }

View File

@ -14,55 +14,56 @@ import org.atriasoft.aknot.annotation.AknotName;
import org.atriasoft.etk.Color; import org.atriasoft.etk.Color;
import org.atriasoft.etk.math.Vector2f; import org.atriasoft.etk.math.Vector2f;
import org.atriasoft.ewol.compositing.CompositingDrawing; import org.atriasoft.ewol.compositing.CompositingDrawing;
import org.atriasoft.ewol.compositing.CompositingGC;
public class Spacer extends Widget { public class Spacer extends Widget {
private final CompositingDrawing draw = new CompositingDrawing(); //!< Compositing drawing element private final CompositingDrawing vectorialDraw = new CompositingGC(); //!< Compositing drawing element
@AknotManaged @AknotManaged
@AknotAttribute @AknotAttribute
@AknotName("color") @AknotName("color")
@AknotDescription("background of the spacer") @AknotDescription("background of the spacer")
protected Color propertyColor = Color.NONE; //!< Background color protected Color propertyColor = Color.NONE; //!< Background color
/** /**
* Main ructer * Main ructer
*/ */
public Spacer() { public Spacer() {
} }
public Color getPropertyColor() { public Color getPropertyColor() {
return this.propertyColor; return this.propertyColor;
} }
@Override @Override
public Widget getWidgetAtPos(final Vector2f pos) { public Widget getWidgetAtPos(final Vector2f pos) {
return null; return null;
} }
@Override @Override
public void onDraw() { public void onDraw() {
this.draw.draw(); this.vectorialDraw.draw();
} }
@Override @Override
public void onRegenerateDisplay() { public void onRegenerateDisplay() {
if (!needRedraw()) { if (!needRedraw()) {
return; return;
} }
this.draw.clear(); this.vectorialDraw.clear();
if (this.propertyColor.a() == 0) { if (this.propertyColor.a() == 0) {
return; return;
} }
this.draw.setColor(this.propertyColor); this.vectorialDraw.setColor(this.propertyColor);
this.draw.setPos(Vector2f.ZERO); this.vectorialDraw.setPos(Vector2f.ZERO);
this.draw.rectangleWidth(new Vector2f(this.size.x(), this.size.y())); this.vectorialDraw.rectangleWidth(new Vector2f(this.size.x(), this.size.y()));
//this.draw.setPos(new Vector2f(this.size.x() * 0.1f, this.size.y() * 0.1f, 0)); //this.draw.setPos(new Vector2f(this.size.x() * 0.1f, this.size.y() * 0.1f, 0));
//this.draw.rectangleWidth(new Vector2f(this.size.x() * 0.8f, this.size.y() * 0.8f, 0)); //this.draw.rectangleWidth(new Vector2f(this.size.x() * 0.8f, this.size.y() * 0.8f, 0));
this.draw.flush(); this.vectorialDraw.flush();
} }
public void setPropertyColor(final Color propertyColor) { public void setPropertyColor(final Color propertyColor) {
if (propertyColor.equals(this.propertyColor)) { if (propertyColor.equals(this.propertyColor)) {
return; return;

View File

@ -11,9 +11,7 @@ import org.atriasoft.esignal.SignalEmpty;
import org.atriasoft.etk.Color; import org.atriasoft.etk.Color;
import org.atriasoft.etk.Dimension1f; import org.atriasoft.etk.Dimension1f;
import org.atriasoft.etk.Dimension2f; import org.atriasoft.etk.Dimension2f;
import org.atriasoft.etk.Dimension2f;
import org.atriasoft.etk.Uri; import org.atriasoft.etk.Uri;
import org.atriasoft.etk.math.Vector2f;
import org.atriasoft.etk.math.Vector2b; import org.atriasoft.etk.math.Vector2b;
import org.atriasoft.etk.math.Vector2f; import org.atriasoft.etk.math.Vector2f;
import org.atriasoft.etk.math.Vector2i; import org.atriasoft.etk.math.Vector2i;
@ -47,19 +45,19 @@ public Uri> propertyShape; //!< shape of the widget
public class Tick extends Box { public class Tick extends Box {
private static final Logger LOGGER = LoggerFactory.getLogger(Tick.class); private static final Logger LOGGER = LoggerFactory.getLogger(Tick.class);
protected CompositingSVG compositingTick = new CompositingSVG(); protected CompositingSVG compositingTick = new CompositingSVG();
/// color property of the text foreground /// color property of the text foreground
private int colorIdTextFg; private int colorIdTextFg;
/// text display this.text /// text display this.text
//private final CompositingGraphicContext gc = new CompositingGraphicContext(); //private final CompositingGraphicContext gc = new CompositingGraphicContext();
/// Periodic call handle to remove it when needed /// Periodic call handle to remove it when needed
protected Connection periodicConnectionHanble = new Connection(); protected Connection periodicConnectionHanble = new Connection();
private final Uri propertyConfig = new Uri("THEME", "shape/Tick.json", "ewol"); private final Uri propertyConfig = new Uri("THEME", "shape/Tick.json", "ewol");
private final Uri uriCheckGreen = new Uri("THEME", "CheckBoxCrossRed.svg", "ewol"); private final Uri uriCheckGreen = new Uri("THEME", "CheckBoxCrossRed.svg", "ewol");
private Boolean propertyValue = false; //!< string that must be displayed
private Boolean propertyValue = false; //!< string that must be displayed
@AknotSignal @AknotSignal
@AknotName("down") @AknotName("down")
@AknotDescription("Tick is Down") @AknotDescription("Tick is Down")
@ -79,9 +77,9 @@ public class Tick extends Box {
// element over: // element over:
Vector2f overPositionStart = Vector2f.ZERO; Vector2f overPositionStart = Vector2f.ZERO;
Vector2f overPositionStop = Vector2f.ZERO; Vector2f overPositionStop = Vector2f.ZERO;
private boolean isDown; private boolean isDown;
/** /**
* Constuctor * Constuctor
*/ */
@ -99,9 +97,9 @@ public class Tick extends Box {
setPropertyColor(Color.WHITE); setPropertyColor(Color.WHITE);
setPropertyPadding(new Dimension2f(new Vector2f(3, 3))); setPropertyPadding(new Dimension2f(new Vector2f(3, 3)));
setPropertyMargin(new Dimension2f(new Vector2f(0, 0))); setPropertyMargin(new Dimension2f(new Vector2f(0, 0)));
} }
@Override @Override
public void calculateMinMaxSize() { public void calculateMinMaxSize() {
// call main class // call main class
@ -109,7 +107,7 @@ public class Tick extends Box {
// get generic padding // get generic padding
final Padding padding = Padding.ZERO; final Padding padding = Padding.ZERO;
final Vector2i minHeight = Vector2i.VALUE_16; final Vector2i minHeight = Vector2i.VALUE_16;
Vector2f minimumSizeBase = new Vector2f(minHeight.x(), minHeight.y()); Vector2f minimumSizeBase = new Vector2f(minHeight.x(), minHeight.y());
// add padding : // add padding :
minimumSizeBase = minimumSizeBase.add(padding.x(), padding.y()); minimumSizeBase = minimumSizeBase.add(padding.x(), padding.y());
@ -118,7 +116,7 @@ public class Tick extends Box {
checkMinSize(); checkMinSize();
LOGGER.error("min size = " + this.minSize); LOGGER.error("min size = " + this.minSize);
} }
protected void changeStatusIn(final GuiShapeMode newStatusId) { protected void changeStatusIn(final GuiShapeMode newStatusId) {
// if (this.shape.changeStatusIn(newStatusId)) { // if (this.shape.changeStatusIn(newStatusId)) {
// if (!this.periodicConnectionHanble.isConnected()) { // if (!this.periodicConnectionHanble.isConnected()) {
@ -129,12 +127,12 @@ public class Tick extends Box {
// markToRedraw(); // markToRedraw();
// } // }
} }
private boolean checkIfOver(final Vector2f relPos) { private boolean checkIfOver(final Vector2f relPos) {
return relPos.x() > this.overPositionStart.x() && relPos.y() > this.overPositionStart.y() return relPos.x() > this.overPositionStart.x() && relPos.y() > this.overPositionStart.y()
&& relPos.x() < this.overPositionStop.x() && relPos.y() < this.overPositionStop.y(); && relPos.x() < this.overPositionStop.x() && relPos.y() < this.overPositionStop.y();
} }
@AknotManaged @AknotManaged
@AknotAttribute @AknotAttribute
@AknotName("value") @AknotName("value")
@ -142,16 +140,16 @@ public class Tick extends Box {
public Boolean getPropertyValue() { public Boolean getPropertyValue() {
return this.propertyValue; return this.propertyValue;
} }
protected void onChangePropertyTextWhenNothing() { protected void onChangePropertyTextWhenNothing() {
markToRedraw(); markToRedraw();
} }
protected void onChangePropertyValue() { protected void onChangePropertyValue() {
//Boolean newData = this.propertyValue; //Boolean newData = this.propertyValue;
markToRedraw(); markToRedraw();
} }
@Override @Override
protected void onDraw() { protected void onDraw() {
super.onDraw(); super.onDraw();
@ -164,7 +162,7 @@ public class Tick extends Box {
// this.shape.draw(true, this.propertyValue ? 0 : 1); // this.shape.draw(true, this.propertyValue ? 0 : 1);
// } // }
} }
@Override @Override
public boolean onEventInput(final EventInput event) { public boolean onEventInput(final EventInput event) {
final Vector2f positionAbsolute = new Vector2f(event.pos().x(), event.pos().y()); final Vector2f positionAbsolute = new Vector2f(event.pos().x(), event.pos().y());
@ -226,20 +224,19 @@ public class Tick extends Box {
} }
return false; return false;
} }
@Override @Override
public void onRegenerateDisplay() { public void onRegenerateDisplay() {
super.onRegenerateDisplay(); super.onRegenerateDisplay();
if (!needRedraw()) { if (!needRedraw()) {
//return; //return;
} }
this.compositingTick.setSource(Uri.getAllDataString(this.uriCheckGreen), this.renderSize.less(4)); this.compositingTick.setSource(Uri.getAllDataString(this.uriCheckGreen), this.startPosition.less(4));
this.compositingTick.setPos(this.propertyMargin.size().add(2)); this.compositingTick.setPos(this.propertyMargin.size().add(2));
this.compositingTick.print(this.renderSize.less(4)); this.compositingTick.print(this.startPosition.less(4).toVector2f());
this.compositingTick.flush(); this.compositingTick.flush();
} }
/** /**
* internal check the value with RegExp checking * internal check the value with RegExp checking
* @param newData The new string to display * @param newData The new string to display
@ -248,7 +245,7 @@ public class Tick extends Box {
this.propertyValue = newData; this.propertyValue = newData;
markToRedraw(); markToRedraw();
} }
public void setPropertyValue(final Boolean propertyValue) { public void setPropertyValue(final Boolean propertyValue) {
if (this.propertyValue.equals(propertyValue)) { if (this.propertyValue.equals(propertyValue)) {
return; return;
@ -257,5 +254,5 @@ public class Tick extends Box {
this.signalValue.emit(this.propertyValue); this.signalValue.emit(this.propertyValue);
onChangePropertyValue(); onChangePropertyValue();
} }
} }

View File

@ -14,10 +14,9 @@ import java.util.Map.Entry;
import org.atriasoft.etk.Color; import org.atriasoft.etk.Color;
import org.atriasoft.etk.math.Vector2f; import org.atriasoft.etk.math.Vector2f;
import org.atriasoft.etk.math.Vector2i; import org.atriasoft.etk.math.Vector2i;
import org.atriasoft.etk.math.Vector2f;
import org.atriasoft.etk.math.Vector2i;
import org.atriasoft.ewol.compositing.Compositing; import org.atriasoft.ewol.compositing.Compositing;
import org.atriasoft.ewol.compositing.CompositingDrawing; import org.atriasoft.ewol.compositing.CompositingDrawing;
import org.atriasoft.ewol.compositing.CompositingGC;
import org.atriasoft.ewol.compositing.CompositingText; import org.atriasoft.ewol.compositing.CompositingText;
import org.atriasoft.ewol.event.EventInput; import org.atriasoft.ewol.event.EventInput;
import org.atriasoft.ewol.widget.model.ListRole; import org.atriasoft.ewol.widget.model.ListRole;
@ -28,37 +27,37 @@ class WidgetList extends WidgetScrolled {
private static final Logger LOGGER = LoggerFactory.getLogger(WidgetList.class); private static final Logger LOGGER = LoggerFactory.getLogger(WidgetList.class);
// drawing capabilities .... // drawing capabilities ....
protected List<Compositing> listOObject = new ArrayList<>(); //!< generic element to display... protected List<Compositing> listOObject = new ArrayList<>(); //!< generic element to display...
protected List<Integer> listSizeX = new ArrayList<>(); //!< size of every colons protected List<Integer> listSizeX = new ArrayList<>(); //!< size of every colons
protected List<Integer> listSizeY = new ArrayList<>(); //!< size of every rows protected List<Integer> listSizeY = new ArrayList<>(); //!< size of every rows
protected Map<String, Compositing> compositingElements = new HashMap<>(); protected Map<String, Compositing> compositingElements = new HashMap<>();
// list properties ... // list properties ...
protected int paddingSizeX = 0; protected int paddingSizeX = 0;
protected int paddingSizeY = 0; protected int paddingSizeY = 0;
protected int displayStartRaw = 0; //!< Current starting displayed raw protected int displayStartRaw = 0; //!< Current starting displayed raw
protected int displayCurrentNbLine = 0; //!< Number of line in the display protected int displayCurrentNbLine = 0; //!< Number of line in the display
protected int nbVisibleRaw = 0; // set the number of visible raw (calculate don display) protected int nbVisibleRaw = 0; // set the number of visible raw (calculate don display)
// function call to display the list : // function call to display the list :
public WidgetList() { public WidgetList() {
this.paddingSizeX = 2; this.paddingSizeX = 2;
this.paddingSizeY = 2; this.paddingSizeY = 2;
this.nbVisibleRaw = 0; this.nbVisibleRaw = 0;
this.propertyCanFocus = true; this.propertyCanFocus = true;
this.limitScrolling = new Vector2f(1.0f, 0.5f); this.limitScrolling = new Vector2f(1.0f, 0.5f);
addComposeElemnent("drawing", new CompositingDrawing()); addComposeElemnent("drawing", new CompositingGC());
addComposeElemnent("text", new CompositingText()); addComposeElemnent("text", new CompositingText());
} }
protected void addComposeElemnent(final String name, final Compositing element) { protected void addComposeElemnent(final String name, final Compositing element) {
this.compositingElements.put(name, element); this.compositingElements.put(name, element);
//this.listOObject.add(element); //this.listOObject.add(element);
} }
/** /**
* Calculate an element size to estimate the render size. * Calculate an element size to estimate the render size.
* @note Does not generate the with the same size. * @note Does not generate the with the same size.
@ -75,7 +74,7 @@ class WidgetList extends WidgetScrolled {
} }
return Vector2f.ZERO; return Vector2f.ZERO;
} }
@Override @Override
public void calculateMinMaxSize() { public void calculateMinMaxSize() {
/*int fontId = getDefaultFontId(); /*int fontId = getDefaultFontId();
@ -86,18 +85,18 @@ class WidgetList extends WidgetScrolled {
*/ */
this.minSize = new Vector2f(200, 150); this.minSize = new Vector2f(200, 150);
} }
protected void clearComposeElemnent() { protected void clearComposeElemnent() {
for (final Entry<String, Compositing> it : this.compositingElements.entrySet()) { for (final Entry<String, Compositing> it : this.compositingElements.entrySet()) {
//it.setValue(null); //it.setValue(null);
it.getValue().clear(); it.getValue().clear();
} }
} }
public void clearOObjectList() { public void clearOObjectList() {
//this.listOObject.clear(); //this.listOObject.clear();
} }
/** /**
* Draw the background * Draw the background
*/ */
@ -109,7 +108,7 @@ class WidgetList extends WidgetScrolled {
BGOObjects.rectangleWidth(new Vector2f(this.size.x(), this.size.y())); BGOObjects.rectangleWidth(new Vector2f(this.size.x(), this.size.y()));
} }
} }
/** /**
* Draw an element in the specific size and position. * Draw an element in the specific size and position.
* @param pos Position of colomn and Raw of the element. * @param pos Position of colomn and Raw of the element.
@ -138,7 +137,7 @@ class WidgetList extends WidgetScrolled {
} }
} }
} }
protected void flushElements() { protected void flushElements() {
for (final Entry<String, Compositing> it : this.compositingElements.entrySet()) { for (final Entry<String, Compositing> it : this.compositingElements.entrySet()) {
it.getValue().flush(); it.getValue().flush();
@ -149,15 +148,15 @@ class WidgetList extends WidgetScrolled {
} }
} }
} }
protected Color getBasicBG() { protected Color getBasicBG() {
return new Color(0xFF, 0xFF, 0xFF, 0xFF); return new Color(0xFF, 0xFF, 0xFF, 0xFF);
} }
protected Compositing getComposeElemnent(final String name) { protected Compositing getComposeElemnent(final String name) {
return this.compositingElements.get(name); return this.compositingElements.get(name);
} }
protected Object getData(final ListRole role, final Vector2i pos) { protected Object getData(final ListRole role, final Vector2i pos) {
switch (role) { switch (role) {
case Text: case Text:
@ -174,7 +173,7 @@ class WidgetList extends WidgetScrolled {
} }
return null; return null;
} }
/** /**
* Get the number of colomn and row availlable in the list * Get the number of colomn and row availlable in the list
* @return Number of colomn and row * @return Number of colomn and row
@ -182,7 +181,7 @@ class WidgetList extends WidgetScrolled {
protected Vector2i getMatrixSize() { protected Vector2i getMatrixSize() {
return new Vector2i(1, 0); return new Vector2i(1, 0);
} }
@Override @Override
protected void onDraw() { protected void onDraw() {
for (final Entry<String, Compositing> it : this.compositingElements.entrySet()) { for (final Entry<String, Compositing> it : this.compositingElements.entrySet()) {
@ -195,7 +194,7 @@ class WidgetList extends WidgetScrolled {
} }
super.onDraw(); super.onDraw();
} }
@Override @Override
public boolean onEventInput(final EventInput event) { public boolean onEventInput(final EventInput event) {
Vector2f relativePos = relativePosition(new Vector2f(event.pos().x(), event.pos().y())); Vector2f relativePos = relativePosition(new Vector2f(event.pos().x(), event.pos().y()));
@ -247,7 +246,7 @@ class WidgetList extends WidgetScrolled {
} }
return isUsed; return isUsed;
} }
/** /**
* set a raw visible in the main display * set a raw visible in the main display
* @param _id Id of the raw that might be visible. * @param _id Id of the raw that might be visible.
@ -257,16 +256,16 @@ class WidgetList extends WidgetScrolled {
protected void onGetFocus() { protected void onGetFocus() {
LOGGER.debug("WidgetList get focus"); LOGGER.debug("WidgetList get focus");
} }
protected boolean onItemEvent(final EventInput event, final Vector2i pos, final Vector2f mousePosition) { protected boolean onItemEvent(final EventInput event, final Vector2i pos, final Vector2f mousePosition) {
return false; return false;
} }
@Override @Override
protected void onLostFocus() { protected void onLostFocus() {
LOGGER.debug("WidgetList Lost focus"); LOGGER.debug("WidgetList Lost focus");
} }
@Override @Override
public void onRegenerateDisplay() { public void onRegenerateDisplay() {
if (!needRedraw()) { if (!needRedraw()) {
@ -394,9 +393,9 @@ class WidgetList extends WidgetScrolled {
// flush all compositing drawing // flush all compositing drawing
flushElements(); flushElements();
} }
protected void removeComposeElemnent() { protected void removeComposeElemnent() {
this.compositingElements.clear(); this.compositingElements.clear();
} }
} }

View File

@ -19,7 +19,6 @@ import org.atriasoft.etk.math.Matrix4f;
import org.atriasoft.etk.math.Vector2f; import org.atriasoft.etk.math.Vector2f;
import org.atriasoft.etk.math.Vector2i; import org.atriasoft.etk.math.Vector2i;
import org.atriasoft.ewol.DrawProperty; import org.atriasoft.ewol.DrawProperty;
import org.atriasoft.ewol.compositing.CompositingDrawing;
import org.atriasoft.ewol.context.EwolContext; import org.atriasoft.ewol.context.EwolContext;
import org.atriasoft.ewol.object.EwolObject; import org.atriasoft.ewol.object.EwolObject;
import org.atriasoft.ewol.resource.ResourceColorFile; import org.atriasoft.ewol.resource.ResourceColorFile;
@ -51,11 +50,7 @@ public class Windows extends Widget {
protected ResourceColorFile resourceColor = null; //!< theme color property (name of file in @ref propertyColorConfiguration) protected ResourceColorFile resourceColor = null; //!< theme color property (name of file in @ref propertyColorConfiguration)
protected Widget subWidget; protected Widget subWidget;
// internal event at ewol system:
protected CompositingDrawing vectorialDraw = new CompositingDrawing();
protected Windows() { protected Windows() {
this.propertyCanFocus = true; this.propertyCanFocus = true;
onChangePropertyColor(); onChangePropertyColor();