[FEAT] continue refacto of the gui generation on SVG instead of native webGl

This commit is contained in:
Edouard DUPIN 2025-05-26 08:00:16 +02:00
parent 847bcb14f4
commit fe423be3d9
20 changed files with 1337 additions and 872 deletions

View File

@ -171,8 +171,10 @@ public class BasicWindows extends Windows {
spin.setPropertyValue((int) value.size());
lineSizer.subWidgetAdd(spin);
final Connection con = spin.signalValue.connect(valueButton -> {
LOGGER.warn("Receved event for button ...");
try {
final Object oldValue = pojo.getValue(widget);
LOGGER.warn("Receved event for button ... {}", oldValue);
if (oldValue instanceof final Dimension1f castedValue) {
LOGGER.warn("Set new value: {}", castedValue.withSize(valueButton));
pojo.setExistingValue(widget, new Dimension1f(valueButton));
@ -445,7 +447,7 @@ public class BasicWindows extends Windows {
buttonGravity.setPropertyMinSize(new Dimension3f(Vector3f.VALUE_16, Distance.PIXEL));
buttonGravity.setPropertyGravity(Gravity.CENTER);
this.sizerMenu.subWidgetAdd(buttonGravity);
final Label gravLabel = (Label) (buttonGravity.getSubWidgets()[0]);
final Label gravLabel = (Label) (buttonGravity.getSubWidget());
gravLabel.setPropertyValue(LABEL_GRAVITY + Gravity.BOTTOM_LEFT);
final Connection con = buttonGravity.signalClick.connect(() -> {

View File

@ -20,6 +20,7 @@ public class MainWindows extends BasicWindows {
final Box innerWidget = new Box();
//this.testWidget.setPropertySource(new Uri("DATA", "mireA.png"));
innerWidget.setPropertyExpand(Vector3b.FALSE);
innerWidget.setPropertyExpandIfFree(Vector3b.TRUE);
innerWidget.setPropertyFill(Vector3b.TRUE);
innerWidget.setPropertyColor(Color.PINK);

View File

@ -0,0 +1,83 @@
package sample.atriasoft.ewol.simpleWindowsWithButton;
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,27 @@
package sample.atriasoft.ewol.simpleWindowsWithButton;
import org.atriasoft.ewol.widget.Box;
import org.atriasoft.ewol.widget.Button;
import sample.atriasoft.ewol.BasicWindows;
public class MainWindows extends BasicWindows {
Box testWidget;
public MainWindows() {
//! [ewol_sample_HW_windows_title]
setPropertyTitle("Simple Button");
this.testWidget = Button.createLabelButton("A simple Label");
//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.simpleWindowsWithButton;
import org.atriasoft.etk.Uri;
import org.atriasoft.ewol.Ewol;
public class SimpleWindowsWithButtonMain {
public static void main(final String[] args) {
Ewol.init();
//Uri.addLibrary("test-data", SimpleWindowsWithImageMain.class, "test-ewol/");
Uri.setApplication(SimpleWindowsWithButtonMain.class, "test-ewol/");
Ewol.run(new Appl(), args);
}
private SimpleWindowsWithButtonMain() {}
}

View File

@ -38,20 +38,20 @@ public class MainWindows extends BasicWindows {
this.testWidget.setPropertyExpand(Vector3b.TRUE);
this.testWidget.setPropertyFill(Vector3b.TRUE);
this.testWidget.setPropertyMinSize(new Dimension3f(Vector3f.VALUE_16, Distance.PIXEL));
this.setTestWidget(this.testWidget);
setTestWidget(this.testWidget);
{
final Button button = Button.createToggleLabelButton("mireA.png", "mireC.png");
button.setPropertyExpand(Vector3b.FALSE);
button.setPropertyFill(Vector3b.FALSE);
button.setPropertyMinSize(new Dimension3f(Vector3f.VALUE_16, Distance.PIXEL));
this.addButton(button);
button.signalValue.connectAuto(this, MainWindows::eventButtonChangeImage);
// final Button button = Button.createToggleLabelButton("mireA.png", "mireC.png");
// button.setPropertyExpand(Vector3b.FALSE);
// button.setPropertyFill(Vector3b.FALSE);
// button.setPropertyMinSize(new Dimension3f(Vector3f.VALUE_16, Distance.PIXEL));
// this.addButton(button);
// button.signalValue.connectAuto(this, MainWindows::eventButtonChangeImage);
}
this.buttonAspectRatio = Button.createLabelButton("keep aspect ratio");
this.buttonAspectRatio.setPropertyExpand(Vector3b.FALSE);
this.buttonAspectRatio.setPropertyFill(Vector3b.FALSE);
this.buttonAspectRatio.setPropertyMinSize(new Dimension3f(Vector3f.VALUE_16, Distance.PIXEL));
this.addButton(this.buttonAspectRatio);
addButton(this.buttonAspectRatio);
this.buttonAspectRatio.signalClick.connectAuto(this, MainWindows::eventButtonChangeKeepRatio);
}
}

View File

@ -153,8 +153,8 @@ public class CompositingSVG extends Compositing {
}
/**
* 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.
* Sometimes the user declare an image but not allocate the resources all the time, this is to know it ..
* @return the validity of the resources.
*/
public boolean hasSources() {
return this.resource != null;
@ -328,6 +328,10 @@ public class CompositingSVG extends Compositing {
setPos(new Vector3f(pos.x(), pos.y(), 0));
}
public void setPos(final Vector2i pos) {
setPos(new Vector3f(pos.x(), pos.y(), 0));
}
/**
* set position for the next text writen
* @param pos Position of the text (in 3D)
@ -364,6 +368,11 @@ public class CompositingSVG extends Compositing {
setSource(data, new Vector2i(size, size));
}
// public void setSource(final Uri data, final Vector2i size) {
// data
// setSource
// }
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()) {

View File

@ -701,7 +701,7 @@ public abstract class TextBase extends Compositing {
currentId = stop.value;
}
}
LOGGER.debug(" 4 print in not alligned mode : start=" + this.sizeDisplayStart + " stop="
LOGGER.trace(" 4 print in not alligned mode : start=" + this.sizeDisplayStart + " stop="
+ this.sizeDisplayStop + " pos=" + this.position);
}
}

View File

@ -1,12 +1,18 @@
package org.atriasoft.ewol.widget;
import java.io.IOException;
import org.atriasoft.aknot.annotation.AknotAttribute;
import org.atriasoft.aknot.annotation.AknotDescription;
import org.atriasoft.aknot.annotation.AknotManaged;
import org.atriasoft.aknot.annotation.AknotName;
import org.atriasoft.aknot.exception.AknotException;
import org.atriasoft.ejson.JsonMapper;
import org.atriasoft.ejson.exception.EjsonException;
import org.atriasoft.etk.Color;
import org.atriasoft.etk.Dimension1f;
import org.atriasoft.etk.Dimension2f;
import org.atriasoft.etk.Uri;
import org.atriasoft.etk.math.Vector2f;
import org.atriasoft.etk.math.Vector2i;
import org.atriasoft.etk.math.Vector3b;
@ -30,6 +36,15 @@ public class Box extends Container {
private static final Logger LOGGER = LoggerFactory.getLogger(Box.class);
protected CompositingSVG compositing = new CompositingSVG();
public static class BoxParameter {
public Float margin;
public Float padding;
public Float borderWidth;
public Float borderRadius;
public String borderColor;
public String color;
}
/**
* Periodic call to update grapgic display
* @param event Time generic event
@ -39,18 +54,42 @@ public class Box extends Container {
self.markToRedraw();
}
//private Uri propertyConfig = new Uri("THEME", "shape/Button.json", "ewol");
private final Uri propertyConfig = new Uri("THEME", "shape/Button.json", "ewol");
Vector2i startPosition = Vector2i.ZERO;
Vector2i endPosition = Vector2i.ZERO;
public boolean isInside(final Vector3f value) {
return value.x() > this.startPosition.x() //
&& value.y() > this.startPosition.y() //
&& value.x() < this.endPosition.x() //
&& value.y() < this.endPosition.y();
}
/**
* Constructor
*/
public Box() {}
public Box() {
updateBasicConfig();
}
/**
* Constructor with his subWidget
*/
public Box(final Widget subWidget) {
super(subWidget);
updateBasicConfig();
}
private void updateBasicConfig() {
final JsonMapper mapper = new JsonMapper();
try {
final BoxParameter parameters = mapper.read(BoxParameter.class, this.propertyConfig);
// TODO ...
} catch (EjsonException | AknotException | IOException e) {
e.printStackTrace();
}
}
protected Dimension1f propertyBorderWidth = Dimension1f.ZERO;
@ -169,6 +208,144 @@ public class Box extends Container {
@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);
Vector3f 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());
}
if (this.subWidget.canExpand().z() && this.propertyFill.z()) {
subWidgetSize = subWidgetSize.withZ(this.size.z());
} else {
subWidgetSize = subWidgetSize.withZ(this.minSize.z());
}
subWidgetSize = subWidgetSize.less(offsetSubWidget.x(), offsetSubWidget.y(), 0);
subWidgetSize = subWidgetSize.clipInteger();
// set config to the Sub-widget
//Vector3f subWidgetOrigin = this.origin.add(this.size.less(subWidgetSize).multiply(0.5f));
Vector3f subWidgetOrigin = this.origin
.add(this.propertyGravity.gravityGenerateDelta(this.size.less(subWidgetSize))).add(50);
// NOTE le add 150 est pour un pb de test ==> a nlever en prod ...
subWidgetOrigin = subWidgetOrigin.clipInteger();
this.subWidget.setOrigin(subWidgetOrigin);
this.subWidget.setSize(subWidgetSize);
this.subWidget.onChangeSize();
}
protected Vector2i renderOrigin;
protected Vector2i renderSize;
@Override
public void onRegenerateDisplay() {
super.onRegenerateDisplay();
if (!needRedraw()) {
//return;
}
final Vector2f localMargin = this.propertyMargin.size();
final Vector3f minSizeWithoutMargin = this.minSize.less(localMargin.x() * 2, localMargin.y() * 2, 0);
Vector3f tmpRenderSize = minSizeWithoutMargin;
Vector3f tmpRenderOrigin = this.propertyGravity.gravityGenerateDelta(this.size.less(minSizeWithoutMargin));
if (this.propertyFill.x()) {
tmpRenderSize = tmpRenderSize.withX(this.size.x());
tmpRenderOrigin = tmpRenderOrigin.withX(0.0f);
}
if (this.propertyFill.y()) {
tmpRenderSize = tmpRenderSize.withY(this.size.y());
tmpRenderOrigin = tmpRenderOrigin.withY(0.0f);
}
if (this.propertyFill.z()) {
tmpRenderSize = tmpRenderSize.withZ(this.size.y());
tmpRenderOrigin = tmpRenderOrigin.withZ(0.0f);
}
// 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());
// remove data of the previous composition :
this.compositing.clear();
final int borderSize = (int) this.propertyBorderWidth.size();
final int paddingCompensateBorder = Math.round(borderSize * 0.5f);
// this.renderSize = new Vector2i((int) (this.size.x() - this.propertyMargin.size().x() * 2),
// (int) (this.size.y() - this.propertyMargin.size().y() * 2));
// Bug intéressant: la parsing de la couleur est foireux, black et #000000FF ne rend pas la même chose ==> pour ètre plus précs le rendu avec alpha est foireux...
if (borderSize > 0.0f) {
this.compositing.setSource("""
<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, //
this.renderSize.x() - 2 * paddingCompensateBorder,
this.renderSize.y() - 2 * paddingCompensateBorder, //
(int) this.propertyBorderRadius.size(), //
(int) this.propertyBorderRadius.size(), //
this.propertyColor.toStringSharp(), //
this.propertyBorderColor.toStringSharp(), //
borderSize //
), //
this.renderSize);
} else {
this.compositing.setSource("""
<svg>
<rect
x="%d"
y="%d"
width="%d"
height="%d"
fill="%s"
/>
</svg>""".formatted( //
paddingCompensateBorder, paddingCompensateBorder, //
this.renderSize.x() - 2 * paddingCompensateBorder,
this.renderSize.y() - 2 * paddingCompensateBorder, //
this.propertyColor.toStringSharp() //
), //
this.renderSize);
}
this.compositing.setPos(this.renderOrigin);
// For events:
this.startPosition = this.renderOrigin;
this.endPosition = this.renderOrigin.add(this.renderSize);
this.compositing.print(this.renderSize);
// 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();
}
public void onChangeSize_____sdfgsdfqsdfqsdfqsdfsqdfqsdfqsdfsqdfsqdfqsdfqdfsqdfqsdfqsdfqsdfqsdfsqfgsdfg() {
super.onChangeSize();
if (this.propertyHide) {
return;
@ -193,22 +370,23 @@ public class Box extends Container {
@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());
final Vector2f childMinSize = 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 Vector2f padding = this.propertyPadding.size().multiply(2)
.max(new Vector2f(this.propertyBorderRadius.size() * 2 + this.propertyBorderWidth.size(),
this.propertyBorderRadius.size() * 2 + this.propertyBorderWidth.size()));
final Vector2f margin = this.propertyMargin.size().multiply(2);
final Vector3f minSize = this.propertyMinSize.size();
final Vector2f borderMinSize = parentMinSize.add(margin).add(padding).add(borderSize);
final Vector2f borderMinSize = childMinSize.add(margin).add(padding).add(borderSize);
final Vector2f calculatedBoxMinSize = Vector2f.max(borderMinSize, new Vector2f(minSize.x(), minSize.y()));
// LOGGER.debug("set widget min=" + this.minSize + " max=" + this.maxSize);
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();
}
@ -220,101 +398,4 @@ public class Box extends Container {
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

@ -6,20 +6,18 @@ import org.atriasoft.aknot.annotation.AknotManaged;
import org.atriasoft.aknot.annotation.AknotName;
import org.atriasoft.aknot.annotation.AknotSignal;
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.Uri;
import org.atriasoft.etk.math.Vector2f;
import org.atriasoft.etk.math.Vector3b;
import org.atriasoft.etk.math.Vector3f;
import org.atriasoft.ewol.Gravity;
import org.atriasoft.ewol.Padding;
import org.atriasoft.ewol.compositing.GuiShape;
import org.atriasoft.ewol.compositing.GuiShapeMode;
import org.atriasoft.ewol.compositing.ShapeBox;
import org.atriasoft.ewol.event.EventEntry;
import org.atriasoft.ewol.event.EventInput;
import org.atriasoft.ewol.event.EventTime;
import org.atriasoft.ewol.object.EwolObject;
import org.atriasoft.gale.key.KeyKeyboard;
import org.atriasoft.gale.key.KeyStatus;
import org.slf4j.Logger;
@ -35,16 +33,9 @@ import org.slf4j.LoggerFactory;
* ----------------------------------------------
* ~~~~~~~~~~~~~~~~~~~~~~
*/
public class Button extends ContainerToggle {
public class Button extends Box {
private static final Logger LOGGER = LoggerFactory.getLogger(Button.class);
public enum ButtonLock {
LOCK_NONE, //!< normal status of the button
LOCK_WHEN_PRESSED, //!< When the state is set in pressed, the status stay in this one
LOCK_WHEN_RELEASED, //!< When the state is set in not pressed, the status stay in this one
LOCK_ACCESS, //!< all event are trashed == > acctivity of the button is disable
}
public static Button createLabelButton(final String label) {
final Button out = new Button();
final Label labelWidget = new Label();
@ -53,41 +44,19 @@ public class Button extends ContainerToggle {
labelWidget.setPropertyExpand(Vector3b.FALSE);
labelWidget.setPropertyGravity(Gravity.CENTER);
labelWidget.setPropertyValue(label);
out.setSubWidget(labelWidget, 0);
return out;
}
public static Button createToggleLabelButton(final String label0, final String label1) {
final Button out = new Button();
{
final Label labelWidget = new Label();
labelWidget.setPropertyFill(Vector3b.FALSE);
labelWidget.setPropertyExpand(Vector3b.FALSE);
labelWidget.setPropertyGravity(Gravity.CENTER);
labelWidget.setPropertyValue(label0);
out.setSubWidget(labelWidget, 0);
}
{
final Label labelWidget = new Label();
labelWidget.setPropertyFill(Vector3b.FALSE);
labelWidget.setPropertyExpand(Vector3b.FALSE);
labelWidget.setPropertyGravity(Gravity.CENTER);
labelWidget.setPropertyValue(label1);
out.setSubWidget(labelWidget, 1);
}
out.setPropertyToggleMode(true);
out.setSubWidget(labelWidget);
return out;
}
/**
* Periodic call to update grapgic display
* Periodic call to update graphic display
* @param event Time generic event
*/
protected static void periodicCall(final Button self, final EventTime event) {
LOGGER.trace("Periodic call on Entry(" + event + ")");
if (!self.shape.periodicCall(event)) {
self.periodicConnectionHanble.close();
}
// if (!self.shape.periodicCall(event)) {
// self.periodicConnectionHanble.close();
// }
self.markToRedraw();
}
@ -95,13 +64,6 @@ public class Button extends ContainerToggle {
protected Connection periodicConnectionHanble = new Connection();
private Uri propertyConfig = new Uri("THEME", "shape/Button.json", "ewol");
private boolean propertyValue = false;
private ButtonLock propertyLock = ButtonLock.LOCK_NONE;
private boolean propertyToggleMode = false;
private boolean propertyEnableSingle = false;
protected ShapeBox shapeProperty = ShapeBox.ZERO;
private GuiShape shape;
@AknotSignal
@AknotName(value = "down")
@ -123,62 +85,27 @@ public class Button extends ContainerToggle {
@AknotName(value = "leave")
@AknotDescription("The cursor leave the button")
public SignalEmpty signalLeave = new SignalEmpty();
@AknotSignal
@AknotName(value = "value")
@AknotDescription("The button value change")
public Signal<Boolean> signalValue = new Signal<>();
private boolean buttonPressed = false;
private boolean mouseHover = false;
private final boolean mouseHover = false;
/**
* Constructor
*/
public Button() {
this.propertyCanFocus = true;
onChangePropertyShaper();
//onChangePropertyShaper();
// can not support multiple click...
setMouseLimit(1);
}
setPropertyExpand(Vector3b.TRUE);
setPropertyFill(Vector3b.TRUE);
setPropertyBorderWidth(new Dimension1f(4));
//setPropertyBorderRadius(new Dimension1f(15));
setPropertyBorderColor(Color.BLACK);
setPropertyColor(Color.WHITE);
setPropertyPadding(new Dimension2f(new Vector2f(3, 3)));
setPropertyMargin(new Dimension2f(new Vector2f(0, 0)));
@Override
public void calculateMinMaxSize() {
// call main class
super.calculateMinMaxSize();
// get generic padding
Padding padding = Padding.ZERO;
if (this.shape != null) {
padding = this.shape.getPadding();
}
calculateMinMaxSizePadded(padding);
LOGGER.trace("[{}] Result min size : {}", getId(), this.minSize);
}
protected void changeStatusIn(final GuiShapeMode newStatusId) {
if (this.shape.changeStatusIn(newStatusId)) {
if (!this.periodicConnectionHanble.isConnected()) {
//LOGGER.error("REQUEST: connection on periodic call");
this.periodicConnectionHanble = EwolObject.getObjectManager().periodicCall.connect(this,
Button::periodicCall);
}
markToRedraw();
}
}
void checkStatus() {
if (this.buttonPressed) {
changeStatusIn(GuiShapeMode.SELECT);
return;
}
if (this.mouseHover) {
changeStatusIn(GuiShapeMode.OVER);
return;
}
if (this.propertyValue) {
changeStatusIn(GuiShapeMode.NORMAL);
}
changeStatusIn(GuiShapeMode.NONE);
}
@AknotManaged
@ -189,122 +116,6 @@ public class Button extends ContainerToggle {
return this.propertyConfig;
}
@AknotManaged
@AknotAttribute
@AknotName(value = "lock")
@AknotDescription(value = "Lock the button in a special state to permit changing state only by the coder")
public ButtonLock getPropertyLock() {
return this.propertyLock;
}
@AknotManaged
@AknotAttribute
@AknotName(value = "value")
@AknotDescription(value = "Value display in the entry (decorated text)")
public boolean getPropertyValue() {
return this.propertyValue;
}
@AknotManaged
@AknotAttribute
@AknotName(value = "enable-single")
@AknotDescription(value = "If one element set in the Button ==> display only set")
public boolean isPropertyEnableSingle() {
return this.propertyEnableSingle;
}
@AknotManaged
@AknotAttribute
@AknotName(value = "toggle")
@AknotDescription(value = "The button can toggle")
public boolean isPropertyToggleMode() {
return this.propertyToggleMode;
}
void onChangePropertyEnableSingle() {
if (this.propertyEnableSingle) {
if (this.idWidgetDisplayed == 0 && this.subWidget[0] == null && this.subWidget[1] != null) {
this.idWidgetDisplayed = 1;
} else if (this.idWidgetDisplayed == 1 && this.subWidget[1] == null && this.subWidget[0] != null) {
this.idWidgetDisplayed = 0;
} else if (this.subWidget[0] == null && this.subWidget[1] == null) {
this.idWidgetDisplayed = 0;
}
}
}
void onChangePropertyLock() {
if (ButtonLock.LOCK_ACCESS == this.propertyLock) {
this.buttonPressed = false;
this.mouseHover = false;
}
checkStatus();
markToRedraw();
}
protected void onChangePropertyShaper() {
if (this.shape == null) {
this.shape = new GuiShape(this.propertyConfig);
} else {
this.shape.setSource(this.propertyConfig);
}
markToRedraw();
}
void onChangePropertyToggleMode() {
this.propertyValue = !this.propertyValue;
this.signalValue.emit(this.propertyValue);
if (!this.propertyToggleMode) {
this.idWidgetDisplayed = 0;
} else if (!this.propertyValue) {
this.idWidgetDisplayed = 0;
} else {
this.idWidgetDisplayed = 1;
}
if (this.propertyEnableSingle) {
if (this.idWidgetDisplayed == 0 && this.subWidget[0] == null && this.subWidget[1] != null) {
this.idWidgetDisplayed = 1;
} else if (this.idWidgetDisplayed == 1 && this.subWidget[1] == null && this.subWidget[0] != null) {
this.idWidgetDisplayed = 0;
}
}
checkStatus();
markToRedraw();
}
protected void onChangePropertyValue() {
if (this.propertyToggleMode) {
if (!this.propertyValue) {
this.idWidgetDisplayed = 0;
} else {
this.idWidgetDisplayed = 1;
}
}
if (this.propertyEnableSingle) {
if (this.idWidgetDisplayed == 0 && this.subWidget[0] == null && this.subWidget[1] != null) {
this.idWidgetDisplayed = 1;
} else if (this.idWidgetDisplayed == 1 && this.subWidget[1] == null && this.subWidget[0] != null) {
this.idWidgetDisplayed = 0;
}
}
checkStatus();
markToRedraw();
}
@Override
public void onChangeSize() {
final Padding padding = this.shape.getPadding();
onChangeSizePadded(padding);
}
@Override
protected void onDraw() {
if (this.shape != null) {
this.shape.draw(true);
}
super.onDraw();
}
@Override
protected boolean onEventEntry(final EventEntry event) {
//LOGGER.debug("BT PRESSED : \"" << UTF8_data << "\" size=" << strlen(UTF8_data));
@ -318,26 +129,26 @@ public class Button extends ContainerToggle {
@Override
public boolean onEventInput(final EventInput event) {
final Vector3f relPos = relativePosition(new Vector3f(event.pos().x(), event.pos().y(), 0));
LOGGER.warn("Event on Input ... " + event + " relPos = " + relPos);
final boolean over = this.shapeProperty.isInside(relPos);
//LOGGER.warn("Event on Input ... " + event + " relPos = " + relPos);
final boolean over = isInside(relPos);
//filter if outside the element...
if (event.status() == KeyStatus.leave) {
changeStatusIn(GuiShapeMode.NORMAL);
// changeStatusIn(GuiShapeMode.NORMAL);
this.buttonPressed = false;
return true;
}
if (event.inputId() == 0) {
if (!this.buttonPressed) {
if (KeyStatus.leave == event.status()) {
changeStatusIn(GuiShapeMode.NORMAL);
} else {
LOGGER.trace("Detect Over : " + this.shapeProperty);
if (over) {
changeStatusIn(GuiShapeMode.OVER);
} else {
changeStatusIn(GuiShapeMode.NORMAL);
}
}
// if (KeyStatus.leave == event.status()) {
// changeStatusIn(GuiShapeMode.NORMAL);
// } else {
// LOGGER.trace("Detect Over : " + this.shapeProperty);
// if (over) {
// changeStatusIn(GuiShapeMode.OVER);
// } else {
// changeStatusIn(GuiShapeMode.NORMAL);
// }
// }
return true;
}
}
@ -347,18 +158,14 @@ public class Button extends ContainerToggle {
if (KeyStatus.pressSingle == event.status() && over) {
keepFocus();
this.signalClick.emit();
if (this.propertyToggleMode) {
setPropertyValue(!this.propertyValue);
} else {
setPropertyValue(!this.propertyValue);
setPropertyValue(!this.propertyValue);
}
LOGGER.info("Generate click event !!!!!!!!!!");
/////// setPropertyValue(!this.propertyValue);
return true;
}
if (KeyStatus.down == event.status() && over) {
keepFocus();
this.buttonPressed = true;
changeStatusIn(GuiShapeMode.SELECT);
///// changeStatusIn(GuiShapeMode.SELECT);
markToRedraw();
this.signalDown.emit();
return true;
@ -372,7 +179,7 @@ public class Button extends ContainerToggle {
keepFocus();
this.buttonPressed = false;
this.signalUp.emit();
changeStatusIn(GuiShapeMode.OVER);
////// changeStatusIn(GuiShapeMode.OVER);
markToRedraw();
return true;
}
@ -383,48 +190,7 @@ public class Button extends ContainerToggle {
protected void onLostFocus() {
this.buttonPressed = false;
LOGGER.trace(this.name + " : Remove Focus ...");
checkStatus();
}
@Override
public void onRegenerateDisplay() {
super.onRegenerateDisplay();
if (!needRedraw()) {
//return;
}
//LOGGER.trace("Regenerate Display ==> is needed: '" + this.propertyValue + "'");
this.shape.clear();
final Padding padding = this.shape.getPadding();
Vector3f tmpSizeShaper = this.minSize;
Vector3f delta = this.propertyGravity.gravityGenerateDelta(this.size.less(this.minSize));
if (this.propertyFill.x()) {
tmpSizeShaper = tmpSizeShaper.withX(this.size.x());
delta = delta.withX(0.0f);
}
if (this.propertyFill.y()) {
tmpSizeShaper = tmpSizeShaper.withY(this.size.y());
delta = delta.withY(0.0f);
}
if (this.propertyFill.z()) {
tmpSizeShaper = tmpSizeShaper.withZ(this.size.y());
delta = delta.withZ(0.0f);
}
Vector3f tmpOriginShaper = delta;
Vector3f tmpSizeText = tmpSizeShaper.less(padding.x(), padding.y(), padding.z());
//Vector3f tmpOriginText = this.size.less(tmpSizeText).multiply(0.5f);
Vector3f tmpOriginText = new Vector3f(0, 0, 0);
// not sure this is needed...
tmpSizeShaper = tmpSizeShaper.clipInteger();
tmpOriginShaper = tmpOriginShaper.clipInteger();
tmpSizeText = tmpSizeText.clipInteger();
tmpOriginText = tmpOriginText.clipInteger();
this.shapeProperty = new ShapeBox(tmpOriginShaper, tmpSizeShaper, padding);
this.shape.setShape(tmpOriginShaper, tmpSizeShaper, tmpOriginText, tmpSizeText);
this.shape.flush();
//checkStatus();
}
public void setPropertyConfig(final Uri propertyConfig) {
@ -432,31 +198,6 @@ public class Button extends ContainerToggle {
return;
}
this.propertyConfig = propertyConfig;
onChangePropertyShaper();
//onChangePropertyShaper();
}
public void setPropertyEnableSingle(final boolean propertyEnableSingle) {
this.propertyEnableSingle = propertyEnableSingle;
markToRedraw();
}
public void setPropertyLock(final ButtonLock propertyLock) {
this.propertyLock = propertyLock;
markToRedraw();
}
public void setPropertyToggleMode(final boolean propertyToggleMode) {
this.propertyToggleMode = propertyToggleMode;
markToRedraw();
}
public void setPropertyValue(final boolean propertyValue) {
if (this.propertyValue == propertyValue) {
return;
}
this.propertyValue = propertyValue;
this.signalValue.emit(this.propertyValue);
onChangePropertyValue();
}
}

View File

@ -0,0 +1,462 @@
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.aknot.annotation.AknotSignal;
import org.atriasoft.esignal.Connection;
import org.atriasoft.esignal.Signal;
import org.atriasoft.esignal.SignalEmpty;
import org.atriasoft.etk.Uri;
import org.atriasoft.etk.math.Vector3b;
import org.atriasoft.etk.math.Vector3f;
import org.atriasoft.ewol.Gravity;
import org.atriasoft.ewol.Padding;
import org.atriasoft.ewol.compositing.GuiShape;
import org.atriasoft.ewol.compositing.GuiShapeMode;
import org.atriasoft.ewol.compositing.ShapeBox;
import org.atriasoft.ewol.event.EventEntry;
import org.atriasoft.ewol.event.EventInput;
import org.atriasoft.ewol.event.EventTime;
import org.atriasoft.ewol.object.EwolObject;
import org.atriasoft.gale.key.KeyKeyboard;
import org.atriasoft.gale.key.KeyStatus;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* @ingroup ewolWidgetGroup
* Entry box display :
*
* ~~~~~~~~~~~~~~~~~~~~~~
* ----------------------------------------------
* | Text Label |
* ----------------------------------------------
* ~~~~~~~~~~~~~~~~~~~~~~
*/
public class Button_old extends ContainerToggle {
private static final Logger LOGGER = LoggerFactory.getLogger(Button_old.class);
public enum ButtonLock {
LOCK_NONE, //!< normal status of the button
LOCK_WHEN_PRESSED, //!< When the state is set in pressed, the status stay in this one
LOCK_WHEN_RELEASED, //!< When the state is set in not pressed, the status stay in this one
LOCK_ACCESS, //!< all event are trashed == > acctivity of the button is disable
}
public static Button_old createLabelButton(final String label) {
final Button_old out = new Button_old();
final Label labelWidget = new Label();
labelWidget.setPropertyFontSize(12);
labelWidget.setPropertyFill(Vector3b.FALSE);
labelWidget.setPropertyExpand(Vector3b.FALSE);
labelWidget.setPropertyGravity(Gravity.CENTER);
labelWidget.setPropertyValue(label);
out.setSubWidget(labelWidget, 0);
return out;
}
public static Button_old createToggleLabelButton(final String label0, final String label1) {
final Button_old out = new Button_old();
{
final Label labelWidget = new Label();
labelWidget.setPropertyFill(Vector3b.FALSE);
labelWidget.setPropertyExpand(Vector3b.FALSE);
labelWidget.setPropertyGravity(Gravity.CENTER);
labelWidget.setPropertyValue(label0);
out.setSubWidget(labelWidget, 0);
}
{
final Label labelWidget = new Label();
labelWidget.setPropertyFill(Vector3b.FALSE);
labelWidget.setPropertyExpand(Vector3b.FALSE);
labelWidget.setPropertyGravity(Gravity.CENTER);
labelWidget.setPropertyValue(label1);
out.setSubWidget(labelWidget, 1);
}
out.setPropertyToggleMode(true);
return out;
}
/**
* Periodic call to update grapgic display
* @param event Time generic event
*/
protected static void periodicCall(final Button_old self, final EventTime event) {
LOGGER.trace("Periodic call on Entry(" + event + ")");
if (!self.shape.periodicCall(event)) {
self.periodicConnectionHanble.close();
}
self.markToRedraw();
}
/// Periodic call handle to remove it when needed
protected Connection periodicConnectionHanble = new Connection();
private Uri propertyConfig = new Uri("THEME", "shape/Button.json", "ewol");
private boolean propertyValue = false;
private ButtonLock propertyLock = ButtonLock.LOCK_NONE;
private boolean propertyToggleMode = false;
private boolean propertyEnableSingle = false;
protected ShapeBox shapeProperty = ShapeBox.ZERO;
private GuiShape shape;
@AknotSignal
@AknotName(value = "down")
@AknotDescription("Button is Down")
public SignalEmpty signalDown = new SignalEmpty();
@AknotSignal
@AknotName(value = "up")
@AknotDescription("Button is Up")
public SignalEmpty signalUp = new SignalEmpty();
@AknotSignal
@AknotName(value = "click")
@AknotDescription("Button is Clicked")
public SignalEmpty signalClick = new SignalEmpty();
@AknotSignal
@AknotName(value = "enter")
@AknotDescription("The cursor enter inside the button")
public SignalEmpty signalEnter = new SignalEmpty();
@AknotSignal
@AknotName(value = "leave")
@AknotDescription("The cursor leave the button")
public SignalEmpty signalLeave = new SignalEmpty();
@AknotSignal
@AknotName(value = "value")
@AknotDescription("The button value change")
public Signal<Boolean> signalValue = new Signal<>();
private boolean buttonPressed = false;
private boolean mouseHover = false;
/**
* Constructor
*/
public Button_old() {
this.propertyCanFocus = true;
onChangePropertyShaper();
// can not support multiple click...
setMouseLimit(1);
}
@Override
public void calculateMinMaxSize() {
// call main class
super.calculateMinMaxSize();
// get generic padding
Padding padding = Padding.ZERO;
if (this.shape != null) {
padding = this.shape.getPadding();
}
calculateMinMaxSizePadded(padding);
LOGGER.trace("[{}] Result min size : {}", getId(), this.minSize);
}
protected void changeStatusIn(final GuiShapeMode newStatusId) {
if (this.shape.changeStatusIn(newStatusId)) {
if (!this.periodicConnectionHanble.isConnected()) {
//LOGGER.error("REQUEST: connection on periodic call");
this.periodicConnectionHanble = EwolObject.getObjectManager().periodicCall.connect(this,
Button_old::periodicCall);
}
markToRedraw();
}
}
void checkStatus() {
if (this.buttonPressed) {
changeStatusIn(GuiShapeMode.SELECT);
return;
}
if (this.mouseHover) {
changeStatusIn(GuiShapeMode.OVER);
return;
}
if (this.propertyValue) {
changeStatusIn(GuiShapeMode.NORMAL);
}
changeStatusIn(GuiShapeMode.NONE);
}
@AknotManaged
@AknotAttribute
@AknotName(value = "config")
@AknotDescription(value = "configuration of the widget")
public Uri getPropertyConfig() {
return this.propertyConfig;
}
@AknotManaged
@AknotAttribute
@AknotName(value = "lock")
@AknotDescription(value = "Lock the button in a special state to permit changing state only by the coder")
public ButtonLock getPropertyLock() {
return this.propertyLock;
}
@AknotManaged
@AknotAttribute
@AknotName(value = "value")
@AknotDescription(value = "Value display in the entry (decorated text)")
public boolean getPropertyValue() {
return this.propertyValue;
}
@AknotManaged
@AknotAttribute
@AknotName(value = "enable-single")
@AknotDescription(value = "If one element set in the Button ==> display only set")
public boolean isPropertyEnableSingle() {
return this.propertyEnableSingle;
}
@AknotManaged
@AknotAttribute
@AknotName(value = "toggle")
@AknotDescription(value = "The button can toggle")
public boolean isPropertyToggleMode() {
return this.propertyToggleMode;
}
void onChangePropertyEnableSingle() {
if (this.propertyEnableSingle) {
if (this.idWidgetDisplayed == 0 && this.subWidget[0] == null && this.subWidget[1] != null) {
this.idWidgetDisplayed = 1;
} else if (this.idWidgetDisplayed == 1 && this.subWidget[1] == null && this.subWidget[0] != null) {
this.idWidgetDisplayed = 0;
} else if (this.subWidget[0] == null && this.subWidget[1] == null) {
this.idWidgetDisplayed = 0;
}
}
}
void onChangePropertyLock() {
if (ButtonLock.LOCK_ACCESS == this.propertyLock) {
this.buttonPressed = false;
this.mouseHover = false;
}
checkStatus();
markToRedraw();
}
protected void onChangePropertyShaper() {
if (this.shape == null) {
this.shape = new GuiShape(this.propertyConfig);
} else {
this.shape.setSource(this.propertyConfig);
}
markToRedraw();
}
void onChangePropertyToggleMode() {
this.propertyValue = !this.propertyValue;
this.signalValue.emit(this.propertyValue);
if (!this.propertyToggleMode) {
this.idWidgetDisplayed = 0;
} else if (!this.propertyValue) {
this.idWidgetDisplayed = 0;
} else {
this.idWidgetDisplayed = 1;
}
if (this.propertyEnableSingle) {
if (this.idWidgetDisplayed == 0 && this.subWidget[0] == null && this.subWidget[1] != null) {
this.idWidgetDisplayed = 1;
} else if (this.idWidgetDisplayed == 1 && this.subWidget[1] == null && this.subWidget[0] != null) {
this.idWidgetDisplayed = 0;
}
}
checkStatus();
markToRedraw();
}
protected void onChangePropertyValue() {
if (this.propertyToggleMode) {
if (!this.propertyValue) {
this.idWidgetDisplayed = 0;
} else {
this.idWidgetDisplayed = 1;
}
}
if (this.propertyEnableSingle) {
if (this.idWidgetDisplayed == 0 && this.subWidget[0] == null && this.subWidget[1] != null) {
this.idWidgetDisplayed = 1;
} else if (this.idWidgetDisplayed == 1 && this.subWidget[1] == null && this.subWidget[0] != null) {
this.idWidgetDisplayed = 0;
}
}
checkStatus();
markToRedraw();
}
@Override
public void onChangeSize() {
final Padding padding = this.shape.getPadding();
onChangeSizePadded(padding);
}
@Override
protected void onDraw() {
if (this.shape != null) {
this.shape.draw(true);
}
super.onDraw();
}
@Override
protected boolean onEventEntry(final EventEntry event) {
//LOGGER.debug("BT PRESSED : \"" << UTF8_data << "\" size=" << strlen(UTF8_data));
if (event.type() == KeyKeyboard.CHARACTER && event.status() == KeyStatus.down && event.getChar() == '\r') {
this.signalEnter.emit();
return true;
}
return super.onEventEntry(event);
}
@Override
public boolean onEventInput(final EventInput event) {
final Vector3f relPos = relativePosition(new Vector3f(event.pos().x(), event.pos().y(), 0));
LOGGER.warn("Event on Input ... " + event + " relPos = " + relPos);
final boolean over = this.shapeProperty.isInside(relPos);
//filter if outside the element...
if (event.status() == KeyStatus.leave) {
changeStatusIn(GuiShapeMode.NORMAL);
this.buttonPressed = false;
return true;
}
if (event.inputId() == 0) {
if (!this.buttonPressed) {
if (KeyStatus.leave == event.status()) {
changeStatusIn(GuiShapeMode.NORMAL);
} else {
LOGGER.trace("Detect Over : " + this.shapeProperty);
if (over) {
changeStatusIn(GuiShapeMode.OVER);
} else {
changeStatusIn(GuiShapeMode.NORMAL);
}
}
return true;
}
}
if (event.inputId() != 1) {
return false;
}
if (KeyStatus.pressSingle == event.status() && over) {
keepFocus();
this.signalClick.emit();
if (this.propertyToggleMode) {
setPropertyValue(!this.propertyValue);
} else {
setPropertyValue(!this.propertyValue);
setPropertyValue(!this.propertyValue);
}
return true;
}
if (KeyStatus.down == event.status() && over) {
keepFocus();
this.buttonPressed = true;
changeStatusIn(GuiShapeMode.SELECT);
markToRedraw();
this.signalDown.emit();
return true;
}
if (KeyStatus.move == event.status() && over) {
keepFocus();
markToRedraw();
return true;
}
if (KeyStatus.up == event.status() && this.buttonPressed) {
keepFocus();
this.buttonPressed = false;
this.signalUp.emit();
changeStatusIn(GuiShapeMode.OVER);
markToRedraw();
return true;
}
return false;
}
@Override
protected void onLostFocus() {
this.buttonPressed = false;
LOGGER.trace(this.name + " : Remove Focus ...");
checkStatus();
}
@Override
public void onRegenerateDisplay() {
super.onRegenerateDisplay();
if (!needRedraw()) {
//return;
}
//LOGGER.trace("Regenerate Display ==> is needed: '" + this.propertyValue + "'");
this.shape.clear();
final Padding padding = this.shape.getPadding();
Vector3f tmpSizeShaper = this.minSize;
Vector3f delta = this.propertyGravity.gravityGenerateDelta(this.size.less(this.minSize));
if (this.propertyFill.x()) {
tmpSizeShaper = tmpSizeShaper.withX(this.size.x());
delta = delta.withX(0.0f);
}
if (this.propertyFill.y()) {
tmpSizeShaper = tmpSizeShaper.withY(this.size.y());
delta = delta.withY(0.0f);
}
if (this.propertyFill.z()) {
tmpSizeShaper = tmpSizeShaper.withZ(this.size.y());
delta = delta.withZ(0.0f);
}
Vector3f tmpOriginShaper = delta;
Vector3f tmpSizeText = tmpSizeShaper.less(padding.x(), padding.y(), padding.z());
//Vector3f tmpOriginText = this.size.less(tmpSizeText).multiply(0.5f);
Vector3f tmpOriginText = new Vector3f(0, 0, 0);
// not sure this is needed...
tmpSizeShaper = tmpSizeShaper.clipInteger();
tmpOriginShaper = tmpOriginShaper.clipInteger();
tmpSizeText = tmpSizeText.clipInteger();
tmpOriginText = tmpOriginText.clipInteger();
this.shapeProperty = new ShapeBox(tmpOriginShaper, tmpSizeShaper, padding);
this.shape.setShape(tmpOriginShaper, tmpSizeShaper, tmpOriginText, tmpSizeText);
this.shape.flush();
}
public void setPropertyConfig(final Uri propertyConfig) {
if (this.propertyConfig.equals(propertyConfig)) {
return;
}
this.propertyConfig = propertyConfig;
onChangePropertyShaper();
}
public void setPropertyEnableSingle(final boolean propertyEnableSingle) {
this.propertyEnableSingle = propertyEnableSingle;
markToRedraw();
}
public void setPropertyLock(final ButtonLock propertyLock) {
this.propertyLock = propertyLock;
markToRedraw();
}
public void setPropertyToggleMode(final boolean propertyToggleMode) {
this.propertyToggleMode = propertyToggleMode;
markToRedraw();
}
public void setPropertyValue(final boolean propertyValue) {
if (this.propertyValue == propertyValue) {
return;
}
this.propertyValue = propertyValue;
this.signalValue.emit(this.propertyValue);
onChangePropertyValue();
}
}

View File

@ -46,7 +46,7 @@ public class Container extends Widget {
final Vector3f min = this.subWidget.getCalculateMinSize();
this.minSize = Vector3f.max(this.minSize, min);
}
LOGGER.warn("[{}] Result min size : {}", getId(), this.minSize);
LOGGER.trace("[{}] Result min size : {}", getId(), this.minSize);
}
@Override

View File

@ -145,13 +145,13 @@ public class Entry extends Widget {
this.minSize = Vector3f.max(this.minSize, minimumSizeBase);
// verify the min max of the min size ...
checkMinSize();
LOGGER.error("min size = " + this.minSize);
//LOGGER.trace("min size = " + this.minSize);
}
protected void changeStatusIn(final GuiShapeMode newStatusId) {
if (this.shape.changeStatusIn(newStatusId)) {
if (!this.periodicConnectionHanble.isConnected()) {
LOGGER.error("REQUEST: connection on operiodic call");
//LOGGER.trace("REQUEST: connection on operiodic call");
this.periodicConnectionHanble = EwolObject.getObjectManager().periodicCall.connect(this,
Entry::periodicCall);
}
@ -819,7 +819,7 @@ public class Entry extends Widget {
} else {
// check if the Cursor is visible at 10px nearest the border :
final int tmp1 = this.displayCursorPositionPixel + this.displayStartPosition;
LOGGER.debug(
LOGGER.trace(
"cursorPos=" + this.displayCursorPositionPixel + "px maxSize=" + tmpUserSize + "px tmp1=" + tmp1);
if (tmp1 < 10) {
// set the cursor on the left

View File

@ -62,10 +62,10 @@ public class Spin extends SpinBase {
this.connectionEntry = this.widgetEntry.signalModify.connect(this, Spin::onCallbackModify);
}
if (this.widgetButtonUp != null && !this.connectionButtonUp.isConnected()) {
this.connectionButtonUp = this.widgetButtonUp.signalValue.connect(this, Spin::onCallbackUp);
this.connectionButtonUp = this.widgetButtonUp.signalClick.connect(this, Spin::onCallbackUp);
}
if (this.widgetButtonDown != null && !this.connectionButtonDown.isConnected()) {
this.connectionButtonDown = this.widgetButtonDown.signalValue.connect(this, Spin::onCallbackDown);
this.connectionButtonDown = this.widgetButtonDown.signalClick.connect(this, Spin::onCallbackDown);
}
checkValue(this.propertyValue);
LOGGER.warn("updateGui [STOP]");
@ -111,10 +111,8 @@ public class Spin extends SpinBase {
return this.propertyValue;
}
protected void onCallbackDown(final Boolean value) {
if (value) {
return;
}
protected void onCallbackDown() {
LOGGER.warn("lkjlkjljlkjlkjlkjlkjlkjlklkjlkjlkj {}");
final long data = this.propertyValue - this.propertyIncrement;
checkValue(data);
}
@ -131,10 +129,7 @@ public class Spin extends SpinBase {
}
}
protected void onCallbackUp(final Boolean value) {
if (value) {
return;
}
protected void onCallbackUp() {
final long data = this.propertyValue + this.propertyIncrement;
checkValue(data);
}

View File

@ -8,15 +8,19 @@ import org.atriasoft.aknot.annotation.AknotSignal;
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.Uri;
import org.atriasoft.etk.math.Vector2f;
import org.atriasoft.etk.math.Vector3b;
import org.atriasoft.etk.math.Vector3f;
import org.atriasoft.etk.math.Vector3i;
import org.atriasoft.ewol.Padding;
import org.atriasoft.ewol.compositing.GuiShape;
import org.atriasoft.ewol.compositing.CompositingSVG;
import org.atriasoft.ewol.compositing.GuiShapeMode;
import org.atriasoft.ewol.event.EventInput;
import org.atriasoft.ewol.event.EventTime;
import org.atriasoft.ewol.object.EwolObject;
import org.atriasoft.gale.key.KeyStatus;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -40,21 +44,9 @@ public Signal<Boolean> signalValue;
public boolean propertyValue; //!< Current state of the Tick.
public Uri> propertyShape; //!< shape of the widget
*/
public class Tick extends Widget {
public class Tick extends Box {
private static final Logger LOGGER = LoggerFactory.getLogger(Tick.class);
/**
* Periodic call to update grapgic display
* @param _event Time generic event
*/
protected static void periodicCall(final Tick self, final EventTime event) {
LOGGER.trace("Periodic call on Entry(" + event + ")");
if (!self.shape.periodicCall(event)) {
//LOGGER.error("end periodic call");
self.periodicConnectionHanble.close();
}
self.markToRedraw();
}
protected CompositingSVG compositingTick = new CompositingSVG();
/// color property of the text foreground
private int colorIdTextFg;
@ -63,10 +55,11 @@ public class Tick extends Widget {
/// Periodic call handle to remove it when needed
protected Connection periodicConnectionHanble = new Connection();
private 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 Boolean propertyValue = false; //!< string that must be displayed
private GuiShape shape;
@AknotSignal
@AknotName("down")
@AknotDescription("Tick is Down")
@ -94,10 +87,19 @@ public class Tick extends Widget {
*/
public Tick() {
this.propertyCanFocus = true;
onChangePropertyShaper();
markToRedraw();
// can not support multiple click...
setMouseLimit(1);
setPropertyExpand(Vector3b.FALSE);
setPropertyFill(Vector3b.TRUE);
setPropertyMinSize(new Dimension3f(new Vector3f(32f, 32f, 32f)));
setPropertyBorderWidth(new Dimension1f(4));
//setPropertyBorderRadius(new Dimension1f(15));
setPropertyBorderColor(Color.BLACK);
setPropertyColor(Color.WHITE);
setPropertyPadding(new Dimension2f(new Vector2f(3, 3)));
setPropertyMargin(new Dimension2f(new Vector2f(0, 0)));
}
@Override
@ -105,10 +107,7 @@ public class Tick extends Widget {
// call main class
super.calculateMinMaxSize();
// get generic padding
Padding padding = Padding.ZERO;
if (this.shape != null) {
padding = this.shape.getPadding();
}
final Padding padding = Padding.ZERO;
final Vector3i minHeight = Vector3i.VALUE_16;
Vector3f minimumSizeBase = new Vector3f(minHeight.x(), minHeight.y(), minHeight.z());
@ -121,14 +120,14 @@ public class Tick extends Widget {
}
protected void changeStatusIn(final GuiShapeMode newStatusId) {
if (this.shape.changeStatusIn(newStatusId)) {
if (!this.periodicConnectionHanble.isConnected()) {
//LOGGER.error("REQUEST: connection on periodic call");
this.periodicConnectionHanble = EwolObject.getObjectManager().periodicCall.connect(this,
Tick::periodicCall);
}
markToRedraw();
}
// if (this.shape.changeStatusIn(newStatusId)) {
// if (!this.periodicConnectionHanble.isConnected()) {
// //LOGGER.error("REQUEST: connection on periodic call");
// this.periodicConnectionHanble = EwolObject.getObjectManager().periodicCall.connect(this,
// Tick::periodicCall);
// }
// markToRedraw();
// }
}
private boolean checkIfOver(final Vector3f relPos) {
@ -136,14 +135,6 @@ public class Tick extends Widget {
&& 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
@AknotAttribute
@AknotName("value")
@ -152,14 +143,6 @@ public class Tick extends Widget {
return this.propertyValue;
}
protected void onChangePropertyShaper() {
if (this.shape == null) {
this.shape = new GuiShape(this.propertyConfig);
} else {
this.shape.setSource(this.propertyConfig);
}
}
protected void onChangePropertyTextWhenNothing() {
markToRedraw();
}
@ -171,16 +154,22 @@ public class Tick extends Widget {
@Override
protected void onDraw() {
if (this.shape != null) {
this.shape.draw(true, this.propertyValue ? 0 : 1);
super.onDraw();
if (this.propertyValue) {
if (this.compositingTick != null) {
this.compositingTick.draw(true);
}
}
// if (this.shape != null) {
// this.shape.draw(true, this.propertyValue ? 0 : 1);
// }
}
@Override
public boolean onEventInput(final EventInput event) {
final Vector3f positionAbsolute = new Vector3f(event.pos().x(), event.pos().y(), 0);
final Vector3f relPos = relativePosition(positionAbsolute);
LOGGER.warn("Event on Input ... " + event + " relPos = " + relPos);
LOGGER.trace("Event on Input ... " + event + " relPos = " + relPos);
final boolean over = checkIfOver(relPos);
//filter if outside the element...
if (event.status() == KeyStatus.leave) {
@ -238,61 +227,15 @@ public class Tick extends Widget {
@Override
public void onRegenerateDisplay() {
super.onRegenerateDisplay();
if (!needRedraw()) {
//return;
}
//LOGGER.trace("Regenerate Display ==> is needed: '" + this.propertyValue + "'");
this.shape.clear();
//this.gc.clear();
if (this.colorIdTextFg >= 0) {
//this.text.setDefaultColorFg(this.shape.getColor(this.colorIdTextFg));
//this.text.setDefaultColorBg(this.shape.getColor(this.colorIdTextBg));
//this.text.setCursorColor(this.shape.getColor(this.colorIdCursor));
//this.text.setSelectionColor(this.shape.getColor(this.colorIdSelection));
}
final Padding padding = this.shape.getPadding();
Vector3f tmpSizeShaper = this.minSize;
Vector3f delta = this.propertyGravity.gravityGenerateDelta(this.size.less(this.minSize));
if (this.propertyFill.x()) {
tmpSizeShaper = tmpSizeShaper.withX(this.size.x());
delta = delta.withX(0.0f);
}
if (this.propertyFill.y()) {
tmpSizeShaper = tmpSizeShaper.withY(this.size.y());
delta = delta.withY(0.0f);
}
Vector3f tmpOriginShaper = delta;
Vector3f tmpSizeInside = tmpSizeShaper.less(padding.x(), padding.y(), padding.z());
//Vector3f tmpOriginText = this.size.less(tmpSizeText).multiply(0.5f);
Vector3f tmpOriginInside = Vector3f.ZERO;//this.gc.getTextSize());
// sometimes, the user define an height bigger than the real size needed == > in this case we need to center the text in the shaper ...
/*
int minHeight = this.gc.getTextHeight();
if (tmpSizeText.y() > minHeight) {
tmpOriginText = tmpOriginText.add(0, (tmpSizeText.y() - minHeight) * 0.5f);
}
*/
// fix all the position in the int class:
tmpSizeShaper = Vector3f.clipInt(tmpSizeShaper);
tmpOriginShaper = Vector3f.clipInt(tmpOriginShaper);
tmpSizeInside = Vector3f.clipInt(tmpSizeInside);
tmpOriginInside = Vector3f.clipInt(tmpOriginInside);
//this.gc.clear();
//this.gc.setSize((int)tmpSizeText.x(), (int)tmpSizeText.y());
//this.gc.setColorFill(Color.BLACK);
//this.gc.setColorStroke(Color.NONE);
//this.gc.setStrokeWidth(1);
//this.gc.text(tmpOriginText, this.propertyValue);
this.overPositionStart = tmpOriginShaper;
this.overPositionStop = tmpOriginShaper.add(tmpSizeShaper);
this.shape.setShape(tmpOriginShaper, tmpSizeShaper, tmpOriginInside, tmpSizeInside);
//this.gc.flush();
this.shape.flush();
this.compositingTick.setSource(Uri.getAllDataString(this.uriCheckGreen), this.renderSize.less(4));
this.compositingTick.setPos(this.propertyMargin.size().add(2));
this.compositingTick.print(this.renderSize.less(4));
this.compositingTick.flush();
}
/**
@ -304,14 +247,6 @@ public class Tick extends Widget {
markToRedraw();
}
public void setPropertyConfig(final Uri propertyConfig) {
if (this.propertyConfig.equals(propertyConfig)) {
return;
}
this.propertyConfig = propertyConfig;
onChangePropertyShaper();
}
public void setPropertyValue(final Boolean propertyValue) {
if (this.propertyValue.equals(propertyValue)) {
return;

View File

@ -76,10 +76,7 @@ import org.slf4j.LoggerFactory;
public class FileChooser extends Composer {
private static final Logger LOGGER = LoggerFactory.getLogger(FileChooser.class);
static void onCallbackButtonCancelPressed(final FileChooser self, final Boolean value) {
if (!value) {
return;
}
static void onCallbackButtonCancelPressed(final FileChooser self) {
// == > Auto remove ...
self.signalCancel.emit();
self.autoDestroy();
@ -150,10 +147,7 @@ public class FileChooser extends Composer {
self.updateCurrentFolder();
}
protected static void onCallbackListValidate(final FileChooser self, final Boolean value) {
if (!value) {
return;
}
protected static void onCallbackListValidate(final FileChooser self) {
if (self.propertyFile.isEmpty()) {
LOGGER.warn(" Validate : '" + self.propertyFile + "' ==> error No name ...");
return;
@ -195,11 +189,11 @@ public class FileChooser extends Composer {
}
if (getSubObjectNamed(
"[" + Long.toString(getId()) + "]file-chooser:button-validate") instanceof final Button tmp) {
tmp.signalValue.connectAuto(this, FileChooser::onCallbackListValidate);
tmp.signalClick.connectAuto(this, FileChooser::onCallbackListValidate);
}
if (getSubObjectNamed(
"[" + Long.toString(getId()) + "]file-chooser:button-cancel") instanceof final Button tmp) {
tmp.signalValue.connectAuto(this, FileChooser::onCallbackButtonCancelPressed);
tmp.signalClick.connectAuto(this, FileChooser::onCallbackButtonCancelPressed);
}
if (getSubObjectNamed(
"[" + Long.toString(getId()) + "]file-chooser:list-folder") instanceof final ListFileSystem tmp) {

View File

@ -132,7 +132,8 @@ public class SpinBase extends Sizer {
this.widgetButtonDown.setPropertyFill(Vector3b.TRUE);
final String data = this.config.getString(this.confIdDownData);
final Widget widget = Composer.composerGenerateString(data);
this.widgetButtonDown.setSubWidget(widget, 0);
//this.widgetButtonDown.setSubWidget(widget, 0);
this.widgetButtonDown.setSubWidget(widget);
}
if (this.widgetButtonUp == null) {
this.widgetButtonUp = new Button();

View File

@ -0,0 +1,68 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
height="64"
width="64"
version="1.1"
id="svg1"
sodipodi:docname="CheckBoxEmpty.svg"
inkscape:version="1.4.1 (93de688d07, 2025-03-30)"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:dc="http://purl.org/dc/elements/1.1/">
<defs
id="defs1" />
<sodipodi:namedview
id="namedview1"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:showpageshadow="2"
inkscape:pageopacity="0.0"
inkscape:pagecheckerboard="0"
inkscape:deskcolor="#d1d1d1"
showgrid="true"
inkscape:zoom="14.421875"
inkscape:cx="74.262189"
inkscape:cy="29.711809"
inkscape:window-width="3838"
inkscape:window-height="2118"
inkscape:window-x="0"
inkscape:window-y="20"
inkscape:window-maximized="1"
inkscape:current-layer="svg1">
<inkscape:grid
id="grid2"
units="px"
originx="0"
originy="0"
spacingx="1"
spacingy="1"
empcolor="#0099e5"
empopacity="0.30196078"
color="#0099e5"
opacity="0.14901961"
empspacing="5"
enabled="true"
visible="true" />
</sodipodi:namedview>
<metadata
id="metadata1">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
</cc:Work>
</rdf:RDF>
</metadata>
<path
style="fill:#008a09;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="M 3.0075839,31.00325 8.9447454,26.55688 21.989166,46.327194 56.019873,4.9985448 60.997388,9.9916825 22.023835,59.71831 Z"
id="path2"
sodipodi:nodetypes="ccccccc" />
</svg>

After

Width:  |  Height:  |  Size: 2.0 KiB

View File

@ -0,0 +1,67 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
height="64"
width="64"
version="1.1"
id="svg1"
sodipodi:docname="CheckBoxCrossRed.svg"
inkscape:version="1.4.1 (93de688d07, 2025-03-30)"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:dc="http://purl.org/dc/elements/1.1/">
<defs
id="defs1" />
<sodipodi:namedview
id="namedview1"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:showpageshadow="2"
inkscape:pageopacity="0.0"
inkscape:pagecheckerboard="0"
inkscape:deskcolor="#d1d1d1"
showgrid="true"
inkscape:zoom="14.421875"
inkscape:cx="74.262189"
inkscape:cy="29.711809"
inkscape:window-width="3838"
inkscape:window-height="2118"
inkscape:window-x="0"
inkscape:window-y="20"
inkscape:window-maximized="1"
inkscape:current-layer="svg1">
<inkscape:grid
id="grid2"
units="px"
originx="0"
originy="0"
spacingx="1"
spacingy="1"
empcolor="#0099e5"
empopacity="0.30196078"
color="#0099e5"
opacity="0.14901961"
empspacing="5"
enabled="true"
visible="true" />
</sodipodi:namedview>
<metadata
id="metadata1">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
</cc:Work>
</rdf:RDF>
</metadata>
<path
style="fill:#c20000;fill-opacity:1;stroke:none;stroke-width:1.08028px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="M 4.8537378,10.460232 26.652341,31.956986 5.0784656,53.753348 10.322116,59.146262 31.9709,37.349901 53.694595,58.996458 58.863335,53.678447 37.439278,32.031888 58.938244,10.535133 53.544776,5.0673176 32.120719,26.638974 10.397025,4.992416 Z"
id="path1" />
</svg>

After

Width:  |  Height:  |  Size: 2.1 KiB

View File

@ -1,24 +1,8 @@
{
# padding "outside" the object in pixel ==> prevent bad display
"padding-out-left":2,
"padding-out-right":2,
"padding-out-top":2,
"padding-out-buttom":2,
# padding "inside" the object in pixel ==> prevent bad display
"padding-in-left":2,
"padding-in-right":2,
"padding-in-top":2,
"padding-in-buttom":2,
# render program:
"program-vert":"THEME:shape/aaRenderShape.vert?lib=ewol",
"program-frag":"THEME:shape/aaRenderShape.frag?lib=ewol",
# Object to render (with modification)
"object-file":"THEME:shape/Button.emf?lib=ewol",
"palette":"THEME:shape/palette_gui.json?lib=ewol",
"change-time":200
"margin": 2,
"padding": 2,
"borderWidth": 2,
"borderRadius": 15,
"borderColor": "#000000",
"color": "#FFFFFF",
}