[FEAT] basic concept of box to simple manage the HTML rectangle rendering

This commit is contained in:
Edouard DUPIN 2025-05-25 11:44:41 +02:00
parent 2743abe410
commit 847bcb14f4
12 changed files with 744 additions and 228 deletions

50
pom.xml
View File

@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.atriasoft</groupId>
<artifactId>ewol</artifactId>
<version>0.1.0</version>
<modelVersion>4.0.0</modelVersion>
<groupId>org.atriasoft</groupId>
<artifactId>ewol</artifactId>
<version>0.1.0</version>
<licenses>
<license>
<name>Mozilla Public License 2.0</name>
@ -21,24 +21,22 @@
</roles>
</developer>
</developers>
<repositories>
<repository>
<id>gitea</id>
<url>https://gitea.atria-soft.org/api/packages/org.atriasoft/maven</url>
</repository>
<repository>
<id>gitea</id>
<url>https://gitea.atria-soft.org/api/packages/org.atriasoft/maven</url>
</repository>
</repositories>
<distributionManagement>
<repository>
<id>gitea</id>
<url>https://gitea.atria-soft.org/api/packages/org.atriasoft/maven</url>
</repository>
<snapshotRepository>
<id>gitea</id>
<url>https://gitea.atria-soft.org/api/packages/org.atriasoft/maven</url>
</snapshotRepository>
<repository>
<id>gitea</id>
<url>https://gitea.atria-soft.org/api/packages/org.atriasoft/maven</url>
</repository>
<snapshotRepository>
<id>gitea</id>
<url>https://gitea.atria-soft.org/api/packages/org.atriasoft/maven</url>
</snapshotRepository>
</distributionManagement>
<dependencies>
<dependency>
<groupId>org.atriasoft</groupId>
@ -76,10 +74,10 @@
<version>0.1.0</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.11.0</version>
<scope>test</scope>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.11.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
@ -87,8 +85,7 @@
<version>2.1.0-alpha1</version>
<scope>test</scope>
</dependency>
</dependencies>
</dependencies>
<build>
<sourceDirectory>src/main</sourceDirectory>
<resources>
@ -132,7 +129,7 @@
<artifactId>maven-surefire-plugin</artifactId>
<version>3.2.5</version>
</plugin>
<plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
@ -144,7 +141,7 @@
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
</plugin>
<!-- Java-doc generation for stand-alone site -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
@ -170,5 +167,4 @@
</plugin>
</plugins>
</reporting>
</project>

View File

