Better test unit add capability to sizer and progressive render for inside element

This commit is contained in:
Edouard DUPIN 2022-01-03 23:50:55 +01:00
parent 1f315d1afd
commit 3e233e5bdf
18 changed files with 400 additions and 539 deletions

View File

@ -12,7 +12,7 @@
"padding-in-buttom":0,
# render program:
"program-vert":"THEME:shape/aaRenderShape.vert?lib=ewol",
"program-vert":"THEME:shape/aaRenderShapeScale.vert?lib=ewol",
"program-frag":"THEME:shape/aaRenderShape.frag?lib=ewol",
# Object to render (with modification)

View File

@ -9,7 +9,6 @@ precision mediump int;
layout (location = 0) in vec3 in_position;
layout (location = 1) in vec2 in_textureCoords;
uniform vec3 in_offsetScaleInside;
uniform vec3 in_offsetScaleOutside;
uniform mat4 in_matrixTransformation;
@ -20,31 +19,9 @@ uniform mat4 in_matrixView;
out vec2 io_textureCoords;
void main(void) {
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;
}

View File

@ -0,0 +1,44 @@
#version 400 core
#ifdef GL_ES
precision mediump float;
precision mediump int;
#endif
// Input:
layout (location = 0) in vec3 in_position;
layout (location = 1) in vec2 in_textureCoords;
uniform vec3 in_offsetScaleInside;
uniform vec3 in_offsetScaleOutside;
uniform mat4 in_matrixTransformation;
uniform mat4 in_matrixProjection;
uniform mat4 in_matrixView;
// output:
out vec2 io_textureCoords;
void main(void) {
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);
gl_Position = in_matrixProjection * in_matrixView * in_matrixTransformation * position;
io_textureCoords = in_textureCoords;
}

View File

