diff --git a/blender_files/exportEmf.py b/blender_files/exportEmf.py new file mode 100644 index 0000000..dfabb20 --- /dev/null +++ b/blender_files/exportEmf.py @@ -0,0 +1,15 @@ +import bpy + +##To export manualy a emf... (for test ...) +# blender --background -P ./exportEmf.py + + + +list_elem = [ + "Entry", + "CheckBox" + ] + +for elem in list_elem: + bpy.ops.wm.open_mainfile(filepath="/home/heero/dev/WORKSPACE-game/jatria-soft/ewol/blender_files/" + elem + ".blend") + bpy.ops.export_scene.emf(filepath="/home/heero/dev/WORKSPACE-game/jatria-soft/ewol/resources/resources/ewol/theme/shape/" + elem + ".emf") diff --git a/resources/resources/ewol/theme/shape/CheckBox.emf b/resources/resources/ewol/theme/shape/CheckBox.emf new file mode 100644 index 0000000..f407476 --- /dev/null +++ b/resources/resources/ewol/theme/shape/CheckBox.emf @@ -0,0 +1,90 @@ +EMF(STRING) +# Blender v3.0.0 EMF File: 'CheckBox.blend' +Mesh:CheckBox_Cube + Vertex:16 + 20.042355 19.982376 -7.860689|20.042355 -20.102333 -7.862826|20.042355 19.981716 4.524041|20.042355 -20.102993 4.521903|-20.042355 19.982376 -7.860689|-20.042355 -20.102333 -7.862826|-20.042355 19.981716 4.524041|-20.042355 -20.102993 4.521903|10.127714 10.066911 7.616918|10.127714 -10.188519 7.615837|-10.127714 10.066911 7.616918|-10.127714 -10.188519 7.615837|-10.199120 -10.192897 3.116539|-10.199120 10.181330 3.117619|10.199120 10.181330 3.117619|10.199120 -10.192897 3.116539| + UV-mapping: + 0.074219 0.995849|0.120606 0.943115|0.121582 0.993408|0.112927 0.992387|0.078245 0.948093|0.073324 0.991157|0.101769 0.970961|0.080974 0.959440|0.102023 0.957458|0.111927 0.985005|0.078476 0.953015|0.082167 0.983774|0.074219 0.944092|0.111696 0.944402|0.080720 0.975385|0.113157 0.949323|0.174907 0.947863|0.131613 0.991157|0.132843 0.945402|0.178368 0.944941|0.137534 0.984544|0.142456 0.948632|0.171985 0.949093|0.136074 0.991157|0.137304 0.950323|0.174677 0.949093|0.135074 0.992387|0.136304 0.949093|0.178598 0.993618|0.178368 0.988235|0.173216 0.991157|0.175907 0.989926|0.013265 0.951784|0.051868 0.992387|0.013034 0.993618|0.054098 0.951784|0.137534 0.988235|0.177138 0.947863|0.135074 0.947862|0.172446 0.988465| + Normal(face):28 + -0.297843 -0.000051 0.954615|0.000000 -0.297894 0.954599|0.000000 0.297792 0.954631|0.297843 -0.000051 0.954615|0.000000 1.000000 0.000053|-1.000000 0.000000 0.000000|0.000000 -1.000000 -0.000053|1.000000 -0.000000 -0.000000|-0.999874 0.000001 -0.015868|0.000000 -0.999677 -0.025422|0.999874 0.000001 -0.015868|0.000000 1.000000 -0.000973|0.000000 -0.000053 1.000000|0.000000 0.000053 -1.000000| + Face:28 + palette:gui_border_1 + 7/0/0 10/1/0 6/2/0| 3/3/1 11/4/1 7/5/1| 6/6/2 8/7/2 2/8/2| 2/9/3 9/10/3 3/11/3| 7/0/0 11/12/0 10/1/0| 3/3/1 9/13/1 11/4/1| 6/6/2 10/14/2 8/7/2| 2/9/3 8/15/3 9/10/3| + palette:gui_border_2 + 4/16/4 2/17/4 0/18/4| 6/19/5 5/20/5 7/21/5| 1/22/6 7/23/6 5/24/6| 0/25/7 3/26/7 1/27/7| 4/16/4 6/28/4 2/17/4| 6/19/5 4/29/5 5/20/5| 1/22/6 3/30/6 7/23/6| 0/25/7 2/31/7 3/26/7| + pallette_gui_border_inside + 8/7/8 15/32/8 9/10/8| 13/33/9 8/7/9 10/14/9| 10/14/10 12/34/10 13/33/10| 15/32/11 11/4/11 9/10/11| 8/7/8 14/35/8 15/32/8| 13/33/9 14/35/9 8/7/9| 10/14/10 11/4/10 12/34/10| 15/32/11 12/34/11 11/4/11| + palette:gui_center + 15/32/12 13/33/12 12/34/12| 15/32/12 14/35/12 13/33/12| + palette:gui_back + 5/36/13 0/37/13 1/38/13| 5/36/13 4/39/13 0/37/13| +Mesh:Check_Cube.001 + Vertex:24 + 8.995508 -7.035839 7.616555|6.980225 -8.995319 7.616555|8.995420 -8.995663 7.616555|9.004554 7.030243 7.616555|-7.023398 -9.003085 7.616555|-9.002556 -9.002914 7.616555|-9.002995 -7.043067 7.616555|-8.995707 7.044378 7.616555|-8.996955 9.000613 7.616555|-7.018671 8.999785 7.616555|6.991146 8.995932 7.616555|9.004070 8.994483 7.616555|8.995508 -7.035839 3.038752|6.980224 -8.995319 3.038752|8.995419 -8.995663 3.038752|9.004553 7.030243 3.038752|-7.023399 -9.003085 3.038752|-9.002556 -9.002914 3.038752|-9.002996 -7.043067 3.038752|-8.995708 7.044378 3.038752|-8.996956 9.000613 3.038752|-7.018671 8.999785 3.038752|6.991146 8.995932 3.038752|9.004069 8.994483 3.038752| + UV-mapping: + 0.000000 0.000000| + Normal(face):32 + 0.000000 0.000000 1.000000|-1.000000 -0.000638 0.000000|-0.000170 -1.000000 0.000000|0.000720 1.000000 -0.000000|-1.000000 -0.000224 -0.000000|1.000000 0.000246 -0.000000|0.707580 0.706634 0.000000|0.707225 -0.706988 0.000000|-0.708096 0.706116 0.000000|-0.000086 -1.000000 0.000000|0.000418 1.000000 -0.000000|1.000000 -0.000045 0.000000|-0.708514 -0.705697 0.000000|-1.000000 -0.000225 0.000000|1.000000 -0.000046 -0.000000| + Face:32 + palette:gui_checked + 5/0/0 4/0/0 6/0/0| 8/0/1 19/0/1 7/0/1| 1/0/2 14/0/2 2/0/2| 10/0/3 23/0/3 22/0/3| 6/0/4 17/0/4 5/0/4| 3/0/5 23/0/5 11/0/5| 12/0/6 9/0/6 0/0/6| 16/0/7 3/0/7 4/0/7| 6/0/8 22/0/8 18/0/8| 5/0/9 16/0/9 4/0/9| 9/0/10 20/0/10 8/0/10| 2/0/11 12/0/11 0/0/11| 7/0/12 13/0/12 1/0/12| 9/0/0 1/0/0 0/0/0| 8/0/0 7/0/0 9/0/0| 4/0/0 10/0/0 6/0/0| 10/0/0 3/0/0 11/0/0| 2/0/0 0/0/0 1/0/0| 8/0/1 20/0/1 19/0/1| 1/0/2 13/0/2 14/0/2| 10/0/3 11/0/3 23/0/3| 6/0/13 18/0/13 17/0/13| 3/0/5 15/0/5 23/0/5| 12/0/6 21/0/6 9/0/6| 16/0/7 15/0/7 3/0/7| 6/0/8 10/0/8 22/0/8| 5/0/9 17/0/9 16/0/9| 9/0/10 21/0/10 20/0/10| 2/0/14 14/0/14 12/0/14| 7/0/12 19/0/12 13/0/12| 9/0/0 7/0/0 1/0/0| 4/0/0 3/0/0 10/0/0| + +# Just for information: +Palettes:gui_back + Ns 225.000000 + Ka 1.000000 1.000000 1.000000 + Kd 0.800000 0.000000 0.005632 + Ks 0.500000 0.500000 0.500000 + Ke 0.000000 0.000000 0.000000 + vNi 1.450000 + d 1.000000 + illum 2 +# Just for information: +Palettes:gui_border_1 + Ns 225.000000 + Ka 1.000000 1.000000 1.000000 + Kd 0.000000 0.002615 0.800000 + Ks 0.500000 0.500000 0.500000 + Ke 0.000000 0.000000 0.000000 + vNi 1.450000 + d 1.000000 + illum 2 +# Just for information: +Palettes:gui_border_2 + Ns 225.000000 + Ka 1.000000 1.000000 1.000000 + Kd 0.000000 0.800000 0.170495 + Ks 0.500000 0.500000 0.500000 + Ke 0.000000 0.000000 0.000000 + vNi 1.450000 + d 1.000000 + illum 2 +# Just for information: +Palettes:gui_center + Ns 225.000000 + Ka 1.000000 1.000000 1.000000 + Kd 0.438544 0.438544 0.438544 + Ks 0.500000 0.500000 0.500000 + Ke 0.000000 0.000000 0.000000 + vNi 1.450000 + d 1.000000 + illum 2 +# Just for information: +Palettes:gui_checked + Ns 225.000000 + Ka 1.000000 1.000000 1.000000 + Kd 0.000000 0.000000 0.000000 + Ks 0.500000 0.500000 0.500000 + Ke 0.000000 0.000000 0.000000 + vNi 1.450000 + d 1.000000 + illum 2 +Materials:pallette_gui_border_inside + Ns 225.000000 + Ka 1.000000 1.000000 1.000000 + Kd 0.003877 0.001682 0.147314 + Ks 0.500000 0.500000 0.500000 + Ke 0.000000 0.000000 0.000000 + vNi 1.450000 + d 1.000000 + illum 2 diff --git a/resources/resources/ewol/theme/shape/CheckBox.json b/resources/resources/ewol/theme/shape/CheckBox.json index e7a42f9..64cabc0 100644 --- a/resources/resources/ewol/theme/shape/CheckBox.json +++ b/resources/resources/ewol/theme/shape/CheckBox.json @@ -6,11 +6,11 @@ "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, - + "padding-in-left":0, + "padding-in-right":0, + "padding-in-top":0, + "padding-in-buttom":0, + # render program: "program-vert":"THEME:shape/aaRenderShape.vert?lib=ewol", "program-frag":"THEME:shape/aaRenderShape.frag?lib=ewol", diff --git a/resources/resources/ewol/theme/shape/Entry.blend b/resources/resources/ewol/theme/shape/Entry.blend deleted file mode 100644 index 0c39e1a..0000000 Binary files a/resources/resources/ewol/theme/shape/Entry.blend and /dev/null differ diff --git a/resources/resources/ewol/theme/shape/Entry.emf b/resources/resources/ewol/theme/shape/Entry.emf index e4e9a27..96a8313 100644 --- a/resources/resources/ewol/theme/shape/Entry.emf +++ b/resources/resources/ewol/theme/shape/Entry.emf @@ -1,5 +1,5 @@ EMF(STRING) -# Blender v2.92.0 EMF File: 'Entry.blend' +# Blender v3.0.0 EMF File: 'Entry.blend' Mesh:EntryBox_Cube Vertex:16 20.042355 19.982376 -7.860689|20.042355 -20.102333 -7.862826|20.042355 19.981716 4.524041|20.042355 -20.102993 4.521903|-20.042355 19.982376 -7.860689|-20.042355 -20.102333 -7.862826|-20.042355 19.981716 4.524041|-20.042355 -20.102993 4.521903|10.127714 10.066911 7.616918|10.127714 -10.188519 7.615837|-10.127714 10.066911 7.616918|-10.127714 -10.188519 7.615837|-10.127714 -10.188596 7.897926|-10.127714 10.066834 7.899007|10.127714 10.066834 7.899007|10.127714 -10.188596 7.897926| diff --git a/resources/resources/ewol/theme/shape/aaRenderShape.vert b/resources/resources/ewol/theme/shape/aaRenderShape.vert index 09510bb..1bd3356 100644 --- a/resources/resources/ewol/theme/shape/aaRenderShape.vert +++ b/resources/resources/ewol/theme/shape/aaRenderShape.vert @@ -9,7 +9,8 @@ precision mediump int; layout (location = 0) in vec3 in_position; layout (location = 1) in vec2 in_textureCoords; -uniform vec3 in_offsetScale; +uniform vec3 in_offsetScaleInside; +uniform vec3 in_offsetScaleOutside; uniform mat4 in_matrixTransformation; uniform mat4 in_matrixProjection; @@ -19,9 +20,31 @@ uniform mat4 in_matrixView; out vec2 io_textureCoords; void main(void) { - vec4 position = vec4(in_position.x + sign(in_position.x)*in_offsetScale.x, - in_position.y + sign(in_position.y)*in_offsetScale.y, - in_position.z + sign(in_position.z)*in_offsetScale.z, 1.0); + float xxx = in_position.x; + if (abs(xxx) < 10.0) { + xxx = xxx * in_offsetScaleInside.x * 0.1; + } else { + xxx = xxx + sign(xxx)*in_offsetScaleOutside.x; + } + float yyy = in_position.y; + if (abs(yyy) < 10.0) { + yyy = yyy * in_offsetScaleInside.y * 0.1; + } else { + yyy = yyy + sign(yyy)*in_offsetScaleOutside.y; + } + float zzz = in_position.z; + if (abs(zzz) < 10.0) { + zzz = zzz * in_offsetScaleInside.z * 0.1; + } else { + zzz = zzz + sign(zzz)*in_offsetScaleOutside.z; + } + vec4 position = vec4(xxx, yyy, zzz, 1.0); + /* + // this is the old mode before checkbox : ==> maybe create 2 shader???? + vec4 position = vec4(in_position.x + sign(in_position.x)*in_offsetScaleOutside.x, + in_position.y + sign(in_position.y)*in_offsetScaleOutside.y, + in_position.z + sign(in_position.z)*in_offsetScaleOutside.z, 1.0); + */ gl_Position = in_matrixProjection * in_matrixView * in_matrixTransformation * position; io_textureCoords = in_textureCoords; } diff --git a/resources/resources/ewol/theme/shape/coeur.blend b/resources/resources/ewol/theme/shape/coeur.blend deleted file mode 100644 index 7ed7f59..0000000 Binary files a/resources/resources/ewol/theme/shape/coeur.blend and /dev/null differ diff --git a/resources/resources/ewol/theme/shape/palette_gui.json b/resources/resources/ewol/theme/shape/palette_gui.json index 051a525..739e89f 100644 --- a/resources/resources/ewol/theme/shape/palette_gui.json +++ b/resources/resources/ewol/theme/shape/palette_gui.json @@ -27,6 +27,12 @@ }, "gui_back":{ "Kd":"1.0 0.0 0.0" + }, + "gui_checked":{ + "Kd":"0.0 0.0 0.0" + }, + "gui_border_inside":{ + "Kd":"0.5 0.5 0.5" } } } \ No newline at end of file diff --git a/resources/resources/ewol/theme/shape/pot.blend b/resources/resources/ewol/theme/shape/pot.blend deleted file mode 100644 index 95aeb3a..0000000 Binary files a/resources/resources/ewol/theme/shape/pot.blend and /dev/null differ diff --git a/src/org/atriasoft/ewol/compositing/GuiShape.java b/src/org/atriasoft/ewol/compositing/GuiShape.java index e73a35d..cfe4a21 100644 --- a/src/org/atriasoft/ewol/compositing/GuiShape.java +++ b/src/org/atriasoft/ewol/compositing/GuiShape.java @@ -49,11 +49,12 @@ public class GuiShape extends Compositing { private int oGLMatrixTransformation = -1; //!< openGL id on the element (transformation matrix) private int oGLMatrixView = -1; //!< openGL id on the element (view matrix) private int oGLPaletteOffset = -1; //!< openGL id on the element (offset for the palet rendering) - private int oGLOffsetScale = -1; + private int oGLOffsetScaleInside = -1; + private int oGLOffsetScaleOutside = -1; // openGL shaders programs: private ResourceProgram oGLprogram = null; //!< pointer on the opengl display program // For the Image : - + private ResourcePaletteFile palette; private ResourceTexture2 texture; private ResourceMesh mesh = null; @@ -64,10 +65,11 @@ public class GuiShape extends Compositing { private Matrix4f transform = Matrix4f.IDENTITY; private Uri uri; //!< Name of the configuration of the shaper. - private Vector3f offsetScale = Vector3f.ZERO; + private Vector3f offsetScaleInside = Vector3f.ZERO; + private Vector3f offsetScaleOutside = Vector3f.ZERO; // dynamic change: - private float stateTransition = 0; //!< working state between 2 states + private float stateTransition = 0; //!< working state between 2 states /** * @brief generic constructor @@ -85,27 +87,7 @@ public class GuiShape extends Compositing { loadPalette(); loadProgram(); } - protected void loadPalette() { - String paletteFile = this.config.getString(this.confIdPaletteFile); - Uri paletteFileInterface = Uri.valueOf(paletteFile); - this.palette = ResourcePaletteFile.create(paletteFileInterface); - this.texture = ResourceTexture2.createNamed("TEXTURE_OF_PALETTE:" + paletteFile); - if (this.texture == null) { - Log.error("can not instanciate Texture ..."); - } - // element already called - loadPaletteUpdate(); - // for next update (realTime reload) - this.palette.onUpdate(() -> { - loadPaletteUpdate(); - }); - } - protected void loadPaletteUpdate() { - Log.warning("update palet environnement"); - final ImageByte img = this.palette.getImageByte(); - //IOgami.storePNG(new Uri("/home/heero/000000000aaaaplopppp.png"), img); - this.texture.set(img); - } + /** * @brief change the current status in an other * @param _newStatusId the next new status requested @@ -155,40 +137,42 @@ public class GuiShape extends Compositing { this.oGLprogram.uniformMatrix(this.oGLMatrixProjection, projMatrix); this.oGLprogram.uniformMatrix(this.oGLMatrixTransformation, tmpMatrix); this.oGLprogram.uniformMatrix(this.oGLMatrixView, camMatrix); - - + Set layers = this.mesh.getLayers(); Log.verbose("get layers:" + layers); // Texture: - float imageDelta = (float)1 / ResourcePaletteFile.getHeight(); + float imageDelta = (float) 1 / ResourcePaletteFile.getHeight(); float basicValue = this.stateOld.getValue() / ResourcePaletteFile.getHeight(); if (this.stateOld != this.stateNew) { - if(this.stateOld == GuiShapeMode.NORMAL) { + if (this.stateOld == GuiShapeMode.NORMAL) { if (this.stateNew == GuiShapeMode.OVER) { - basicValue += imageDelta*this.stateTransition; + basicValue += imageDelta * this.stateTransition; } else if (this.stateNew == GuiShapeMode.SELECT) { - basicValue += imageDelta*3.0f - imageDelta*this.stateTransition; + basicValue += imageDelta * 3.0f - imageDelta * this.stateTransition; } - } else if(this.stateOld == GuiShapeMode.OVER) { + } else if (this.stateOld == GuiShapeMode.OVER) { if (this.stateNew == GuiShapeMode.NORMAL) { - basicValue -= imageDelta*this.stateTransition; + basicValue -= imageDelta * this.stateTransition; } else if (this.stateNew == GuiShapeMode.SELECT) { - basicValue += imageDelta*this.stateTransition; + basicValue += imageDelta * this.stateTransition; } - } else if(this.stateOld == GuiShapeMode.SELECT) { + } else if (this.stateOld == GuiShapeMode.SELECT) { if (this.stateNew == GuiShapeMode.NORMAL) { - basicValue += imageDelta*this.stateTransition; + basicValue += imageDelta * this.stateTransition; } else if (this.stateNew == GuiShapeMode.OVER) { - basicValue -= imageDelta*this.stateTransition; + basicValue -= imageDelta * this.stateTransition; } } } - Log.verbose("colorDelta = " + basicValue + " old = " + this.stateOld + "(" + this.stateOld.getValue()*imageDelta + ") new = " + this.stateNew + "(" + this.stateNew.getValue()*imageDelta + ")"); + Log.verbose("colorDelta = " + basicValue + " old = " + this.stateOld + "(" + this.stateOld.getValue() * imageDelta + ") new = " + this.stateNew + "(" + this.stateNew.getValue() * imageDelta + + ")"); this.oGLprogram.uniformFloat(this.oGLPaletteOffset, basicValue); - Log.error("plop: " + this.offsetScale); - this.oGLprogram.uniformVector(this.oGLOffsetScale, this.offsetScale); + Log.error("plop: " + this.offsetScaleOutside); + Log.error("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"); @@ -271,7 +255,7 @@ public class GuiShape extends Compositing { } /** - * @brief get the current trasion status + * @brief get the current transition status * @return value of the transition status (0.0f when no activity) */ public float getTransitionStatus() { @@ -309,6 +293,52 @@ public class GuiShape extends Compositing { } } + protected void loadPalette() { + String paletteFile = this.config.getString(this.confIdPaletteFile); + Uri paletteFileInterface = Uri.valueOf(paletteFile); + this.palette = ResourcePaletteFile.create(paletteFileInterface); + this.texture = ResourceTexture2.createNamed("TEXTURE_OF_PALETTE:" + paletteFile); + if (this.texture == null) { + Log.error("can not instanciate Texture ..."); + } + // element already called + loadPaletteUpdate(); + // for next update (realTime reload) + this.palette.onUpdate(() -> { + loadPaletteUpdate(); + }); + } + + protected void loadPaletteUpdate() { + Log.warning("update palet environnement"); + final ImageByte img = this.palette.getImageByte(); + //IOgami.storePNG(new Uri("/home/heero/000000000aaaaplopppp.png"), img); + this.texture.set(img); + } + + /** + * load the openGL program and get all the ID needed + */ + private void loadProgram() { + if (this.config == null) { + Log.debug("no Shaper set for loading resources ..."); + return; + } + String basicShaderFileVert = this.config.getString(this.confProgramFileVert); + String basicShaderFileFrag = this.config.getString(this.confProgramFileFrag); + if (!basicShaderFileVert.isEmpty() && !basicShaderFileFrag.isEmpty()) { + this.oGLprogram = ResourceProgram.create(Uri.valueOf(basicShaderFileVert), Uri.valueOf(basicShaderFileFrag)); + if (this.oGLprogram != null) { + this.oGLMatrixTransformation = this.oGLprogram.getUniform("in_matrixTransformation"); + this.oGLMatrixProjection = this.oGLprogram.getUniform("in_matrixProjection"); + this.oGLMatrixView = this.oGLprogram.getUniform("in_matrixView"); + this.oGLPaletteOffset = this.oGLprogram.getUniform("in_offsetPalette"); + this.oGLOffsetScaleInside = this.oGLprogram.getUniform("in_offsetScaleInside"); + this.oGLOffsetScaleOutside = this.oGLprogram.getUniform("in_offsetScaleOutside"); + } + } + } + /** * load the openGL program and get all the ID needed */ @@ -328,6 +358,10 @@ public class GuiShape extends Compositing { float back = 0; float font = 0; // estimate size of border: + if (verticesToModify == null) { + Log.critical("Element is null : verticesToModify"); + 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()); @@ -339,28 +373,6 @@ public class GuiShape extends Compositing { this.sizeObject = new Padding(Math.abs(left), Math.abs(top), Math.abs(right), Math.abs(bottom)); } } - - /** - * load the openGL program and get all the ID needed - */ - private void loadProgram() { - if (this.config == null) { - Log.debug("no Shaper set for loading resources ..."); - return; - } - String basicShaderFileVert = this.config.getString(this.confProgramFileVert); - String basicShaderFileFrag = this.config.getString(this.confProgramFileFrag); - if (!basicShaderFileVert.isEmpty() && !basicShaderFileFrag.isEmpty()) { - this.oGLprogram = ResourceProgram.create(Uri.valueOf(basicShaderFileVert), Uri.valueOf(basicShaderFileFrag)); - if (this.oGLprogram != null) { - this.oGLMatrixTransformation = this.oGLprogram.getUniform("in_matrixTransformation"); - this.oGLMatrixProjection = this.oGLprogram.getUniform("in_matrixProjection"); - this.oGLMatrixView = this.oGLprogram.getUniform("in_matrixView"); - this.oGLPaletteOffset = this.oGLprogram.getUniform("in_offsetPalette"); - this.oGLOffsetScale = this.oGLprogram.getUniform("in_offsetScale"); - } - } - } /** * @brief Same as the widfget periodic call (this is for change display) @@ -373,7 +385,7 @@ public class GuiShape extends Compositing { // start : if (this.stateTransition >= 1.0) { this.stateOld = this.stateNew; - if( (this.nextStatusRequested == GuiShapeMode.NONE) || (this.nextStatusRequested == this.stateOld)) { + if ((this.nextStatusRequested == GuiShapeMode.NONE) || (this.nextStatusRequested == this.stateOld)) { this.nextStatusRequested = GuiShapeMode.NONE; // disable periodic call ... return false; @@ -384,9 +396,9 @@ public class GuiShape extends Compositing { Log.verbose(" ##### START ##### "); return true; } - if (this.stateTransition<1.0) { + if (this.stateTransition < 1.0) { // check if no new state requested: - if (this.nextStatusRequested != GuiShapeMode.NONE && this.stateTransition<0.5) { + if (this.nextStatusRequested != GuiShapeMode.NONE && this.stateTransition < 0.5) { // invert sources with destination GuiShapeMode tmppp = this.stateOld; this.stateOld = this.stateNew; @@ -467,10 +479,11 @@ public class GuiShape extends Compositing { public void setShape(final Vector2f origin, final Vector2f size, final Vector2f insidePos, final Vector2f insideSize) { //Log.error("Set shape property : origin=" + origin + " size=" + size + " in-pos=" + insidePos + " in-size=" + insideSize); Vector2f halfSize = insideSize.multiply(0.5f); - this.offsetScale = new Vector3f(halfSize.x(), halfSize.y(), 1.0f); + this.offsetScaleOutside = new Vector3f(halfSize.x(), halfSize.y(), 1.0f); + this.offsetScaleInside = new Vector3f(halfSize.x() + this.sizeObject.x() * 0.25f, halfSize.y() + this.sizeObject.y() * 0.25f, 1.0f); /* List verticesToModify = this.mesh.getGeneratedPosition(); - float[] newVertices = new float[verticesToModify.size()*3]; + float[] newVertices = new float[verticesToModify.size()*3]; for (int iii=0; iii verticesToModify = this.mesh.getGeneratedPosition(); - float[] newVertices = new float[verticesToModify.size()*3]; + float[] newVertices = new float[verticesToModify.size()*3]; for (int iii=0; iii " + this.overPositionStop); if (relPos.x() > this.overPositionStart.x() && relPos.y() > this.overPositionStart.y() && relPos.x() < this.overPositionStop.x() && relPos.y() < this.overPositionStop.y()) { - changeStatusIn(GuiShapeMode.OVER); + changeStatusIn(GuiShapeMode.OVER); } else { - changeStatusIn(GuiShapeMode.NORMAL); + changeStatusIn(GuiShapeMode.NORMAL); } } } @@ -223,7 +235,7 @@ public class Button extends Widget { tmpOriginText = Vector2f.clipInt(tmpOriginText); this.gc.clear(); - this.gc.setSize((int)tmpSizeText.x(), (int)tmpSizeText.y()); + this.gc.setSize((int) tmpSizeText.x(), (int) tmpSizeText.y()); this.gc.setColorFill(Color.BLACK); this.gc.setColorStroke(Color.NONE); @@ -237,18 +249,6 @@ public class Button extends Widget { } - /** - * Periodic call to update grapgic display - * @param _event Time generic event - */ - protected static void periodicCall(final Button self, final EventTime event) { - Log.verbose("Periodic call on Entry(" + event + ")"); - if (!self.shape.periodicCall(event)) { - self.periodicConnectionHanble.close(); - } - self.markToRedraw(); - } - /** * internal check the value with RegExp checking * @param newData The new string to display @@ -284,7 +284,6 @@ public class Button extends Widget { onChangePropertyShaper(); } - public void setPropertyValue(final String propertyValue) { if (this.propertyValue.equals(propertyValue)) { return; @@ -292,5 +291,5 @@ public class Button extends Widget { this.propertyValue = propertyValue; onChangePropertyValue(); } - + } diff --git a/src/org/atriasoft/ewol/widget/CheckBox.java b/src/org/atriasoft/ewol/widget/CheckBox.java index ed300e2..5c03288 100644 --- a/src/org/atriasoft/ewol/widget/CheckBox.java +++ b/src/org/atriasoft/ewol/widget/CheckBox.java @@ -40,16 +40,28 @@ public Signal signalValue; public Uri> propertyShape; //!< shape of the widget */ public class CheckBox extends Widget { + /** + * Periodic call to update grapgic display + * @param _event Time generic event + */ + protected static void periodicCall(final CheckBox self, final EventTime event) { + Log.verbose("Periodic call on Entry(" + event + ")"); + if (!self.shape.periodicCall(event)) { + self.periodicConnectionHanble.close(); + } + self.markToRedraw(); + } + /// color property of the text foreground private int colorIdTextFg; /// text display this.text //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/CheckBox.json", "ewol"); private Boolean propertyValue = false; //!< string that must be displayed - private GuiShape shape; @EwolSignal(name = "down", description = "CheckBox is Down") public SignalEmpty signalDown = new SignalEmpty(); @@ -59,10 +71,10 @@ public class CheckBox extends Widget { public SignalEmpty signalClick = new SignalEmpty(); @EwolSignal(name = "value", description = "CheckBox value change") public Signal signalValue; - // element over: Vector2f overPositionStart = Vector2f.ZERO; Vector2f overPositionStop = Vector2f.ZERO; + private boolean isDown; /** @@ -104,7 +116,7 @@ public class CheckBox extends Widget { markToRedraw(); } } - + @XmlManaged @XmlAttribute @XmlName(value = "config") @@ -112,7 +124,7 @@ public class CheckBox extends Widget { public Uri getPropertyConfig() { return this.propertyConfig; } - + @XmlManaged @XmlAttribute @XmlName(value = "value") @@ -121,7 +133,6 @@ public class CheckBox extends Widget { return this.propertyValue; } - protected void onChangePropertyShaper() { if (this.shape == null) { this.shape = new GuiShape(this.propertyConfig); @@ -142,14 +153,14 @@ public class CheckBox extends Widget { @Override protected void onDraw() { if (this.shape != null) { - //this.shape.draw(this.gc.getResourceTexture(), true); + this.shape.draw(true); } } - + @Override public boolean onEventInput(final EventInput event) { Vector2f relPos = relativePosition(event.pos()); - Log.verbose("Event on Input ... " + event + " relPos = "+ relPos); + Log.verbose("Event on Input ... " + event + " relPos = " + relPos); if (event.inputId() == 0) { if (!this.isDown) { if (KeyStatus.leave == event.status()) { @@ -157,9 +168,9 @@ public class CheckBox extends Widget { } 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()) { - changeStatusIn(GuiShapeMode.OVER); + changeStatusIn(GuiShapeMode.OVER); } else { - changeStatusIn(GuiShapeMode.NORMAL); + changeStatusIn(GuiShapeMode.NORMAL); } } } @@ -247,18 +258,6 @@ public class CheckBox extends Widget { } - /** - * Periodic call to update grapgic display - * @param _event Time generic event - */ - protected static void periodicCall(final CheckBox self, final EventTime event) { - Log.verbose("Periodic call on Entry(" + event + ")"); - if (!self.shape.periodicCall(event)) { - self.periodicConnectionHanble.close(); - } - self.markToRedraw(); - } - /** * internal check the value with RegExp checking * @param newData The new string to display @@ -276,7 +275,6 @@ public class CheckBox extends Widget { onChangePropertyShaper(); } - public void setPropertyValue(final Boolean propertyValue) { if (this.propertyValue.equals(propertyValue)) { return; @@ -284,5 +282,5 @@ public class CheckBox extends Widget { this.propertyValue = propertyValue; onChangePropertyValue(); } - + } diff --git a/src/org/atriasoft/ewol/widget/Entry.java b/src/org/atriasoft/ewol/widget/Entry.java index 6286cbf..a918482 100644 --- a/src/org/atriasoft/ewol/widget/Entry.java +++ b/src/org/atriasoft/ewol/widget/Entry.java @@ -41,6 +41,18 @@ import org.atriasoft.gale.key.KeyType; * ~~~~~~~~~~~~~~~~~~~~~~ */ public class Entry extends Widget { + /** + * Periodic call to update grapgic display + * @param _event Time generic event + */ + protected static void periodicCall(final Entry self, final EventTime event) { + Log.verbose("Periodic call on Entry(" + event + ")"); + if (!self.shape.periodicCall(event)) { + self.periodicConnectionHanble.close(); + } + self.markToRedraw(); + } + /// color property of the text foreground private int colorIdTextFg; /// Cursor must be display only when the widget has the focus @@ -50,7 +62,7 @@ public class Entry extends Widget { /// Selection position end (can be before or after cursor and == this.displayCursorPos chan no selection availlable private int displayCursorPosSelection = 0; /// offset in pixel of the display of the UString - private int displayStartPosition = 0; + private int displayStartPosition = 0; /// offset in pixel of the display of the UString private int displayCursorPositionPixel = 0; /// text display this.text @@ -74,6 +86,7 @@ public class Entry extends Widget { @XmlName(value = "password") @EwolDescription(value = "Not display content in password mode") private boolean propertyPassword = false; //!< Disable display of the content of the entry + /// regular expression value @XmlManaged @XmlAttribute @@ -93,7 +106,6 @@ public class Entry extends Widget { @XmlName(value = "value") @EwolDescription(value = "Value display in the entry (decorated text)") private String propertyValue = "Test Text..."; //!< string that must be displayed - private Pattern regex = null; //!< regular expression to check content private GuiShape shape; //.create() @@ -101,11 +113,12 @@ public class Entry extends Widget { public SignalEmpty signalClick = new SignalEmpty(); //!< bang on click the entry box @EwolSignal(name = "enter", description = "The cursor enter inside the button") public Signal signalEnter = new Signal<>(); //!< Enter key is pressed + @EwolSignal(name = "modify", description = "Entry box value change") public Signal signalModify = new Signal<>(); //!< data change - // element over: Vector2f overPositionStart = Vector2f.ZERO; + Vector2f overPositionStop = Vector2f.ZERO; /** @@ -379,7 +392,7 @@ public class Entry extends Widget { } else { StringBuilder newData = new StringBuilder(this.propertyValue); newData.insert(this.displayCursorPos, event.getChar()); - String newDataGenerated =newData.toString(); + String newDataGenerated = newData.toString(); setInternalValue(newDataGenerated); if (this.propertyValue.equals(newDataGenerated)) { this.displayCursorPos += 1;//inputData.length(); @@ -421,7 +434,7 @@ public class Entry extends Widget { @Override public boolean onEventInput(final EventInput event) { Vector2f relPos = relativePosition(event.pos()); - Log.verbose("Event on Input ... " + event + " relPos = "+ relPos); + Log.verbose("Event on Input ... " + event + " relPos = " + relPos); if (event.inputId() == 0) { if (!isFocused()) { if (KeyStatus.leave == event.status()) { @@ -429,9 +442,9 @@ public class Entry extends Widget { } 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()) { - changeStatusIn(GuiShapeMode.OVER); + changeStatusIn(GuiShapeMode.OVER); } else { - changeStatusIn(GuiShapeMode.NORMAL); + changeStatusIn(GuiShapeMode.NORMAL); } } } @@ -496,7 +509,7 @@ public class Entry extends Widget { } else if (KeyType.mouse == event.type() && event.inputId() == 2) { if (event.status() == KeyStatus.down || event.status() == KeyStatus.move || event.status() == KeyStatus.up) { keepFocus(); - // updatethe cursor position : + // updatethe cursor position : updateCursorPosition(event.pos()); } // Paste current selection only when up button @@ -568,20 +581,19 @@ public class Entry extends Widget { tmpOriginText = Vector2f.clipInt(tmpOriginText); this.gc.clear(); - this.gc.setSize((int)tmpSizeText.x(), (int)tmpSizeText.y()); + this.gc.setSize((int) tmpSizeText.x(), (int) tmpSizeText.y()); -// if (this.displayCursorPosSelection != this.displayCursorPos) { -// -// //this.text.setCursorSelection(this.displayCursorPos, this.displayCursorPosSelection); -// } else { -// this.text.setCursorPos(this.displayCursorPos); -// } + // if (this.displayCursorPosSelection != this.displayCursorPos) { + // + // //this.text.setCursorSelection(this.displayCursorPos, this.displayCursorPosSelection); + // } else { + // this.text.setCursorPos(this.displayCursorPos); + // } this.gc.setColorFill(Color.RED); this.gc.setColorStroke(Color.GREEN); this.gc.setStrokeWidth(5); //this.gc.rectangleRounded(new Vector2f(20, 2), new Vector2f(55, 70), new Vector2f(15, 15)); - this.gc.line(new Vector2f(this.displayCursorPositionPixel, 2), new Vector2f(this.displayCursorPositionPixel, this.gc.getTextHeight()-4)); - + this.gc.line(new Vector2f(this.displayCursorPositionPixel, 2), new Vector2f(this.displayCursorPositionPixel, this.gc.getTextHeight() - 4)); this.gc.setColorFill(Color.BLACK); this.gc.setColorStroke(Color.NONE); @@ -604,18 +616,6 @@ public class Entry extends Widget { } - /** - * Periodic call to update grapgic display - * @param _event Time generic event - */ - protected static void periodicCall(final Entry self, final EventTime event) { - Log.verbose("Periodic call on Entry(" + event + ")"); - if (!self.shape.periodicCall(event)) { - self.periodicConnectionHanble.close(); - } - self.markToRedraw(); - } - /** * remove the selected area * @note This request a regeneration of the display @@ -737,7 +737,7 @@ public class Entry extends Widget { if (this.displayStartPosition > this.propertyValue.length()) { this.displayStartPosition = this.propertyValue.length(); } - if (this.displayStartPosition <0) { + if (this.displayStartPosition < 0) { Log.error("wring cursor position : " + this.displayStartPosition + "/" + this.propertyValue.length()); this.displayStartPosition = 0; }