[FEAT] basic concept of box to simple manage the HTML rectangle rendering
This commit is contained in:
parent
2743abe410
commit
847bcb14f4
4
pom.xml
4
pom.xml
@ -21,7 +21,6 @@
|
|||||||
</roles>
|
</roles>
|
||||||
</developer>
|
</developer>
|
||||||
</developers>
|
</developers>
|
||||||
|
|
||||||
<repositories>
|
<repositories>
|
||||||
<repository>
|
<repository>
|
||||||
<id>gitea</id>
|
<id>gitea</id>
|
||||||
@ -38,7 +37,6 @@
|
|||||||
<url>https://gitea.atria-soft.org/api/packages/org.atriasoft/maven</url>
|
<url>https://gitea.atria-soft.org/api/packages/org.atriasoft/maven</url>
|
||||||
</snapshotRepository>
|
</snapshotRepository>
|
||||||
</distributionManagement>
|
</distributionManagement>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.atriasoft</groupId>
|
<groupId>org.atriasoft</groupId>
|
||||||
@ -88,7 +86,6 @@
|
|||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
<sourceDirectory>src/main</sourceDirectory>
|
<sourceDirectory>src/main</sourceDirectory>
|
||||||
<resources>
|
<resources>
|
||||||
@ -170,5 +167,4 @@
|
|||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</reporting>
|
</reporting>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
@ -12,6 +12,7 @@ import org.atriasoft.esignal.Connection;
|
|||||||
import org.atriasoft.esignal.Signal;
|
import org.atriasoft.esignal.Signal;
|
||||||
import org.atriasoft.esignal.SignalEmpty;
|
import org.atriasoft.esignal.SignalEmpty;
|
||||||
import org.atriasoft.etk.Color;
|
import org.atriasoft.etk.Color;
|
||||||
|
import org.atriasoft.etk.Dimension1f;
|
||||||
import org.atriasoft.etk.Dimension2f;
|
import org.atriasoft.etk.Dimension2f;
|
||||||
import org.atriasoft.etk.Dimension3f;
|
import org.atriasoft.etk.Dimension3f;
|
||||||
import org.atriasoft.etk.Distance;
|
import org.atriasoft.etk.Distance;
|
||||||
@ -149,6 +150,43 @@ public class BasicWindows extends Windows {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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) {
|
public void addMenuDimension2f(final Widget widget, final IntrospectionProperty pojo) {
|
||||||
Object valueRaw = null;
|
Object valueRaw = null;
|
||||||
try {
|
try {
|
||||||
@ -1139,6 +1177,8 @@ public class BasicWindows extends Windows {
|
|||||||
addMenuDimension3f(widget, pojo);
|
addMenuDimension3f(widget, pojo);
|
||||||
} else if (pojo.getType() == Dimension2f.class) {
|
} else if (pojo.getType() == Dimension2f.class) {
|
||||||
addMenuDimension2f(widget, pojo);
|
addMenuDimension2f(widget, pojo);
|
||||||
|
} else if (pojo.getType() == Dimension1f.class) {
|
||||||
|
addMenuDimension1f(widget, pojo);
|
||||||
} else if (pojo.getType() == DisplayMode.class) {
|
} else if (pojo.getType() == DisplayMode.class) {
|
||||||
LOGGER.error(" ==> plop");
|
LOGGER.error(" ==> plop");
|
||||||
} else if (pojo.getType() == Uri.class) {
|
} else if (pojo.getType() == Uri.class) {
|
||||||
|
@ -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 ]");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
@ -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() {}
|
||||||
|
}
|
@ -3,13 +3,13 @@ package sample.atriasoft.ewol.simpleWindowsWithCheckBox;
|
|||||||
import org.atriasoft.etk.Uri;
|
import org.atriasoft.etk.Uri;
|
||||||
import org.atriasoft.ewol.Ewol;
|
import org.atriasoft.ewol.Ewol;
|
||||||
|
|
||||||
public class SimpleWindowsWithCheckBoxMain {
|
public class Main {
|
||||||
public static void main(final String[] args) {
|
public static void main(final String[] args) {
|
||||||
Ewol.init();
|
Ewol.init();
|
||||||
//Uri.addLibrary("test-data", SimpleWindowsWithImageMain.class, "test-ewol/");
|
//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);
|
Ewol.run(new Appl(), args);
|
||||||
}
|
}
|
||||||
|
|
||||||
private SimpleWindowsWithCheckBoxMain() {}
|
private Main() {}
|
||||||
}
|
}
|
@ -17,7 +17,7 @@ public class MainWindows extends BasicWindows {
|
|||||||
//this.testWidget.setPropertySource(new Uri("DATA", "mireA.png"));
|
//this.testWidget.setPropertySource(new Uri("DATA", "mireA.png"));
|
||||||
this.testWidget.setPropertyExpand(Vector3b.TRUE);
|
this.testWidget.setPropertyExpand(Vector3b.TRUE);
|
||||||
this.testWidget.setPropertyFill(Vector3b.TRUE);
|
this.testWidget.setPropertyFill(Vector3b.TRUE);
|
||||||
this.setTestWidget(this.testWidget);
|
setTestWidget(this.testWidget);
|
||||||
/*
|
/*
|
||||||
Button simpleButton = new Button();
|
Button simpleButton = new Button();
|
||||||
simpleButton.setPropertyValue("Top Button");
|
simpleButton.setPropertyValue("Top Button");
|
||||||
|
@ -34,6 +34,7 @@ public class CompositingSVG extends Compositing {
|
|||||||
private float angle = 0; //!< Angle to set at the axes
|
private float angle = 0; //!< Angle to set at the axes
|
||||||
private Color color = new Color(1, 1, 1); //!< The text foreground color
|
private Color color = new Color(1, 1, 1); //!< The text foreground color
|
||||||
private String svgData;
|
private String svgData;
|
||||||
|
private EsvgDocument svgDoc;
|
||||||
protected int oGLMatrixProjection = -1; //!< openGL id on the element (Projection matrix)
|
protected int oGLMatrixProjection = -1; //!< openGL id on the element (Projection matrix)
|
||||||
protected int oGLMatrixTransformation = -1; //!< openGL id on the element (transformation matrix)
|
protected int oGLMatrixTransformation = -1; //!< openGL id on the element (transformation matrix)
|
||||||
protected int oGLMatrixView = -1; //!< openGL id on the element (view matrix)
|
protected int oGLMatrixView = -1; //!< openGL id on the element (view matrix)
|
||||||
@ -41,8 +42,7 @@ public class CompositingSVG extends Compositing {
|
|||||||
private Vector3f position = Vector3f.ZERO; //!< The current position to draw
|
private Vector3f position = Vector3f.ZERO; //!< The current position to draw
|
||||||
private Vector2i requestSize = new Vector2i(2, 2);
|
private Vector2i requestSize = new Vector2i(2, 2);
|
||||||
|
|
||||||
private ResourceTexture2 resource = null;
|
private ResourceTexture2 resource = null; //!< texture resources
|
||||||
private ResourceTexture2 resourceImage = null; //!< texture resources
|
|
||||||
private ResourceVirtualArrayObject vbo = null;
|
private ResourceVirtualArrayObject vbo = null;
|
||||||
|
|
||||||
private Color[] vboDataColors = null;
|
private Color[] vboDataColors = null;
|
||||||
@ -50,7 +50,9 @@ public class CompositingSVG extends Compositing {
|
|||||||
private Vector2f[] vboDataCoordsTex = null;
|
private Vector2f[] vboDataCoordsTex = null;
|
||||||
|
|
||||||
public CompositingSVG() {
|
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) {
|
public CompositingSVG(final String data, final int size) {
|
||||||
@ -63,7 +65,7 @@ public class CompositingSVG 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 " + this.getClass().getCanonicalName());
|
this.vbo.setName("[VBO] of " + this.getClass().getCanonicalName());
|
||||||
setSource(data, size);
|
setSource(this.svgData, size);
|
||||||
loadProgram();
|
loadProgram();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -94,7 +96,7 @@ public class CompositingSVG extends Compositing {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
if (this.resourceImage == null) {
|
if (this.resource == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (this.oGLprogram == null) {
|
if (this.oGLprogram == null) {
|
||||||
@ -116,7 +118,7 @@ public class CompositingSVG extends Compositing {
|
|||||||
this.oGLprogram.uniformMatrix(this.oGLMatrixTransformation, this.matrixApply);
|
this.oGLprogram.uniformMatrix(this.oGLMatrixTransformation, this.matrixApply);
|
||||||
this.oGLprogram.uniformMatrix(this.oGLMatrixView, camMatrix);
|
this.oGLprogram.uniformMatrix(this.oGLMatrixView, camMatrix);
|
||||||
// TextureID
|
// TextureID
|
||||||
this.resourceImage.bindForRendering(0);
|
this.resource.bindForRendering(0);
|
||||||
this.vbo.renderArrays(RenderMode.TRIANGLE);
|
this.vbo.renderArrays(RenderMode.TRIANGLE);
|
||||||
this.vbo.unBindForRendering();
|
this.vbo.unBindForRendering();
|
||||||
this.oGLprogram.unUse();
|
this.oGLprogram.unUse();
|
||||||
@ -144,10 +146,10 @@ public class CompositingSVG extends Compositing {
|
|||||||
* @return tre image registered size
|
* @return tre image registered size
|
||||||
*/
|
*/
|
||||||
public Vector2i getRealSize() {
|
public Vector2i getRealSize() {
|
||||||
if (this.resourceImage == null) {
|
if (this.resource == null) {
|
||||||
return Vector2i.ZERO;
|
return Vector2i.ZERO;
|
||||||
}
|
}
|
||||||
return this.resourceImage.getUsableSize();
|
return this.resource.getUsableSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -350,8 +352,8 @@ public class CompositingSVG extends Compositing {
|
|||||||
clear();
|
clear();
|
||||||
this.svgData = null;
|
this.svgData = null;
|
||||||
this.requestSize = image.getSize();
|
this.requestSize = image.getSize();
|
||||||
this.resourceImage = new ResourceTexture2();
|
this.resource = new ResourceTexture2();
|
||||||
this.resourceImage.set(image);
|
this.resource.set(image);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSource(final String data) {
|
public void setSource(final String data) {
|
||||||
@ -363,8 +365,13 @@ public class CompositingSVG extends Compositing {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setSource(final String data, final Vector2i 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();
|
clear();
|
||||||
|
this.svgDoc = null;
|
||||||
final EsvgDocument doc = new EsvgDocument();
|
final EsvgDocument doc = new EsvgDocument();
|
||||||
doc.parse(data);
|
doc.parse(data);
|
||||||
final ImageByte tmp = ToolImage.convertImageByte(doc.renderImageFloatRGBA(size));
|
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 ... ");
|
LOGGER.error("Can not load the Raw SVG ... ");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.resourceImage.set(tmp);
|
if (this.resource == null) {
|
||||||
|
this.resource = new ResourceTexture2();
|
||||||
|
}
|
||||||
|
this.resource.set(tmp);
|
||||||
|
this.svgData = data;
|
||||||
|
this.requestSize = size;
|
||||||
|
}
|
||||||
|
|
||||||
if (this.svgData.equals(data) && this.requestSize.x() == size.x() && this.requestSize.y() == size.y()) {
|
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 ...
|
// Nothing to do ...
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final ResourceTexture2 resource = this.resource;
|
this.svgData = null;
|
||||||
final ResourceTexture2 resourceTex = this.resourceImage;
|
clear();
|
||||||
this.svgData = data;
|
final ImageByte tmp = ToolImage.convertImageByte(data.renderImageFloatRGBA(size));
|
||||||
this.requestSize = size;
|
if (tmp == null) {
|
||||||
this.resource = null;
|
LOGGER.error("Can not load the Raw SVG ... ");
|
||||||
this.resourceImage = null;
|
return;
|
||||||
|
}
|
||||||
final Vector2i tmpSize = new Vector2i(size.x(), size.y());
|
|
||||||
|
|
||||||
// link to new one
|
|
||||||
this.resource = ResourceTexture2.create();
|
|
||||||
if (this.resource == null) {
|
if (this.resource == null) {
|
||||||
LOGGER.error("Can not get Image resource");
|
this.resource = new ResourceTexture2();
|
||||||
}
|
}
|
||||||
|
this.resource.set(tmp);
|
||||||
|
this.svgDoc = data;
|
||||||
|
this.requestSize = size;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
320
src/main/org/atriasoft/ewol/widget/Box.java
Normal file
320
src/main/org/atriasoft/ewol/widget/Box.java
Normal 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();
|
||||||
|
}
|
||||||
|
}
|
@ -29,6 +29,13 @@ public class Container extends Widget {
|
|||||||
*/
|
*/
|
||||||
public Container() {}
|
public Container() {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor with his child
|
||||||
|
*/
|
||||||
|
public Container(final Widget subWidget) {
|
||||||
|
this.subWidget = subWidget;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void calculateMinMaxSize() {
|
public void calculateMinMaxSize() {
|
||||||
// call main class
|
// call main class
|
||||||
@ -249,7 +256,7 @@ public class Container extends Widget {
|
|||||||
//LOGGER.info("Draw : [" + propertyName + "] t=" + getObjectType() + " o=" + this.origin + " s=" + this.size);
|
//LOGGER.info("Draw : [" + propertyName + "] t=" + getObjectType() + " o=" + this.origin + " s=" + this.size);
|
||||||
this.subWidget.systemDraw(prop);
|
this.subWidget.systemDraw(prop);
|
||||||
} else {
|
} else {
|
||||||
LOGGER.info("[" + getId() + "] ++++++ : [null]");
|
LOGGER.trace("[" + getId() + "] ++++++ : [null]");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -757,6 +757,9 @@ public class Widget extends EwolObject {
|
|||||||
*/
|
*/
|
||||||
public void setSize(final Vector3f value) {
|
public void setSize(final Vector3f value) {
|
||||||
this.size = value;
|
this.size = value;
|
||||||
|
if (this.size.x() > 15000) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user