@ -0,0 +1,192 @@
package sample.atriasoft.ewol;
import org.atriasoft.etk.Color;
import org.atriasoft.etk.Dimension;
import org.atriasoft.etk.Distance;
import org.atriasoft.etk.math.Vector2b;
import org.atriasoft.etk.math.Vector2f;
import org.atriasoft.ewol.Gravity;
import org.atriasoft.ewol.widget.Button;
import org.atriasoft.ewol.widget.Sizer;
import org.atriasoft.ewol.widget.Sizer.DisplayMode;
import org.atriasoft.ewol.widget.Spacer;
import org.atriasoft.ewol.widget.Widget;
import org.atriasoft.ewol.widget.Windows;
public class BasicWindows extends Windows {
public static void eventButtonChangeGravity(final BasicWindows self) {
Gravity state = self.testWidget.getPropertyGravity();
state = switch (state) {
case BUTTOM -> Gravity.BUTTOM_LEFT;
case BUTTOM_LEFT -> Gravity.BUTTOM_RIGHT;
case BUTTOM_RIGHT -> Gravity.CENTER;
case CENTER -> Gravity.LEFT;
case LEFT -> Gravity.RIGHT;
case RIGHT -> Gravity.TOP;
case TOP -> Gravity.TOP_LEFT;
case TOP_LEFT -> Gravity.TOP_RIGHT;
case TOP_RIGHT -> Gravity.BUTTOM;
};
self.testWidget.setPropertyGravity(state);
self.buttonGravity.setPropertyValue("gravity: " + state);
}
public static void eventButtonExpandX(final BasicWindows self) {
Vector2b state = self.testWidget.getPropertyExpand();
self.testWidget.setPropertyExpand(state.withX(!state.x()));
self.buttonExpandX.setPropertyValue(state.x() ? "expand X" : "un-expand X");
}
public static void eventButtonExpandY(final BasicWindows self) {
Vector2b state = self.testWidget.getPropertyExpand();
self.testWidget.setPropertyExpand(state.withY(!state.y()));
self.buttonExpandY.setPropertyValue(state.y() ? "expand Y" : "un-expand Y");
}
public static void eventButtonFillX(final BasicWindows self) {
Vector2b state = self.testWidget.getPropertyFill();
self.testWidget.setPropertyFill(state.withX(!state.x()));
self.buttonFillX.setPropertyValue(state.x() ? "fill X" : "un-fill X");
}
public static void eventButtonFillY(final BasicWindows self) {
Vector2b state = self.testWidget.getPropertyFill();
self.testWidget.setPropertyFill(state.withY(!state.y()));
self.buttonFillY.setPropertyValue(state.y() ? "fill Y" : "un-fill Y");
}
Widget testWidget;
Button buttonExpandX;
Button buttonExpandY;
Button buttonFillX;
Button buttonFillY;
Button buttonGravity;
Sizer sizerTestAreaHori;
Sizer sizerMenuHori;
public BasicWindows() {
//! [ewol_sample_HW_windows_title]
setPropertyTitle("No title set !!! for this test");
Sizer sizerVertMain = new Sizer(DisplayMode.modeVert);
sizerVertMain.setPropertyExpand(Vector2b.TRUE_TRUE);
sizerVertMain.setPropertyFill(Vector2b.TRUE_TRUE);
setSubWidget(sizerVertMain);
this.sizerMenuHori = new Sizer(DisplayMode.modeHori);
this.sizerMenuHori.setPropertyExpand(Vector2b.TRUE_FALSE);
this.sizerMenuHori.setPropertyLockExpand(Vector2b.TRUE_TRUE);
this.sizerMenuHori.setPropertyFill(Vector2b.TRUE_TRUE);
sizerVertMain.subWidgetAdd(this.sizerMenuHori);
{
Spacer simpleSpacer = new Spacer();
simpleSpacer.setPropertyMinSize(new Dimension(new Vector2f(100, 100), Distance.PIXEL));
simpleSpacer.setPropertyColor(Color.ALICE_BLUE);
simpleSpacer.setPropertyExpand(Vector2b.TRUE_FALSE);
simpleSpacer.setPropertyExpandIfFree(Vector2b.TRUE_TRUE);
simpleSpacer.setPropertyFill(Vector2b.TRUE_TRUE);
simpleSpacer.setPropertyMinSize(new Dimension(new Vector2f(10, 10), Distance.PIXEL));
sizerVertMain.subWidgetAdd(simpleSpacer);
}
this.sizerTestAreaHori = new Sizer(DisplayMode.modeHori);
this.sizerTestAreaHori.setPropertyExpand(Vector2b.TRUE_FALSE);
this.sizerTestAreaHori.setPropertyExpandIfFree(Vector2b.TRUE_TRUE);
this.sizerTestAreaHori.setPropertyFill(Vector2b.TRUE_FALSE);
sizerVertMain.subWidgetAdd(this.sizerTestAreaHori);
{
Spacer simpleSpacer = new Spacer();
simpleSpacer.setPropertyColor(Color.DARK_GREEN);
simpleSpacer.setPropertyExpand(Vector2b.TRUE_FALSE);
simpleSpacer.setPropertyExpandIfFree(Vector2b.TRUE_TRUE);
simpleSpacer.setPropertyFill(Vector2b.TRUE_TRUE);
simpleSpacer.setPropertyMinSize(new Dimension(new Vector2f(10, 10), Distance.PIXEL));
sizerVertMain.subWidgetAdd(simpleSpacer);
}
{
Spacer simpleSpacer = new Spacer();
simpleSpacer.setPropertyColor(Color.PINK);
simpleSpacer.setPropertyExpand(Vector2b.TRUE_TRUE);
simpleSpacer.setPropertyFill(Vector2b.TRUE_TRUE);
simpleSpacer.setPropertyMinSize(new Dimension(new Vector2f(30, 30), Distance.PIXEL));
this.sizerMenuHori.subWidgetAdd(simpleSpacer);
}
{
this.buttonExpandX = new Button();
this.buttonExpandX.setPropertyValue("un-expand X");
this.buttonExpandX.setPropertyExpand(Vector2b.FALSE_FALSE);
this.buttonExpandX.setPropertyFill(Vector2b.FALSE_FALSE);
this.buttonExpandX.setPropertyMinSize(new Dimension(new Vector2f(10, 10), Distance.PIXEL));
this.sizerMenuHori.subWidgetAdd(this.buttonExpandX);
this.buttonExpandX.signalClick.connectAuto(this, BasicWindows::eventButtonExpandX);
}
{
this.buttonExpandY = new Button();
this.buttonExpandY.setPropertyValue("un-expand Y");
this.buttonExpandY.setPropertyExpand(Vector2b.FALSE_FALSE);
this.buttonExpandY.setPropertyFill(Vector2b.FALSE_FALSE);
this.buttonExpandY.setPropertyMinSize(new Dimension(new Vector2f(10, 10), Distance.PIXEL));
this.sizerMenuHori.subWidgetAdd(this.buttonExpandY);
this.buttonExpandY.signalClick.connectAuto(this, BasicWindows::eventButtonExpandY);
}
{
this.buttonFillX = new Button();
this.buttonFillX.setPropertyValue("un-fill X");
this.buttonFillX.setPropertyExpand(Vector2b.FALSE_FALSE);
this.buttonFillX.setPropertyFill(Vector2b.FALSE_FALSE);
this.buttonFillX.setPropertyMinSize(new Dimension(new Vector2f(10, 10), Distance.PIXEL));
this.sizerMenuHori.subWidgetAdd(this.buttonFillX);
this.buttonFillX.signalClick.connectAuto(this, BasicWindows::eventButtonFillX);
}
{
this.buttonFillY = new Button();
this.buttonFillY.setPropertyValue("un-fill Y");
this.buttonFillY.setPropertyExpand(Vector2b.FALSE_FALSE);
this.buttonFillY.setPropertyFill(Vector2b.FALSE_FALSE);
this.buttonFillY.setPropertyMinSize(new Dimension(new Vector2f(10, 10), Distance.PIXEL));
this.sizerMenuHori.subWidgetAdd(this.buttonFillY);
this.buttonFillY.signalClick.connectAuto(this, BasicWindows::eventButtonFillY);
}
{
this.buttonGravity = new Button();
this.buttonGravity.setPropertyValue("gravity");
this.buttonGravity.setPropertyExpand(Vector2b.FALSE_FALSE);
this.buttonGravity.setPropertyFill(Vector2b.FALSE_FALSE);
this.buttonGravity.setPropertyMinSize(new Dimension(new Vector2f(10, 10), Distance.PIXEL));
this.sizerMenuHori.subWidgetAdd(this.buttonGravity);
this.buttonGravity.signalClick.connectAuto(this, BasicWindows::eventButtonChangeGravity);
}
}
public void addButton(Widget widget) {
this.sizerMenuHori.subWidgetAdd(widget);
}
public void setTestWidget(Widget widget) {
this.sizerTestAreaHori.subWidgetRemoveAll();
{
Spacer simpleSpacer = new Spacer();
simpleSpacer.setPropertyColor(Color.CHOCOLATE);
simpleSpacer.setPropertyExpand(Vector2b.FALSE_FALSE);
simpleSpacer.setPropertyExpandIfFree(Vector2b.TRUE_TRUE);
simpleSpacer.setPropertyFill(Vector2b.TRUE_TRUE);
simpleSpacer.setPropertyMinSize(new Dimension(new Vector2f(10, 10), Distance.PIXEL));
this.sizerTestAreaHori.subWidgetAdd(simpleSpacer);
}
this.testWidget = widget;
this.sizerTestAreaHori.subWidgetAdd(this.testWidget);
{
Spacer simpleSpacer = new Spacer();
simpleSpacer.setPropertyColor(Color.GREEN_YELLOW);
simpleSpacer.setPropertyExpand(Vector2b.FALSE_FALSE);
simpleSpacer.setPropertyExpandIfFree(Vector2b.TRUE_TRUE);
simpleSpacer.setPropertyFill(Vector2b.TRUE_TRUE);
simpleSpacer.setPropertyMinSize(new Dimension(new Vector2f(10, 10), Distance.PIXEL));
this.sizerTestAreaHori.subWidgetAdd(simpleSpacer);
}
}
}

View File

