From f29254547d4f2d7e7e2bd9d59778c27c2f1c1502 Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Mon, 21 Feb 2022 18:19:28 +0100 Subject: [PATCH] sdcsdc --- .../ewol/data/ewol-gui-file-chooser.json | 121 ++++++++++++++++++ .../ewol/data/ewol-gui-file-chooser2.json | 119 +++++++++++++++++ .../resources/ewol/theme/shape/CheckBox.emf | 4 +- .../resources/ewol/theme/shape/CheckBox.json | 1 + .../atriasoft/ewol/ComplexWindiows1/Appl.java | 2 + .../ewol/ComplexWindiows1/MainWindows.java | 32 ++--- .../ewol/{ComplexWindiows1 => }/Log.java | 2 +- .../atriasoft/ewol/sampleButton/Appl.java | 4 +- .../atriasoft/ewol/sampleButton/Log.java | 39 ------ .../ewol/sampleButton/MainWindows.java | 4 +- .../atriasoft/ewol/sampleEntry/Appl.java | 2 + .../atriasoft/ewol/sampleEntry/Log.java | 39 ------ .../ewol/sampleEntry/MainWindows.java | 4 +- .../ewol/simpleWindowsLabel/Appl.java | 2 + .../ewol/simpleWindowsLabel/Log.java | 39 ------ .../ewol/simpleWindowsLabel/MainWindows.java | 8 +- .../ewol/simpleWindowsWithCheckBox/Appl.java | 2 + .../ewol/simpleWindowsWithCheckBox/Log.java | 39 ------ .../MainWindows.java | 7 + .../ewol/simpleWindowsWithImage/Appl.java | 2 + .../ewol/simpleWindowsWithImage/Log.java | 39 ------ .../simpleWindowsWithImage/MainWindows.java | 12 +- src/org/atriasoft/ewol/Ewol.java | 7 +- .../atriasoft/ewol/compositing/GuiShape.java | 76 ++++++++--- src/org/atriasoft/ewol/object/EwolObject.java | 74 +++-------- .../ewol/resource/ResourceTexturedFont.java | 2 +- src/org/atriasoft/ewol/widget/Button.java | 77 +++++++---- src/org/atriasoft/ewol/widget/CheckBox.java | 91 ++++++++----- src/org/atriasoft/ewol/widget/ContainerN.java | 77 ++++------- .../atriasoft/ewol/widget/ImageDisplay.java | 45 ------- src/org/atriasoft/ewol/widget/Label.java | 13 -- src/org/atriasoft/ewol/widget/Widget.java | 15 --- .../atriasoft/ewol/widget/WidgetManager.java | 10 +- .../ewol/widget/WidgetXmlFactory.java | 28 ++++ 34 files changed, 539 insertions(+), 499 deletions(-) create mode 100644 resources/resources/ewol/data/ewol-gui-file-chooser.json create mode 100644 resources/resources/ewol/data/ewol-gui-file-chooser2.json rename samples/src/sample/atriasoft/ewol/{ComplexWindiows1 => }/Log.java (95%) delete mode 100644 samples/src/sample/atriasoft/ewol/sampleButton/Log.java delete mode 100644 samples/src/sample/atriasoft/ewol/sampleEntry/Log.java delete mode 100644 samples/src/sample/atriasoft/ewol/simpleWindowsLabel/Log.java delete mode 100644 samples/src/sample/atriasoft/ewol/simpleWindowsWithCheckBox/Log.java delete mode 100644 samples/src/sample/atriasoft/ewol/simpleWindowsWithImage/Log.java create mode 100644 src/org/atriasoft/ewol/widget/WidgetXmlFactory.java diff --git a/resources/resources/ewol/data/ewol-gui-file-chooser.json b/resources/resources/ewol/data/ewol-gui-file-chooser.json new file mode 100644 index 0000000..5fe4c7a --- /dev/null +++ b/resources/resources/ewol/data/ewol-gui-file-chooser.json @@ -0,0 +1,121 @@ +{ + "type":"popup", + "child": [ + { + "type":"sizer", + "property": { + "mode": "vert", + "lock": true, + "fill": true, + "expand": true + }, + "child": [ + { + "type":"sizer", + "property": { + "mode": "hori" + }, + "child": [ + { + "type":"checkbox-text", + "property": { + "name": "[{ID}]file-shooser:show-hiden-file", + "label": "_T{ShowHiddenFiles}" + } + }, { + "type":"spacer", + "property": { + "expand": "true,false" + } + }, { + "type":"button-icon-text", + "property": { + "name": "[{ID}]file-shooser:button-validate", + "icon": "THEME_GUI:///Load.svg?lib:ewol", + "label": "_T{Validate}" + } + }, { + "type":"button-icon-text", + "property": { + "name": "[{ID}]file-shooser:button-cancel", + "icon": "THEME_GUI:///Remove.svg?lib:ewol", + "label": "_T{Cancel}" + } + } + ] + }, { + "type":"sizer", + "property": { + "mode": "hori" + }, + "child": [ + { + "type":"spacer", + "property": { + "expand": "true,false" + } + }, { + "type":"ListFileSystem", + "property": { + "name":"[{ID}]file-shooser:list-folder", + "min-size":"20,0%", + "expand":"false,true", + "show-hidden":false, + "show-file":false, + "show-folder":true, + "show-temporary":false + } + }, { + "type":"spacer", + "property": { + "expand": "true,false" + } + }, { + "type":"ListFileSystem", + "property": { + "name":"[{ID}]file-shooser:list-files", + "min-size":"20,0%", + "expand":"true,true", + "show-hidden":false, + "show-file":true, + "show-folder":false, + "show-temporary":false + } + }, { + "type":"spacer", + "property": { + "expand": "true,false" + } + } + ] + }, { + "type":"sizer", + "property": { + "mode": "hori" + }, + "child": [ + llo. World

- Coucou comment ca vas ???
- Pas trop bien, je me suis cassé la jambe.

The end
"); - simpleLabel.setPropertyExpand(new Vector2b(true, true)); - simpleLabel.setPropertyFill(new Vector2b(true, true)); + simpleLabel.setPropertyExpand(Vector2b.TRUE_TRUE); + simpleLabel.setPropertyFill(Vector2b.TRUE_TRUE); this.setTestWidget(simpleLabel); //! [ewol_sample_HW_windows_label] } else { Spacer simpleSpacer = new Spacer(); - simpleSpacer.setPropertyExpand(new Vector2b(true, true)); - simpleSpacer.setPropertyFill(new Vector2b(true, true)); + simpleSpacer.setPropertyExpand(Vector2b.TRUE_TRUE); + simpleSpacer.setPropertyFill(Vector2b.TRUE_TRUE); this.setTestWidget(simpleSpacer); } } diff --git a/samples/src/sample/atriasoft/ewol/simpleWindowsWithCheckBox/Appl.java b/samples/src/sample/atriasoft/ewol/simpleWindowsWithCheckBox/Appl.java index e23b8ef..74589d1 100644 --- a/samples/src/sample/atriasoft/ewol/simpleWindowsWithCheckBox/Appl.java +++ b/samples/src/sample/atriasoft/ewol/simpleWindowsWithCheckBox/Appl.java @@ -5,6 +5,8 @@ import org.atriasoft.etk.math.Vector2f; import org.atriasoft.ewol.context.EwolApplication; import org.atriasoft.ewol.context.EwolContext; +import sample.atriasoft.ewol.Log; + public class Appl implements EwolApplication { //! [ewol_sample_HW_main_application] diff --git a/samples/src/sample/atriasoft/ewol/simpleWindowsWithCheckBox/Log.java b/samples/src/sample/atriasoft/ewol/simpleWindowsWithCheckBox/Log.java deleted file mode 100644 index 5921c2e..0000000 --- a/samples/src/sample/atriasoft/ewol/simpleWindowsWithCheckBox/Log.java +++ /dev/null @@ -1,39 +0,0 @@ -package sample.atriasoft.ewol.simpleWindowsWithCheckBox; - -public class Log { - private static final String LIBNAME = "LoxelEngine"; - - public static void critical(final String data) { - System.out.println("[C] " + Log.LIBNAME + " | " + data); - } - - public static void debug(final String data) { - System.out.println("[D] " + Log.LIBNAME + " | " + data); - } - - public static void error(final String data) { - System.out.println("[E] " + Log.LIBNAME + " | " + data); - } - - public static void info(final String data) { - System.out.println("[I] " + Log.LIBNAME + " | " + data); - } - - public static void print(final String data) { - System.out.println(data); - } - - public static void todo(final String data) { - System.out.println("[TODO] " + Log.LIBNAME + " | " + data); - } - - public static void verbose(final String data) { - System.out.println("[V] " + Log.LIBNAME + " | " + data); - } - - public static void warning(final String data) { - System.out.println("[W] " + Log.LIBNAME + " | " + data); - } - - private Log() {} -} diff --git a/samples/src/sample/atriasoft/ewol/simpleWindowsWithCheckBox/MainWindows.java b/samples/src/sample/atriasoft/ewol/simpleWindowsWithCheckBox/MainWindows.java index 53a4d2b..a730d08 100644 --- a/samples/src/sample/atriasoft/ewol/simpleWindowsWithCheckBox/MainWindows.java +++ b/samples/src/sample/atriasoft/ewol/simpleWindowsWithCheckBox/MainWindows.java @@ -18,5 +18,12 @@ public class MainWindows extends BasicWindows { this.testWidget.setPropertyExpand(Vector2b.TRUE_TRUE); this.testWidget.setPropertyFill(Vector2b.TRUE_TRUE); this.setTestWidget(this.testWidget); + /* + Button simpleButton = new Button(); + simpleButton.setPropertyValue("Top Button"); + simpleButton.setPropertyExpand(Vector2b.TRUE_TRUE); + simpleButton.setPropertyFill(Vector2b.TRUE_TRUE); + this.setTestWidget(simpleButton); + */ } } diff --git a/samples/src/sample/atriasoft/ewol/simpleWindowsWithImage/Appl.java b/samples/src/sample/atriasoft/ewol/simpleWindowsWithImage/Appl.java index 94895eb..6cbf6d7 100644 --- a/samples/src/sample/atriasoft/ewol/simpleWindowsWithImage/Appl.java +++ b/samples/src/sample/atriasoft/ewol/simpleWindowsWithImage/Appl.java @@ -5,6 +5,8 @@ import org.atriasoft.etk.math.Vector2f; import org.atriasoft.ewol.context.EwolApplication; import org.atriasoft.ewol.context.EwolContext; +import sample.atriasoft.ewol.Log; + public class Appl implements EwolApplication { //! [ewol_sample_HW_main_application] diff --git a/samples/src/sample/atriasoft/ewol/simpleWindowsWithImage/Log.java b/samples/src/sample/atriasoft/ewol/simpleWindowsWithImage/Log.java deleted file mode 100644 index cdb56f1..0000000 --- a/samples/src/sample/atriasoft/ewol/simpleWindowsWithImage/Log.java +++ /dev/null @@ -1,39 +0,0 @@ -package sample.atriasoft.ewol.simpleWindowsWithImage; - -public class Log { - private static final String LIBNAME = "LoxelEngine"; - - public static void critical(final String data) { - System.out.println("[C] " + Log.LIBNAME + " | " + data); - } - - public static void debug(final String data) { - System.out.println("[D] " + Log.LIBNAME + " | " + data); - } - - public static void error(final String data) { - System.out.println("[E] " + Log.LIBNAME + " | " + data); - } - - public static void info(final String data) { - System.out.println("[I] " + Log.LIBNAME + " | " + data); - } - - public static void print(final String data) { - System.out.println(data); - } - - public static void todo(final String data) { - System.out.println("[TODO] " + Log.LIBNAME + " | " + data); - } - - public static void verbose(final String data) { - System.out.println("[V] " + Log.LIBNAME + " | " + data); - } - - public static void warning(final String data) { - System.out.println("[W] " + Log.LIBNAME + " | " + data); - } - - private Log() {} -} diff --git a/samples/src/sample/atriasoft/ewol/simpleWindowsWithImage/MainWindows.java b/samples/src/sample/atriasoft/ewol/simpleWindowsWithImage/MainWindows.java index 7a966af..ac10906 100644 --- a/samples/src/sample/atriasoft/ewol/simpleWindowsWithImage/MainWindows.java +++ b/samples/src/sample/atriasoft/ewol/simpleWindowsWithImage/MainWindows.java @@ -31,23 +31,23 @@ public class MainWindows extends BasicWindows { this.testWidget = new ImageDisplay(); this.testWidget.setPropertySource(new Uri("DATA", "mireA.png")); - this.testWidget.setPropertyExpand(new Vector2b(true, true)); - this.testWidget.setPropertyFill(new Vector2b(true, true)); + this.testWidget.setPropertyExpand(Vector2b.TRUE_TRUE); + this.testWidget.setPropertyFill(Vector2b.TRUE_TRUE); this.testWidget.setPropertyMinSize(new Dimension(Vector2f.VALUE_16, Distance.PIXEL)); this.setTestWidget(this.testWidget); { Button button = new Button(); button.setPropertyValue("Change image"); - button.setPropertyExpand(new Vector2b(false, false)); - button.setPropertyFill(new Vector2b(false, false)); + button.setPropertyExpand(Vector2b.FALSE_FALSE); + button.setPropertyFill(Vector2b.FALSE_FALSE); button.setPropertyMinSize(new Dimension(new Vector2f(10, 10), Distance.PIXEL)); this.addButton(button); button.signalClick.connectAuto(this, MainWindows::eventButtonChangeImage); } this.buttonAspectRatio = new Button(); this.buttonAspectRatio.setPropertyValue("keep aspect ratio"); - this.buttonAspectRatio.setPropertyExpand(new Vector2b(false, false)); - this.buttonAspectRatio.setPropertyFill(new Vector2b(false, false)); + this.buttonAspectRatio.setPropertyExpand(Vector2b.FALSE_FALSE); + this.buttonAspectRatio.setPropertyFill(Vector2b.FALSE_FALSE); this.buttonAspectRatio.setPropertyMinSize(new Dimension(new Vector2f(10, 10), Distance.PIXEL)); this.addButton(this.buttonAspectRatio); this.buttonAspectRatio.signalClick.connectAuto(this, MainWindows::eventButtonChangeKeepRatio); diff --git a/src/org/atriasoft/ewol/Ewol.java b/src/org/atriasoft/ewol/Ewol.java index cca90ff..adcc7ec 100644 --- a/src/org/atriasoft/ewol/Ewol.java +++ b/src/org/atriasoft/ewol/Ewol.java @@ -1,12 +1,13 @@ package org.atriasoft.ewol; -import org.atriasoft.esvg.Esvg; -import org.atriasoft.etk.Uri; /** @file * @author Edouard DUPIN * @copyright 2011, Edouard DUPIN, all right reserved * @license MPL v2.0 (see license file) */ + +import org.atriasoft.esvg.Esvg; +import org.atriasoft.etk.Uri; import org.atriasoft.etranslate.ETranslate; import org.atriasoft.ewol.context.EwolApplication; import org.atriasoft.ewol.context.EwolContext; @@ -28,7 +29,7 @@ public class Ewol { * This is the only one things the User might done in his main(); * @note To answare you before you ask the question, this is really simple: * Due to the fect that the current system is multiple-platform, you "main" - * Does not exist in the android platform, then ewol call other start + * Does not exist in the android platform, then ewol call other start * and stop function, to permit to have only one code * @note The main can not be in the ewol, due to the fact thet is an librairy * @param application just created instance of the applicationo diff --git a/src/org/atriasoft/ewol/compositing/GuiShape.java b/src/org/atriasoft/ewol/compositing/GuiShape.java index cfe4a21..f90469c 100644 --- a/src/org/atriasoft/ewol/compositing/GuiShape.java +++ b/src/org/atriasoft/ewol/compositing/GuiShape.java @@ -40,6 +40,7 @@ public class GuiShape extends Compositing { private ResourceConfigFile config = null; //!< pointer on the config file resources private int confObjectFile = -1; //!< Config Id of the object file to display + private int confObjectFile2 = -1; //!< Config Id of the object file to display private int confProgramFileFrag = -1; //!< ConfigFile opengGl program Name private int confProgramFileVert = -1; //!< ConfigFile opengGl program Name private final List listAssiciatedId = new ArrayList<>(); //!< Correlation ID between ColorProperty (Y) and OpenGL Program (X) @@ -57,7 +58,7 @@ public class GuiShape extends Compositing { private ResourcePaletteFile palette; private ResourceTexture2 texture; - private ResourceMesh mesh = null; + private ResourceMesh[] mesh = new ResourceMesh[2]; private Padding sizeObject = Padding.ZERO; private int stateActivate = -1; //!< Activate state of the element private GuiShapeMode stateNew = GuiShapeMode.NORMAL; //!< destination state @@ -119,13 +120,32 @@ public class GuiShape extends Compositing { draw(null, disableDepthTest); } + public void draw(final boolean disableDepthTest, int idMesh) { + draw(null, disableDepthTest, idMesh); + } + public void draw(final ResourceTexture2 secondaryTexture, final boolean disableDepthTest) { + this.draw(secondaryTexture, disableDepthTest, 0); + } + + public void draw(final ResourceTexture2 secondaryTexture, final boolean disableDepthTest, int idMesh) { if (this.config == null) { // this is a normal case ... the user can choice to have no config basic file ... return; } + if (idMesh == 0 && this.mesh[0] == null) { + Log.error("No Object (0) to display ..."); + return; + } else if (idMesh == 1 && this.mesh[1] == null) { + Log.error("No Object (1) to display ..."); + return; + } else if (idMesh < 0 && idMesh > 1) { + Log.critical("No Object (" + idMesh + ") to display [0..1]"); + return; + } if (this.oGLprogram == null) { Log.error("No shader ..."); + return; } OpenGL.enable(Flag.flag_depthTest); // set Matrix : translation/positionMatrix @@ -133,12 +153,12 @@ public class GuiShape extends Compositing { Matrix4f camMatrix = OpenGL.getCameraMatrix(); Matrix4f tmpMatrix = this.matrixApply.multiply(this.transform); this.oGLprogram.use(); - this.mesh.bindForRendering(); + this.mesh[idMesh].bindForRendering(); this.oGLprogram.uniformMatrix(this.oGLMatrixProjection, projMatrix); this.oGLprogram.uniformMatrix(this.oGLMatrixTransformation, tmpMatrix); this.oGLprogram.uniformMatrix(this.oGLMatrixView, camMatrix); - Set layers = this.mesh.getLayers(); + Set layers = this.mesh[idMesh].getLayers(); Log.verbose("get layers:" + layers); // Texture: float imageDelta = (float) 1 / ResourcePaletteFile.getHeight(); @@ -155,7 +175,6 @@ public class GuiShape extends Compositing { basicValue -= imageDelta * this.stateTransition; } else if (this.stateNew == GuiShapeMode.SELECT) { basicValue += imageDelta * this.stateTransition; - } } else if (this.stateOld == GuiShapeMode.SELECT) { if (this.stateNew == GuiShapeMode.NORMAL) { @@ -169,23 +188,23 @@ public class GuiShape extends Compositing { + ")"); this.oGLprogram.uniformFloat(this.oGLPaletteOffset, basicValue); - Log.error("plop: " + this.offsetScaleOutside); - Log.error("plop: " + this.offsetScaleInside); + //Log.verbose("plop: " + this.offsetScaleOutside); + //Log.verbose("plop: " + this.offsetScaleInside); this.oGLprogram.uniformVector(this.oGLOffsetScaleInside, this.offsetScaleInside); this.oGLprogram.uniformVector(this.oGLOffsetScaleOutside, this.offsetScaleOutside); this.texture.bindForRendering(0); - this.mesh.render("palette"); + this.mesh[idMesh].render("palette"); if (secondaryTexture != null) { this.oGLprogram.uniformFloat(this.oGLPaletteOffset, 0); secondaryTexture.bindForRendering(0); - this.mesh.render("gui_dynamic_1"); + this.mesh[idMesh].render("gui_dynamic_1"); } // Request the draw of the elements: - this.mesh.render(); + this.mesh[idMesh].render(); - this.mesh.unBindForRendering(); + this.mesh[idMesh].unBindForRendering(); this.oGLprogram.unUse(); OpenGL.disable(Flag.flag_depthTest); } @@ -289,6 +308,7 @@ public class GuiShape extends Compositing { this.confProgramFileVert = this.config.request("program-vert"); this.confProgramFileFrag = this.config.request("program-frag"); this.confObjectFile = this.config.request("object-file"); + this.confObjectFile2 = this.config.request("object-file-2"); this.confIdPaletteFile = this.config.request("palette"); } } @@ -349,8 +369,8 @@ public class GuiShape extends Compositing { } String objectFile = this.config.getString(this.confObjectFile); if (!objectFile.isEmpty()) { - this.mesh = ResourceMesh.create(Uri.valueOf(objectFile)); - List verticesToModify = this.mesh.getGeneratedPosition(); + this.mesh[0] = ResourceMesh.create(Uri.valueOf(objectFile)); + List verticesToModify = this.mesh[0].getGeneratedPosition(); float top = 0; float bottom = 0; float left = 0; @@ -372,6 +392,30 @@ public class GuiShape extends Compositing { } this.sizeObject = new Padding(Math.abs(left), Math.abs(top), Math.abs(right), Math.abs(bottom)); } + String objectFile2 = this.config.getString(this.confObjectFile2); + if (!objectFile2.isEmpty()) { + this.mesh[1] = ResourceMesh.create(Uri.valueOf(objectFile2)); + List verticesToModify = this.mesh[1].getGeneratedPosition(); + float top = 0; + float bottom = 0; + float left = 0; + float right = 0; + float back = 0; + float font = 0; + // estimate size of border: + if (verticesToModify == null) { + Log.critical("Element is null : verticesToModify 2"); + return; + } + for (int iii = 0; iii < verticesToModify.size(); iii++) { + left = Math.min(left, verticesToModify.get(iii).x()); + right = Math.max(right, verticesToModify.get(iii).x()); + top = Math.min(top, verticesToModify.get(iii).y()); + bottom = Math.max(bottom, verticesToModify.get(iii).y()); + back = Math.min(back, verticesToModify.get(iii).z()); + font = Math.max(font, verticesToModify.get(iii).z()); + } + } } /** @@ -438,7 +482,7 @@ public class GuiShape extends Compositing { * @brief set the shape property: * * ******************************************************************************** - * * _size * + * * size * * * * * * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * * * * * @@ -447,7 +491,7 @@ public class GuiShape extends Compositing { * * | * * | * * * * * * * * | * * - - - - - - - - - - - - - - - - - - * * | * - * * * _insideSize * * + * * * insideSize * * * * | * | | * | * * * * * * * * | * | | * | * @@ -459,7 +503,7 @@ public class GuiShape extends Compositing { * * | * | | * | * * * * * * * * | * | | * | * - * * * _insidePos * * + * * * insidePos * * * * | * * - - - - - - - - - - - - - - - - - - * * | * * * * * * * * | *************************************************** | * @@ -470,7 +514,7 @@ public class GuiShape extends Compositing { * * * * * * * ******************************************************************************** - * _origin + * origin * * * @param center Center of the object diff --git a/src/org/atriasoft/ewol/object/EwolObject.java b/src/org/atriasoft/ewol/object/EwolObject.java index 2df0312..fa76a64 100644 --- a/src/org/atriasoft/ewol/object/EwolObject.java +++ b/src/org/atriasoft/ewol/object/EwolObject.java @@ -3,9 +3,15 @@ package org.atriasoft.ewol.object; import java.lang.ref.WeakReference; import org.atriasoft.ewol.Ewol; +import org.atriasoft.ewol.annotation.EwolDescription; import org.atriasoft.ewol.context.EwolContext; import org.atriasoft.ewol.internal.Log; -import org.atriasoft.exml.model.XmlElement; +import org.atriasoft.exml.annotation.XmlAttribute; +import org.atriasoft.exml.annotation.XmlDefaultManaged; +import org.atriasoft.exml.annotation.XmlDefaultOptional; +import org.atriasoft.exml.annotation.XmlIgnoreUnknow; +import org.atriasoft.exml.annotation.XmlManaged; +import org.atriasoft.exml.annotation.XmlName; /** @file * @author Edouard DUPIN @@ -17,6 +23,9 @@ import org.atriasoft.exml.model.XmlElement; * Basic message classes for ewol system * this class permit at every Object to communicate between them. */ +@XmlDefaultManaged(value = false) +@XmlDefaultOptional +@XmlIgnoreUnknow public class EwolObject { private static Integer valUID = 0; //!< Static used for the unique ID definition @@ -36,7 +45,7 @@ public class EwolObject { return Ewol.getContext().getEObjectManager(); } - /** + /** * Retrive an object with his name (in the global list) * @param objectName Name of the object * @return the requested object or null @@ -103,36 +112,14 @@ public class EwolObject { return this.uniqueId; } + @XmlManaged + @XmlAttribute + @XmlName(value = "name") + @EwolDescription(value = "Name of the object.") public String getName() { return this.name; } - /** - * load attribute properties with an XML node. - * @param node Reference on the XML node. - * @return true : All has been done corectly. - * @return false : An error occured. - */ - /* - boolean loadXMLAttributes( exml::Element node){ - if (node.exist() == false) { - return false; - } - boolean errorOccured = false; - - for( auto it : node.attributes) { - auto pair = it.getPair(); - if (pair.first == "") { - continue; - } - if (properties.set(pair.first, pair.second) == false) { - errorOccured = true; - } - } - return errorOccured; - } - */ - /** * get the static status of the Object == > mark at true if the user set the object mark as static allocated element ==> not auto remove element * @return true if it might not be removed == > usefull for conficuration class @@ -141,25 +128,6 @@ public class EwolObject { return this.staticObject; } - /** - * store properties in this XML node. - * @param[in,out] node Reference on the XML node. - * @return true : All has been done corectly. - * @return false : An error occured. - */ - /* - boolean storeXML(exml::Element node){ - if (node.exist() == false) { - return false; - } - boolean errorOccured = true; - for (auto it : properties.getAll(true)) { - node.attributes.set(it.first, it.second); - } - return errorOccured; - } - */ - /** * Get the resource status of the element. * @return the resource status. @@ -190,16 +158,6 @@ public class EwolObject { return this.destroy; } - /** - * load properties with an XML node. - * @param node Reference on the XML node. - * @return true : All has been done corectly. - * @return false : An error occured. - */ - protected boolean loadXML(final XmlElement node) { - return true; - } - /** * Remove the current parenting. */ @@ -230,7 +188,7 @@ public class EwolObject { } /** - * Declare this element as a resource (or singleton) this mean the element will + * Declare this element as a resource (or singleton) this mean the element will * not be auto Remove at the end of the programm. It just notify that it is not removed. * @param val Value of the type of the element. */ diff --git a/src/org/atriasoft/ewol/resource/ResourceTexturedFont.java b/src/org/atriasoft/ewol/resource/ResourceTexturedFont.java index 3230454..54d19e4 100644 --- a/src/org/atriasoft/ewol/resource/ResourceTexturedFont.java +++ b/src/org/atriasoft/ewol/resource/ResourceTexturedFont.java @@ -87,7 +87,7 @@ public class ResourceTexturedFont extends ResourceTexture2 { this.listElement[2] = new ArrayList<>(); this.listElement[3] = new ArrayList<>(); - String sizeString = fontBaseUri.getproperty("size"); + String sizeString = fontBaseUri.getProperty("size"); if (sizeString == null) { this.size = 25; } else { diff --git a/src/org/atriasoft/ewol/widget/Button.java b/src/org/atriasoft/ewol/widget/Button.java index ec7e438..fd404e8 100644 --- a/src/org/atriasoft/ewol/widget/Button.java +++ b/src/org/atriasoft/ewol/widget/Button.java @@ -6,6 +6,7 @@ import org.atriasoft.etk.Color; import org.atriasoft.etk.Uri; import org.atriasoft.etk.math.Vector2f; import org.atriasoft.etk.math.Vector2i; +import org.atriasoft.ewol.Gravity; import org.atriasoft.ewol.Padding; import org.atriasoft.ewol.annotation.EwolDescription; import org.atriasoft.ewol.annotation.EwolSignal; @@ -75,6 +76,8 @@ public class Button extends Widget { this.propertyCanFocus = true; onChangePropertyShaper(); markToRedraw(); + // can not support multiple click... + setMouseLimit(1); this.shape = new GuiShape(this.propertyConfig); } @@ -101,13 +104,17 @@ public class Button extends Widget { protected void changeStatusIn(final GuiShapeMode newStatusId) { if (this.shape.changeStatusIn(newStatusId)) { if (!this.periodicConnectionHanble.isConnected()) { - Log.error("REQUEST: connection on operiodic call"); + //Log.error("REQUEST: connection on operiodic call"); this.periodicConnectionHanble = EwolObject.getObjectManager().periodicCall.connect(this, Button::periodicCall); } markToRedraw(); } } + private boolean checkIfOver(Vector2f relPos) { + return relPos.x() > this.overPositionStart.x() && relPos.y() > this.overPositionStart.y() && relPos.x() < this.overPositionStop.x() && relPos.y() < this.overPositionStop.y(); + } + @XmlManaged @XmlAttribute @XmlName(value = "config") @@ -151,44 +158,57 @@ public class Button extends Widget { @Override public boolean onEventInput(final EventInput event) { Vector2f relPos = relativePosition(event.pos()); - Log.verbose("Event on Input ... " + event + " relPos = " + relPos); + Log.warning("Event on Input ... " + event + " relPos = " + relPos); + boolean over = checkIfOver(relPos); + //filter if outside the element... + if (event.status() == KeyStatus.leave) { + changeStatusIn(GuiShapeMode.NORMAL); + this.isDown = false; + return true; + } if (event.inputId() == 0) { if (!this.isDown) { if (KeyStatus.leave == event.status()) { changeStatusIn(GuiShapeMode.NORMAL); } else { Log.verbose("Detect Over : " + this.overPositionStart + " -> " + this.overPositionStop); - if (relPos.x() > this.overPositionStart.x() && relPos.y() > this.overPositionStart.y() && relPos.x() < this.overPositionStop.x() && relPos.y() < this.overPositionStop.y()) { + if (over) { changeStatusIn(GuiShapeMode.OVER); } else { changeStatusIn(GuiShapeMode.NORMAL); } } - } - } - if (event.inputId() == 1) { - if (KeyStatus.pressSingle == event.status()) { - keepFocus(); - this.signalClick.emit(); - //nothing to do ... return true; } - if (KeyStatus.down == event.status()) { - keepFocus(); - this.isDown = true; - changeStatusIn(GuiShapeMode.SELECT); - markToRedraw(); - this.signalDown.emit(); - } else if (KeyStatus.move == event.status()) { - keepFocus(); - markToRedraw(); - } else if (KeyStatus.up == event.status()) { - keepFocus(); - this.isDown = false; - this.signalUp.emit(); - changeStatusIn(GuiShapeMode.OVER); - markToRedraw(); - } + } + if (event.inputId() != 1) { + return false; + } + if (KeyStatus.pressSingle == event.status() && over) { + keepFocus(); + this.signalClick.emit(); + return true; + } + if (KeyStatus.down == event.status() && over) { + keepFocus(); + this.isDown = 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.isDown) { + keepFocus(); + this.isDown = false; + this.signalUp.emit(); + changeStatusIn(GuiShapeMode.OVER); + markToRedraw(); + return true; } return false; } @@ -210,14 +230,17 @@ public class Button extends Widget { Padding padding = this.shape.getPadding(); Vector2f tmpSizeShaper = this.minSize; + Vector2f delta = Gravity.gravityGenerateDelta(this.propertyGravity, 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); } - Vector2f tmpOriginShaper = this.size.less(tmpSizeShaper).multiply(0.5f); + Vector2f tmpOriginShaper = delta; Vector2f tmpSizeText = tmpSizeShaper.less(padding.x(), padding.y()); //Vector2f tmpOriginText = this.size.less(tmpSizeText).multiply(0.5f); Vector2f tmpOriginText = new Vector2f(0, this.gc.getTextSize()); diff --git a/src/org/atriasoft/ewol/widget/CheckBox.java b/src/org/atriasoft/ewol/widget/CheckBox.java index 5c03288..7f123cc 100644 --- a/src/org/atriasoft/ewol/widget/CheckBox.java +++ b/src/org/atriasoft/ewol/widget/CheckBox.java @@ -6,6 +6,7 @@ import org.atriasoft.esignal.SignalEmpty; import org.atriasoft.etk.Uri; import org.atriasoft.etk.math.Vector2f; import org.atriasoft.etk.math.Vector2i; +import org.atriasoft.ewol.Gravity; import org.atriasoft.ewol.Padding; import org.atriasoft.ewol.annotation.EwolDescription; import org.atriasoft.ewol.annotation.EwolSignal; @@ -47,6 +48,7 @@ public class CheckBox extends Widget { protected static void periodicCall(final CheckBox self, final EventTime event) { Log.verbose("Periodic call on Entry(" + event + ")"); if (!self.shape.periodicCall(event)) { + //Log.error("end periodic call"); self.periodicConnectionHanble.close(); } self.markToRedraw(); @@ -84,6 +86,8 @@ public class CheckBox extends Widget { this.propertyCanFocus = true; onChangePropertyShaper(); markToRedraw(); + // can not support multiple click... + setMouseLimit(1); this.shape = new GuiShape(this.propertyConfig); } @@ -110,13 +114,17 @@ public class CheckBox extends Widget { protected void changeStatusIn(final GuiShapeMode newStatusId) { if (this.shape.changeStatusIn(newStatusId)) { if (!this.periodicConnectionHanble.isConnected()) { - Log.error("REQUEST: connection on operiodic call"); + //Log.error("REQUEST: connection on periodic call"); this.periodicConnectionHanble = EwolObject.getObjectManager().periodicCall.connect(this, CheckBox::periodicCall); } markToRedraw(); } } + private boolean checkIfOver(Vector2f relPos) { + return relPos.x() > this.overPositionStart.x() && relPos.y() > this.overPositionStart.y() && relPos.x() < this.overPositionStop.x() && relPos.y() < this.overPositionStop.y(); + } + @XmlManaged @XmlAttribute @XmlName(value = "config") @@ -153,51 +161,65 @@ public class CheckBox extends Widget { @Override protected void onDraw() { if (this.shape != null) { - this.shape.draw(true); + this.shape.draw(true, this.propertyValue ? 0 : 1); } } @Override public boolean onEventInput(final EventInput event) { Vector2f relPos = relativePosition(event.pos()); - Log.verbose("Event on Input ... " + event + " relPos = " + relPos); + Log.warning("Event on Input ... " + event + " relPos = " + relPos); + boolean over = checkIfOver(relPos); + //filter if outside the element... + if (event.status() == KeyStatus.leave) { + changeStatusIn(GuiShapeMode.NORMAL); + this.isDown = false; + return true; + } if (event.inputId() == 0) { if (!this.isDown) { if (KeyStatus.leave == event.status()) { changeStatusIn(GuiShapeMode.NORMAL); } else { Log.verbose("Detect Over : " + this.overPositionStart + " -> " + this.overPositionStop); - if (relPos.x() > this.overPositionStart.x() && relPos.y() > this.overPositionStart.y() && relPos.x() < this.overPositionStop.x() && relPos.y() < this.overPositionStop.y()) { + if (over) { changeStatusIn(GuiShapeMode.OVER); } else { changeStatusIn(GuiShapeMode.NORMAL); } } - } - } - if (event.inputId() == 1) { - if (KeyStatus.pressSingle == event.status()) { - keepFocus(); - this.signalClick.emit(); - //nothing to do ... return true; } - if (KeyStatus.down == event.status()) { - keepFocus(); - this.isDown = true; - changeStatusIn(GuiShapeMode.SELECT); - markToRedraw(); - this.signalDown.emit(); - } else if (KeyStatus.move == event.status()) { - keepFocus(); - markToRedraw(); - } else if (KeyStatus.up == event.status()) { - keepFocus(); - this.isDown = false; - this.signalUp.emit(); - changeStatusIn(GuiShapeMode.OVER); - markToRedraw(); - } + } + if (event.inputId() != 1) { + return false; + } + if (KeyStatus.pressSingle == event.status() && over) { + keepFocus(); + this.signalClick.emit(); + this.propertyValue = !this.propertyValue; + return true; + } + if (KeyStatus.down == event.status() && over) { + keepFocus(); + this.isDown = 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.isDown) { + keepFocus(); + this.isDown = false; + this.signalUp.emit(); + changeStatusIn(GuiShapeMode.OVER); + markToRedraw(); + return true; } return false; } @@ -219,17 +241,20 @@ public class CheckBox extends Widget { Padding padding = this.shape.getPadding(); Vector2f tmpSizeShaper = this.minSize; + Vector2f delta = Gravity.gravityGenerateDelta(this.propertyGravity, 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); } - Vector2f tmpOriginShaper = this.size.less(tmpSizeShaper).multiply(0.5f); - Vector2f tmpSizeText = tmpSizeShaper.less(padding.x(), padding.y()); + Vector2f tmpOriginShaper = delta; + Vector2f tmpSizeInside = tmpSizeShaper.less(padding.x(), padding.y()); //Vector2f tmpOriginText = this.size.less(tmpSizeText).multiply(0.5f); - Vector2f tmpOriginText = new Vector2f(0, 0);//this.gc.getTextSize()); + Vector2f tmpOriginInside = new Vector2f(0, 0);//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(); @@ -240,8 +265,8 @@ public class CheckBox extends Widget { // fix all the position in the int class: tmpSizeShaper = Vector2f.clipInt(tmpSizeShaper); tmpOriginShaper = Vector2f.clipInt(tmpOriginShaper); - tmpSizeText = Vector2f.clipInt(tmpSizeText); - tmpOriginText = Vector2f.clipInt(tmpOriginText); + tmpSizeInside = Vector2f.clipInt(tmpSizeInside); + tmpOriginInside = Vector2f.clipInt(tmpOriginInside); //this.gc.clear(); //this.gc.setSize((int)tmpSizeText.x(), (int)tmpSizeText.y()); @@ -252,7 +277,7 @@ public class CheckBox extends Widget { //this.gc.text(tmpOriginText, this.propertyValue); this.overPositionStart = tmpOriginShaper; this.overPositionStop = tmpOriginShaper.add(tmpSizeShaper); - this.shape.setShape(tmpOriginShaper, tmpSizeShaper, tmpOriginText, tmpSizeText); + this.shape.setShape(tmpOriginShaper, tmpSizeShaper, tmpOriginInside, tmpSizeInside); //this.gc.flush(); this.shape.flush(); diff --git a/src/org/atriasoft/ewol/widget/ContainerN.java b/src/org/atriasoft/ewol/widget/ContainerN.java index 627438e..f84eb0c 100644 --- a/src/org/atriasoft/ewol/widget/ContainerN.java +++ b/src/org/atriasoft/ewol/widget/ContainerN.java @@ -17,10 +17,9 @@ import org.atriasoft.ewol.annotation.EwolDescription; import org.atriasoft.ewol.internal.Log; import org.atriasoft.ewol.object.EwolObject; import org.atriasoft.exml.annotation.XmlAttribute; +import org.atriasoft.exml.annotation.XmlFactory; import org.atriasoft.exml.annotation.XmlManaged; import org.atriasoft.exml.annotation.XmlName; -import org.atriasoft.exml.model.XmlElement; -import org.atriasoft.exml.model.XmlNode; /** * @ingroup ewolWidgetGroup @@ -114,6 +113,13 @@ public class ContainerN extends Widget { return null; } + @XmlManaged + @XmlFactory(value = WidgetXmlFactory.class) + @EwolDescription(value = "Request the widget Expand size while free space is detected (does not generate expand in upper widget)") + public List getSubWidgets() { + return this.subWidget; + } + @Override public Widget getWidgetAtPos(final Vector2f pos) { if (this.propertyHide) { @@ -137,58 +143,6 @@ public class ContainerN extends Widget { return null; } - @Override - public boolean loadXML(final XmlElement node) { - if (node == null) { - return false; - } - // parse generic properties : - super.loadXML(node); - // remove previous element : - subWidgetRemoveAll(); - - String tmpAttributeValue = node.getAttribute("lock", ""); - if (tmpAttributeValue.length() != 0) { - setPropertyLockExpand(Vector2b.valueOf(tmpAttributeValue)); - } - boolean invertAdding = false; - tmpAttributeValue = node.getAttribute("addmode", "").toLowerCase(); - if (tmpAttributeValue.contentEquals("invert")) { - invertAdding = true; - } - // parse all the elements : - for (XmlNode nodeIt : node.getNodes()) { - if (!nodeIt.isElement()) { - // trash here all that is not element - continue; - } - XmlElement pNode = nodeIt.toElement(); - String widgetName = pNode.getValue(); - Log.verbose(" t=" + this.getClass().getCanonicalName() + " Load node name : '" + widgetName + "'"); - if (!getWidgetManager().exist(widgetName)) { - Log.error("[" + getId() + "] {" + this.getClass().getCanonicalName() + "} Unknown basic node='" + widgetName + "' not in : [" + getWidgetManager().list() + "]"); - continue; - } - Log.debug("[" + getId() + "] {" + this.getClass().getCanonicalName() + "} load new element : '" + widgetName + "'"); - Widget subWidget = getWidgetManager().create(widgetName, pNode); - if (subWidget == null) { - Log.error("[" + getId() + "] {" + this.getClass().getCanonicalName() + "} Can not create the widget : '" + widgetName + "'"); - continue; - } - // add sub element : - if (!invertAdding) { - subWidgetAdd(subWidget); - } else { - subWidgetAddStart(subWidget); - } - if (!subWidget.loadXML(pNode)) { - Log.error("[" + getId() + "] {" + this.getClass().getCanonicalName() + "} can not load widget properties : '" + widgetName + "'"); - return false; - } - } - return true; - } - @Override public void onChangeSize() { for (Widget it : this.subWidget) { @@ -247,6 +201,21 @@ public class ContainerN extends Widget { requestUpdateSize(); } + public void setSubWidgets(List listData) { + // Clean all previous widget + this.subWidgetRemoveAll(); + // add separately all widgets + for (Widget elem : listData) { + if (elem == null) { + continue; + } + elem.setParent(this); + this.subWidget.add(0, elem); + } + markToRedraw(); + requestUpdateSize(); + } + /** * add at end position a Widget (note : This system use an inverted phylisophie (button to top, and left to right) * @param newWidget the element pointer diff --git a/src/org/atriasoft/ewol/widget/ImageDisplay.java b/src/org/atriasoft/ewol/widget/ImageDisplay.java index ccd16f0..90732d0 100644 --- a/src/org/atriasoft/ewol/widget/ImageDisplay.java +++ b/src/org/atriasoft/ewol/widget/ImageDisplay.java @@ -21,7 +21,6 @@ import org.atriasoft.ewol.resource.ResourceColorFile; import org.atriasoft.exml.annotation.XmlAttribute; import org.atriasoft.exml.annotation.XmlManaged; import org.atriasoft.exml.annotation.XmlName; -import org.atriasoft.exml.model.XmlElement; import org.atriasoft.gale.key.KeyStatus; public class ImageDisplay extends Widget { @@ -140,50 +139,6 @@ public class ImageDisplay extends Widget { return this.propertyUseThemeColor; } - @Override - public boolean loadXML(final XmlElement node) { - if (node == null) { - return false; - } - super.loadXML(node); - // get internal data : - - String tmpAttributeValue = node.getAttribute("ratio", "").toLowerCase(); - if (tmpAttributeValue.length() != 0) { - if (tmpAttributeValue.equals("true")) { - this.propertyKeepRatio = true; - } else if (tmpAttributeValue.equals("1")) { - this.propertyKeepRatio = true; - } else { - this.propertyKeepRatio = false; - } - } - tmpAttributeValue = node.getAttribute("size", ""); - if (tmpAttributeValue.length() != 0) { - //Log.critical(" Parse SIZE : " + tmpAttributeValue); - this.propertyImageSize = Dimension.valueOf(tmpAttributeValue); - //Log.critical(" == > " + propertyImageSize); - } - tmpAttributeValue = node.getAttribute("border", ""); - if (tmpAttributeValue.length() != 0) { - this.propertyBorder = Dimension.valueOf(tmpAttributeValue); - } - tmpAttributeValue = node.getAttribute("smooth", ""); - if (tmpAttributeValue.length() != 0) { - this.propertySmooth = Boolean.parseBoolean(tmpAttributeValue); - } - //Log.debug("Load label:" + node.ToElement().getText()); - if (node.getNodes().size() != 0) { - this.propertySource = Uri.valueOf(node.getText()); - } else { - tmpAttributeValue = node.getAttribute("src", ""); - if (tmpAttributeValue.length() != 0) { - this.propertySource = Uri.valueOf(tmpAttributeValue); - } - } - return true; - } - @Override protected void onDraw() { this.compositing.draw(); diff --git a/src/org/atriasoft/ewol/widget/Label.java b/src/org/atriasoft/ewol/widget/Label.java index c71347e..c70faa2 100644 --- a/src/org/atriasoft/ewol/widget/Label.java +++ b/src/org/atriasoft/ewol/widget/Label.java @@ -22,7 +22,6 @@ import org.atriasoft.ewol.resource.ResourceColorFile; import org.atriasoft.exml.annotation.XmlAttribute; import org.atriasoft.exml.annotation.XmlManaged; import org.atriasoft.exml.annotation.XmlName; -import org.atriasoft.exml.model.XmlElement; import org.atriasoft.gale.key.KeyStatus; public class Label extends Widget { @@ -92,18 +91,6 @@ public class Label extends Widget { return this.propertyAutoTranslate; } - @Override - public boolean loadXML(final XmlElement node) { - if (node == null) { - return false; - } - super.loadXML(node); - // get internal data : - Log.debug("Load label:" + node.getText()); - setPropertyValue(node.getText()); - return true; - } - @Override protected void onDraw() { this.text.draw(); diff --git a/src/org/atriasoft/ewol/widget/Widget.java b/src/org/atriasoft/ewol/widget/Widget.java index 494d939..4adae2a 100644 --- a/src/org/atriasoft/ewol/widget/Widget.java +++ b/src/org/atriasoft/ewol/widget/Widget.java @@ -32,12 +32,8 @@ import org.atriasoft.ewol.event.InputSystem; import org.atriasoft.ewol.internal.Log; import org.atriasoft.ewol.object.EwolObject; import org.atriasoft.exml.annotation.XmlAttribute; -import org.atriasoft.exml.annotation.XmlDefaultManaged; -import org.atriasoft.exml.annotation.XmlDefaultOptional; -import org.atriasoft.exml.annotation.XmlIgnoreUnknow; import org.atriasoft.exml.annotation.XmlManaged; import org.atriasoft.exml.annotation.XmlName; -import org.atriasoft.exml.model.XmlElement; import org.atriasoft.gale.backend3d.OpenGL; import org.atriasoft.gale.context.ClipboardList; import org.atriasoft.gale.context.Cursor; @@ -53,10 +49,6 @@ import org.lwjgl.opengl.GL11; * :** Receive Event (keyboard / mouse / ...) * */ - -@XmlDefaultManaged(value = false) -@XmlDefaultOptional -@XmlIgnoreUnknow public class Widget extends EwolObject { // ---------------------------------------------------------------------------------------------------------------- // -- keyboard event properties Area @@ -423,13 +415,6 @@ public class Widget extends EwolObject { getWidgetManager().focusKeep(this); } - @Override - public boolean loadXML(final XmlElement node) { - super.loadXML(node); - markToRedraw(); - return true; - } - /** * The widget mark itself that it need to regenerate the nest time. */ diff --git a/src/org/atriasoft/ewol/widget/WidgetManager.java b/src/org/atriasoft/ewol/widget/WidgetManager.java index c074846..5333ae1 100644 --- a/src/org/atriasoft/ewol/widget/WidgetManager.java +++ b/src/org/atriasoft/ewol/widget/WidgetManager.java @@ -15,10 +15,10 @@ import org.atriasoft.exml.model.XmlElement; */ public class WidgetManager { + // --------------------------------------------- // -- Factory area // --------------------------------------------- - private final Map> creatorList = new HashMap<>(); //!< List of factory of a widget private WeakReference focusWidgetCurrent; //!< Current focus selected // --------------------------------------------- // -- Focus area @@ -83,7 +83,7 @@ public class WidgetManager { } /** - * @throws Exception + * @throws Exception * add a factory of a specific widget. * @param name Name of the widget that is associated of the factory. * @param klass class interface @@ -94,7 +94,7 @@ public class WidgetManager { } //Keep name in lower case : final String nameLower = name.toLowerCase(); - final Class it = this.creatorList.get(nameLower); + final Class it = WidgetXmlFactory..creatorList.get(nameLower); if (it != null) { Log.warning("Replace Creator of a specify widget : " + nameLower); return; @@ -172,7 +172,7 @@ public class WidgetManager { //elog::displayBacktrace(); Widget focusWidgetCurrent = this.focusWidgetCurrent.get(); if (newWidget == focusWidgetCurrent) { - // nothing to do ... + // nothing to do ... return; } if (focusWidgetCurrent != null) { @@ -186,7 +186,7 @@ public class WidgetManager { } this.focusWidgetCurrent = new WeakReference<>(newWidget); if (newWidget != null) { - Log.debug("Set focus on WidgetID=" + newWidget.getId() ); + Log.debug("Set focus on WidgetID=" + newWidget.getId()); newWidget.setFocus(); } } diff --git a/src/org/atriasoft/ewol/widget/WidgetXmlFactory.java b/src/org/atriasoft/ewol/widget/WidgetXmlFactory.java new file mode 100644 index 0000000..eabf050 --- /dev/null +++ b/src/org/atriasoft/ewol/widget/WidgetXmlFactory.java @@ -0,0 +1,28 @@ +package org.atriasoft.ewol.widget; + +import java.util.HashMap; +import java.util.Map; + +import org.atriasoft.exml.annotation.XmlFactory.InterfaceXmlFactoryAccess; + +public class WidgetXmlFactory implements InterfaceXmlFactoryAccess { + private static Map> listWidgetAvaillable = new HashMap<>(); + static { + listWidgetAvaillable.put("Button", Button.class); + listWidgetAvaillable.put("Sizer", Sizer.class); + listWidgetAvaillable.put("Label", Label.class); + listWidgetAvaillable.put("CheckBox", CheckBox.class); + listWidgetAvaillable.put("Image", ImageDisplay.class); + } + + @Override + public Class findClass(String name) { + return listWidgetAvaillable.get(name); + } + + @Override + public String generateName(Object widget) { + return null; + } + +}