diff --git a/samples/src/main/sample/atriasoft/ewol/BasicWindows.java b/samples/src/main/sample/atriasoft/ewol/BasicWindows.java
index 5f54bfc..dd28818 100644
--- a/samples/src/main/sample/atriasoft/ewol/BasicWindows.java
+++ b/samples/src/main/sample/atriasoft/ewol/BasicWindows.java
@@ -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(() -> {
diff --git a/samples/src/main/sample/atriasoft/ewol/simpleWindowsWithBox/MainWindows.java b/samples/src/main/sample/atriasoft/ewol/simpleWindowsWithBox/MainWindows.java
index 9155588..b52dd90 100644
--- a/samples/src/main/sample/atriasoft/ewol/simpleWindowsWithBox/MainWindows.java
+++ b/samples/src/main/sample/atriasoft/ewol/simpleWindowsWithBox/MainWindows.java
@@ -10,19 +10,20 @@ 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.setPropertyExpandIfFree(Vector3b.TRUE);
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);
diff --git a/samples/src/main/sample/atriasoft/ewol/simpleWindowsWithButton/Appl.java b/samples/src/main/sample/atriasoft/ewol/simpleWindowsWithButton/Appl.java
new file mode 100644
index 0000000..43fe8a1
--- /dev/null
+++ b/samples/src/main/sample/atriasoft/ewol/simpleWindowsWithButton/Appl.java
@@ -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 ]");
+ }
+
+}
\ No newline at end of file
diff --git a/samples/src/main/sample/atriasoft/ewol/simpleWindowsWithButton/MainWindows.java b/samples/src/main/sample/atriasoft/ewol/simpleWindowsWithButton/MainWindows.java
new file mode 100644
index 0000000..deb71a2
--- /dev/null
+++ b/samples/src/main/sample/atriasoft/ewol/simpleWindowsWithButton/MainWindows.java
@@ -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);
+ }
+}
diff --git a/samples/src/main/sample/atriasoft/ewol/simpleWindowsWithButton/SimpleWindowsWithButtonMain.java b/samples/src/main/sample/atriasoft/ewol/simpleWindowsWithButton/SimpleWindowsWithButtonMain.java
new file mode 100644
index 0000000..e5a6175
--- /dev/null
+++ b/samples/src/main/sample/atriasoft/ewol/simpleWindowsWithButton/SimpleWindowsWithButtonMain.java
@@ -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() {}
+}
diff --git a/samples/src/main/sample/atriasoft/ewol/simpleWindowsWithImage/MainWindows.java b/samples/src/main/sample/atriasoft/ewol/simpleWindowsWithImage/MainWindows.java
index 4bf5a95..9305f6a 100644
--- a/samples/src/main/sample/atriasoft/ewol/simpleWindowsWithImage/MainWindows.java
+++ b/samples/src/main/sample/atriasoft/ewol/simpleWindowsWithImage/MainWindows.java
@@ -11,7 +11,7 @@ import org.atriasoft.ewol.widget.ImageDisplay;
import sample.atriasoft.ewol.BasicWindows;
public class MainWindows extends BasicWindows {
-
+
public static void eventButtonChangeImage(final MainWindows self, final Boolean value) {
if (value) {
self.testWidget.setPropertySource(new Uri("DATA", "mireC.png"));
@@ -19,39 +19,39 @@ public class MainWindows extends BasicWindows {
self.testWidget.setPropertySource(new Uri("DATA", "mireA.png"));
}
}
-
+
public static void eventButtonChangeKeepRatio(final MainWindows self) {
final boolean state = self.testWidget.isPropertyKeepRatio();
self.testWidget.setPropertyKeepRatio(!state);
//self.buttonAspectRatio.setPropertyValue(state ? "fkeep aspect ratio" : "un-keep aspect ratio");
}
-
+
ImageDisplay testWidget;
Button buttonAspectRatio;
-
+
public MainWindows() {
//! [ewol_sample_HW_windows_title]
setPropertyTitle("Simple Image");
-
+
this.testWidget = new ImageDisplay();
this.testWidget.setPropertySource(new Uri("DATA", "mireA.png"));
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);
}
}
diff --git a/src/main/org/atriasoft/ewol/compositing/CompositingSVG.java b/src/main/org/atriasoft/ewol/compositing/CompositingSVG.java
index 5d4defc..413b2a0 100644
--- a/src/main/org/atriasoft/ewol/compositing/CompositingSVG.java
+++ b/src/main/org/atriasoft/ewol/compositing/CompositingSVG.java
@@ -41,20 +41,20 @@ public class CompositingSVG extends Compositing {
private ResourceProgram oGLprogram = null; //!< pointer on the opengl display program
private Vector3f position = Vector3f.ZERO; //!< The current position to draw
private Vector2i requestSize = new Vector2i(2, 2);
-
+
private ResourceTexture2 resource = null; //!< texture resources
private ResourceVirtualArrayObject vbo = null;
-
+
private Color[] vboDataColors = null;
private Vector3f[] vboDataCoords = null;
private Vector2f[] vboDataCoordsTex = null;
-
+
public CompositingSVG() {
this("""
""", CompositingSVG.SIZE_AUTO);
}
-
+
public CompositingSVG(final String data, final int size) {
this.svgData = data;
// Create the VBO:
@@ -68,7 +68,7 @@ public class CompositingSVG extends Compositing {
setSource(this.svgData, size);
loadProgram();
}
-
+
/**
* clear alll tre registered element in the current element
*/
@@ -83,7 +83,7 @@ public class CompositingSVG extends Compositing {
this.color = Color.WHITE;
this.angle = 0;
}
-
+
/**
* draw All the registered text in the current element on openGL
* @param disableDepthTest disable the Depth test for display
@@ -123,7 +123,7 @@ public class CompositingSVG extends Compositing {
this.vbo.unBindForRendering();
this.oGLprogram.unUse();
}
-
+
@Override
public void flush() {
this.vbo.setPosition(this.vboDataCoords);
@@ -132,7 +132,7 @@ public class CompositingSVG extends Compositing {
this.vbo.setVertexCount(this.vboDataCoords.length);
this.vbo.flush();
}
-
+
/**
* get the current display position (sometime needed in the gui control)
* @return the current position.
@@ -140,7 +140,7 @@ public class CompositingSVG extends Compositing {
public Vector3f getPos() {
return this.position;
}
-
+
/**
* get the source image registered size in the file (<0 when multiple size image)
* @return tre image registered size
@@ -151,15 +151,15 @@ public class CompositingSVG extends Compositing {
}
return this.resource.getUsableSize();
}
-
+
/**
- * Sometimes the user declare an image but not allocate the ressources all the time, this is to know it ..
- * @return the validity od the resources.
+ * 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;
}
-
+
/**
* load the openGL program and get all the ID needed
*/
@@ -173,11 +173,11 @@ public class CompositingSVG extends Compositing {
this.oGLMatrixView = this.oGLprogram.getUniform("in_matrixView");
}
}
-
+
public void print(final Vector2f size) {
printPart(size, Vector2f.ZERO, Vector2f.ONE);
}
-
+
/**
* add a compleate of the image to display with the requested size
* @param size size of the output image
@@ -185,7 +185,7 @@ public class CompositingSVG extends Compositing {
public void print(final Vector2i size) {
print(new Vector2f(size.x(), size.y()));
}
-
+
/**
* add a part of the image to display with the requested size
* @param size size of the output image
@@ -203,73 +203,73 @@ public class CompositingSVG extends Compositing {
final Vector2f sourcePosStop = sourcePosStopIn.multiply(ratio);
LOGGER.trace(" openGLSize=" + openGLSize + " usableSize=" + usefullSize + " start=" + sourcePosStart
+ " stop=" + sourcePosStop);
-
+
this.vboDataColors = new Color[6];
this.vboDataCoords = new Vector3f[6];
this.vboDataCoordsTex = new Vector2f[6];
-
+
if (this.angle == 0.0f) {
Vector3f point = this.position;
int indexElem = 0;
-
+
Vector2f tex = new Vector2f(sourcePosStart.x(), sourcePosStop.y());
this.vboDataCoords[indexElem] = point;
this.vboDataCoordsTex[indexElem] = tex;
this.vboDataColors[indexElem] = this.color;
indexElem++;
-
+
tex = new Vector2f(sourcePosStop.x(), sourcePosStop.y());
point = new Vector3f(this.position.x() + size.x(), this.position.y(), 0);
this.vboDataCoords[indexElem] = point;
this.vboDataCoordsTex[indexElem] = tex;
this.vboDataColors[indexElem] = this.color;
indexElem++;
-
+
tex = new Vector2f(sourcePosStop.x(), sourcePosStart.y());
point = new Vector3f(this.position.x() + size.x(), this.position.y() + size.y(), 0);
this.vboDataCoords[indexElem] = point;
this.vboDataCoordsTex[indexElem] = tex;
this.vboDataColors[indexElem] = this.color;
indexElem++;
-
+
this.vboDataCoords[indexElem] = point;
this.vboDataCoordsTex[indexElem] = tex;
this.vboDataColors[indexElem] = this.color;
indexElem++;
-
+
tex = new Vector2f(sourcePosStart.x(), sourcePosStart.y());
point = new Vector3f(this.position.x(), this.position.y() + size.y(), 0);
this.vboDataCoords[indexElem] = point;
this.vboDataCoordsTex[indexElem] = tex;
this.vboDataColors[indexElem] = this.color;
indexElem++;
-
+
tex = new Vector2f(sourcePosStart.x(), sourcePosStop.y());
point = new Vector3f(this.position.x(), this.position.y(), 0);
this.vboDataCoords[indexElem] = point;
this.vboDataCoordsTex[indexElem] = tex;
this.vboDataColors[indexElem] = this.color;
-
+
return;
}
-
+
final Vector3f center = this.position.add(new Vector3f(size.x(), size.y(), 0)).divide(2.0f);
-
+
final Vector3f limitedSize = new Vector3f(size.x() * 0.5f, size.y() * 0.5f, 0.0f);
-
+
Vector3f point = Vector3f.ZERO;
-
+
Vector2f tex = new Vector2f(sourcePosStart.x(), sourcePosStop.y());
-
+
int indexElem = 0;
-
+
point = new Vector3f(-limitedSize.x(), -limitedSize.y(), 0);
point = point.rotateNew(new Vector3f(0, 0, 1), this.angle).add(center);
this.vboDataCoords[indexElem] = point;
this.vboDataCoordsTex[indexElem] = tex;
this.vboDataColors[indexElem] = this.color;
indexElem++;
-
+
tex = new Vector2f(sourcePosStop.x(), sourcePosStop.y());
point = new Vector3f(limitedSize.x(), -limitedSize.y(), 0);
point = point.rotateNew(new Vector3f(0, 0, 1), this.angle).add(center);
@@ -277,7 +277,7 @@ public class CompositingSVG extends Compositing {
this.vboDataCoordsTex[indexElem] = tex;
this.vboDataColors[indexElem] = this.color;
indexElem++;
-
+
tex = new Vector2f(sourcePosStop.x(), sourcePosStart.y());
point = new Vector3f(limitedSize.x(), limitedSize.y(), 0);
point = point.rotateNew(new Vector3f(0, 0, 1), this.angle).add(center);
@@ -285,12 +285,12 @@ public class CompositingSVG extends Compositing {
this.vboDataCoordsTex[indexElem] = tex;
this.vboDataColors[indexElem] = this.color;
indexElem++;
-
+
this.vboDataCoords[indexElem] = point;
this.vboDataCoordsTex[indexElem] = tex;
this.vboDataColors[indexElem] = this.color;
indexElem++;
-
+
tex = new Vector2f(sourcePosStart.x(), sourcePosStart.y());
point = new Vector3f(-limitedSize.x(), limitedSize.y(), 0);
point = point.rotateNew(new Vector3f(0, 0, 1), this.angle).add(center);
@@ -298,16 +298,16 @@ public class CompositingSVG extends Compositing {
this.vboDataCoordsTex[indexElem] = tex;
this.vboDataColors[indexElem] = this.color;
indexElem++;
-
+
tex = new Vector2f(sourcePosStart.x(), sourcePosStop.y());
point = new Vector3f(-limitedSize.x(), -limitedSize.y(), 0);
point = point.rotateNew(new Vector3f(0, 0, 1), this.angle).add(center);
this.vboDataCoords[indexElem] = point;
this.vboDataCoordsTex[indexElem] = tex;
this.vboDataColors[indexElem] = this.color;
-
+
}
-
+
/**
* set a unique rotation of this element (not set in the rotate Generic system)
* @param angleRad Angle to set in radiant.
@@ -315,7 +315,7 @@ public class CompositingSVG extends Compositing {
public void setAngle(final float angleRad) {
this.angle = angleRad;
}
-
+
/**
* set the Color of the current foreground font
* @param color Color to set on foreground (for next print)
@@ -323,11 +323,15 @@ public class CompositingSVG extends Compositing {
public void setColor(final Color color) {
this.color = color;
}
-
+
public void setPos(final Vector2f pos) {
setPos(new Vector3f(pos.x(), pos.y(), 0));
}
-
+
+ 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)
@@ -335,11 +339,11 @@ public class CompositingSVG extends Compositing {
public void setPos(final Vector3f pos) {
this.position = pos;
}
-
+
public void setRelPos(final Vector2f pos) {
setRelPos(new Vector3f(pos.x(), pos.y(), 0));
}
-
+
/**
* set relative position for the next text writen
* @param pos ofset apply of the text (in 3D)
@@ -347,7 +351,7 @@ public class CompositingSVG extends Compositing {
public void setRelPos(final Vector3f pos) {
this.position = this.position.add(pos);
}
-
+
public void setSource(final ImageByteRGBA image) {
clear();
this.svgData = null;
@@ -355,15 +359,20 @@ public class CompositingSVG extends Compositing {
this.resource = new ResourceTexture2();
this.resource.set(image);
}
-
+
public void setSource(final String data) {
setSource(data, 32);
}
-
+
public void setSource(final String data, final int size) {
setSource(data, new Vector2i(size, size));
}
+ // public void setSource(final 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()) {
@@ -386,7 +395,7 @@ public class CompositingSVG extends Compositing {
this.svgData = data;
this.requestSize = size;
}
-
+
public void setSource(final EsvgDocument data, final Vector2i size) {
if (this.svgData == null && this.svgDoc.equals(data) && this.requestSize.x() == size.x()
&& this.requestSize.y() == size.y()) {
@@ -407,5 +416,5 @@ public class CompositingSVG extends Compositing {
this.svgDoc = data;
this.requestSize = size;
}
-
+
}
diff --git a/src/main/org/atriasoft/ewol/compositing/TextBase.java b/src/main/org/atriasoft/ewol/compositing/TextBase.java
index c61df33..ece3590 100644
--- a/src/main/org/atriasoft/ewol/compositing/TextBase.java
+++ b/src/main/org/atriasoft/ewol/compositing/TextBase.java
@@ -47,7 +47,7 @@ public abstract class TextBase extends Compositing {
protected Color defaultColorFg = Color.BLACK; // !< The text foreground color
// this section is reserved for HTML parsing and display:
public String htmlCurrentLine = ""; // !< current line for HTML display
-
+
public List htmlDecoration = new ArrayList<>(); // !< current decoration for the HTML display
public TextDecoration htmlDecoTmp = new TextDecoration(); // !< current decoration
protected boolean kerning = true; // !< Kerning enable or disable on the next elements displayed
@@ -71,18 +71,18 @@ public abstract class TextBase extends Compositing {
protected float stopTextPos = 0; // !< end of the alignment (when a string is too height it cut at the word
protected ResourceVirtualArrayObject vbo = null;
protected CompositingDrawing vectorialDraw = new CompositingDrawing();
-
+
/**
* generic constructor
*/
public TextBase() {
this(new Uri("DATA", "text.vert", "ewol"), new Uri("DATA", "text.frag", "ewol"));
}
-
+
public TextBase(final Uri vertexShader, final Uri fragmentShader) {
this(vertexShader, fragmentShader, true);
}
-
+
public TextBase(final Uri vertexShader, final Uri fragmentShader, final boolean loadProgram) {
if (loadProgram) {
loadProgram(vertexShader, fragmentShader);
@@ -92,7 +92,7 @@ public abstract class TextBase extends Compositing {
// TO facilitate some debugs we add a name of the VBO:
this.vbo.setName("[VBO] of super.TextBase");
}
-
+
/**
* calculate a theoric charcode size
* @param charcode The Unicode value to calculate dimention.
@@ -101,7 +101,7 @@ public abstract class TextBase extends Compositing {
public Vector3f calculateSize(final Character charcode) {
return calculateSizeChar(charcode);
}
-
+
/**
* calculate a theoric text size
* @param text The string to calculate dimention.
@@ -118,10 +118,10 @@ public abstract class TextBase extends Compositing {
}
return outputSize;
}
-
+
// ! @previous
public abstract Vector3f calculateSizeChar(Character charcode);
-
+
/**
* calculate a theoric text size
* @param text The string to calculate dimention.
@@ -131,13 +131,13 @@ public abstract class TextBase extends Compositing {
if (text.length() == 0) {
return Vector3f.ZERO;
}
-
+
final StringBuilder tmpData = new StringBuilder("\n");
tmpData.append(text);
tmpData.append("\n\n");
return calculateSizeHTML(tmpData.toString());
}
-
+
/**
* calculate a theoric text size
* @param text The string to calculate dimention.
@@ -149,28 +149,28 @@ public abstract class TextBase extends Compositing {
// LOGGER.debug(" 0 size for=\n" + text);
// disable display system
this.needDisplay = false;
-
+
setPos(Vector3f.ZERO);
// same as print without the end display ...
printHTML(text);
//LOGGER.error(" ]]]] position={}", this.position);
//LOGGER.error(" ]]]] sizeDisplayStart={}", this.sizeDisplayStart);
//LOGGER.error(" ]]]] sizeDisplayStop={}", this.sizeDisplayStop);
-
+
// get the last elements
this.sizeDisplayStop = Vector3f.max(this.position, this.sizeDisplayStop);
this.sizeDisplayStart = Vector3f.min(this.position, this.sizeDisplayStart);
-
+
// LOGGER.debug(" 2 Start pos=" + this.sizeDisplayStart);
// LOGGER.debug(" 2 Stop pos=" + this.sizeDisplayStop);
// set back the display system
this.needDisplay = true;
-
+
return new Vector3f(this.sizeDisplayStop.x() - this.sizeDisplayStart.x(),
this.sizeDisplayStop.y() - this.sizeDisplayStart.y(),
this.sizeDisplayStop.z() - this.sizeDisplayStart.z());
}
-
+
/**
* clear all the registered element in the current element
*/
@@ -185,14 +185,14 @@ public abstract class TextBase extends Compositing {
// reset temporal variables:
reset();
}
-
+
/**
* disable the alignement system
*/
public void disableAlignement() {
this.alignment = AlignMode.DISABLE;
}
-
+
/**
* remove the cursor display
*/
@@ -200,7 +200,7 @@ public abstract class TextBase extends Compositing {
this.selectionStartPos = -100;
this.cursorPos = -100;
}
-
+
/**
* draw All the registered text in the current element on openGL
*/
@@ -208,20 +208,20 @@ public abstract class TextBase extends Compositing {
public void draw(final boolean disableDepthTest) {
drawD(disableDepthTest);
}
-
+
// ! @previous
public void draw(final Matrix4f transformationMatrix, final boolean enableDepthTest) {
drawMT(transformationMatrix, enableDepthTest);
}
-
+
/**
* draw All the refistered text in the current element on openGL
*/
public abstract void drawD(final boolean disableDepthTest);
-
+
// ! @previous
public abstract void drawMT(final Matrix4f transformationMatrix, final boolean enableDepthTest);
-
+
/**
* calculate the element number that is the first out the alignment
* range (start at the specify ID, and use start pos with current one)
@@ -242,21 +242,21 @@ public abstract class TextBase extends Compositing {
final Dynamic freeSpace) {
// store previous :
final Character storePrevious = this.previousCharcode;
-
+
stop.value = text.length();
space.value = 0;
-
+
int lastSpacePosition = start;
int lastSpacefreeSize = 0;
-
+
float endPos = this.position.x();
boolean endOfLine = false;
-
+
float stopPosition = this.stopTextPos;
if (!this.needDisplay || this.stopTextPos == this.startTextPos) {
stopPosition = this.startTextPos + 3999999999.0f;
}
-
+
for (int iii = start; iii < text.length(); iii++) {
final Vector3f tmpSize = calculateSize(text.charAt(iii));
// check overflow :
@@ -294,12 +294,12 @@ public abstract class TextBase extends Compositing {
freeSpace.value = lastSpacefreeSize;
return false;
}
-
+
@Override
public void flush() {
this.vectorialDraw.flush();
}
-
+
/**
* This generate the line return == > it return to the alignment
* position start and at the correct line position ==> it might be use to
@@ -309,7 +309,7 @@ public abstract class TextBase extends Compositing {
// reset position :
setPos(new Vector3f(this.startTextPos, this.position.y() - getHeight(), 0));
}
-
+
/**
* get the current alignment property
* @return the current alignment type
@@ -317,12 +317,12 @@ public abstract class TextBase extends Compositing {
public AlignMode getAlignment() {
return this.alignment;
}
-
+
// This is used to draw background selection and other things ...
public CompositingDrawing getDrawing() {
return this.vectorialDraw;
}
-
+
/**
* get the current font mode
* @return The font mode applied
@@ -330,11 +330,11 @@ public abstract class TextBase extends Compositing {
public FontMode getFontMode() {
return this.mode;
}
-
+
public abstract GlyphProperty getGlyphPointer(Character charcode);
-
+
public abstract float getHeight();
-
+
/**
* get the current display position (sometime needed in the gui control)
* @return the current position.
@@ -342,9 +342,9 @@ public abstract class TextBase extends Compositing {
public Vector3f getPos() {
return this.position;
}
-
+
public abstract float getSize();
-
+
/**
* add a line with the current this.htmlDecoTmp decoration
* @param data The cuurent data to add.
@@ -366,7 +366,7 @@ public abstract class TextBase extends Compositing {
this.htmlDecoration.add(this.htmlDecoTmp);
}
}
-
+
/**
* draw the current line
*/
@@ -377,7 +377,7 @@ public abstract class TextBase extends Compositing {
this.htmlCurrentLine = "";
this.htmlDecoration.clear();
}
-
+
/**
* load the openGL program and get all the ID needed
*/
@@ -397,7 +397,7 @@ public abstract class TextBase extends Compositing {
old = null;
}
}
-
+
/**
* This parse a tinyXML node (void pointer to permit to hide tiny XML in
* include).
@@ -510,11 +510,11 @@ public abstract class TextBase extends Compositing {
} else {
LOGGER.error("node not suported type: " + elem.getType() + " val='" + elem.getValue() + "'");
}
-
+
//LOGGER.error("Add data elems... @pos=", this.position);
}
}
-
+
/**
* display a compleat string in the current element.
* @param text The string to display.
@@ -523,7 +523,7 @@ public abstract class TextBase extends Compositing {
final List decorationEmpty = new ArrayList<>();
print(text, decorationEmpty);
}
-
+
/**
* display a compleat string in the current element whith specific
* decorations (advence mode).
@@ -701,18 +701,18 @@ 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);
}
}
-
+
/**
* display the current char in the current element (note that the kerning
* is availlable if the position is not changed)
* @param charcode Char that might be dispalyed
*/
public abstract void printChar(Character charcode);
-
+
/**
* draw a cursor at the specify position
* @param isInsertMode True if the insert mode is activated
@@ -720,7 +720,7 @@ public abstract class TextBase extends Compositing {
public void printCursor(final boolean isInsertMode) {
printCursor(isInsertMode, 20.0f);
}
-
+
public void printCursor(final boolean isInsertMode, final float cursorSize) {
final int fontHeigh = (int) getHeight();
if (isInsertMode) {
@@ -731,7 +731,7 @@ public abstract class TextBase extends Compositing {
this.vectorialDraw.setThickness(0);
}
}
-
+
/**
* display a compleat string in the current element with the generic
* decoration specification. (basic html data)
@@ -767,7 +767,7 @@ public abstract class TextBase extends Compositing {
// LOGGER.debug("plop : " + tmpData);
printHTML(tmpData.toString());
}
-
+
/**
* display a compleat string in the current element with the generic
* decoration specification. (basic html data)
@@ -807,7 +807,7 @@ public abstract class TextBase extends Compositing {
return;
}
final XmlElement root = (XmlElement) doc.getNode("html");
-
+
if (!root.existNode("body")) {
LOGGER.error("can not load XML: main node not find: 'body'");
return;
@@ -829,7 +829,7 @@ public abstract class TextBase extends Compositing {
e.printStackTrace();
}
}
-
+
/**
* clear all the intermediate result detween 2 prints
*/
@@ -855,24 +855,24 @@ public abstract class TextBase extends Compositing {
this.needDisplay = true;
this.nbCharDisplayed = 0;
}
-
+
@Override
public void rotate(final Vector3f vect, final float angle) {
super.rotate(vect, angle);
this.vectorialDraw.rotate(vect, angle);
}
-
+
@Override
public void scale(final Vector3f vect) {
super.scale(vect);
this.vectorialDraw.scale(vect);
}
-
+
// ! @previous
public void setClipping(final Vector2f pos, final Vector2f posEnd) {
setClipping(new Vector3f(pos.x(), pos.y(), -1), new Vector3f(posEnd.x(), posEnd.y(), 1));
}
-
+
/**
* Request a clipping area for the text (next draw only)
* @param pos Start position of the clipping
@@ -886,7 +886,7 @@ public abstract class TextBase extends Compositing {
this.clippingEnable = true;
this.vectorialDraw.setClipping(this.clippingPosStart, this.clippingPosStop);
}
-
+
/**
* enable/Disable the clipping (without lose the current clipping
* position)
@@ -897,12 +897,12 @@ public abstract class TextBase extends Compositing {
this.clippingEnable = newMode;
this.vectorialDraw.setClippingMode(this.clippingEnable);
}
-
+
// ! @previous
public void setClippingWidth(final Vector2f pos, final Vector2f width) {
setClipping(pos, pos.add(width));
}
-
+
/**
* Request a clipping area for the text (next draw only)
* @param pos Start position of the clipping
@@ -911,7 +911,7 @@ public abstract class TextBase extends Compositing {
public void setClippingWidth(final Vector3f pos, final Vector3f width) {
setClipping(pos, pos.add(width));
}
-
+
/**
* set the Color of the current foreground font
* @param color Color to set on foreground (for next print)
@@ -919,7 +919,7 @@ public abstract class TextBase extends Compositing {
public void setColor(final Color color) {
this.color = color;
}
-
+
/**
* set the background color of the font (for selected Text (not the
* global BG))
@@ -929,7 +929,7 @@ public abstract class TextBase extends Compositing {
this.colorBg = color;
this.vectorialDraw.setColor(color);
}
-
+
/**
* change the cursor color
* @param color New color for the Selection
@@ -937,7 +937,7 @@ public abstract class TextBase extends Compositing {
public void setCursorColor(final Color color) {
this.colorCursor = color;
}
-
+
/**
* set a cursor at a specific position:
* @param cursorPos id of the cursor position
@@ -946,7 +946,7 @@ public abstract class TextBase extends Compositing {
this.selectionStartPos = cursorPos;
this.cursorPos = cursorPos;
}
-
+
/**
* set a cursor at a specific position with his associated selection:
* @param cursorPos id of the cursor position
@@ -956,7 +956,7 @@ public abstract class TextBase extends Compositing {
this.selectionStartPos = selectionStartPos;
this.cursorPos = cursorPos;
}
-
+
/**
* set the default background color of the font (when reset, set this
* value ...)
@@ -965,7 +965,7 @@ public abstract class TextBase extends Compositing {
public void setDefaultColorBg(final Color color) {
this.defaultColorBg = color;
}
-
+
/**
* set the default Foreground color of the font (when reset, set this
* value ...)
@@ -974,7 +974,7 @@ public abstract class TextBase extends Compositing {
public void setDefaultColorFg(final Color color) {
this.defaultColorFg = color;
}
-
+
/**
* Specify the font property (this reset the internal element of the
* current text (system requirement)
@@ -982,7 +982,7 @@ public abstract class TextBase extends Compositing {
* @param fontSize New font size
*/
public abstract void setFont(final String fontName, final int fontSize);
-
+
/**
* enable or disable the bold mode
* @param status The new status for this display property
@@ -1002,7 +1002,7 @@ public abstract class TextBase extends Compositing {
setFontMode(FontMode.ITALIC);
}
}
-
+
/**
* enable or disable the italic mode
* @param status The new status for this display property
@@ -1022,27 +1022,27 @@ public abstract class TextBase extends Compositing {
setFontMode(FontMode.BOLD);
}
}
-
+
/**
* Specify the font mode for the next @ref print
* @param mode The font mode requested
*/
public abstract void setFontMode(FontMode mode);
-
+
/**
* Specify the font name (this reset the internal element of the current
* text (system requirement)
* @param fontName Current name of the selected font
*/
public abstract void setFontName(final String fontName);
-
+
/**
* Specify the font size (this reset the internal element of the current
* text (system requirement)
* @param fontSize New font size
*/
public abstract void setFontSize(final int fontSize);
-
+
/**
* set the activation of the Kerning for the display (if it existed)
* @param newMode enable/Diasable the kerning on this font.
@@ -1050,12 +1050,12 @@ public abstract class TextBase extends Compositing {
public void setKerningMode(final boolean newMode) {
this.kerning = newMode;
}
-
+
// ! @previous
public void setPos(final Vector2f pos) {
setPos(new Vector3f(pos.x(), pos.y(), 0));
}
-
+
/**
* set position for the next text writen
* @param pos Position of the text (in 3D)
@@ -1083,12 +1083,12 @@ public abstract class TextBase extends Compositing {
//LOGGER.trace("update size 4 " + this.sizeDisplayStart + " " + this.sizeDisplayStop);
}
}
-
+
// ! @previous
public void setRelPos(final Vector2f pos) {
setRelPos(new Vector3f(pos.x(), pos.y(), 0));
}
-
+
/**
* set relative position for the next text written
* @param pos offset apply of the text (in 3D)
@@ -1098,7 +1098,7 @@ public abstract class TextBase extends Compositing {
this.previousCharcode = 0;
this.vectorialDraw.setPos(this.position);
}
-
+
/**
* change the selection color
* @param color New color for the Selection
@@ -1106,7 +1106,7 @@ public abstract class TextBase extends Compositing {
public void setSelectionColor(final Color color) {
this.colorSelection = color;
}
-
+
/**
* This generate the possibility to generate the big text property
* @param startTextPos The x text start position of the display.
@@ -1117,7 +1117,7 @@ public abstract class TextBase extends Compositing {
public void setTextAlignment(final float startTextPos, final float stopTextPos) {
setTextAlignment(startTextPos, stopTextPos, AlignMode.DISABLE);
}
-
+
public void setTextAlignment(final float startTextPos, final float stopTextPos, final AlignMode alignement) {
this.startTextPos = startTextPos;
this.stopTextPos = stopTextPos + 1;
@@ -1127,11 +1127,11 @@ public abstract class TextBase extends Compositing {
LOGGER.trace("Request alignment with Borne position error : " + startTextPos + " => " + stopTextPos);
}
}
-
+
@Override
public void translate(final Vector3f vect) {
super.translate(vect);
this.vectorialDraw.translate(vect);
}
-
+
}
\ No newline at end of file
diff --git a/src/main/org/atriasoft/ewol/widget/Box.java b/src/main/org/atriasoft/ewol/widget/Box.java
index 1200689..af7a791 100644
--- a/src/main/org/atriasoft/ewol/widget/Box.java
+++ b/src/main/org/atriasoft/ewol/widget/Box.java
@@ -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;
@@ -29,7 +35,16 @@ import org.slf4j.LoggerFactory;
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
@@ -38,23 +53,47 @@ public class Box extends Container {
LOGGER.trace("Periodic call on Entry(" + event + ")");
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();
}
-
- protected Dimension1f propertyBorderWidth = Dimension1f.ZERO;
+ 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;
+
@AknotManaged
@AknotAttribute
@AknotName(value = "border-width")
@@ -62,7 +101,7 @@ public class Box extends Container {
public Dimension1f getPropertyBorderWidth() {
return this.propertyBorderWidth;
}
-
+
public void setPropertyBorderWidth(final Dimension1f propertyBorder) {
if (this.propertyBorderWidth.equals(propertyBorder)) {
return;
@@ -71,9 +110,9 @@ public class Box extends Container {
markToRedraw();
requestUpdateSize();
}
-
+
protected Dimension1f propertyBorderRadius = new Dimension1f(0);
-
+
@AknotManaged
@AknotAttribute
@AknotName(value = "border-radius")
@@ -81,7 +120,7 @@ public class Box extends Container {
public Dimension1f getPropertyBorderRadius() {
return this.propertyBorderRadius;
}
-
+
public void setPropertyBorderRadius(final Dimension1f propertyBorderRadius) {
if (this.propertyBorderRadius.equals(propertyBorderRadius)) {
return;
@@ -90,9 +129,9 @@ public class Box extends Container {
markToRedraw();
requestUpdateSize();
}
-
- protected Color propertyBorderColor = Color.NONE;
+ protected Color propertyBorderColor = Color.NONE;
+
@AknotManaged
@AknotAttribute
@AknotName(value = "border-color")
@@ -100,7 +139,7 @@ public class Box extends Container {
public Color getPropertyBorderColor() {
return this.propertyBorderColor;
}
-
+
public void setPropertyBorderColor(final Color propertyBorderColor) {
if (this.propertyBorderColor.equals(propertyBorderColor)) {
return;
@@ -109,9 +148,9 @@ public class Box extends Container {
markToRedraw();
requestUpdateSize();
}
-
+
protected Color propertyColor = Color.NONE;
-
+
@AknotManaged
@AknotAttribute
@AknotName(value = "color")
@@ -119,7 +158,7 @@ public class Box extends Container {
public Color getPropertyColor() {
return this.propertyColor;
}
-
+
public void setPropertyColor(final Color propertyColor) {
if (this.propertyColor.equals(propertyColor)) {
return;
@@ -128,9 +167,9 @@ public class Box extends Container {
markToRedraw();
requestUpdateSize();
}
-
- protected Dimension2f propertyMargin = Dimension2f.ZERO;
+ protected Dimension2f propertyMargin = Dimension2f.ZERO;
+
@AknotManaged
@AknotAttribute
@AknotName(value = "margin")
@@ -138,7 +177,7 @@ public class Box extends Container {
public Dimension2f getPropertyMargin() {
return this.propertyMargin;
}
-
+
public void setPropertyMargin(final Dimension2f propertyMargin) {
if (this.propertyMargin.equals(propertyMargin)) {
return;
@@ -147,9 +186,9 @@ public class Box extends Container {
markToRedraw();
requestUpdateSize();
}
-
- protected Dimension2f propertyPadding = Dimension2f.ZERO;
+ protected Dimension2f propertyPadding = Dimension2f.ZERO;
+
@AknotManaged
@AknotAttribute
@AknotName(value = "padding")
@@ -157,7 +196,7 @@ public class Box extends Container {
public Dimension2f getPropertyPadding() {
return this.propertyPadding;
}
-
+
public void setPropertyPadding(final Dimension2f propertyPadding) {
if (this.propertyPadding.equals(propertyPadding)) {
return;
@@ -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("""
+ """.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("""
+ """.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;
@@ -180,7 +357,7 @@ public class Box extends Container {
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();
@@ -189,29 +366,30 @@ public class Box extends Container {
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());
-
+ 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();
}
-
+
@Override
protected void onDraw() {
if (this.compositing != null) {
@@ -219,102 +397,5 @@ 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("""
- """.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("""
- """.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();
- }
}
diff --git a/src/main/org/atriasoft/ewol/widget/Button.java b/src/main/org/atriasoft/ewol/widget/Button.java
index 50172d6..61ef196 100644
--- a/src/main/org/atriasoft/ewol/widget/Button.java
+++ b/src/main/org/atriasoft/ewol/widget/Button.java
@@ -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,15 +33,8 @@ 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();
@@ -53,56 +44,27 @@ public class Button extends ContainerToggle {
labelWidget.setPropertyExpand(Vector3b.FALSE);
labelWidget.setPropertyGravity(Gravity.CENTER);
labelWidget.setPropertyValue(label);
- out.setSubWidget(labelWidget, 0);
+ out.setSubWidget(labelWidget);
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);
- 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();
}
-
+
/// 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")
@@ -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 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));
@@ -314,30 +125,30 @@ public class Button extends ContainerToggle {
}
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);
+ //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,91 +179,25 @@ public class Button extends ContainerToggle {
keepFocus();
this.buttonPressed = false;
this.signalUp.emit();
- changeStatusIn(GuiShapeMode.OVER);
+ ////// changeStatusIn(GuiShapeMode.OVER);
markToRedraw();
return true;
}
return false;
}
-
+
@Override
protected void onLostFocus() {
this.buttonPressed = false;
LOGGER.trace(this.name + " : Remove Focus ...");
- checkStatus();
+ //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();
+ //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();
- }
-
}
diff --git a/src/main/org/atriasoft/ewol/widget/Button_old.java b/src/main/org/atriasoft/ewol/widget/Button_old.java
new file mode 100644
index 0000000..11b81e0
--- /dev/null
+++ b/src/main/org/atriasoft/ewol/widget/Button_old.java
@@ -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 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();
+ }
+
+}
diff --git a/src/main/org/atriasoft/ewol/widget/Container.java b/src/main/org/atriasoft/ewol/widget/Container.java
index 25b2717..d2439a8 100644
--- a/src/main/org/atriasoft/ewol/widget/Container.java
+++ b/src/main/org/atriasoft/ewol/widget/Container.java
@@ -23,19 +23,19 @@ import org.slf4j.LoggerFactory;
public class Container extends Widget {
private static final Logger LOGGER = LoggerFactory.getLogger(Container.class);
protected Widget subWidget = null;
-
+
/**
* Constructor
*/
public Container() {}
-
+
/**
* Constructor with his child
*/
public Container(final Widget subWidget) {
this.subWidget = subWidget;
}
-
+
@Override
public void calculateMinMaxSize() {
// call main class
@@ -46,9 +46,9 @@ 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
public void drawWidgetTree(int level) {
super.drawWidgetTree(level);
@@ -57,7 +57,7 @@ public class Container extends Widget {
this.subWidget.drawWidgetTree(level);
}
}
-
+
@Override
public EwolObject getSubObjectNamed(final String objectName) {
final EwolObject tmpObject = super.getSubObjectNamed(objectName);
@@ -69,7 +69,7 @@ public class Container extends Widget {
}
return null;
}
-
+
/**
* get the main node widget
* @return the requested pointer on the node
@@ -81,7 +81,7 @@ public class Container extends Widget {
public Widget getSubWidget() {
return this.subWidget;
}
-
+
@Override
public Widget getWidgetAtPos(final Vector3f pos) {
if (!this.propertyHide) {
@@ -91,7 +91,7 @@ public class Container extends Widget {
}
return null;
}
-
+
// @Override
// public boolean loadXML(final XmlElement node) {
// if (node == null) {
@@ -136,7 +136,7 @@ public class Container extends Widget {
// }
// return true;
// }
-
+
@Override
public void onChangeSize() {
super.onChangeSize();
@@ -154,14 +154,14 @@ public class Container extends Widget {
this.subWidget.setSize(this.size);
this.subWidget.onChangeSize();
}
-
+
@Override
public void onRegenerateDisplay() {
if (this.subWidget != null) {
this.subWidget.systemRegenerateDisplay();
}
}
-
+
@Override
public void requestDestroyFromChild(final EwolObject child) {
if (this.subWidget != child) {
@@ -174,7 +174,7 @@ public class Container extends Widget {
this.subWidget = null;
markToRedraw();
}
-
+
@Override
public void setOffset(final Vector3f newVal) {
if (this.offset.equals(newVal)) {
@@ -183,9 +183,9 @@ public class Container extends Widget {
super.setOffset(newVal);
// recalculate the new sise and position of sub widget ...
onChangeSize();
-
+
}
-
+
/**
* set the subWidget node widget.
* @param newWidget The widget to add.
@@ -202,7 +202,7 @@ public class Container extends Widget {
markToRedraw();
requestUpdateSize();
}
-
+
/**
* remove the subWidget node (async).
*/
@@ -214,7 +214,7 @@ public class Container extends Widget {
requestUpdateSize();
}
}
-
+
/**
* Replace a old subwidget with a new one.
* @param oldWidget The widget to replace.
@@ -233,7 +233,7 @@ public class Container extends Widget {
markToRedraw();
requestUpdateSize();
}
-
+
/**
* Unlink the subwidget Node.
*/
@@ -243,7 +243,7 @@ public class Container extends Widget {
}
this.subWidget = null;
}
-
+
@Override
public void systemDraw(final DrawProperty displayProp) {
if (this.propertyHide) {
diff --git a/src/main/org/atriasoft/ewol/widget/Entry.java b/src/main/org/atriasoft/ewol/widget/Entry.java
index abc6e71..2dd0464 100644
--- a/src/main/org/atriasoft/ewol/widget/Entry.java
+++ b/src/main/org/atriasoft/ewol/widget/Entry.java
@@ -42,7 +42,7 @@ import org.slf4j.LoggerFactory;
*/
public class Entry extends Widget {
private static final Logger LOGGER = LoggerFactory.getLogger(Entry.class);
-
+
/**
* Periodic call to update grapgic display
* @param _event Time generic event
@@ -54,7 +54,7 @@ public class Entry extends Widget {
}
self.markToRedraw();
}
-
+
/// color property of the text foreground
private int colorIdTextFg;
/// Cursor must be display only when the widget has the focus
@@ -76,13 +76,13 @@ public class Entry extends Widget {
private Uri propertyConfig = new Uri("THEME", "shape/Entry.json", "ewol");
private int propertyMaxCharacter = Integer.MAX_VALUE; //!< number max of Character in the list
private boolean propertyPassword = false; //!< Disable display of the content of the entry
-
+
/// regular expression value
private String propertyRegex = ".*";
-
+
/// Text to display when nothing in in the entry (decorated text...)
private String propertyTextWhenNothing = null;
-
+
private String propertyValue = "Test Text..."; //!< string that must be displayed
private Pattern regex = null; //!< regular expression to check content
private GuiShape shape;
@@ -95,16 +95,16 @@ public class Entry extends Widget {
@AknotName(value = "enter")
@AknotDescription("The cursor enter inside the button")
public Signal signalEnter = new Signal<>(); //!< Enter key is pressed
-
+
@AknotSignal
@AknotName(value = "modify")
@AknotDescription("Entry box value change")
public Signal signalModify = new Signal<>(); //!< data change
// element over:
Vector3f overPositionStart = Vector3f.ZERO;
-
+
Vector3f overPositionStop = Vector3f.ZERO;
-
+
/**
* Constructor
* @param _newData The USting that might be set in the Entry box (no event generation!!)
@@ -112,7 +112,7 @@ public class Entry extends Widget {
public Entry() {
this.propertyCanFocus = true;
onChangePropertyShaper();
-
+
this.regex = Pattern.compile(this.propertyRegex);
if (this.regex == null) {
LOGGER.error("can not parse regex for : " + this.propertyRegex);
@@ -127,7 +127,7 @@ public class Entry extends Widget {
this.shape = new GuiShape(this.propertyConfig);
//TODO this.signalShortcut.connect(this, Entry::onCallbackShortCut);
}
-
+
@Override
public void calculateMinMaxSize() {
// call main class
@@ -138,27 +138,27 @@ public class Entry extends Widget {
padding = this.shape.getPadding();
}
final int minHeight = (int) this.text.getHeight();//calculateSize('A').y();
-
+
Vector3f minimumSizeBase = new Vector3f(20, minHeight, 10);
// add padding :
minimumSizeBase = minimumSizeBase.add(padding.x(), padding.y(), padding.z());
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);
}
markToRedraw();
}
}
-
+
/**
* Copy the selected data on the specify clipboard
* @param clipboardID Selected clipboard
@@ -178,48 +178,48 @@ public class Entry extends Widget {
final String tmpData = this.propertyValue.substring(pos1, pos2);
ClipBoard.set(clipboardID, tmpData);
}
-
+
public Uri getPropertyConfig() {
return this.propertyConfig;
}
-
+
public int getPropertyMaxCharacter() {
return this.propertyMaxCharacter;
}
-
+
public String getPropertyRegex() {
return this.propertyRegex;
}
-
+
public String getPropertyTextWhenNothing() {
return this.propertyTextWhenNothing;
}
-
+
public String getPropertyValue() {
return this.propertyValue;
}
-
+
public boolean isPropertyPassword() {
return this.propertyPassword;
}
-
+
/**
* informe the system thet the text change and the start position change
*/
protected void markToUpdateTextPosition() {
this.needUpdateTextPos = true;
}
-
+
private void onCallbackCopy() {
copySelectionToClipBoard(ClipboardList.CLIPBOARD_STD);
}
-
+
private void onCallbackCut() {
copySelectionToClipBoard(ClipboardList.CLIPBOARD_STD);
removeSelected();
this.signalModify.emit(this.propertyValue);
}
-
+
private void onCallbackEntryClean() {
this.propertyValue = "";
this.displayStartPosition = 0;
@@ -227,11 +227,11 @@ public class Entry extends Widget {
this.displayCursorPosSelection = this.displayCursorPos;
markToRedraw();
}
-
+
private void onCallbackPaste() {
ClipBoard.request(ClipboardList.CLIPBOARD_STD);
}
-
+
private void onCallbackSelect(final boolean all) {
if (all) {
this.displayCursorPosSelection = 0;
@@ -241,7 +241,7 @@ public class Entry extends Widget {
}
markToRedraw();
}
-
+
private void onCallbackShortCut(final String value) {
if (value.equals("clean")) {
onCallbackEntryClean();
@@ -260,15 +260,15 @@ public class Entry extends Widget {
LOGGER.warn("Unknow event from ShortCut : " + value);
}
}
-
+
protected void onChangePropertyMaxCharacter() {
// TODO : check number of char in the data
}
-
+
protected void onChangePropertyPassword() {
markToRedraw();
}
-
+
protected void onChangePropertyRegex() {
this.regex = Pattern.compile(this.propertyRegex);
if (this.regex != null) {
@@ -276,7 +276,7 @@ public class Entry extends Widget {
}
markToRedraw();
}
-
+
protected void onChangePropertyShaper() {
if (this.shape == null) {
this.shape = new GuiShape(this.propertyConfig);
@@ -288,11 +288,11 @@ public class Entry extends Widget {
// this.colorIdCursor = this.shape.requestColor("text-cursor");
// this.colorIdSelection = this.shape.requestColor("text-selection");
}
-
+
protected void onChangePropertyTextWhenNothing() {
markToRedraw();
}
-
+
protected void onChangePropertyValue() {
String newData = this.propertyValue;
if ((long) newData.length() > this.propertyMaxCharacter) {
@@ -308,7 +308,7 @@ public class Entry extends Widget {
}
markToRedraw();
}
-
+
@Override
protected void onDraw() {
if (this.shape != null) {
@@ -316,7 +316,7 @@ public class Entry extends Widget {
}
this.text.draw();
}
-
+
@Override
public void onEventClipboard(final ClipboardList clipboardID) {
// remove curent selected data ...
@@ -340,7 +340,7 @@ public class Entry extends Widget {
}
this.signalModify.emit(this.propertyValue);
}
-
+
@Override
public boolean onEventEntry(final EventEntry event) {
LOGGER.trace("Event on Entry ... " + event);
@@ -416,7 +416,7 @@ public class Entry extends Widget {
}
return false;
}
-
+
@Override
public boolean onEventInput(final EventInput event) {
final Vector3f absolutePosition = new Vector3f(event.pos().x(), event.pos().y(), 0);
@@ -519,7 +519,7 @@ public class Entry extends Widget {
}
return false;
}
-
+
@Override
protected void onGetFocus() {
this.displayCursor = true;
@@ -527,7 +527,7 @@ public class Entry extends Widget {
showKeyboard();
markToRedraw();
}
-
+
@Override
protected void onLostFocus() {
this.displayCursor = false;
@@ -535,7 +535,7 @@ public class Entry extends Widget {
hideKeyboard();
markToRedraw();
}
-
+
@Override
public void onRegenerateDisplay() {
if (!needRedraw()) {
@@ -552,7 +552,7 @@ public class Entry extends Widget {
}
updateTextPosition();
final Padding padding = this.shape.getPadding();
-
+
Vector3f tmpSizeShaper = this.minSize;
Vector3f delta = this.propertyGravity.gravityGenerateDelta(this.size.less(this.minSize));
if (this.propertyFill.x()) {
@@ -573,7 +573,7 @@ public class Entry extends Widget {
Vector3f tmpOriginText = tmpOriginShaper.add(padding.bottom(), padding.left(), padding.back()); //this.size.less(tmpSizeText).multiply(0.5f);
//Vector3f tmpOriginText = new Vector3f(0, this.text.getSize(), 0);
// sometimes, the user define an height bigger than the real size needed == > in this case we need to center the text in the shaper ...
-
+
final int minHeight = (int) this.text.getHeight();
if (tmpSizeText.y() > minHeight) {
tmpOriginText = tmpOriginText.add(0, (tmpSizeText.y() - minHeight) * 0.5f, 0);
@@ -583,7 +583,7 @@ public class Entry extends Widget {
tmpOriginShaper = Vector3f.clipInt(tmpOriginShaper);
tmpSizeText = Vector3f.clipInt(tmpSizeText);
tmpOriginText = Vector3f.clipInt(tmpOriginText);
-
+
this.text.clear();
//this.text.setSize((int) tmpSizeText.x(), (int) tmpSizeText.y());
this.text.setClippingWidth(tmpOriginText, tmpSizeText);
@@ -597,7 +597,7 @@ public class Entry extends Widget {
if (this.propertyPassword) {
Arrays.fill(valueToDisplay, '*');
}
-
+
//final Vector2f plop = new Vector2f(tmpOriginText.x() + this.displayStartPosition, tmpOriginText.y());
if (valueToDisplay.length != 0) {
this.text.print(new String(valueToDisplay));
@@ -610,9 +610,9 @@ public class Entry extends Widget {
this.shape.setShape(tmpOriginShaper, tmpSizeShaper, tmpOriginText, tmpSizeText);
this.text.flush();
this.shape.flush();
-
+
}
-
+
/**
* remove the selected area
* @note This request a regeneration of the display
@@ -640,7 +640,7 @@ public class Entry extends Widget {
this.propertyValue = tmp.toString();
markToRedraw();
}
-
+
/**
* internal check the value with RegExp checking
* @param newData The new string to display
@@ -667,7 +667,7 @@ public class Entry extends Widget {
this.propertyValue = newData;
markToRedraw();
}
-
+
@AknotManaged
@AknotAttribute
@AknotName(value = "config")
@@ -679,7 +679,7 @@ public class Entry extends Widget {
this.propertyConfig = propertyConfig;
onChangePropertyShaper();
}
-
+
@AknotManaged
@AknotAttribute
@AknotName(value = "max")
@@ -691,7 +691,7 @@ public class Entry extends Widget {
this.propertyMaxCharacter = propertyMaxCharacter;
onChangePropertyMaxCharacter();
}
-
+
@AknotManaged
@AknotAttribute
@AknotName(value = "password")
@@ -703,7 +703,7 @@ public class Entry extends Widget {
this.propertyPassword = propertyPassword;
onChangePropertyPassword();
}
-
+
@AknotManaged
@AknotAttribute
@AknotName(value = "regex")
@@ -715,7 +715,7 @@ public class Entry extends Widget {
this.propertyRegex = propertyRegex;
onChangePropertyRegex();
}
-
+
@AknotManaged
@AknotAttribute
@AknotName(value = "empty-text")
@@ -727,7 +727,7 @@ public class Entry extends Widget {
this.propertyTextWhenNothing = propertyTextWhenNothing;
onChangePropertyTextWhenNothing();
}
-
+
@AknotManaged
@AknotAttribute
@AknotName(value = "value")
@@ -739,7 +739,7 @@ public class Entry extends Widget {
this.propertyValue = propertyValue;
onChangePropertyValue();
}
-
+
/**
* change the cursor position with the curent position requested on the display
* @param pos Absolute position of the event
@@ -748,13 +748,13 @@ public class Entry extends Widget {
protected void updateCursorPosition(final Vector3f pos) {
updateCursorPosition(pos, false);
}
-
+
protected void updateCursorPosition(final Vector3f pos, final boolean selection/*=false*/) {
final Padding padding = this.shape.getPadding();
-
+
final Vector3f relPos = relativePosition(pos).less(this.overPositionStart);
// reject when outside ...
-
+
// try to find the new cursor position :
if (this.displayStartPosition > this.propertyValue.length()) {
this.displayStartPosition = this.propertyValue.length();
@@ -792,7 +792,7 @@ public class Entry extends Widget {
}
markToUpdateTextPosition();
}
-
+
/**
* update the display position start == > depending of the position of the Cursor and the size of the Data inside
* @change this.displayStartPosition < == updated
@@ -802,7 +802,7 @@ public class Entry extends Widget {
return;
}
final Padding padding = this.shape.getPadding();
-
+
int tmpSizeX = (int) this.minSize.x();
if (this.propertyFill.x()) {
tmpSizeX = (int) this.size.x();
@@ -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
@@ -832,5 +832,5 @@ public class Entry extends Widget {
//this.displayStartPosition = -totalWidth + tmpUserSize;
}
}
-
+
}
diff --git a/src/main/org/atriasoft/ewol/widget/Spin.java b/src/main/org/atriasoft/ewol/widget/Spin.java
index 4c03f08..bf499fb 100644
--- a/src/main/org/atriasoft/ewol/widget/Spin.java
+++ b/src/main/org/atriasoft/ewol/widget/Spin.java
@@ -37,7 +37,7 @@ public class Spin extends SpinBase {
protected Connection connectionEntry = new Connection();
protected Connection connectionButtonUp = new Connection();
protected Connection connectionButtonDown = new Connection();
-
+
/**
* Constructor
* @param _mode mode to display the spin
@@ -47,14 +47,14 @@ public class Spin extends SpinBase {
super(new Uri("THEME", "shape/Spin.json", "ewol"));
connectGui();
}
-
+
public void checkValue(long value) {
value = FMath.clamp(this.propertyMin, value, this.propertyMax);
this.propertyValue = value;
this.widgetEntry.setPropertyValue(Long.toString(value));
this.signalValue.emit(this.propertyValue);
}
-
+
public void connectGui() {
LOGGER.warn("updateGui [START]");
super.updateGui();
@@ -62,15 +62,15 @@ 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]");
}
-
+
@AknotManaged
@AknotAttribute
@AknotName("increment")
@@ -78,7 +78,7 @@ public class Spin extends SpinBase {
public long getPropertyIncrement() {
return this.propertyIncrement;
}
-
+
@AknotManaged
@AknotAttribute
@AknotName("mantis")
@@ -86,7 +86,7 @@ public class Spin extends SpinBase {
public int getPropertyMantis() {
return this.propertyMantis;
}
-
+
@AknotManaged
@AknotAttribute
@AknotName(value = "max")
@@ -94,7 +94,7 @@ public class Spin extends SpinBase {
public long getPropertyMax() {
return this.propertyMax;
}
-
+
@AknotManaged
@AknotAttribute
@AknotName("min")
@@ -102,7 +102,7 @@ public class Spin extends SpinBase {
public long getPropertyMin() {
return this.propertyMin;
}
-
+
@AknotManaged
@AknotAttribute
@AknotName("value")
@@ -110,15 +110,13 @@ public class Spin extends SpinBase {
public long getPropertyValue() {
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);
}
-
+
protected void onCallbackModify(final String value) {
if (value.isEmpty()) {
return;
@@ -130,31 +128,28 @@ public class Spin extends SpinBase {
LOGGER.error("This is not a value {} ==> {}", value, ex.getLocalizedMessage());
}
}
-
- protected void onCallbackUp(final Boolean value) {
- if (value) {
- return;
- }
+
+ protected void onCallbackUp() {
final long data = this.propertyValue + this.propertyIncrement;
checkValue(data);
}
-
+
protected void onChangePropertyIncrement() {
-
+
}
-
+
protected void onChangePropertyMantis() {
-
+
}
-
+
protected void onChangePropertyMax() {
checkValue(this.propertyValue);
}
-
+
protected void onChangePropertyMin() {
checkValue(this.propertyValue);
}
-
+
protected void onChangePropertyValue() {
markToRedraw();
if (this.widgetEntry == null) {
@@ -163,7 +158,7 @@ public class Spin extends SpinBase {
}
checkValue(this.propertyValue);
}
-
+
public void setPropertyIncrement(final long propertyIncrement) {
if (this.propertyIncrement == propertyIncrement) {
return;
@@ -171,7 +166,7 @@ public class Spin extends SpinBase {
this.propertyIncrement = propertyIncrement;
onChangePropertyIncrement();
}
-
+
public void setPropertyMantis(final int propertyMantis) {
if (this.propertyMantis == propertyMantis) {
return;
@@ -179,7 +174,7 @@ public class Spin extends SpinBase {
this.propertyMantis = propertyMantis;
onChangePropertyMantis();
}
-
+
public void setPropertyMax(final long propertyMax) {
if (this.propertyMax == propertyMax) {
return;
@@ -187,7 +182,7 @@ public class Spin extends SpinBase {
this.propertyMax = propertyMax;
onChangePropertyMax();
}
-
+
public void setPropertyMin(final long propertyMin) {
if (this.propertyMin == propertyMin) {
return;
@@ -195,7 +190,7 @@ public class Spin extends SpinBase {
this.propertyMin = propertyMin;
onChangePropertyMin();
}
-
+
public void setPropertyValue(final long propertyValue) {
if (this.propertyValue == propertyValue) {
return;
diff --git a/src/main/org/atriasoft/ewol/widget/Tick.java b/src/main/org/atriasoft/ewol/widget/Tick.java
index 736a2d2..a54a4a5 100644
--- a/src/main/org/atriasoft/ewol/widget/Tick.java
+++ b/src/main/org/atriasoft/ewol/widget/Tick.java
@@ -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 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;
@@ -62,11 +54,12 @@ public class Tick extends Widget {
//private final CompositingGraphicContext gc = new CompositingGraphicContext();
/// 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")
@@ -86,31 +79,37 @@ public class Tick extends Widget {
// element over:
Vector3f overPositionStart = Vector3f.ZERO;
Vector3f overPositionStop = Vector3f.ZERO;
-
+
private boolean isDown;
-
+
/**
* Constuctor
*/
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
public void calculateMinMaxSize() {
// 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());
// add padding :
minimumSizeBase = minimumSizeBase.add(padding.x(), padding.y(), padding.z());
@@ -119,31 +118,23 @@ public class Tick extends Widget {
checkMinSize();
LOGGER.error("min size = " + 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,
- 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) {
return relPos.x() > this.overPositionStart.x() && relPos.y() > this.overPositionStart.y()
&& relPos.x() < this.overPositionStop.x() && relPos.y() < this.overPositionStop.y();
}
-
- @AknotManaged
- @AknotAttribute
- @AknotName("config")
- @AknotDescription("configuration of the widget")
- public Uri getPropertyConfig() {
- return this.propertyConfig;
- }
-
+
@AknotManaged
@AknotAttribute
@AknotName("value")
@@ -151,36 +142,34 @@ public class Tick extends Widget {
public Boolean getPropertyValue() {
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();
}
-
+
protected void onChangePropertyValue() {
//Boolean newData = this.propertyValue;
markToRedraw();
}
-
+
@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) {
@@ -235,66 +224,20 @@ public class Tick extends Widget {
}
return false;
}
-
+
@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();
}
-
+
/**
* internal check the value with RegExp checking
* @param newData The new string to display
@@ -303,15 +246,7 @@ public class Tick extends Widget {
this.propertyValue = newData;
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;
@@ -320,5 +255,5 @@ public class Tick extends Widget {
this.signalValue.emit(this.propertyValue);
onChangePropertyValue();
}
-
+
}
diff --git a/src/main/org/atriasoft/ewol/widget/meta/FileChooser.java b/src/main/org/atriasoft/ewol/widget/meta/FileChooser.java
index 3f72e1e..8ce62ef 100644
--- a/src/main/org/atriasoft/ewol/widget/meta/FileChooser.java
+++ b/src/main/org/atriasoft/ewol/widget/meta/FileChooser.java
@@ -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) {
diff --git a/src/main/org/atriasoft/ewol/widget/meta/SpinBase.java b/src/main/org/atriasoft/ewol/widget/meta/SpinBase.java
index 577c3af..3e38379 100644
--- a/src/main/org/atriasoft/ewol/widget/meta/SpinBase.java
+++ b/src/main/org/atriasoft/ewol/widget/meta/SpinBase.java
@@ -31,13 +31,13 @@ public class SpinBase extends Sizer {
protected int confIdDownShaper = -1;
protected int confIdUpData = -1;
protected int confIdDownData = -1;
-
+
protected Entry widgetEntry = null;
-
+
protected Button widgetButtonDown = null;
-
+
protected Button widgetButtonUp = null;
-
+
/**
* Constructor
*/
@@ -54,7 +54,7 @@ public class SpinBase extends Sizer {
setPropertyGravity(Gravity.CENTER);
updateGui();
}
-
+
@AknotManaged
@AknotAttribute
@AknotName(value = "shape")
@@ -62,7 +62,7 @@ public class SpinBase extends Sizer {
public Uri getPropertyShape() {
return this.propertyShape;
}
-
+
@AknotManaged
@AknotAttribute
@AknotName(value = "spin-mode")
@@ -70,7 +70,7 @@ public class SpinBase extends Sizer {
public SpinPosition getPropertySpinMode() {
return this.propertySpinMode;
}
-
+
protected void onChangePropertyShape() {
this.config = ResourceConfigFile.create(this.propertyShape);
if (this.config != null) {
@@ -82,11 +82,11 @@ public class SpinBase extends Sizer {
}
markToRedraw();
}
-
+
protected void onChangePropertySpinMode() {
updateGui();
}
-
+
public void setPropertyShape(final Uri propertyShape) {
if (this.propertyShape != null && this.propertyShape.equals(propertyShape)) {
return;
@@ -94,7 +94,7 @@ public class SpinBase extends Sizer {
this.propertyShape = propertyShape;
onChangePropertyShape();
}
-
+
public void setPropertySpinMode(final SpinPosition propertySpinMode) {
if (this.propertySpinMode == propertySpinMode) {
return;
@@ -102,7 +102,7 @@ public class SpinBase extends Sizer {
this.propertySpinMode = propertySpinMode;
onChangePropertySpinMode();
}
-
+
protected void updateGui() {
subWidgetRemoveAll();
markToRedraw();
@@ -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();
@@ -180,5 +181,5 @@ public class SpinBase extends Sizer {
break;
}
}
-
+
}
diff --git a/src/resources/resources/ewol/theme/CheckBoxCheckGreen.svg b/src/resources/resources/ewol/theme/CheckBoxCheckGreen.svg
new file mode 100644
index 0000000..3983fea
--- /dev/null
+++ b/src/resources/resources/ewol/theme/CheckBoxCheckGreen.svg
@@ -0,0 +1,68 @@
+
+
diff --git a/src/resources/resources/ewol/theme/CheckBoxCrossRed.svg b/src/resources/resources/ewol/theme/CheckBoxCrossRed.svg
new file mode 100644
index 0000000..f4de5e2
--- /dev/null
+++ b/src/resources/resources/ewol/theme/CheckBoxCrossRed.svg
@@ -0,0 +1,67 @@
+
+
diff --git a/src/resources/resources/ewol/theme/shape/Button.json b/src/resources/resources/ewol/theme/shape/Button.json
index 25d7468..87ab6e4 100644
--- a/src/resources/resources/ewol/theme/shape/Button.json
+++ b/src/resources/resources/ewol/theme/shape/Button.json
@@ -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",
}