@ -2,31 +2,18 @@ package sample.atriasoft.ewol.sampleButton;
import org.atriasoft.etk.math.Vector2b;
import org.atriasoft.ewol.widget.Button;
import org.atriasoft.ewol.widget.Sizer;
import org.atriasoft.ewol.widget.Sizer.DisplayMode;
import org.atriasoft.ewol.widget.Windows;
public class MainWindows extends Windows {
import sample.atriasoft.ewol.BasicWindows;
public class MainWindows extends BasicWindows {
public MainWindows() {
setPropertyTitle("Simple Button test");
//EwolObject.getContext().getFontDefault().setName("FreeSans");
Sizer sizerMain = new Sizer(DisplayMode.modeVert);
sizerMain.setPropertyExpand(new Vector2b(true, true));
sizerMain.setPropertyFill(new Vector2b(true, true));
setSubWidget(sizerMain);
Button simpleButton = new Button();
simpleButton.setPropertyValue("Top Button");
simpleButton.setPropertyExpand(new Vector2b(true, true));
simpleButton.setPropertyFill(new Vector2b(true, false));
sizerMain.subWidgetAdd(simpleButton);
Button simpleButton2 = new Button();
simpleButton2.setPropertyValue("Botom Button");
simpleButton2.setPropertyExpand(new Vector2b(true, true));
simpleButton2.setPropertyFill(new Vector2b(false, true));
sizerMain.subWidgetAdd(simpleButton2);
this.setTestWidget(simpleButton);
}
}

View File

@ -2,29 +2,18 @@ package sample.atriasoft.ewol.sampleEntry;
import org.atriasoft.etk.math.Vector2b;
import org.atriasoft.ewol.widget.Entry;
import org.atriasoft.ewol.widget.Sizer;
import org.atriasoft.ewol.widget.Sizer.DisplayMode;
import org.atriasoft.ewol.widget.Windows;
public class MainWindows extends Windows {
import sample.atriasoft.ewol.BasicWindows;
public class MainWindows extends BasicWindows {
public MainWindows() {
setPropertyTitle("Simple Entry test");
//EwolObject.getContext().getFontDefault().setName("FreeSans");
Sizer sizerMain = new Sizer(DisplayMode.modeVert);
sizerMain.setPropertyExpand(new Vector2b(true, true));
sizerMain.setPropertyFill(new Vector2b(true, true));
setSubWidget(sizerMain);
Entry simpleEntry = new Entry();
simpleEntry.setPropertyExpand(new Vector2b(true, true));
simpleEntry.setPropertyFill(new Vector2b(true, false));
sizerMain.subWidgetAdd(simpleEntry);
this.setTestWidget(simpleEntry);
Entry simpleEntry2 = new Entry();
simpleEntry2.setPropertyExpand(new Vector2b(true, true));
simpleEntry2.setPropertyFill(new Vector2b(true, false));
sizerMain.subWidgetAdd(simpleEntry2);
}
}

View File

@ -3,9 +3,10 @@ package sample.atriasoft.ewol.simpleWindowsLabel;
import org.atriasoft.etk.math.Vector2b;
import org.atriasoft.ewol.widget.Label;
import org.atriasoft.ewol.widget.Spacer;
import org.atriasoft.ewol.widget.Windows;
public class MainWindows extends Windows {
import sample.atriasoft.ewol.BasicWindows;
public class MainWindows extends BasicWindows {
public MainWindows() {
//! [ewol_sample_HW_windows_title]
@ -19,13 +20,13 @@ public class MainWindows extends Windows {
"He<b>llo.</b> <font color='blue'>World</font><br/><br/> - Coucou comment ca vas ???<br/> - Pas trop bien, je me suis cassé la jambe.<br/><br/><center>The end</center>");
simpleLabel.setPropertyExpand(new Vector2b(true, true));
simpleLabel.setPropertyFill(new Vector2b(true, true));
setSubWidget(simpleLabel);
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));
setSubWidget(simpleSpacer);
this.setTestWidget(simpleSpacer);
}
}
}

View File