@ -12,6 +12,7 @@ import org.atriasoft.esignal.Connection;
import org.atriasoft.esignal.Signal;
import org.atriasoft.esignal.SignalEmpty;
import org.atriasoft.etk.Color;
import org.atriasoft.etk.Dimension1f;
import org.atriasoft.etk.Dimension2f;
import org.atriasoft.etk.Dimension3f;
import org.atriasoft.etk.Distance;
@ -148,7 +149,44 @@ public class BasicWindows extends Windows {
this.conections.add(con);
}
}
public void addMenuDimension1f(final Widget widget, final IntrospectionProperty pojo) {
Object valueRaw = null;
try {
valueRaw = pojo.getValue(widget);
} catch (final AknotException e) {
e.printStackTrace();
return;
}
if (valueRaw instanceof final Dimension1f value) {
{
final Sizer lineSizer = new Sizer(DisplayMode.HORIZONTAL);
lineSizer.setPropertyExpand(Vector3b.TRUE_FALSE_FALSE);
lineSizer.setPropertyFill(Vector3b.TRUE);
this.sizerMenu.subWidgetAdd(lineSizer);
final Spin spin = new Spin();
spin.setPropertyExpand(Vector3b.TRUE_FALSE_FALSE);
spin.setPropertyFill(Vector3b.TRUE);
spin.setPropertyValue((int) value.size());
lineSizer.subWidgetAdd(spin);
final Connection con = spin.signalValue.connect(valueButton -> {
try {
final Object oldValue = pojo.getValue(widget);
if (oldValue instanceof final Dimension1f castedValue) {
LOGGER.warn("Set new value: {}", castedValue.withSize(valueButton));
pojo.setExistingValue(widget, new Dimension1f(valueButton));
}
} catch (final AknotException e) {
e.printStackTrace();
return;
}
});
this.conections.add(con);
}
}
}
public void addMenuDimension2f(final Widget widget, final IntrospectionProperty pojo) {
Object valueRaw = null;
try {
@ -1139,6 +1177,8 @@ public class BasicWindows extends Windows {
addMenuDimension3f(widget, pojo);
} else if (pojo.getType() == Dimension2f.class) {
addMenuDimension2f(widget, pojo);
} else if (pojo.getType() == Dimension1f.class) {
addMenuDimension1f(widget, pojo);
} else if (pojo.getType() == DisplayMode.class) {
LOGGER.error(" ==> plop");
} else if (pojo.getType() == Uri.class) {

View File

@ -0,0 +1,83 @@
package sample.atriasoft.ewol.simpleWindowsWithBox;
import org.atriasoft.etk.Configs;
import org.atriasoft.etk.math.Vector2f;
import org.atriasoft.ewol.context.EwolApplication;
import org.atriasoft.ewol.context.EwolContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class Appl implements EwolApplication {
private static final Logger LOGGER = LoggerFactory.getLogger(Appl.class);
//! [ewol_sample_HW_main_application]
private void localCreate(final EwolContext context) {
//! [ewol_sample_HW_main_parse_arguments]
// parse all the argument of the application
for (int iii = 0; iii < context.getCmd().size(); iii++) {
final String tmpppp = context.getCmd().get(iii);
if (tmpppp == "-h" || tmpppp == "--help") {
LOGGER.info(" -h/--help display this help");
System.exit(0);
}
}
//! [ewol_sample_HW_main_parse_arguments]
//! [ewol_sample_HW_main_set_windows_size]
// TODO : Remove this: Move if in the windows properties
context.setSize(new Vector2f(800, 600));
//! [ewol_sample_HW_main_set_windows_size]
//! [ewol_sample_HW_main_set_font_property]
// select font preference of der with a basic application size
Configs.getConfigFonts().set("FreeSherif", 12);
//! [ewol_sample_HW_main_set_font_property]
//! [ewol_sample_HW_main_set_windows]
// Create the windows
final MainWindows basicWindows = new MainWindows();
// configure the ewol context to use the new windows
context.setWindows(basicWindows);
//! [ewol_sample_HW_main_set_windows]
}
@Override
public void onCreate(final EwolContext context) {
LOGGER.info("Application onCreate: [BEGIN]");
localCreate(context);
LOGGER.info("Application onCreate: [ END ]");
}
@Override
public void onDestroy(final EwolContext context) {
LOGGER.info("Application onDestroy: [BEGIN]");
LOGGER.info("Application onDestroy: [ END ]");
}
@Override
public void onPause(final EwolContext context) {
LOGGER.info("Application onPause: [BEGIN]");
LOGGER.info("Application onPause: [ END ]");
}
@Override
public void onResume(final EwolContext context) {
LOGGER.info("Application onResume: [BEGIN]");
LOGGER.info("Application onResume: [ END ]");
}
@Override
public void onStart(final EwolContext context) {
LOGGER.info("Application onStart: [BEGIN]");
LOGGER.info("Application onStart: [ END ]");
}
@Override
public void onStop(final EwolContext context) {
LOGGER.info("Application onStop: [BEGIN]");
LOGGER.info("Application onStop: [ END ]");
}
}

View File

@ -0,0 +1,38 @@
package sample.atriasoft.ewol.simpleWindowsWithBox;
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.Vector3b;
import org.atriasoft.ewol.widget.Box;
import sample.atriasoft.ewol.BasicWindows;
public class MainWindows extends BasicWindows {
Box testWidget;
public MainWindows() {
//! [ewol_sample_HW_windows_title]
setPropertyTitle("Simple CheckBox");
final Box innerWidget = new Box();
//this.testWidget.setPropertySource(new Uri("DATA", "mireA.png"));
innerWidget.setPropertyExpand(Vector3b.FALSE);
innerWidget.setPropertyFill(Vector3b.TRUE);
innerWidget.setPropertyColor(Color.PINK);
this.testWidget = new Box(innerWidget);
//this.testWidget.setPropertySource(new Uri("DATA", "mireA.png"));
this.testWidget.setPropertyExpand(Vector3b.TRUE);
this.testWidget.setPropertyFill(Vector3b.TRUE);
this.testWidget.setPropertyBorderWidth(new Dimension1f(10));
this.testWidget.setPropertyBorderRadius(new Dimension1f(25));
this.testWidget.setPropertyBorderColor(Color.BLACK);
this.testWidget.setPropertyColor(Color.GREEN_YELLOW);
this.testWidget.setPropertyPadding(new Dimension2f(new Vector2f(15, 15)));
this.testWidget.setPropertyMargin(new Dimension2f(new Vector2f(25, 25)));
setTestWidget(this.testWidget);
}
}

View File

@ -0,0 +1,15 @@
package sample.atriasoft.ewol.simpleWindowsWithBox;
import org.atriasoft.etk.Uri;
import org.atriasoft.ewol.Ewol;
public class SimpleWindowsWithBoxMain {
public static void main(final String[] args) {
Ewol.init();
//Uri.addLibrary("test-data", SimpleWindowsWithImageMain.class, "test-ewol/");
Uri.setApplication(SimpleWindowsWithBoxMain.class, "test-ewol/");
Ewol.run(new Appl(), args);
}
private SimpleWindowsWithBoxMain() {}
}

View File

@ -3,13 +3,13 @@ package sample.atriasoft.ewol.simpleWindowsWithCheckBox;
import org.atriasoft.etk.Uri;
import org.atriasoft.ewol.Ewol;
public class SimpleWindowsWithCheckBoxMain {
public class Main {
public static void main(final String[] args) {
Ewol.init();
//Uri.addLibrary("test-data", SimpleWindowsWithImageMain.class, "test-ewol/");
Uri.setApplication(SimpleWindowsWithCheckBoxMain.class, "test-ewol/");
Uri.setApplication(Main.class, "test-ewol/");
Ewol.run(new Appl(), args);
}
private SimpleWindowsWithCheckBoxMain() {}
private Main() {}
}

View File

@ -6,18 +6,18 @@ import org.atriasoft.ewol.widget.CheckBox;
import sample.atriasoft.ewol.BasicWindows;
public class MainWindows extends BasicWindows {
CheckBox testWidget;
public MainWindows() {
//! [ewol_sample_HW_windows_title]
setPropertyTitle("Simple CheckBox");
this.testWidget = new CheckBox("<b>Hello, how Are</b> You?<br/>second-life?");
//this.testWidget.setPropertySource(new Uri("DATA", "mireA.png"));
this.testWidget.setPropertyExpand(Vector3b.TRUE);
this.testWidget.setPropertyFill(Vector3b.TRUE);
this.setTestWidget(this.testWidget);
setTestWidget(this.testWidget);
/*
Button simpleButton = new Button();
simpleButton.setPropertyValue("Top Button");

View File

@ -34,25 +34,27 @@ public class CompositingSVG extends Compositing {
private float angle = 0; //!< Angle to set at the axes
private Color color = new Color(1, 1, 1); //!< The text foreground color
private String svgData;
private EsvgDocument svgDoc;
protected int oGLMatrixProjection = -1; //!< openGL id on the element (Projection matrix)
protected int oGLMatrixTransformation = -1; //!< openGL id on the element (transformation matrix)
protected int oGLMatrixView = -1; //!< openGL id on the element (view matrix)
private ResourceProgram oGLprogram = null; //!< pointer on the opengl display program
private Vector3f position = Vector3f.ZERO; //!< The current position to draw
private Vector2i requestSize = new Vector2i(2, 2);
private ResourceTexture2 resource = null;
private ResourceTexture2 resourceImage = null; //!< texture resources
private ResourceTexture2 resource = null; //!< texture resources
private ResourceVirtualArrayObject vbo = null;
private Color[] vboDataColors = null;
private Vector3f[] vboDataCoords = null;
private Vector2f[] vboDataCoordsTex = null;
public CompositingSVG() {
this("<svg></svg>", CompositingSVG.SIZE_AUTO);
this("""
<svg width="10" height="10"></svg>
""", CompositingSVG.SIZE_AUTO);
}
public CompositingSVG(final String data, final int size) {
this.svgData = data;
// Create the VBO:
@ -63,10 +65,10 @@ public class CompositingSVG extends Compositing {
}
// TO facilitate some debugs we add a name of the VBO:
this.vbo.setName("[VBO] of " + this.getClass().getCanonicalName());
setSource(data, size);
setSource(this.svgData, size);
loadProgram();
}
/**
* clear alll tre registered element in the current element
*/
@ -81,7 +83,7 @@ public class CompositingSVG extends Compositing {
this.color = Color.WHITE;
this.angle = 0;
}
/**
* draw All the registered text in the current element on openGL
* @param disableDepthTest disable the Depth test for display
@ -94,7 +96,7 @@ public class CompositingSVG extends Compositing {
return;
}
*/
if (this.resourceImage == null) {
if (this.resource == null) {
return;
}
if (this.oGLprogram == null) {
@ -116,12 +118,12 @@ public class CompositingSVG extends Compositing {
this.oGLprogram.uniformMatrix(this.oGLMatrixTransformation, this.matrixApply);
this.oGLprogram.uniformMatrix(this.oGLMatrixView, camMatrix);
// TextureID
this.resourceImage.bindForRendering(0);
this.resource.bindForRendering(0);
this.vbo.renderArrays(RenderMode.TRIANGLE);
this.vbo.unBindForRendering();
this.oGLprogram.unUse();
}
@Override
public void flush() {
this.vbo.setPosition(this.vboDataCoords);
@ -130,7 +132,7 @@ public class CompositingSVG extends Compositing {
this.vbo.setVertexCount(this.vboDataCoords.length);
this.vbo.flush();
}
/**
* get the current display position (sometime needed in the gui control)
* @return the current position.
@ -138,18 +140,18 @@ public class CompositingSVG extends Compositing {
public Vector3f getPos() {
return this.position;
}
/**
* get the source image registered size in the file (<0 when multiple size image)
* @return tre image registered size
*/
public Vector2i getRealSize() {
if (this.resourceImage == null) {
if (this.resource == null) {
return Vector2i.ZERO;
}
return this.resourceImage.getUsableSize();
return this.resource.getUsableSize();
}
/**
* 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.
@ -157,7 +159,7 @@ public class CompositingSVG extends Compositing {
public boolean hasSources() {
return this.resource != null;
}
/**
* load the openGL program and get all the ID needed
*/
@ -171,11 +173,11 @@ public class CompositingSVG extends Compositing {
this.oGLMatrixView = this.oGLprogram.getUniform("in_matrixView");
}
}
public void print(final Vector2f size) {
printPart(size, Vector2f.ZERO, Vector2f.ONE);
}
/**
* add a compleate of the image to display with the requested size
* @param size size of the output image
@ -183,7 +185,7 @@ public class CompositingSVG extends Compositing {
public void print(final Vector2i size) {
print(new Vector2f(size.x(), size.y()));
}
/**
* add a part of the image to display with the requested size
* @param size size of the output image
@ -201,73 +203,73 @@ public class CompositingSVG extends Compositing {
final Vector2f sourcePosStop = sourcePosStopIn.multiply(ratio);
LOGGER.trace(" openGLSize=" + openGLSize + " usableSize=" + usefullSize + " start=" + sourcePosStart
+ " stop=" + sourcePosStop);
this.vboDataColors = new Color[6];
this.vboDataCoords = new Vector3f[6];
this.vboDataCoordsTex = new Vector2f[6];
if (this.angle == 0.0f) {
Vector3f point = this.position;
int indexElem = 0;
Vector2f tex = new Vector2f(sourcePosStart.x(), sourcePosStop.y());
this.vboDataCoords[indexElem] = point;
this.vboDataCoordsTex[indexElem] = tex;
this.vboDataColors[indexElem] = this.color;
indexElem++;
tex = new Vector2f(sourcePosStop.x(), sourcePosStop.y());
point = new Vector3f(this.position.x() + size.x(), this.position.y(), 0);
this.vboDataCoords[indexElem] = point;
this.vboDataCoordsTex[indexElem] = tex;
this.vboDataColors[indexElem] = this.color;
indexElem++;
tex = new Vector2f(sourcePosStop.x(), sourcePosStart.y());
point = new Vector3f(this.position.x() + size.x(), this.position.y() + size.y(), 0);
this.vboDataCoords[indexElem] = point;
this.vboDataCoordsTex[indexElem] = tex;
this.vboDataColors[indexElem] = this.color;
indexElem++;
this.vboDataCoords[indexElem] = point;
this.vboDataCoordsTex[indexElem] = tex;
this.vboDataColors[indexElem] = this.color;
indexElem++;
tex = new Vector2f(sourcePosStart.x(), sourcePosStart.y());
point = new Vector3f(this.position.x(), this.position.y() + size.y(), 0);
this.vboDataCoords[indexElem] = point;
this.vboDataCoordsTex[indexElem] = tex;
this.vboDataColors[indexElem] = this.color;
indexElem++;
tex = new Vector2f(sourcePosStart.x(), sourcePosStop.y());
point = new Vector3f(this.position.x(), this.position.y(), 0);
this.vboDataCoords[indexElem] = point;
this.vboDataCoordsTex[indexElem] = tex;
this.vboDataColors[indexElem] = this.color;
return;
}
final Vector3f center = this.position.add(new Vector3f(size.x(), size.y(), 0)).divide(2.0f);
final Vector3f limitedSize = new Vector3f(size.x() * 0.5f, size.y() * 0.5f, 0.0f);
Vector3f point = Vector3f.ZERO;
Vector2f tex = new Vector2f(sourcePosStart.x(), sourcePosStop.y());
int indexElem = 0;
point = new Vector3f(-limitedSize.x(), -limitedSize.y(), 0);
point = point.rotateNew(new Vector3f(0, 0, 1), this.angle).add(center);
this.vboDataCoords[indexElem] = point;
this.vboDataCoordsTex[indexElem] = tex;
this.vboDataColors[indexElem] = this.color;
indexElem++;
tex = new Vector2f(sourcePosStop.x(), sourcePosStop.y());
point = new Vector3f(limitedSize.x(), -limitedSize.y(), 0);
point = point.rotateNew(new Vector3f(0, 0, 1), this.angle).add(center);
@ -275,7 +277,7 @@ public class CompositingSVG extends Compositing {
this.vboDataCoordsTex[indexElem] = tex;
this.vboDataColors[indexElem] = this.color;
indexElem++;
tex = new Vector2f(sourcePosStop.x(), sourcePosStart.y());
point = new Vector3f(limitedSize.x(), limitedSize.y(), 0);
point = point.rotateNew(new Vector3f(0, 0, 1), this.angle).add(center);
@ -283,12 +285,12 @@ public class CompositingSVG extends Compositing {
this.vboDataCoordsTex[indexElem] = tex;
this.vboDataColors[indexElem] = this.color;
indexElem++;
this.vboDataCoords[indexElem] = point;
this.vboDataCoordsTex[indexElem] = tex;
this.vboDataColors[indexElem] = this.color;
indexElem++;
tex = new Vector2f(sourcePosStart.x(), sourcePosStart.y());
point = new Vector3f(-limitedSize.x(), limitedSize.y(), 0);
point = point.rotateNew(new Vector3f(0, 0, 1), this.angle).add(center);
@ -296,16 +298,16 @@ public class CompositingSVG extends Compositing {
this.vboDataCoordsTex[indexElem] = tex;
this.vboDataColors[indexElem] = this.color;
indexElem++;
tex = new Vector2f(sourcePosStart.x(), sourcePosStop.y());
point = new Vector3f(-limitedSize.x(), -limitedSize.y(), 0);
point = point.rotateNew(new Vector3f(0, 0, 1), this.angle).add(center);
this.vboDataCoords[indexElem] = point;
this.vboDataCoordsTex[indexElem] = tex;
this.vboDataColors[indexElem] = this.color;
}
/**
* set a unique rotation of this element (not set in the rotate Generic system)
* @param angleRad Angle to set in radiant.
@ -313,7 +315,7 @@ public class CompositingSVG extends Compositing {
public void setAngle(final float angleRad) {
this.angle = angleRad;
}
/**
* set the Color of the current foreground font
* @param color Color to set on foreground (for next print)
@ -321,11 +323,11 @@ public class CompositingSVG extends Compositing {
public void setColor(final Color color) {
this.color = color;
}
public void setPos(final Vector2f pos) {
setPos(new Vector3f(pos.x(), pos.y(), 0));
}
/**
* set position for the next text writen
* @param pos Position of the text (in 3D)
@ -333,11 +335,11 @@ public class CompositingSVG extends Compositing {
public void setPos(final Vector3f pos) {
this.position = pos;
}
public void setRelPos(final Vector2f pos) {
setRelPos(new Vector3f(pos.x(), pos.y(), 0));
}
/**
* set relative position for the next text writen
* @param pos ofset apply of the text (in 3D)
@ -345,26 +347,31 @@ public class CompositingSVG extends Compositing {
public void setRelPos(final Vector3f pos) {
this.position = this.position.add(pos);
}
public void setSource(final ImageByteRGBA image) {
clear();
this.svgData = null;
this.requestSize = image.getSize();
this.resourceImage = new ResourceTexture2();
this.resourceImage.set(image);
this.resource = new ResourceTexture2();
this.resource.set(image);
}
public void setSource(final String data) {
setSource(data, 32);
}
public void setSource(final String data, final int size) {
setSource(data, new Vector2i(size, size));
}
public void setSource(final String data, final Vector2i size) {
if (this.svgDoc == null && this.svgData.equals(data) && this.requestSize.x() == size.x()
&& this.requestSize.y() == size.y()) {
// Nothing to do ...
return;
}
clear();
this.svgDoc = null;
final EsvgDocument doc = new EsvgDocument();
doc.parse(data);
final ImageByte tmp = ToolImage.convertImageByte(doc.renderImageFloatRGBA(size));
@ -372,26 +379,33 @@ public class CompositingSVG extends Compositing {
LOGGER.error("Can not load the Raw SVG ... ");
return;
}
this.resourceImage.set(tmp);
if (this.svgData.equals(data) && this.requestSize.x() == size.x() && this.requestSize.y() == size.y()) {
if (this.resource == null) {
this.resource = new ResourceTexture2();
}
this.resource.set(tmp);
this.svgData = data;
this.requestSize = size;
}
public void setSource(final EsvgDocument data, final Vector2i size) {
if (this.svgData == null && this.svgDoc.equals(data) && this.requestSize.x() == size.x()
&& this.requestSize.y() == size.y()) {
// Nothing to do ...
return;
}
final ResourceTexture2 resource = this.resource;
final ResourceTexture2 resourceTex = this.resourceImage;
this.svgData = data;
this.requestSize = size;
this.resource = null;
this.resourceImage = null;
final Vector2i tmpSize = new Vector2i(size.x(), size.y());
// link to new one
this.resource = ResourceTexture2.create();
if (this.resource == null) {
LOGGER.error("Can not get Image resource");
this.svgData = null;
clear();
final ImageByte tmp = ToolImage.convertImageByte(data.renderImageFloatRGBA(size));
if (tmp == null) {
LOGGER.error("Can not load the Raw SVG ... ");
return;
}
if (this.resource == null) {
this.resource = new ResourceTexture2();
}
this.resource.set(tmp);
this.svgDoc = data;
this.requestSize = size;
}
}

View File

@ -0,0 +1,320 @@
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.etk.math.Vector3b;
import org.atriasoft.etk.math.Vector3f;
import org.atriasoft.ewol.compositing.CompositingSVG;
import org.atriasoft.ewol.event.EventTime;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* @ingroup ewolWidgetGroup
* Entry box display :
*
* ~~~~~~~~~~~~~~~~~~~~~~
* -------------
* | Content |
* -------------
* ~~~~~~~~~~~~~~~~~~~~~~
*/
public class Box extends Container {
private static final Logger LOGGER = LoggerFactory.getLogger(Box.class);
protected CompositingSVG compositing = new CompositingSVG();
/**
* Periodic call to update grapgic display
* @param event Time generic event
*/
protected static void periodicCall(final Box self, final EventTime event) {
LOGGER.trace("Periodic call on Entry(" + event + ")");
self.markToRedraw();
}
//private Uri propertyConfig = new Uri("THEME", "shape/Button.json", "ewol");
/**
* Constructor
*/
public Box() {}
/**
* Constructor with his subWidget
*/
public Box(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 onChangeSize() {
super.onChangeSize();
if (this.propertyHide) {
return;
}
if (this.subWidget == null) {
return;
}
Vector3f origin = this.origin.add(this.offset);
final Vector3f minSize = this.subWidget.getCalculateMinSize();
final Vector3b expand = this.subWidget.getPropertyExpand();
origin = origin.add(this.propertyGravity.gravityGenerateDelta(minSize.less(this.size)));
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);
this.subWidget.setOrigin(origin.add(offsetSubWidget.x(), offsetSubWidget.y(), 0.0f));
this.subWidget.setSize(this.size.less(offsetSubWidget.x() * 2, offsetSubWidget.y() * 2, 0.0f));
this.subWidget.onChangeSize();
}
@Override
public void calculateMinMaxSize() {
super.calculateMinMaxSize();
final Vector2f parentMinSize = new Vector2f(this.minSize.x(), this.minSize.y());
final Vector2f parentMaxSize = new Vector2f(this.maxSize.x(), this.maxSize.y());
LOGGER.debug("calculate min size: border=" + this.propertyBorderWidth + " min-size=" + this.propertyMinSize);
final Vector2f borderSize = new Vector2f(this.propertyBorderWidth.size() * 2.0f,
this.propertyBorderWidth.size() * 2.0f);
final Vector2f padding = this.propertyPadding.size();
final Vector2f margin = this.propertyMargin.size();
final Vector3f minSize = this.propertyMinSize.size();
final Vector2f borderMinSize = parentMinSize.add(margin).add(padding).add(borderSize);
final Vector2f calculatedBoxMinSize = Vector2f.max(borderMinSize, new Vector2f(minSize.x(), minSize.y()));
this.minSize = new Vector3f(calculatedBoxMinSize.x(), calculatedBoxMinSize.y(), 0);
this.maxSize = Vector3f.max(this.minSize, this.propertyMaxSize.size());
LOGGER.debug("set widget min=" + this.minSize + " max=" + this.maxSize);
markToRedraw();
}
@Override
protected void onDraw() {
if (this.compositing != null) {
this.compositing.draw(true);
}
super.onDraw();
}
@Override
public void onRegenerateDisplay() {
super.onRegenerateDisplay();
if (!needRedraw()) {
//return;
}
// remove data of the previous composition :
this.compositing.clear();
final int borderSize = (int) this.propertyBorderWidth.size();
final int paddingCompensateBorder = Math.round(borderSize * 0.5f);
final Vector2i renderSize = new Vector2i((int) (this.size.x() - this.propertyMargin.size().x() * 2),
(int) (this.size.y() - this.propertyMargin.size().y() * 2));
final long startTime = System.nanoTime();
/*
final EsvgDocument doc = new EsvgDocument();
doc.addElement();
final Rectangle rect = new Rectangle(//
new Vector2f(paddingCompensateBorder, paddingCompensateBorder), //
new Vector2f(paddingCompensateBorder, paddingCompensateBorder), //
)
==> render is OK
this.compositing.setSource("""
<svg>
<rect
x="%d"
y="%d"
width="%dpx"
height="%dpx"
rx="%dpx"
ry="%dpx"
fill="white"
stroke="black"
stroke-width="%dpx"
/>
</svg>""".formatted( //
paddingCompensateBorder, paddingCompensateBorder, //
renderSize.x() - 2 * paddingCompensateBorder, renderSize.y() - 2 * paddingCompensateBorder, //
(int) this.propertyBorderRadius.size(), //
200, //
//this.propertyColor.toStringSharp(), //
//this.propertyBorderColor.toStringSharp(), //
borderSize //
), //
renderSize);
*/
// Bug intéressant: la parsing de la couleur est foireux, black et #000000FF ne rend pas la même chose ==> pour ètre plus précs le rendu avec alpha est foireux...
this.compositing.setSource("""
<svg>
<rect
x="%d"
y="%d"
width="%d"
height="%d"
rx="%d"
ry="%d"
fill="%s"
stroke="%s"
stroke-width="%d"
/>
</svg>""".formatted( //
paddingCompensateBorder, paddingCompensateBorder, //
renderSize.x() - 2 * paddingCompensateBorder, renderSize.y() - 2 * paddingCompensateBorder, //
(int) this.propertyBorderRadius.size(), //
(int) this.propertyBorderRadius.size(), //
this.propertyColor.toStringSharp(), //
this.propertyBorderColor.toStringSharp(), //
borderSize //
), //
renderSize);
final Vector2f imageRenderSize = new Vector2f(100, 100);
final long endTime = System.nanoTime();
// ca ca ne devrait pas ètre la ...
Vector3f delta = this.propertyGravity
.gravityGenerateDelta(this.size.less(imageRenderSize.x(), imageRenderSize.y(), 0));
//LOGGER.debug("delta : " + delta);
if (this.propertyFill.x()) {
//imageRealSize = imageRealSize.withX(imageRealSizeMax.x());
delta = delta.withX(0.0f);
}
if (this.propertyFill.y()) {
//imageRealSize = imageRealSize.withY(imageRealSizeMax.y());
delta = delta.withY(0.0f);
}
//this.origin = this.origin.add(delta);
//this.origin = Vector3f.ZERO;
this.compositing.setPos(this.propertyMargin.size());
this.compositing.print(renderSize);
//LOGGER.debug("generate image in : " + (endTime - startTime));
// LOGGER.debug("propertyBorderColor=" + this.propertyBorderColor.toStringSharp());
// LOGGER.debug("Paint Image at : " + this.origin + " size=" + this.size);
// LOGGER.debug("minSize: " + this.minSize + " size=" + this.size);
this.compositing.flush();
}
}

View File

@ -28,6 +28,13 @@ public class Container extends Widget {
* Constructor
*/
public Container() {}
/**
* Constructor with his child
*/
public Container(final Widget subWidget) {
this.subWidget = subWidget;
}
@Override
public void calculateMinMaxSize() {
@ -249,7 +256,7 @@ public class Container extends Widget {
//LOGGER.info("Draw : [" + propertyName + "] t=" + getObjectType() + " o=" + this.origin + " s=" + this.size);
this.subWidget.systemDraw(prop);
} else {
LOGGER.info("[" + getId() + "] ++++++ : [null]");
LOGGER.trace("[" + getId() + "] ++++++ : [null]");
}
}
}

View File

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

View File

@ -56,26 +56,26 @@ public class Widget extends EwolObject {
// ----------------------------------------------------------------------------------------------------------------
private boolean allowRepeatKeyboardEvent = true; //!< This remove the repeating keybord event due to the ant pressing key.
private Cursor cursorDisplay = Cursor.arrow;
private final CompositingDrawing drawDebugBorder = null;//new CompositingDrawing(); //!< Compositing drawing element
// grab cursor mode
private boolean grabCursor = false;
// ----------------------------------------------------------------------------------------------------------------
// -- focus Area
// ----------------------------------------------------------------------------------------------------------------
private boolean hasFocus = false; //!< set the focus on this widget
// ----------------------------------------------------------------------------------------------------------------
// -- Mouse event properties Area
// ----------------------------------------------------------------------------------------------------------------
private int limitMouseEvent = 3; //!< this is to limit the number of mouse event that the widget can supported
private final List<EventShortCut> localShortcut = new ArrayList<>(); //!< list of all shortcut in the widget
protected Vector3f maxSize = Vector3f.MAX_VALUE; //!< internal: maximum size of the widget
protected Vector3f minSize = Vector3f.ZERO; //!< internal: minimum size of the widget
// ----------------------------------------------------------------------------------------------------------------
// -- drawing : All drawing must be done in 2 separate buffer 1 for the current display and 1 for the working...
@ -91,28 +91,28 @@ public class Widget extends EwolObject {
protected boolean propertyHide = false; //!< hide a widget on the display
protected Dimension3f propertyMaxSize = new Dimension3f(Vector3f.MAX_VALUE, Distance.PIXEL); //!< user define the maximum size of the widget
protected Dimension3f propertyMinSize = new Dimension3f(Vector3f.ZERO, Distance.PIXEL); //!< user define the minimum size of the widget
// ----------------------------------------------------------------------------------------------------------------
// -- Shortcut : management of the shortcut
// ----------------------------------------------------------------------------------------------------------------
@AknotSignal
@AknotName("shortcut")
public Signal<String> signalShortcut; //!< signal handle of the message
// ----------------------------------------------------------------------------------------------------------------
// -- Widget size:
// ----------------------------------------------------------------------------------------------------------------
protected Vector3f size = Vector3f.VALUE_16; //!< internal: current size of the widget
// internal element calculated by the system
protected float zoom = 1.0f; //!< generic widget zoom
/**
* Constructor of the widget classes
* @return (no exception generated (not managed in embedded platform))
*/
public Widget() {}
/**
* calculate the minimum and maximum size (need to estimate expend properties of the widget)
* @note : INTERNAL EWOL SYSTEM
@ -120,16 +120,16 @@ public class Widget extends EwolObject {
public void calculateMinMaxSize() {
calculateMinMaxSizeWidget();
}
protected void calculateMinMaxSizeWidget() {
this.minSize = this.propertyMinSize.getPixel();
//LOGGER.error("[" + getId() + "] convert in min size : " + propertyMinSize + " out=" + this.minSize);
this.maxSize = this.propertyMaxSize.getPixel();
markToRedraw();
}
public void calculateSize() {}
/**
* get the expend capabilities (xy)
* @return 2D boolean represents the capacity to expend
@ -141,7 +141,7 @@ public class Widget extends EwolObject {
}
return Vector3b.FALSE;
}
/**
* get the expend if free capabilities (xy)
* @return 2D boolean represents the capacity to expend (if some free space is available)
@ -153,7 +153,7 @@ public class Widget extends EwolObject {
}
return Vector3b.FALSE;
}
/**
* get the filling capabilities xy
* @return Vector3b repensent the capacity to xy filling
@ -162,15 +162,15 @@ public class Widget extends EwolObject {
public Vector3b canFill() {
return this.propertyFill;
}
/**
* Change Zoom property.
* @param range Range of the zoom change.
*/
void changeZoom(final float range) {
}
/**
* Check if the current max size is compatible with the user maximum size
* If it is not the user maximum size will overWrite the maximum size set.
@ -180,7 +180,7 @@ public class Widget extends EwolObject {
final Vector3f pixelSize = this.propertyMaxSize.getPixel();
this.maxSize = Vector3f.min(this.maxSize, pixelSize);
}
/**
* Check if the current min size is compatible with the user minimum size
* If it is not the user minimum size will overWrite the minimum size set.
@ -190,7 +190,7 @@ public class Widget extends EwolObject {
final Vector3f pixelSize = this.propertyMinSize.getPixel();
this.minSize = Vector3f.max(this.minSize, pixelSize);
}
public void drawWidgetTree(final int level) {
final StringBuilder space = new StringBuilder();
for (int iii = 0; iii < level; ++iii) {
@ -200,7 +200,7 @@ public class Widget extends EwolObject {
.append(getClass().getCanonicalName()).append(" o=").append(this.origin).append(" s=")
.append(this.size).append(" hide=").append(this.propertyHide).toString());
}
/**
* get the widget maximum size calculated
* @return Requested size
@ -212,7 +212,7 @@ public class Widget extends EwolObject {
}
return Vector3f.MAX_VALUE;
}
/**
* get the widget minimum size calculated
* @return Requested size
@ -224,7 +224,7 @@ public class Widget extends EwolObject {
}
return Vector3f.ZERO;
}
/**
* get the current cursor.
* @return the type of the cursor.
@ -232,7 +232,7 @@ public class Widget extends EwolObject {
public Cursor getCursor() {
return this.cursorDisplay;
}
/**
* get the grabbing status of the cursor.
* @return true if the cursor is currently grabbed
@ -240,7 +240,7 @@ public class Widget extends EwolObject {
public boolean getGrabStatus() {
return this.grabCursor;
}
/**
* get the keyboard repeating event supporting.
* @return true : the event can be repeated.
@ -249,7 +249,7 @@ public class Widget extends EwolObject {
public boolean getKeyboardRepeat() {
return this.allowRepeatKeyboardEvent;
}
/**
* get the number of mouse event supported
* @return return the number of event that the mouse supported [0..3]
@ -257,7 +257,7 @@ public class Widget extends EwolObject {
public int getMouseLimit() {
return this.limitMouseEvent;
}
/**
* get the offset property of the widget.
* @return The current offset value.
@ -265,7 +265,7 @@ public class Widget extends EwolObject {
Vector3f getOffset() {
return this.offset;
}
/**
* Get the origin (absolute position in the windows).
* @return Coordinate of the origin requested.
@ -273,7 +273,7 @@ public class Widget extends EwolObject {
public Vector3f getOrigin() {
return this.origin;
}
@AknotManaged
@AknotAttribute
@AknotName("focus")
@ -281,7 +281,7 @@ public class Widget extends EwolObject {
public boolean getPropertyCanFocus() {
return this.propertyCanFocus;
}
@AknotManaged
@AknotAttribute
@AknotName("expand")
@ -289,7 +289,7 @@ public class Widget extends EwolObject {
public Vector3b getPropertyExpand() {
return this.propertyExpand;
}
@AknotManaged
@AknotAttribute
@AknotName("expand-free")
@ -297,7 +297,7 @@ public class Widget extends EwolObject {
public Vector3b getPropertyExpandIfFree() {
return this.propertyExpandIfFree;
}
@AknotManaged
@AknotAttribute
@AknotName("fill")
@ -305,7 +305,7 @@ public class Widget extends EwolObject {
public Vector3b getPropertyFill() {
return this.propertyFill;
}
@AknotManaged
@AknotAttribute
@AknotName("gravity")
@ -313,7 +313,7 @@ public class Widget extends EwolObject {
public Gravity getPropertyGravity() {
return this.propertyGravity;
}
@AknotManaged
@AknotAttribute
@AknotName("hide")
@ -321,7 +321,7 @@ public class Widget extends EwolObject {
public boolean getPropertyHide() {
return this.propertyHide;
}
@AknotManaged
@AknotAttribute
@AknotName("max-size")
@ -329,7 +329,7 @@ public class Widget extends EwolObject {
public Dimension3f getPropertyMaxSize() {
return this.propertyMaxSize;
}
@AknotManaged
@AknotAttribute
@AknotName("min-size")
@ -337,7 +337,7 @@ public class Widget extends EwolObject {
public Dimension3f getPropertyMinSize() {
return this.propertyMinSize;
}
/**
* get the widget size
* @return Requested size
@ -349,7 +349,7 @@ public class Widget extends EwolObject {
}
return Vector3f.ZERO;
}
/**
* get the widget at the specific windows absolute position
* @param pos gAbsolute position of the requested widget knowledge
@ -363,21 +363,21 @@ public class Widget extends EwolObject {
}
return null;
}
/**
* Get the current Widget Manager.
*/
public WidgetManager getWidgetManager() {
return EwolObject.getContext().getWidgetManager();
}
/**
* Get the current Windows.
*/
public Windows getWindows() {
return EwolObject.getContext().getWindows();
}
/**
* get the zoom property of the widget
* @return the current zoom value
@ -385,7 +385,7 @@ public class Widget extends EwolObject {
public float getZoom() {
return this.zoom;
}
/**
* Grab the cursor : This get all the movement of the mouse in PC mode, and generate an offset instead of a position.
* @note : the generation of the offset is due to the fact the cursor position is forced at the center of the widget.
@ -397,14 +397,14 @@ public class Widget extends EwolObject {
this.grabCursor = true;
}
}
/**
* Hide the keyboard (if needed)
*/
protected void hideKeyboard() {
EwolObject.getContext().keyboardHide();
}
/**
* get the focus state of the widget
* @return focus state
@ -412,14 +412,14 @@ public class Widget extends EwolObject {
public boolean isFocused() {
return this.hasFocus;
}
/**
* keep the focus on this widget == > this remove the previous focus on all other widget
*/
public void keepFocus() {
getWidgetManager().focusKeep(this);
}
/**
* The widget mark itself that it need to regenerate the nest time.
*/
@ -430,7 +430,7 @@ public class Widget extends EwolObject {
this.needRegenerateDisplay = true;
getWidgetManager().markDrawingIsNeeded();
}
/**
* get the need of the redrawing of the widget and reset it to false
* @return true if we need to redraw
@ -441,7 +441,7 @@ public class Widget extends EwolObject {
this.needRegenerateDisplay = false;
return tmpData;
}
/**
* Parent have set the size and the origin. The container need to update the child widget property
* @note INTERNAL EWOL SYSTEM
@ -450,19 +450,19 @@ public class Widget extends EwolObject {
LOGGER.trace("[" + getId() + "] {" + getClass().getCanonicalName() + "} update size : " + this.size);
markToRedraw();
}
/**
* Common widget drawing function (called by the drawing thread [Android, X11, ...])
*/
protected void onDraw() {}
/**
* Event on a past event == > this event is asynchronous due to all system does not support direct getting data.
* @note : need to have focus ...
* @param clipboardID Mode of data requested
*/
public void onEventClipboard(final ClipboardList clipboardID) {}
/**
* Entry event.
* represent the physical event :
@ -476,7 +476,7 @@ public class Widget extends EwolObject {
protected boolean onEventEntry(final EventEntry event) {
return false;
}
/**
* Event on an input of this Widget (finger, mouse, stylet)
* @param event Event properties
@ -486,7 +486,7 @@ public class Widget extends EwolObject {
protected boolean onEventInput(final EventInput event) {
return false;
}
/**
* Event on a short-cut of this Widget (in case of return false, the event on the keyevent will arrive in the function @ref onEventKb).
* @param special All the special kay pressed at this time.
@ -540,19 +540,19 @@ public class Widget extends EwolObject {
}
return false;
}
/**
* Event of the focus has been grabed by the current widget
*/
protected void onGetFocus() {}
/**
* Event of the focus has been lost by the current widget
*/
protected void onLostFocus() {}
protected void onRegenerateDisplay() {}
protected void onUpdateMinMaxSize() {
final Vector3f pixelMin = this.propertyMinSize.getPixel();
final Vector3f pixelMax = this.propertyMaxSize.getPixel();
@ -563,7 +563,7 @@ public class Widget extends EwolObject {
}
requestUpdateSize();
}
/**
* Convert the absolute position in the local Position (Relative)
* @param pos Absolute position that you request conversion.
@ -572,14 +572,14 @@ public class Widget extends EwolObject {
public Vector3f relativePosition(final Vector3f pos) {
return pos.less(this.origin);
}
/**
* Need to be call When the size of the current widget have change ==> this force the system to recalculate all the widget positions.
*/
public void requestUpdateSize() {
EwolObject.getContext().requestUpdateSize();
}
/**
* remove the focus on this widget
* @return return true if the widget have release his focus (if he has it)
@ -594,7 +594,7 @@ public class Widget extends EwolObject {
}
return false;
}
/**
* set the cursor display type.
* @param newCursor selected new cursor.
@ -604,7 +604,7 @@ public class Widget extends EwolObject {
this.cursorDisplay = newCursor;
EwolObject.getContext().setCursor(this.cursorDisplay);
}
/**
* set focus on this widget
* @return return true if the widget keep the focus
@ -623,7 +623,7 @@ public class Widget extends EwolObject {
LOGGER.trace("set focus (stop) ret false");
return false;
}
/**
* set the keyboard repeating event supporting.
* @param state The repeating status (true: enable, false disable).
@ -631,7 +631,7 @@ public class Widget extends EwolObject {
protected void setKeyboardRepeat(final boolean state) {
this.allowRepeatKeyboardEvent = state;
}
/**
* get the number of mouse event supported
* @param numberState The number of event that the mouse supported [0..3]
@ -639,21 +639,21 @@ public class Widget extends EwolObject {
public void setMouseLimit(final int numberState) {
this.limitMouseEvent = numberState;
}
/**
* User set No maximum size.
*/
public void setNoMaxSize() {
setPropertyMaxSize(new Dimension3f(Vector3f.MAX_VALUE, Distance.PIXEL));
}
/**
* User set No minimum size.
*/
public void setNoMinSize() {
setPropertyMinSize(new Dimension3f(Vector3f.ZERO, Distance.PIXEL));
}
/**
* set the zoom property of the widget.
* @param newVal offset value.
@ -665,7 +665,7 @@ public class Widget extends EwolObject {
markToRedraw();
}
}
/**
* Set origin at the widget (must be an parent widget that set this parameter).
* This represent the absolute origin in the program windows.
@ -675,7 +675,7 @@ public class Widget extends EwolObject {
public void setOrigin(final Vector3f pos) {
this.origin = pos;
}
public void setPropertyCanFocus(final boolean canFocus) {
if (this.propertyCanFocus == canFocus) {
return;
@ -688,7 +688,7 @@ public class Widget extends EwolObject {
rmFocus();
}
}
public void setPropertyExpand(final Vector3b value) {
if (this.propertyExpand.equals(value)) {
return;
@ -697,7 +697,7 @@ public class Widget extends EwolObject {
markToRedraw();
requestUpdateSize();
}
public void setPropertyExpandIfFree(final Vector3b value) {
if (this.propertyExpandIfFree.equals(value)) {
return;
@ -706,7 +706,7 @@ public class Widget extends EwolObject {
markToRedraw();
requestUpdateSize();
}
public void setPropertyFill(final Vector3b value) {
if (this.propertyFill.equals(value)) {
return;
@ -715,7 +715,7 @@ public class Widget extends EwolObject {
markToRedraw();
requestUpdateSize();
}
public void setPropertyGravity(final Gravity gravity) {
if (this.propertyGravity.equals(gravity)) {
return;
@ -724,7 +724,7 @@ public class Widget extends EwolObject {
markToRedraw();
requestUpdateSize();
}
public void setPropertyHide(final boolean value) {
if (this.propertyHide == value) {
return;
@ -733,7 +733,7 @@ public class Widget extends EwolObject {
markToRedraw();
requestUpdateSize();
}
public void setPropertyMaxSize(final Dimension3f value) {
if (this.propertyMaxSize.equals(value)) {
return;
@ -741,7 +741,7 @@ public class Widget extends EwolObject {
this.propertyMaxSize = value;
onUpdateMinMaxSize();
}
public void setPropertyMinSize(final Dimension3f value) {
if (this.propertyMinSize.equals(value)) {
return;
@ -749,7 +749,7 @@ public class Widget extends EwolObject {
this.propertyMinSize = value;
onUpdateMinMaxSize();
}
/**
* set the widget size
* @return Requested size
@ -757,8 +757,11 @@ public class Widget extends EwolObject {
*/
public void setSize(final Vector3f value) {
this.size = value;
if (this.size.x() > 15000) {
return;
}
}
/**
* set the zoom property of the widget
* @param newVal newZoom value
@ -770,7 +773,7 @@ public class Widget extends EwolObject {
this.zoom = FMath.avg(0.0000001f, newVal, 1000000.0f);
markToRedraw();
}
/**
* add a specific shortcut with his description
* @param descriptiveString Description string of the shortcut
@ -778,7 +781,7 @@ public class Widget extends EwolObject {
protected void shortCutAdd(final String descriptiveString) {
shortCutAdd(descriptiveString, "");
}
/**
* add a specific shortcut with his description
* @param descriptiveString Description string of the shortcut
@ -872,14 +875,14 @@ public class Widget extends EwolObject {
// add it on the List ...
this.localShortcut.add(new EventShortCut(message, specialKey, unicodeValue, keyboardMoveValue, true));
}
/**
* remove all current shortCut
*/
protected void shortCutClean() {
this.localShortcut.clear();
}
/**
* remove a specific shortCut with his event name
* @param message generated event name
@ -887,14 +890,14 @@ public class Widget extends EwolObject {
protected void shortCutRemove(final String message) {
this.localShortcut.removeIf(eventShortCut -> eventShortCut.message().contentEquals(message));
}
/**
* display the keyboard (if needed)
*/
protected void showKeyboard() {
EwolObject.getContext().keyboardShow();
}
/**
* {SYSTEM} extern interface to request a draw ... (called by the drawing thread [Android, X11, ...])
* This function generate a clipping with the view-port openGL system. Like this a widget draw can not draw over an other widget
@ -930,7 +933,7 @@ public class Widget extends EwolObject {
public void systemDraw(final DrawProperty displayProp) {
systemDrawWidget(displayProp);
}
protected void systemDrawWidget(final DrawProperty displayProp) {
//LOGGER.info("[" + getId() + "] Draw : [" + propertyName + "] t=" + getObjectType() + " o=" + this.origin + " s=" << this.size << " hide=" << propertyHide);
if (this.propertyHide) {
@ -938,13 +941,13 @@ public class Widget extends EwolObject {
return;
}
final Vector3f displayOrigin = this.origin.add(this.offset);
// check if the element is displayable in the windows :
if (displayProp.windowsSize().x() < this.origin.x() || displayProp.windowsSize().y() < this.origin.y()) {
// out of the windows == > nothing to display ...
return;
}
final DrawProperty tmpSize = displayProp.withLimit(this.origin, this.size);
if (tmpSize.size().x() <= 0 || tmpSize.size().y() <= 0) {
return;
@ -967,7 +970,7 @@ public class Widget extends EwolObject {
final Matrix4f tmpProjection = Matrix4f.createMatrixOrtho(-tmpSize.size().x() / 2, tmpSize.size().x() / 2,
-tmpSize.size().y() / 2, tmpSize.size().y() / 2, -500, 500);
//Matrix4f tmpMat = tmpProjection.multiply(tmpScale).multiply(tmpTranslate);
OpenGL.push();
// set internal matrix system :
//OpenGL.setMatrix(tmpMat);
@ -981,7 +984,7 @@ public class Widget extends EwolObject {
OpenGL.pop();
GL11.glFinish();
}
/**
* {SYSTEM} Entry event (only meta widget might overwrite this function).
* @param event Event properties
@ -996,7 +999,7 @@ public class Widget extends EwolObject {
}
return onEventEntry(event.event());
}
/**
* {SYSTEM} system event input (only meta widget might overwrite this function).
* @param event Event properties
@ -1014,7 +1017,7 @@ public class Widget extends EwolObject {
}
return onEventInput(event.event());
}
/**
* Event generated when a redraw is needed
*/
@ -1040,7 +1043,7 @@ public class Widget extends EwolObject {
}
onRegenerateDisplay();
}
/**
* Un-Grab the cursor (default mode cursor offset)
*/