@ -1,220 +1,22 @@
package sample.atriasoft.ewol.simpleWindowsWithCheckBox;
import org.atriasoft.etk.Color;
import org.atriasoft.etk.Dimension;
import org.atriasoft.etk.Distance;
import org.atriasoft.etk.math.Vector2b;
import org.atriasoft.etk.math.Vector2f;
import org.atriasoft.ewol.Gravity;
import org.atriasoft.ewol.widget.Button;
import org.atriasoft.ewol.widget.CheckBox;
import org.atriasoft.ewol.widget.Sizer;
import org.atriasoft.ewol.widget.Sizer.DisplayMode;
import org.atriasoft.ewol.widget.Spacer;
import org.atriasoft.ewol.widget.Windows;
public class MainWindows extends Windows {
import sample.atriasoft.ewol.BasicWindows;
public class MainWindows extends BasicWindows {
CheckBox testWidget;
Button buttonExpandX;
Button buttonExpandY;
Button buttonFillX;
Button buttonFillY;
Button buttonGravity;
Button buttonAspectRatio;
public MainWindows() {
//! [ewol_sample_HW_windows_title]
setPropertyTitle("Simple CheckBox");
Sizer sizerMain = new Sizer(DisplayMode.modeVert);
sizerMain.setPropertyExpand(new Vector2b(true, true));
sizerMain.setPropertyFill(new Vector2b(true, true));
setSubWidget(sizerMain);
Sizer sizerHori1 = new Sizer(DisplayMode.modeHori);
sizerHori1.setPropertyExpand(new Vector2b(true, false));
sizerHori1.setPropertyLockExpand(new Vector2b(true, true));
sizerHori1.setPropertyFill(new Vector2b(true, true));
sizerMain.subWidgetAdd(sizerHori1);
{
Spacer simpleSpacer = new Spacer();
simpleSpacer.setPropertyMinSize(new Dimension(new Vector2f(100, 100), Distance.PIXEL));
simpleSpacer.setPropertyColor(Color.ALICE_BLUE);
simpleSpacer.setPropertyExpand(new Vector2b(true, false));
simpleSpacer.setPropertyFill(new Vector2b(true, true));
simpleSpacer.setPropertyMinSize(new Dimension(new Vector2f(10, 10), Distance.PIXEL));
sizerMain.subWidgetAdd(simpleSpacer);
}
Sizer sizerHori2 = new Sizer(DisplayMode.modeHori);
sizerHori2.setPropertyExpand(new Vector2b(true, true));
sizerHori2.setPropertyFill(new Vector2b(true, true));
sizerMain.subWidgetAdd(sizerHori2);
{
Spacer simpleSpacer = new Spacer();
simpleSpacer.setPropertyColor(Color.DARK_GREEN);
simpleSpacer.setPropertyExpand(new Vector2b(true, false));
simpleSpacer.setPropertyFill(new Vector2b(true, true));
simpleSpacer.setPropertyMinSize(new Dimension(new Vector2f(10, 10), Distance.PIXEL));
sizerMain.subWidgetAdd(simpleSpacer);
}
{
Spacer simpleSpacer = new Spacer();
simpleSpacer.setPropertyColor(Color.CHOCOLATE);
simpleSpacer.setPropertyExpand(new Vector2b(false, true));
simpleSpacer.setPropertyFill(new Vector2b(true, true));
simpleSpacer.setPropertyMinSize(new Dimension(new Vector2f(10, 10), Distance.PIXEL));
sizerHori2.subWidgetAdd(simpleSpacer);
}
this.testWidget = new CheckBox();
//this.testWidget.setPropertySource(new Uri("DATA", "mireA.png"));
this.testWidget.setPropertyExpand(new Vector2b(true, true));
this.testWidget.setPropertyFill(new Vector2b(true, true));
sizerHori2.subWidgetAdd(this.testWidget);
{
Spacer simpleSpacer = new Spacer();
simpleSpacer.setPropertyColor(Color.GREEN_YELLOW);
simpleSpacer.setPropertyExpand(new Vector2b(false, true));
simpleSpacer.setPropertyFill(new Vector2b(true, true));
simpleSpacer.setPropertyMinSize(new Dimension(new Vector2f(10, 10), Distance.PIXEL));
sizerHori2.subWidgetAdd(simpleSpacer);
}
{
Spacer simpleSpacer = new Spacer();
simpleSpacer.setPropertyColor(Color.PINK);
simpleSpacer.setPropertyExpand(new Vector2b(true, true));
simpleSpacer.setPropertyFill(new Vector2b(true, true));
simpleSpacer.setPropertyMinSize(new Dimension(new Vector2f(30, 30), Distance.PIXEL));
sizerHori1.subWidgetAdd(simpleSpacer);
}
{
this.buttonExpandX = new Button();
this.buttonExpandX.setPropertyValue("un-expand X");
this.buttonExpandX.setPropertyExpand(new Vector2b(false, false));
this.buttonExpandX.setPropertyFill(new Vector2b(false, false));
this.buttonExpandX.setPropertyMinSize(new Dimension(new Vector2f(10, 10), Distance.PIXEL));
sizerHori1.subWidgetAdd(this.buttonExpandX);
this.buttonExpandX.signalClick.connectAuto(this, MainWindows::eventButtonExpandX);
}
{
this.buttonExpandY = new Button();
this.buttonExpandY.setPropertyValue("un-expand Y");
this.buttonExpandY.setPropertyExpand(new Vector2b(false, false));
this.buttonExpandY.setPropertyFill(new Vector2b(false, false));
this.buttonExpandY.setPropertyMinSize(new Dimension(new Vector2f(10, 10), Distance.PIXEL));
sizerHori1.subWidgetAdd(this.buttonExpandY);
this.buttonExpandY.signalClick.connectAuto(this, MainWindows::eventButtonExpandY);
}
{
this.buttonFillX = new Button();
this.buttonFillX.setPropertyValue("un-fill X");
this.buttonFillX.setPropertyExpand(new Vector2b(false, false));
this.buttonFillX.setPropertyFill(new Vector2b(false, false));
this.buttonFillX.setPropertyMinSize(new Dimension(new Vector2f(10, 10), Distance.PIXEL));
sizerHori1.subWidgetAdd(this.buttonFillX);
this.buttonFillX.signalClick.connectAuto(this, MainWindows::eventButtonFillX);
}
{
this.buttonFillY = new Button();
this.buttonFillY.setPropertyValue("un-fill Y");
this.buttonFillY.setPropertyExpand(new Vector2b(false, false));
this.buttonFillY.setPropertyFill(new Vector2b(false, false));
this.buttonFillY.setPropertyMinSize(new Dimension(new Vector2f(10, 10), Distance.PIXEL));
sizerHori1.subWidgetAdd(this.buttonFillY);
this.buttonFillY.signalClick.connectAuto(this, MainWindows::eventButtonFillY);
}
{
Button button = new Button();
button.setPropertyValue("Change image");
button.setPropertyExpand(new Vector2b(false, false));
button.setPropertyFill(new Vector2b(false, false));
button.setPropertyMinSize(new Dimension(new Vector2f(10, 10), Distance.PIXEL));
sizerHori1.subWidgetAdd(button);
button.signalClick.connectAuto(this, MainWindows::eventButtonChangeImage);
}
{
this.buttonGravity = new Button();
this.buttonGravity.setPropertyValue("gravity");
this.buttonGravity.setPropertyExpand(new Vector2b(false, false));
this.buttonGravity.setPropertyFill(new Vector2b(false, false));
this.buttonGravity.setPropertyMinSize(new Dimension(new Vector2f(10, 10), Distance.PIXEL));
sizerHori1.subWidgetAdd(this.buttonGravity);
this.buttonGravity.signalClick.connectAuto(this, MainWindows::eventButtonChangeGravity);
}
{
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.setPropertyMinSize(new Dimension(new Vector2f(10, 10), Distance.PIXEL));
sizerHori1.subWidgetAdd(this.buttonAspectRatio);
this.buttonAspectRatio.signalClick.connectAuto(this, MainWindows::eventButtonChangeKeepRatio);
}
}
public static void eventButtonExpandX(final MainWindows self) {
Vector2b state = self.testWidget.getPropertyExpand();
self.testWidget.setPropertyExpand(state.withX(!state.x()));
self.buttonExpandX.setPropertyValue(state.x()?"expand X":"un-expand X");
}
public static void eventButtonExpandY(final MainWindows self) {
Vector2b state = self.testWidget.getPropertyExpand();
self.testWidget.setPropertyExpand(state.withY(!state.y()));
self.buttonExpandY.setPropertyValue(state.y()?"expand Y":"un-expand Y");
}
public static void eventButtonFillX(final MainWindows self) {
Vector2b state = self.testWidget.getPropertyFill();
self.testWidget.setPropertyFill(state.withX(!state.x()));
self.buttonFillX.setPropertyValue(state.x()?"fill X":"un-fill X");
}
public static void eventButtonFillY(final MainWindows self) {
Vector2b state = self.testWidget.getPropertyFill();
self.testWidget.setPropertyFill(state.withY(!state.y()));
self.buttonFillY.setPropertyValue(state.y()?"fill Y":"un-fill Y");
}
public static void eventButtonChangeKeepRatio(final MainWindows self) {
//boolean state = self.testWidget.isPropertyKeepRatio();
//self.testWidget.setPropertyKeepRatio(!state);
//self.buttonAspectRatio.setPropertyValue(state?"fkeep aspect ratio":"un-keep aspect ratio");
}
public static void eventButtonChangeGravity(final MainWindows self) {
Gravity state = self.testWidget.getPropertyGravity();
switch(state) {
case BUTTOM:
state = Gravity.BUTTOM_LEFT;
break;
case BUTTOM_LEFT:
state = Gravity.BUTTOM_RIGHT;
break;
case BUTTOM_RIGHT:
state = Gravity.CENTER;
break;
case CENTER:
state = Gravity.LEFT;
break;
case LEFT:
state = Gravity.RIGHT;
break;
case RIGHT:
state = Gravity.TOP;
break;
case TOP:
state = Gravity.TOP_LEFT;
break;
case TOP_LEFT:
state = Gravity.TOP_RIGHT;
break;
case TOP_RIGHT:
state = Gravity.BUTTOM;
break;
}
self.testWidget.setPropertyGravity(state);
self.buttonGravity.setPropertyValue("gravity: " + state);
}
public static void eventButtonChangeImage(final MainWindows self) {
self.testWidget.setPropertyValue(!self.testWidget.getPropertyValue());
this.testWidget.setPropertyExpand(Vector2b.TRUE_TRUE);
this.testWidget.setPropertyFill(Vector2b.TRUE_TRUE);
this.setTestWidget(this.testWidget);
}
}

View File

@ -1,221 +1,55 @@
package sample.atriasoft.ewol.simpleWindowsWithImage;
import org.atriasoft.etk.Color;
import org.atriasoft.etk.Dimension;
import org.atriasoft.etk.Distance;
import org.atriasoft.etk.Uri;
import org.atriasoft.etk.math.Vector2b;
import org.atriasoft.etk.math.Vector2f;
import org.atriasoft.ewol.Gravity;
import org.atriasoft.ewol.widget.Button;
import org.atriasoft.ewol.widget.ImageDisplay;
import org.atriasoft.ewol.widget.Sizer;
import org.atriasoft.ewol.widget.Sizer.DisplayMode;
import org.atriasoft.ewol.widget.Spacer;
import org.atriasoft.ewol.widget.Windows;
public class MainWindows extends Windows {
import sample.atriasoft.ewol.BasicWindows;
public class MainWindows extends BasicWindows {
public static void eventButtonChangeImage(final MainWindows self) {
self.testWidget.setPropertySource(new Uri("DATA", "mireC.png"));
}
public static void eventButtonChangeKeepRatio(final MainWindows self) {
boolean state = self.testWidget.isPropertyKeepRatio();
self.testWidget.setPropertyKeepRatio(!state);
self.buttonAspectRatio.setPropertyValue(state ? "fkeep aspect ratio" : "un-keep aspect ratio");
}
ImageDisplay testWidget;
Button buttonExpandX;
Button buttonExpandY;
Button buttonFillX;
Button buttonFillY;
Button buttonGravity;
Button buttonAspectRatio;
public MainWindows() {
//! [ewol_sample_HW_windows_title]
setPropertyTitle("Simple Image");
Sizer sizerMain = new Sizer(DisplayMode.modeVert);
sizerMain.setPropertyExpand(new Vector2b(true, true));
sizerMain.setPropertyFill(new Vector2b(true, true));
setSubWidget(sizerMain);
Sizer sizerHori1 = new Sizer(DisplayMode.modeHori);
sizerHori1.setPropertyExpand(new Vector2b(true, false));
sizerHori1.setPropertyLockExpand(new Vector2b(true, true));
sizerHori1.setPropertyFill(new Vector2b(true, true));
sizerMain.subWidgetAdd(sizerHori1);
{
Spacer simpleSpacer = new Spacer();
simpleSpacer.setPropertyMinSize(new Dimension(new Vector2f(100, 100), Distance.PIXEL));
simpleSpacer.setPropertyColor(Color.ALICE_BLUE);
simpleSpacer.setPropertyExpand(new Vector2b(true, false));
simpleSpacer.setPropertyFill(new Vector2b(true, true));
simpleSpacer.setPropertyMinSize(new Dimension(new Vector2f(10, 10), Distance.PIXEL));
sizerMain.subWidgetAdd(simpleSpacer);
}
Sizer sizerHori2 = new Sizer(DisplayMode.modeHori);
sizerHori2.setPropertyExpand(new Vector2b(true, true));
sizerHori2.setPropertyFill(new Vector2b(true, true));
sizerMain.subWidgetAdd(sizerHori2);
{
Spacer simpleSpacer = new Spacer();
simpleSpacer.setPropertyColor(Color.DARK_GREEN);
simpleSpacer.setPropertyExpand(new Vector2b(true, false));
simpleSpacer.setPropertyFill(new Vector2b(true, true));
simpleSpacer.setPropertyMinSize(new Dimension(new Vector2f(10, 10), Distance.PIXEL));
sizerMain.subWidgetAdd(simpleSpacer);
}
{
Spacer simpleSpacer = new Spacer();
simpleSpacer.setPropertyColor(Color.CHOCOLATE);
simpleSpacer.setPropertyExpand(new Vector2b(false, true));
simpleSpacer.setPropertyFill(new Vector2b(true, true));
simpleSpacer.setPropertyMinSize(new Dimension(new Vector2f(10, 10), Distance.PIXEL));
sizerHori2.subWidgetAdd(simpleSpacer);
}
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));
sizerHori2.subWidgetAdd(this.testWidget);
{
Spacer simpleSpacer = new Spacer();
simpleSpacer.setPropertyColor(Color.GREEN_YELLOW);
simpleSpacer.setPropertyExpand(new Vector2b(false, true));
simpleSpacer.setPropertyFill(new Vector2b(true, true));
simpleSpacer.setPropertyMinSize(new Dimension(new Vector2f(10, 10), Distance.PIXEL));
sizerHori2.subWidgetAdd(simpleSpacer);
}
{
Spacer simpleSpacer = new Spacer();
simpleSpacer.setPropertyColor(Color.PINK);
simpleSpacer.setPropertyExpand(new Vector2b(true, true));
simpleSpacer.setPropertyFill(new Vector2b(true, true));
simpleSpacer.setPropertyMinSize(new Dimension(new Vector2f(30, 30), Distance.PIXEL));
sizerHori1.subWidgetAdd(simpleSpacer);
}
{
this.buttonExpandX = new Button();
this.buttonExpandX.setPropertyValue("un-expand X");
this.buttonExpandX.setPropertyExpand(new Vector2b(false, false));
this.buttonExpandX.setPropertyFill(new Vector2b(false, false));
this.buttonExpandX.setPropertyMinSize(new Dimension(new Vector2f(10, 10), Distance.PIXEL));
sizerHori1.subWidgetAdd(this.buttonExpandX);
this.buttonExpandX.signalClick.connectAuto(this, MainWindows::eventButtonExpandX);
}
{
this.buttonExpandY = new Button();
this.buttonExpandY.setPropertyValue("un-expand Y");
this.buttonExpandY.setPropertyExpand(new Vector2b(false, false));
this.buttonExpandY.setPropertyFill(new Vector2b(false, false));
this.buttonExpandY.setPropertyMinSize(new Dimension(new Vector2f(10, 10), Distance.PIXEL));
sizerHori1.subWidgetAdd(this.buttonExpandY);
this.buttonExpandY.signalClick.connectAuto(this, MainWindows::eventButtonExpandY);
}
{
this.buttonFillX = new Button();
this.buttonFillX.setPropertyValue("un-fill X");
this.buttonFillX.setPropertyExpand(new Vector2b(false, false));
this.buttonFillX.setPropertyFill(new Vector2b(false, false));
this.buttonFillX.setPropertyMinSize(new Dimension(new Vector2f(10, 10), Distance.PIXEL));
sizerHori1.subWidgetAdd(this.buttonFillX);
this.buttonFillX.signalClick.connectAuto(this, MainWindows::eventButtonFillX);
}
{
this.buttonFillY = new Button();
this.buttonFillY.setPropertyValue("un-fill Y");
this.buttonFillY.setPropertyExpand(new Vector2b(false, false));
this.buttonFillY.setPropertyFill(new Vector2b(false, false));
this.buttonFillY.setPropertyMinSize(new Dimension(new Vector2f(10, 10), Distance.PIXEL));
sizerHori1.subWidgetAdd(this.buttonFillY);
this.buttonFillY.signalClick.connectAuto(this, MainWindows::eventButtonFillY);
}
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.setPropertyMinSize(new Dimension(new Vector2f(10, 10), Distance.PIXEL));
sizerHori1.subWidgetAdd(button);
this.addButton(button);
button.signalClick.connectAuto(this, MainWindows::eventButtonChangeImage);
}
{
this.buttonGravity = new Button();
this.buttonGravity.setPropertyValue("gravity");
this.buttonGravity.setPropertyExpand(new Vector2b(false, false));
this.buttonGravity.setPropertyFill(new Vector2b(false, false));
this.buttonGravity.setPropertyMinSize(new Dimension(new Vector2f(10, 10), Distance.PIXEL));
sizerHori1.subWidgetAdd(this.buttonGravity);
this.buttonGravity.signalClick.connectAuto(this, MainWindows::eventButtonChangeGravity);
}
{
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.setPropertyMinSize(new Dimension(new Vector2f(10, 10), Distance.PIXEL));
sizerHori1.subWidgetAdd(this.buttonAspectRatio);
this.addButton(this.buttonAspectRatio);
this.buttonAspectRatio.signalClick.connectAuto(this, MainWindows::eventButtonChangeKeepRatio);
}
}
public static void eventButtonExpandX(final MainWindows self) {
Vector2b state = self.testWidget.getPropertyExpand();
self.testWidget.setPropertyExpand(state.withX(!state.x()));
self.buttonExpandX.setPropertyValue(state.x()?"expand X":"un-expand X");
}
public static void eventButtonExpandY(final MainWindows self) {
Vector2b state = self.testWidget.getPropertyExpand();
self.testWidget.setPropertyExpand(state.withY(!state.y()));
self.buttonExpandY.setPropertyValue(state.y()?"expand Y":"un-expand Y");
}
public static void eventButtonFillX(final MainWindows self) {
Vector2b state = self.testWidget.getPropertyFill();
self.testWidget.setPropertyFill(state.withX(!state.x()));
self.buttonFillX.setPropertyValue(state.x()?"fill X":"un-fill X");
}
public static void eventButtonFillY(final MainWindows self) {
Vector2b state = self.testWidget.getPropertyFill();
self.testWidget.setPropertyFill(state.withY(!state.y()));
self.buttonFillY.setPropertyValue(state.y()?"fill Y":"un-fill Y");
}
public static void eventButtonChangeKeepRatio(final MainWindows self) {
boolean state = self.testWidget.isPropertyKeepRatio();
self.testWidget.setPropertyKeepRatio(!state);
self.buttonAspectRatio.setPropertyValue(state?"fkeep aspect ratio":"un-keep aspect ratio");
}
public static void eventButtonChangeGravity(final MainWindows self) {
Gravity state = self.testWidget.getPropertyGravity();
switch(state) {
case BUTTOM:
state = Gravity.BUTTOM_LEFT;
break;
case BUTTOM_LEFT:
state = Gravity.BUTTOM_RIGHT;
break;
case BUTTOM_RIGHT:
state = Gravity.CENTER;
break;
case CENTER:
state = Gravity.LEFT;
break;
case LEFT:
state = Gravity.RIGHT;
break;
case RIGHT:
state = Gravity.TOP;
break;
case TOP:
state = Gravity.TOP_LEFT;
break;
case TOP_LEFT:
state = Gravity.TOP_RIGHT;
break;
case TOP_RIGHT:
state = Gravity.BUTTOM;
break;
}
self.testWidget.setPropertyGravity(state);
self.buttonGravity.setPropertyValue("gravity: " + state);
}
public static void eventButtonChangeImage(final MainWindows self) {
self.testWidget.setPropertySource(new Uri("DATA", "mireC.png"));
}
}

View File

@ -28,10 +28,6 @@ import org.atriasoft.exml.model.XmlNode;
*/
public class ContainerN extends Widget {
@XmlManaged
@XmlAttribute
@XmlName(value = "lock")
@EwolDescription(value = "Lock the subwidget expand")
protected Vector2b propertyLockExpand = new Vector2b(false, false); //!< Lock the expend of the sub widget to this one == > this permit to limit bigger subWidget
protected Vector2b subExpend = new Vector2b(false, false); //!< reference of the sub element expention requested.
protected List<Widget> subWidget = new ArrayList<>();
@ -93,6 +89,10 @@ public class ContainerN extends Widget {
}
}
@XmlManaged
@XmlAttribute
@XmlName(value = "lock")
@EwolDescription(value = "Lock the subwidget expand")
public Vector2b getPropertyLockExpand() {
return this.propertyLockExpand;
}

View File

@ -71,40 +71,16 @@ public class Entry extends Widget {
private boolean needUpdateTextPos = true;
/// Periodic call handle to remove it when needed
protected Connection periodicConnectionHanble = new Connection();
@XmlManaged
@XmlAttribute
@XmlName(value = "config")
@EwolDescription(value = "configuration of the widget")
private Uri propertyConfig = new Uri("THEME", "shape/Entry.json", "ewol");
@XmlManaged
@XmlAttribute
@XmlName(value = "max")
@EwolDescription(value = "Maximum char that can be set on the Entry")
private int propertyMaxCharacter = Integer.MAX_VALUE; //!< number max of Character in the list
@XmlManaged
@XmlAttribute
@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
@XmlName(value = "regex")
@EwolDescription(value = "Control what it is write with a regular expression")
private String propertyRegex = ".*";
/// Text to display when nothing in in the entry (decorated text...)
@XmlManaged
@XmlAttribute
@XmlName(value = "empty-text")
@EwolDescription(value = "Text when nothing is written")
private String propertyTextWhenNothing = null;
@XmlManaged
@XmlAttribute
@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;
@ -671,6 +647,10 @@ public class Entry extends Widget {
markToRedraw();
}
@XmlManaged
@XmlAttribute
@XmlName(value = "config")
@EwolDescription(value = "configuration of the widget")
public void setPropertyConfig(final Uri propertyConfig) {
if (this.propertyConfig.equals(propertyConfig)) {
return;
@ -679,6 +659,10 @@ public class Entry extends Widget {
onChangePropertyShaper();
}
@XmlManaged
@XmlAttribute
@XmlName(value = "max")
@EwolDescription(value = "Maximum char that can be set on the Entry")
public void setPropertyMaxCharacter(final int propertyMaxCharacter) {
if (this.propertyMaxCharacter == propertyMaxCharacter) {
return;
@ -687,6 +671,10 @@ public class Entry extends Widget {
onChangePropertyMaxCharacter();
}
@XmlManaged
@XmlAttribute
@XmlName(value = "password")
@EwolDescription(value = "Not display content in password mode")
public void setPropertyPassword(final boolean propertyPassword) {
if (this.propertyPassword == propertyPassword) {
return;
@ -695,6 +683,10 @@ public class Entry extends Widget {
onChangePropertyPassword();
}
@XmlManaged
@XmlAttribute
@XmlName(value = "regex")
@EwolDescription(value = "Control what it is write with a regular expression")
public void setPropertyRegex(final String propertyRegex) {
if (this.propertyRegex.equals(propertyRegex)) {
return;
@ -703,6 +695,10 @@ public class Entry extends Widget {
onChangePropertyRegex();
}
@XmlManaged
@XmlAttribute
@XmlName(value = "empty-text")
@EwolDescription(value = "Text when nothing is written")
public void setPropertyTextWhenNothing(final String propertyTextWhenNothing) {
if (this.propertyTextWhenNothing.equals(propertyTextWhenNothing)) {
return;
@ -711,6 +707,10 @@ public class Entry extends Widget {
onChangePropertyTextWhenNothing();
}
@XmlManaged
@XmlAttribute
@XmlName(value = "value")
@EwolDescription(value = "Value display in the entry (decorated text)")
public void setPropertyValue(final String propertyValue) {
if (this.propertyValue.equals(propertyValue)) {
return;

View File

@ -24,9 +24,6 @@ import org.atriasoft.exml.annotation.XmlName;
import org.atriasoft.exml.model.XmlElement;
import org.atriasoft.gale.key.KeyStatus;
/**
* @ingroup ewolWidgetGroup
*/
public class ImageDisplay extends Widget {
protected int colorId = -1; //!< Color of the image.
protected ResourceColorFile colorProperty = null; //!< theme color property
@ -39,7 +36,6 @@ public class ImageDisplay extends Widget {
protected Vector2f propertyPosStart = Vector2f.ZERO; //!< position in the image to start the sisplay (when we want not to display all the image)
protected Vector2f propertyPosStop = Vector2f.ONE; //!< position in the image to start the sisplay (when we want not to display all the image)
protected boolean propertySmooth = true; //!< display is done in the pixel approximation if false
protected Uri propertySource = null; //!< file name of the image.
protected boolean propertyUseThemeColor = false; //!< Use the themo color management ("THEMECOLOR:///Image.json?lib=ewol") default false
@ -63,7 +59,7 @@ public class ImageDisplay extends Widget {
this.minSize = imageBoder.add(imageSize);
this.maxSize = this.minSize;
} else {
Vector2i imageSizeReal = this.compositing.getRealSize();
Vector2i imageSizeReal = this.getPropertyMinSize().getPixeli();//.compositing.getRealSize();
Log.verbose(" Real Size = " + imageSizeReal);
Vector2f min1 = imageBoder.add(this.propertyMinSize.getPixel());
this.minSize = imageBoder.add(imageSizeReal);
@ -103,6 +99,7 @@ public class ImageDisplay extends Widget {
public Vector2f getPropertyPosStart() {
return this.propertyPosStart;
}
@XmlManaged
@XmlAttribute
@XmlName(value = "part-stop")
@ -126,6 +123,7 @@ public class ImageDisplay extends Widget {
public boolean isPropertyKeepRatio() {
return this.propertyKeepRatio;
}
@XmlManaged
@XmlAttribute
@XmlName(value = "smooth")

View File

@ -29,21 +29,9 @@ public class Label extends Widget {
protected int colorDefaultBgText = -1; //!< Default Background color of the text
protected int colorDefaultFgText = -1; //!< Default color of the text
protected ResourceColorFile colorProperty; //!< theme color property
@XmlManaged
@XmlAttribute
@XmlName(value = "auto-translate")
@EwolDescription(value = "Translate the String with the marker {T:xxxxxx}")
protected boolean propertyAutoTranslate = true; //!< if at true the data is translate automaticaly translate.
@XmlManaged
@XmlAttribute
@XmlName(value = "font-size")
@EwolDescription(value = "Default font size (0=> system default)")
protected int propertyFontSize = 0; //!< default size of the font.
@XmlManaged
@XmlAttribute
@XmlName(value = "value")
@EwolDescription(value = "Displayed value string")
protected String propertyValue = ""; //!< decorated text to display.
@EwolSignal(name = "pressed")
@EwolDescription(value = "Label is pressed")
@ -194,6 +182,10 @@ public class Label extends Widget {
this.text.flush();
}
@XmlManaged
@XmlAttribute
@XmlName(value = "auto-translate")
@EwolDescription(value = "Translate the String with the marker {T:xxxxxx}")
public void setPropertyAutoTranslate(final boolean propertyAutoTranslate) {
if (this.propertyAutoTranslate == propertyAutoTranslate) {
return;
@ -208,6 +200,10 @@ public class Label extends Widget {
requestUpdateSize();
}
@XmlManaged
@XmlAttribute
@XmlName(value = "font-size")
@EwolDescription(value = "Default font size (0=> system default)")
public void setPropertyFontSize(final int propertyFontSize) {
if (this.propertyFontSize == propertyFontSize) {
return;
@ -217,6 +213,10 @@ public class Label extends Widget {
requestUpdateSize();
}
@XmlManaged
@XmlAttribute
@XmlName(value = "value")
@EwolDescription(value = "Displayed value string")
public void setPropertyValue(final String propertyValue) {
if (this.propertyValue.equals(propertyValue)) {
return;

View File

@ -33,6 +33,7 @@ class ProgressBar extends Widget {
this.minSize = new Vector2f(Math.max(tmpMin.x(), 40.0f), Math.max(tmpMin.y(), ProgressBar.DOT_RADIUS * 2.0f));
markToRedraw();
}
@XmlManaged
@XmlAttribute
@XmlName(value = "color-off")

View File

@ -149,15 +149,19 @@ public class Sizer extends ContainerN {
countCalculation = nbWidgetExpand.y();
}
// -4.1- Update every subWidget size
Widget lastWidget = null;
if (!this.subWidget.isEmpty()) {
lastWidget = this.subWidget.get(this.subWidget.size() - 1);
}
for (Widget it : this.subWidget) {
if (it == null) {
continue;
}
Vector2f tmpSizeMin = it.getSize();
Vector2f tmpSizeMax = it.getCalculateMaxSize();
// Now update his size his size in X and the curent sizer size in Y:
// Now update his size his size in X and the current sizer size in Y:
if (this.propertyMode == DisplayMode.modeVert) {
if (it.canExpand().y()) {
if (it.canExpand().y() || (it == lastWidget && it.canExpandIfFree().y())) {
float sizeExpand = tmpSizeMin.y() + deltaExpandSize;
if (sizeExpand > tmpSizeMax.y()) {
residualNext += (sizeExpand - tmpSizeMax.y());
@ -168,7 +172,7 @@ public class Sizer extends ContainerN {
}
it.setSize(tmpSizeMin);
} else {
if (it.canExpand().x()) {
if (it.canExpand().x() || (it == lastWidget && it.canExpandIfFree().x())) {
float sizeExpand = tmpSizeMin.x() + deltaExpandSize;
if (sizeExpand > tmpSizeMax.x()) {
residualNext += (sizeExpand - tmpSizeMax.x());
@ -203,16 +207,16 @@ public class Sizer extends ContainerN {
if (it == null) {
continue;
}
// Now update his size his size in X and the curent sizer size in Y:
// Now update his size, his size in X and the current sizer size in Y:
if (this.propertyMode == DisplayMode.modeVert) {
if (!it.canExpand().x()) {
if (!it.canExpand().x() && !it.canExpandIfFree().x()) {
continue;
}
Vector2f tmpSizeMin = it.getSize();
tmpSizeMin = tmpSizeMin.withX(FMath.avg(tmpSizeMin.x(), localWidgetSize.x(), it.getCalculateMaxSize().x()));
it.setSize(tmpSizeMin);
} else {
if (!it.canExpand().y()) {
if (!it.canExpand().y() && !it.canExpandIfFree().y()) {
continue;
}
Vector2f tmpSizeMin = it.getSize();

View File

@ -15,9 +15,6 @@ import org.atriasoft.exml.annotation.XmlAttribute;
import org.atriasoft.exml.annotation.XmlManaged;
import org.atriasoft.exml.annotation.XmlName;
/**
* @ingroup ewolWidgetGroup
*/
public class Spacer extends Widget {
private final CompositingDrawing draw = new CompositingDrawing(); //!< Compositing drawing element
@XmlManaged

View File

@ -33,6 +33,8 @@ 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;
@ -41,7 +43,6 @@ import org.atriasoft.gale.context.ClipboardList;
import org.atriasoft.gale.context.Cursor;
import org.atriasoft.gale.key.KeyKeyboard;
import org.atriasoft.gale.key.KeySpecial;
import org.lwjgl.opengl.GL11;
/**
@ -52,7 +53,10 @@ import org.lwjgl.opengl.GL11;
* :** Receive Event (keyboard / mouse / ...)
*
*/
@XmlDefaultManaged(value = false)
@XmlDefaultOptional
@XmlIgnoreUnknow
public class Widget extends EwolObject {
// ----------------------------------------------------------------------------------------------------------------
// -- keyboard event properties Area
@ -90,6 +94,7 @@ public class Widget extends EwolObject {
protected boolean propertyCanFocus = false; //!< the focus can be done on this widget
protected Vector2b propertyExpand = new Vector2b(false, false); //!< the widget will expand if possible
protected Vector2b propertyExpandIfFree = new Vector2b(false, false); //!< the widget will expand if possible
protected Vector2b propertyFill = new Vector2b(true, true); //!< the widget will fill all the space provided by the parent.
protected Gravity propertyGravity = Gravity.BUTTOM_LEFT; //!< Gravity of the widget
protected boolean propertyHide = false; //!< hide a widget on the display
@ -141,6 +146,18 @@ public class Widget extends EwolObject {
return new Vector2b(false, false);
}
/**
* get the expend if free capabilities (xy)
* @return 2D boolean represents the capacity to expend (if some free space is available)
* @note : INTERNAL EWOL SYSTEM
*/
public Vector2b canExpandIfFree() {
if (!this.propertyHide) {
return this.propertyExpandIfFree;
}
return new Vector2b(false, false);
}
/**
* get the filling capabilities xy
* @return Vector2b repensent the capacity to xy filling
@ -179,11 +196,12 @@ public class Widget extends EwolObject {
}
public void drawWidgetTree(final int level) {
String space = "";
StringBuilder space = new StringBuilder();
for (int iii = 0; iii < level; ++iii) {
space += " ";
space.append(" ");
}
Log.print(space + "[" + getId() + "] name='" + this.name + "' type=" + getClass().getCanonicalName() + " o=" + this.origin + " s=" + this.size + " hide=" + this.propertyHide);
Log.print(space.append("[").append(getId()).append("] name='").append(this.name).append("' type=").append(getClass().getCanonicalName()).append(" o=").append(this.origin).append(" s=")
.append(this.size).append(" hide=").append(this.propertyHide).toString());
}
/**
@ -218,14 +236,6 @@ public class Widget extends EwolObject {
return this.cursorDisplay;
}
/**
* get the focus state of the widget
* @return focus state
*/
public boolean isFocused() {
return this.hasFocus;
}
/**
* get the grabbing status of the cursor.
* @return true if the cursor is currently grabbed
@ -283,6 +293,14 @@ public class Widget extends EwolObject {
return this.propertyExpand;
}
@XmlManaged
@XmlAttribute
@XmlName(value = "expand-free")
@EwolDescription(value = "Request the widget Expand size while free space is detected (does not generate expand in upper wideget)")
public Vector2b getPropertyExpandIfFree() {
return this.propertyExpandIfFree;
}
@XmlManaged
@XmlAttribute
@XmlName(value = "fill")
@ -390,6 +408,14 @@ public class Widget extends EwolObject {
EwolObject.getContext().keyboardHide();
}
/**
* get the focus state of the widget
* @return focus state
*/
public boolean isFocused() {
return this.hasFocus;
}
/**
* keep the focus on this widget == > this remove the previous focus on all other widget
*/
@ -671,6 +697,15 @@ public class Widget extends EwolObject {
requestUpdateSize();
}
public void setPropertyExpandIfFree(final Vector2b value) {
if (this.propertyExpandIfFree.equals(value)) {
return;
}
this.propertyExpandIfFree = value;
markToRedraw();
requestUpdateSize();
}
public void setPropertyFill(final Vector2b value) {
if (this.propertyFill.equals(value)) {
return;