[DEV] update rendering of the Text in GUI (button, text entry)
This commit is contained in:
parent
ef1aa054ad
commit
e26dd68b5e
@ -6,7 +6,11 @@ import org.atriasoft.etk.Distance;
|
|||||||
import org.atriasoft.etk.math.Vector3b;
|
import org.atriasoft.etk.math.Vector3b;
|
||||||
import org.atriasoft.etk.math.Vector3f;
|
import org.atriasoft.etk.math.Vector3f;
|
||||||
import org.atriasoft.ewol.Gravity;
|
import org.atriasoft.ewol.Gravity;
|
||||||
|
import org.atriasoft.ewol.GravityDepth;
|
||||||
|
import org.atriasoft.ewol.GravityHorizontal;
|
||||||
|
import org.atriasoft.ewol.GravityVertical;
|
||||||
import org.atriasoft.ewol.widget.Button;
|
import org.atriasoft.ewol.widget.Button;
|
||||||
|
import org.atriasoft.ewol.widget.Label;
|
||||||
import org.atriasoft.ewol.widget.Sizer;
|
import org.atriasoft.ewol.widget.Sizer;
|
||||||
import org.atriasoft.ewol.widget.Sizer.DisplayMode;
|
import org.atriasoft.ewol.widget.Sizer.DisplayMode;
|
||||||
import org.atriasoft.ewol.widget.Spacer;
|
import org.atriasoft.ewol.widget.Spacer;
|
||||||
@ -14,46 +18,58 @@ import org.atriasoft.ewol.widget.Widget;
|
|||||||
import org.atriasoft.ewol.widget.Windows;
|
import org.atriasoft.ewol.widget.Windows;
|
||||||
|
|
||||||
public class BasicWindows extends Windows {
|
public class BasicWindows extends Windows {
|
||||||
|
private static final String LABEL_GRAVITY = "gravity<br/>";
|
||||||
|
|
||||||
public static void eventButtonChangeGravity(final BasicWindows self) {
|
public static void eventButtonChangeGravity(final BasicWindows self) {
|
||||||
Gravity state = self.testWidget.getPropertyGravity();
|
Gravity state = self.testWidget.getPropertyGravity();
|
||||||
// TODO: I change the gravity model to integrate the 3rd rank...
|
// TODO: I change the gravity model to integrate the 3rd rank...
|
||||||
/*state = switch (state) {
|
if (state.x() == GravityHorizontal.LEFT && state.y() == GravityVertical.BOTTOM) {
|
||||||
case BUTTOM -> Gravity.BOTTOM_LEFT;
|
state = new Gravity(GravityHorizontal.CENTER, GravityVertical.BOTTOM, GravityDepth.CENTER);
|
||||||
case BUTTOM_LEFT -> Gravity.BOTTOM_RIGHT;
|
} else if (state.x() == GravityHorizontal.CENTER && state.y() == GravityVertical.BOTTOM) {
|
||||||
case BUTTOM_RIGHT -> Gravity.CENTER;
|
state = new Gravity(GravityHorizontal.RIGHT, GravityVertical.BOTTOM, GravityDepth.CENTER);
|
||||||
case CENTER -> Gravity.LEFT;
|
} else if (state.x() == GravityHorizontal.RIGHT && state.y() == GravityVertical.BOTTOM) {
|
||||||
case LEFT -> Gravity.RIGHT;
|
state = new Gravity(GravityHorizontal.LEFT, GravityVertical.CENTER, GravityDepth.CENTER);
|
||||||
case RIGHT -> Gravity.TOP;
|
|
||||||
case TOP -> Gravity.TOP_LEFT;
|
} else if (state.x() == GravityHorizontal.LEFT && state.y() == GravityVertical.CENTER) {
|
||||||
case TOP_LEFT -> Gravity.TOP_RIGHT;
|
state = new Gravity(GravityHorizontal.CENTER, GravityVertical.CENTER, GravityDepth.CENTER);
|
||||||
case TOP_RIGHT -> Gravity.BOTTOM;
|
} else if (state.x() == GravityHorizontal.CENTER && state.y() == GravityVertical.CENTER) {
|
||||||
};
|
state = new Gravity(GravityHorizontal.RIGHT, GravityVertical.CENTER, GravityDepth.CENTER);
|
||||||
*/
|
} else if (state.x() == GravityHorizontal.RIGHT && state.y() == GravityVertical.CENTER) {
|
||||||
|
state = new Gravity(GravityHorizontal.LEFT, GravityVertical.TOP, GravityDepth.CENTER);
|
||||||
|
|
||||||
|
} else if (state.x() == GravityHorizontal.LEFT && state.y() == GravityVertical.TOP) {
|
||||||
|
state = new Gravity(GravityHorizontal.CENTER, GravityVertical.TOP, GravityDepth.CENTER);
|
||||||
|
} else if (state.x() == GravityHorizontal.CENTER && state.y() == GravityVertical.TOP) {
|
||||||
|
state = new Gravity(GravityHorizontal.RIGHT, GravityVertical.TOP, GravityDepth.CENTER);
|
||||||
|
} else if (state.x() == GravityHorizontal.RIGHT && state.y() == GravityVertical.TOP) {
|
||||||
|
state = new Gravity(GravityHorizontal.LEFT, GravityVertical.BOTTOM, GravityDepth.CENTER);
|
||||||
|
}
|
||||||
|
final Label gravLabel = (Label) (self.buttonGravity.getSubWidgets()[0]);
|
||||||
|
gravLabel.setPropertyValue(LABEL_GRAVITY + state.toString());
|
||||||
self.testWidget.setPropertyGravity(state);
|
self.testWidget.setPropertyGravity(state);
|
||||||
//self.buttonGravity.setPropertyValue("gravity: " + state);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void eventButtonExpandX(final BasicWindows self) {
|
public static void eventButtonExpandX(final BasicWindows self, final Boolean value) {
|
||||||
Vector3b state = self.testWidget.getPropertyExpand();
|
final Vector3b state = self.testWidget.getPropertyExpand();
|
||||||
self.testWidget.setPropertyExpand(state.withX(!state.x()));
|
self.testWidget.setPropertyExpand(state.withX(value));
|
||||||
//self.buttonExpandX.setPropertyValue(state.x() ? "expand X" : "un-expand X");
|
//self.buttonExpandX.setPropertyValue(state.x() ? "expand X" : "un-expand X");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void eventButtonExpandY(final BasicWindows self) {
|
public static void eventButtonExpandY(final BasicWindows self, final Boolean value) {
|
||||||
Vector3b state = self.testWidget.getPropertyExpand();
|
final Vector3b state = self.testWidget.getPropertyExpand();
|
||||||
self.testWidget.setPropertyExpand(state.withY(!state.y()));
|
self.testWidget.setPropertyExpand(state.withY(value));
|
||||||
//self.buttonExpandY.setPropertyValue(state.y() ? "expand Y" : "un-expand Y");
|
//self.buttonExpandY.setPropertyValue(state.y() ? "expand Y" : "un-expand Y");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void eventButtonFillX(final BasicWindows self) {
|
public static void eventButtonFillX(final BasicWindows self, final Boolean value) {
|
||||||
Vector3b state = self.testWidget.getPropertyFill();
|
final Vector3b state = self.testWidget.getPropertyFill();
|
||||||
self.testWidget.setPropertyFill(state.withX(!state.x()));
|
self.testWidget.setPropertyFill(state.withX(value));
|
||||||
//self.buttonFillX.setPropertyValue(state.x() ? "fill X" : "un-fill X");
|
//self.buttonFillX.setPropertyValue(state.x() ? "fill X" : "un-fill X");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void eventButtonFillY(final BasicWindows self) {
|
public static void eventButtonFillY(final BasicWindows self, final Boolean value) {
|
||||||
Vector3b state = self.testWidget.getPropertyFill();
|
final Vector3b state = self.testWidget.getPropertyFill();
|
||||||
self.testWidget.setPropertyFill(state.withY(!state.y()));
|
self.testWidget.setPropertyFill(state.withY(value));
|
||||||
//self.buttonFillY.setPropertyValue(state.y() ? "fill Y" : "un-fill Y");
|
//self.buttonFillY.setPropertyValue(state.y() ? "fill Y" : "un-fill Y");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -65,12 +81,13 @@ public class BasicWindows extends Windows {
|
|||||||
Button buttonGravity;
|
Button buttonGravity;
|
||||||
Sizer sizerTestAreaHori;
|
Sizer sizerTestAreaHori;
|
||||||
Sizer sizerMenuHori;
|
Sizer sizerMenuHori;
|
||||||
|
Gravity basicGravity = Gravity.BOTTOM_LEFT;
|
||||||
|
|
||||||
public BasicWindows() {
|
public BasicWindows() {
|
||||||
//! [ewol_sample_HW_windows_title]
|
//! [ewol_sample_HW_windows_title]
|
||||||
setPropertyTitle("No title set !!! for this test");
|
setPropertyTitle("No title set !!! for this test");
|
||||||
|
|
||||||
Sizer sizerVertMain = new Sizer(DisplayMode.modeVert);
|
final Sizer sizerVertMain = new Sizer(DisplayMode.modeVert);
|
||||||
sizerVertMain.setPropertyExpand(Vector3b.TRUE);
|
sizerVertMain.setPropertyExpand(Vector3b.TRUE);
|
||||||
sizerVertMain.setPropertyFill(Vector3b.TRUE);
|
sizerVertMain.setPropertyFill(Vector3b.TRUE);
|
||||||
setSubWidget(sizerVertMain);
|
setSubWidget(sizerVertMain);
|
||||||
@ -82,7 +99,7 @@ public class BasicWindows extends Windows {
|
|||||||
sizerVertMain.subWidgetAdd(this.sizerMenuHori);
|
sizerVertMain.subWidgetAdd(this.sizerMenuHori);
|
||||||
|
|
||||||
{
|
{
|
||||||
Spacer simpleSpacer = new Spacer();
|
final Spacer simpleSpacer = new Spacer();
|
||||||
simpleSpacer.setPropertyMinSize(new Dimension3f(Vector3f.VALUE_128, Distance.PIXEL));
|
simpleSpacer.setPropertyMinSize(new Dimension3f(Vector3f.VALUE_128, Distance.PIXEL));
|
||||||
simpleSpacer.setPropertyColor(Color.ALICE_BLUE);
|
simpleSpacer.setPropertyColor(Color.ALICE_BLUE);
|
||||||
simpleSpacer.setPropertyExpand(Vector3b.TRUE_FALSE_FALSE);
|
simpleSpacer.setPropertyExpand(Vector3b.TRUE_FALSE_FALSE);
|
||||||
@ -99,7 +116,7 @@ public class BasicWindows extends Windows {
|
|||||||
sizerVertMain.subWidgetAdd(this.sizerTestAreaHori);
|
sizerVertMain.subWidgetAdd(this.sizerTestAreaHori);
|
||||||
|
|
||||||
{
|
{
|
||||||
Spacer simpleSpacer = new Spacer();
|
final Spacer simpleSpacer = new Spacer();
|
||||||
simpleSpacer.setPropertyColor(Color.DARK_GREEN);
|
simpleSpacer.setPropertyColor(Color.DARK_GREEN);
|
||||||
simpleSpacer.setPropertyExpand(Vector3b.TRUE_FALSE_FALSE);
|
simpleSpacer.setPropertyExpand(Vector3b.TRUE_FALSE_FALSE);
|
||||||
simpleSpacer.setPropertyExpandIfFree(Vector3b.TRUE);
|
simpleSpacer.setPropertyExpandIfFree(Vector3b.TRUE);
|
||||||
@ -109,7 +126,7 @@ public class BasicWindows extends Windows {
|
|||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
Spacer simpleSpacer = new Spacer();
|
final Spacer simpleSpacer = new Spacer();
|
||||||
simpleSpacer.setPropertyColor(Color.PINK);
|
simpleSpacer.setPropertyColor(Color.PINK);
|
||||||
simpleSpacer.setPropertyExpand(Vector3b.TRUE);
|
simpleSpacer.setPropertyExpand(Vector3b.TRUE);
|
||||||
simpleSpacer.setPropertyFill(Vector3b.TRUE);
|
simpleSpacer.setPropertyFill(Vector3b.TRUE);
|
||||||
@ -117,55 +134,62 @@ public class BasicWindows extends Windows {
|
|||||||
this.sizerMenuHori.subWidgetAdd(simpleSpacer);
|
this.sizerMenuHori.subWidgetAdd(simpleSpacer);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
this.buttonExpandX = Button.createToggleLabelButton("un-expand X", "expand X");
|
this.buttonExpandX = Button.createToggleLabelButton("Expand X", "Un-expand X");
|
||||||
this.buttonExpandX.setPropertyExpand(Vector3b.FALSE);
|
this.buttonExpandX.setPropertyExpand(Vector3b.FALSE_TRUE_FALSE);
|
||||||
this.buttonExpandX.setPropertyFill(Vector3b.FALSE);
|
this.buttonExpandX.setPropertyFill(Vector3b.FALSE);
|
||||||
this.buttonExpandX.setPropertyMinSize(new Dimension3f(Vector3f.VALUE_16, Distance.PIXEL));
|
this.buttonExpandX.setPropertyMinSize(new Dimension3f(Vector3f.VALUE_16, Distance.PIXEL));
|
||||||
|
this.buttonExpandX.setPropertyGravity(Gravity.CENTER);
|
||||||
this.sizerMenuHori.subWidgetAdd(this.buttonExpandX);
|
this.sizerMenuHori.subWidgetAdd(this.buttonExpandX);
|
||||||
this.buttonExpandX.signalClick.connectAuto(this, BasicWindows::eventButtonExpandX);
|
this.buttonExpandX.signalValue.connectAuto(this, BasicWindows::eventButtonExpandX);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
this.buttonExpandY = Button.createToggleLabelButton("un-expand Y", "expand Y");
|
this.buttonExpandY = Button.createToggleLabelButton("Expand Y", "Un-expand Y");
|
||||||
this.buttonExpandY.setPropertyExpand(Vector3b.FALSE);
|
this.buttonExpandY.setPropertyExpand(Vector3b.FALSE_TRUE_FALSE);
|
||||||
this.buttonExpandY.setPropertyFill(Vector3b.FALSE);
|
this.buttonExpandY.setPropertyFill(Vector3b.FALSE);
|
||||||
this.buttonExpandY.setPropertyMinSize(new Dimension3f(Vector3f.VALUE_16, Distance.PIXEL));
|
this.buttonExpandY.setPropertyMinSize(new Dimension3f(Vector3f.VALUE_16, Distance.PIXEL));
|
||||||
|
this.buttonExpandY.setPropertyGravity(Gravity.CENTER);
|
||||||
this.sizerMenuHori.subWidgetAdd(this.buttonExpandY);
|
this.sizerMenuHori.subWidgetAdd(this.buttonExpandY);
|
||||||
this.buttonExpandY.signalClick.connectAuto(this, BasicWindows::eventButtonExpandY);
|
this.buttonExpandY.signalValue.connectAuto(this, BasicWindows::eventButtonExpandY);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
this.buttonFillX = Button.createToggleLabelButton("un-fill X", "fill X");
|
this.buttonFillX = Button.createToggleLabelButton("Fill X", "Un-fill X");
|
||||||
this.buttonFillX.setPropertyExpand(Vector3b.FALSE);
|
this.buttonFillX.setPropertyExpand(Vector3b.FALSE_TRUE_FALSE);
|
||||||
this.buttonFillX.setPropertyFill(Vector3b.FALSE);
|
this.buttonFillX.setPropertyFill(Vector3b.FALSE);
|
||||||
this.buttonFillX.setPropertyMinSize(new Dimension3f(Vector3f.VALUE_16, Distance.PIXEL));
|
this.buttonFillX.setPropertyMinSize(new Dimension3f(Vector3f.VALUE_16, Distance.PIXEL));
|
||||||
|
this.buttonFillX.setPropertyGravity(Gravity.CENTER);
|
||||||
this.sizerMenuHori.subWidgetAdd(this.buttonFillX);
|
this.sizerMenuHori.subWidgetAdd(this.buttonFillX);
|
||||||
this.buttonFillX.signalClick.connectAuto(this, BasicWindows::eventButtonFillX);
|
this.buttonFillX.signalValue.connectAuto(this, BasicWindows::eventButtonFillX);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
this.buttonFillY = Button.createToggleLabelButton("un-fill Y", "fill Y");
|
this.buttonFillY = Button.createToggleLabelButton("Fill Y", "Un-fill Y");
|
||||||
this.buttonFillY.setPropertyExpand(Vector3b.FALSE);
|
this.buttonFillY.setPropertyExpand(Vector3b.FALSE_TRUE_FALSE);
|
||||||
this.buttonFillY.setPropertyFill(Vector3b.FALSE);
|
this.buttonFillY.setPropertyFill(Vector3b.FALSE);
|
||||||
this.buttonFillY.setPropertyMinSize(new Dimension3f(Vector3f.VALUE_16, Distance.PIXEL));
|
this.buttonFillY.setPropertyMinSize(new Dimension3f(Vector3f.VALUE_16, Distance.PIXEL));
|
||||||
|
this.buttonFillY.setPropertyGravity(Gravity.CENTER);
|
||||||
this.sizerMenuHori.subWidgetAdd(this.buttonFillY);
|
this.sizerMenuHori.subWidgetAdd(this.buttonFillY);
|
||||||
this.buttonFillY.signalClick.connectAuto(this, BasicWindows::eventButtonFillY);
|
this.buttonFillY.signalValue.connectAuto(this, BasicWindows::eventButtonFillY);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
this.buttonGravity = Button.createLabelButton("gravity");
|
this.buttonGravity = Button.createLabelButton("Gravity");
|
||||||
this.buttonGravity.setPropertyExpand(Vector3b.FALSE);
|
this.buttonGravity.setPropertyExpand(Vector3b.FALSE_TRUE_FALSE);
|
||||||
this.buttonGravity.setPropertyFill(Vector3b.FALSE);
|
this.buttonGravity.setPropertyFill(Vector3b.FALSE);
|
||||||
this.buttonGravity.setPropertyMinSize(new Dimension3f(Vector3f.VALUE_16, Distance.PIXEL));
|
this.buttonGravity.setPropertyMinSize(new Dimension3f(Vector3f.VALUE_16, Distance.PIXEL));
|
||||||
|
this.buttonGravity.setPropertyGravity(Gravity.CENTER);
|
||||||
this.sizerMenuHori.subWidgetAdd(this.buttonGravity);
|
this.sizerMenuHori.subWidgetAdd(this.buttonGravity);
|
||||||
this.buttonGravity.signalClick.connectAuto(this, BasicWindows::eventButtonChangeGravity);
|
this.buttonGravity.signalClick.connectAuto(this, BasicWindows::eventButtonChangeGravity);
|
||||||
|
final Label gravLabel = (Label) (this.buttonGravity.getSubWidgets()[0]);
|
||||||
|
gravLabel.setPropertyValue(LABEL_GRAVITY + Gravity.BOTTOM_LEFT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addButton(Widget widget) {
|
public void addButton(final Widget widget) {
|
||||||
this.sizerMenuHori.subWidgetAdd(widget);
|
this.sizerMenuHori.subWidgetAdd(widget);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTestWidget(Widget widget) {
|
public void setTestWidget(final Widget widget) {
|
||||||
this.sizerTestAreaHori.subWidgetRemoveAll();
|
this.sizerTestAreaHori.subWidgetRemoveAll();
|
||||||
{
|
{
|
||||||
Spacer simpleSpacer = new Spacer();
|
final Spacer simpleSpacer = new Spacer();
|
||||||
simpleSpacer.setPropertyColor(Color.CHOCOLATE);
|
simpleSpacer.setPropertyColor(Color.CHOCOLATE);
|
||||||
simpleSpacer.setPropertyExpand(Vector3b.FALSE);
|
simpleSpacer.setPropertyExpand(Vector3b.FALSE);
|
||||||
simpleSpacer.setPropertyExpandIfFree(Vector3b.TRUE);
|
simpleSpacer.setPropertyExpandIfFree(Vector3b.TRUE);
|
||||||
@ -176,7 +200,7 @@ public class BasicWindows extends Windows {
|
|||||||
this.testWidget = widget;
|
this.testWidget = widget;
|
||||||
this.sizerTestAreaHori.subWidgetAdd(this.testWidget);
|
this.sizerTestAreaHori.subWidgetAdd(this.testWidget);
|
||||||
{
|
{
|
||||||
Spacer simpleSpacer = new Spacer();
|
final Spacer simpleSpacer = new Spacer();
|
||||||
simpleSpacer.setPropertyColor(Color.GREEN_YELLOW);
|
simpleSpacer.setPropertyColor(Color.GREEN_YELLOW);
|
||||||
simpleSpacer.setPropertyExpand(Vector3b.FALSE);
|
simpleSpacer.setPropertyExpand(Vector3b.FALSE);
|
||||||
simpleSpacer.setPropertyExpandIfFree(Vector3b.TRUE);
|
simpleSpacer.setPropertyExpandIfFree(Vector3b.TRUE);
|
||||||
@ -184,5 +208,16 @@ public class BasicWindows extends Windows {
|
|||||||
simpleSpacer.setPropertyMinSize(new Dimension3f(Vector3f.VALUE_16, Distance.PIXEL));
|
simpleSpacer.setPropertyMinSize(new Dimension3f(Vector3f.VALUE_16, Distance.PIXEL));
|
||||||
this.sizerTestAreaHori.subWidgetAdd(simpleSpacer);
|
this.sizerTestAreaHori.subWidgetAdd(simpleSpacer);
|
||||||
}
|
}
|
||||||
|
// update properties...
|
||||||
|
final Vector3b stateExpand = this.testWidget.getPropertyExpand();
|
||||||
|
this.buttonExpandX.setPropertyValue(stateExpand.x());
|
||||||
|
this.buttonExpandY.setPropertyValue(stateExpand.y());
|
||||||
|
final Vector3b stateFill = this.testWidget.getPropertyFill();
|
||||||
|
this.buttonFillX.setPropertyValue(stateFill.x());
|
||||||
|
this.buttonFillY.setPropertyValue(stateFill.y());
|
||||||
|
|
||||||
|
final Gravity gravity = this.testWidget.getPropertyGravity();
|
||||||
|
final Label gravLabel = (Label) (this.buttonGravity.getSubWidgets()[0]);
|
||||||
|
gravLabel.setPropertyValue(LABEL_GRAVITY + gravity.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -9,9 +9,10 @@ public class MainWindows extends BasicWindows {
|
|||||||
|
|
||||||
public MainWindows() {
|
public MainWindows() {
|
||||||
setPropertyTitle("Simple Button test");
|
setPropertyTitle("Simple Button test");
|
||||||
Button simpleButton = Button.createLabelButton("My <font color=\"red\">button <i>internal</i></font> <b>label</b>");
|
final Button simpleButton = Button
|
||||||
|
.createLabelButton("1 - My <font color=\"red\">button <i>internal</i></font> <br/>2 - <b>label</b><br/>3 - an other text ...<br/>4 - and an other line to be sure ...");
|
||||||
simpleButton.setPropertyExpand(Vector3b.TRUE);
|
simpleButton.setPropertyExpand(Vector3b.TRUE);
|
||||||
simpleButton.setPropertyFill(Vector3b.TRUE);
|
simpleButton.setPropertyFill(Vector3b.FALSE);
|
||||||
this.setTestWidget(simpleButton);
|
this.setTestWidget(simpleButton);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@ public class Appl implements EwolApplication {
|
|||||||
//! [ewol_sample_HW_main_parse_arguments]
|
//! [ewol_sample_HW_main_parse_arguments]
|
||||||
// parse all the argument of the application
|
// parse all the argument of the application
|
||||||
for (int iii = 0; iii < context.getCmd().size(); iii++) {
|
for (int iii = 0; iii < context.getCmd().size(); iii++) {
|
||||||
String tmpppp = context.getCmd().get(iii);
|
final String tmpppp = context.getCmd().get(iii);
|
||||||
if (tmpppp == "-h" || tmpppp == "--help") {
|
if (tmpppp == "-h" || tmpppp == "--help") {
|
||||||
Log.print(" -h/--help display this help");
|
Log.print(" -h/--help display this help");
|
||||||
System.exit(0);
|
System.exit(0);
|
||||||
@ -27,11 +27,11 @@ public class Appl implements EwolApplication {
|
|||||||
//! [ewol_sample_HW_main_set_windows_size]
|
//! [ewol_sample_HW_main_set_windows_size]
|
||||||
//! [ewol_sample_HW_main_set_font_property]
|
//! [ewol_sample_HW_main_set_font_property]
|
||||||
// select font preference of der with a basic application size
|
// select font preference of der with a basic application size
|
||||||
Configs.getConfigFonts().set("FreeSherif", 48);
|
Configs.getConfigFonts().set("FreeSherif", 12);
|
||||||
//! [ewol_sample_HW_main_set_font_property]
|
//! [ewol_sample_HW_main_set_font_property]
|
||||||
//! [ewol_sample_HW_main_set_windows]
|
//! [ewol_sample_HW_main_set_windows]
|
||||||
// Create the windows
|
// Create the windows
|
||||||
MainWindows basicWindows = new MainWindows();
|
final MainWindows basicWindows = new MainWindows();
|
||||||
// configure the ewol context to use the new windows
|
// configure the ewol context to use the new windows
|
||||||
context.setWindows(basicWindows);
|
context.setWindows(basicWindows);
|
||||||
//! [ewol_sample_HW_main_set_windows]
|
//! [ewol_sample_HW_main_set_windows]
|
||||||
|
@ -26,7 +26,8 @@ public class CompositingText extends TextBase {
|
|||||||
protected ResourceTexturedFont font; // !< Font resources
|
protected ResourceTexturedFont font; // !< Font resources
|
||||||
protected List<Vector3f> pointPositions = new ArrayList<>();
|
protected List<Vector3f> pointPositions = new ArrayList<>();
|
||||||
protected float size;
|
protected float size;
|
||||||
|
// the forceClimp is to generate a forcing of the rendering in small font, this permit to have a correct view of the font, otherwise it will be transparent.
|
||||||
|
protected final boolean forceClimp = true;
|
||||||
protected List<Vector2f> texturePositions = new ArrayList<>();
|
protected List<Vector2f> texturePositions = new ArrayList<>();
|
||||||
|
|
||||||
protected String currentFontName = "";
|
protected String currentFontName = "";
|
||||||
@ -52,7 +53,7 @@ public class CompositingText extends TextBase {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Vector3f calculateSizeChar(final Character charcode) {
|
public Vector3f calculateSizeChar(final Character charcode) {
|
||||||
final float renderRatio = (float) this.currentFontSize / (float) this.currentFontSizeRequired;
|
final float renderRatio = (float) this.currentFontSizeRequired / (float) this.currentFontSizeRequired;
|
||||||
// get a pointer on the glyph property :
|
// get a pointer on the glyph property :
|
||||||
final GlyphProperty myGlyphProperty = getGlyphPointer(charcode);
|
final GlyphProperty myGlyphProperty = getGlyphPointer(charcode);
|
||||||
final int fontHeigh = (int) getHeight();
|
final int fontHeigh = (int) getHeight();
|
||||||
@ -191,7 +192,7 @@ public class CompositingText extends TextBase {
|
|||||||
Log.warning("no font...");
|
Log.warning("no font...");
|
||||||
return 10.0f;
|
return 10.0f;
|
||||||
}
|
}
|
||||||
final float renderRatio = (float) this.currentFontSize / (float) this.currentFontSizeRequired;
|
final float renderRatio = (float) this.currentFontSizeRequired / (float) this.currentFontSizeRequired;
|
||||||
return this.font.getHeight(this.mode) * renderRatio;
|
return this.font.getHeight(this.mode) * renderRatio;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -201,12 +202,13 @@ public class CompositingText extends TextBase {
|
|||||||
Log.warning("no font...");
|
Log.warning("no font...");
|
||||||
return 1.0f;
|
return 1.0f;
|
||||||
}
|
}
|
||||||
final float renderRatio = (float) this.currentFontSize / (float) this.currentFontSizeRequired;
|
final float renderRatio = (float) this.currentFontSizeRequired / (float) this.currentFontSizeRequired;
|
||||||
return this.font.getFontSize() * renderRatio;
|
return this.font.getFontSize() * renderRatio;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void printChar(final Character charcode) {
|
public void printChar(final Character charcode) {
|
||||||
|
//Log.error("Request printChar : '{}' @pos={}", charcode, this.position);
|
||||||
// get a pointer on the glyph property :
|
// get a pointer on the glyph property :
|
||||||
final GlyphProperty myGlyphProperty = getGlyphPointer(charcode);
|
final GlyphProperty myGlyphProperty = getGlyphPointer(charcode);
|
||||||
if (myGlyphProperty == null) {
|
if (myGlyphProperty == null) {
|
||||||
@ -214,7 +216,7 @@ public class CompositingText extends TextBase {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// sometime we do net require the correct size to the glyph renderer (due to the fact SVG render is not clear on lower size...)
|
// sometime we do net require the correct size to the glyph renderer (due to the fact SVG render is not clear on lower size...)
|
||||||
final float renderRatio = (float) this.currentFontSize / (float) this.currentFontSizeRequired;
|
final float renderRatio = (float) this.currentFontSizeRequired / (float) this.currentFontSizeRequired;
|
||||||
|
|
||||||
final int fontSize = (int) (getSize() * renderRatio);
|
final int fontSize = (int) (getSize() * renderRatio);
|
||||||
final int fontHeigh = (int) (getHeight() * renderRatio);
|
final int fontHeigh = (int) (getHeight() * renderRatio);
|
||||||
@ -351,7 +353,6 @@ public class CompositingText extends TextBase {
|
|||||||
// stop=" + this.sizeDisplayStop + " pos=" + this.position);
|
// stop=" + this.sizeDisplayStop + " pos=" + this.position);
|
||||||
// Register the previous character
|
// Register the previous character
|
||||||
this.previousCharcode = charcode;
|
this.previousCharcode = charcode;
|
||||||
this.vbo.flush();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -373,7 +374,9 @@ public class CompositingText extends TextBase {
|
|||||||
|
|
||||||
// if size in under 25, we request upper size:
|
// if size in under 25, we request upper size:
|
||||||
int sizeRequest = 25;
|
int sizeRequest = 25;
|
||||||
if (fontSize > 25) {
|
if (this.forceClimp) {
|
||||||
|
sizeRequest = fontSize;
|
||||||
|
} else if (fontSize > 25) {
|
||||||
sizeRequest = fontSize;
|
sizeRequest = fontSize;
|
||||||
}
|
}
|
||||||
if (inputFontName.equals(this.currentFontName) && this.currentFontSizeRequired == sizeRequest) {
|
if (inputFontName.equals(this.currentFontName) && this.currentFontSizeRequired == sizeRequest) {
|
||||||
@ -386,6 +389,9 @@ public class CompositingText extends TextBase {
|
|||||||
fontUri.setProperty("size", Integer.toString(sizeRequest));
|
fontUri.setProperty("size", Integer.toString(sizeRequest));
|
||||||
Log.verbose("plop : " + fontName + " size=" + sizeRequest + " result :" + fontName);
|
Log.verbose("plop : " + fontName + " size=" + sizeRequest + " result :" + fontName);
|
||||||
// link to new one
|
// link to new one
|
||||||
|
if (this.forceClimp) {
|
||||||
|
fontUri.setProperty("FORCE_CLIMP", "true");
|
||||||
|
}
|
||||||
this.font = ResourceTexturedFont.create(fontUri);
|
this.font = ResourceTexturedFont.create(fontUri);
|
||||||
if (this.font == null) {
|
if (this.font == null) {
|
||||||
Log.error("Can not get font resource");
|
Log.error("Can not get font resource");
|
||||||
|
@ -22,7 +22,6 @@ import org.atriasoft.exml.Exml;
|
|||||||
import org.atriasoft.exml.exception.ExmlAttributeDoesNotExist;
|
import org.atriasoft.exml.exception.ExmlAttributeDoesNotExist;
|
||||||
import org.atriasoft.exml.exception.ExmlBuilderException;
|
import org.atriasoft.exml.exception.ExmlBuilderException;
|
||||||
import org.atriasoft.exml.exception.ExmlException;
|
import org.atriasoft.exml.exception.ExmlException;
|
||||||
import org.atriasoft.exml.exception.ExmlNodeDoesNotExist;
|
|
||||||
import org.atriasoft.exml.exception.ExmlParserErrorMulti;
|
import org.atriasoft.exml.exception.ExmlParserErrorMulti;
|
||||||
import org.atriasoft.exml.model.XmlElement;
|
import org.atriasoft.exml.model.XmlElement;
|
||||||
import org.atriasoft.exml.model.XmlNode;
|
import org.atriasoft.exml.model.XmlNode;
|
||||||
@ -50,24 +49,24 @@ public abstract class TextBase extends Compositing {
|
|||||||
public TextDecoration htmlDecoTmp = new TextDecoration(); // !< current decoration
|
public TextDecoration htmlDecoTmp = new TextDecoration(); // !< current decoration
|
||||||
protected boolean kerning = true; // !< Kerning enable or disable on the next elements displayed
|
protected boolean kerning = true; // !< Kerning enable or disable on the next elements displayed
|
||||||
protected FontMode mode = FontMode.REGULAR; // !< font display property : Regular/Bold/Italic/BoldItalic
|
protected FontMode mode = FontMode.REGULAR; // !< font display property : Regular/Bold/Italic/BoldItalic
|
||||||
protected int nbCharDisplayed; // !< prevent some error in calculation size.
|
protected int nbCharDisplayed = 0; // !< prevent some error in calculation size.
|
||||||
protected boolean needDisplay; // !< This just need the display and not the size rendering.
|
protected boolean needDisplay = true; // !< This just need the display and not the size rendering.
|
||||||
protected int oGLMatrixProjection = -1; //!< openGL id on the element (Projection matrix)
|
protected int oGLMatrixProjection = -1; //!< openGL id on the element (Projection matrix)
|
||||||
protected int oGLMatrixTransformation = -1; //!< openGL id on the element (transformation matrix)
|
protected int oGLMatrixTransformation = -1; //!< openGL id on the element (transformation matrix)
|
||||||
protected int oGLMatrixView = -1; //!< openGL id on the element (view matrix)
|
protected int oGLMatrixView = -1; //!< openGL id on the element (view matrix)
|
||||||
protected ResourceProgram oGLprogram; // !< pointer on the opengl display program
|
protected ResourceProgram oGLprogram = null; // !< pointer on the opengl display program
|
||||||
protected int oGLtexID = -1; // !< openGL id on the element (texture ID)
|
protected int oGLtexID = -1; // !< openGL id on the element (texture ID)
|
||||||
protected int oGLtextHeight = -1; // !< openGL Id on the texture height
|
protected int oGLtextHeight = -1; // !< openGL Id on the texture height
|
||||||
protected int oGLtextWidth = -1; // !< openGL Id on the texture width
|
protected int oGLtextWidth = -1; // !< openGL Id on the texture width
|
||||||
protected Vector3f position = Vector3f.ZERO; // !< The current position to draw
|
protected Vector3f position = Vector3f.ZERO; // !< The current position to draw
|
||||||
protected Character previousCharcode; // !< we remember the previous charcode to perform the kerning. @ref Kerning
|
protected Character previousCharcode = '\0'; // !< we remember the previous charcode to perform the kerning. @ref Kerning
|
||||||
protected int selectionStartPos = -100; // !< start position of the Selection (if == this.cursorPos ==> no
|
protected int selectionStartPos = -100; // !< start position of the Selection (if == this.cursorPos ==> no
|
||||||
protected Vector3f sizeDisplayStart = Vector3f.ZERO; // !< The start windows of the display.
|
protected Vector3f sizeDisplayStart = Vector3f.ZERO; // !< The start windows of the display.
|
||||||
protected Vector3f sizeDisplayStop = Vector3f.ZERO; // !< The end windows of the display.
|
protected Vector3f sizeDisplayStop = Vector3f.ZERO; // !< The end windows of the display.
|
||||||
protected float startTextPos = 0; // !< start position of the Alignment (when \n the text return at this
|
protected float startTextPos = 0; // !< start position of the Alignment (when \n the text return at this
|
||||||
// position)
|
// position)
|
||||||
protected float stopTextPos = 0; // !< end of the alignment (when a string is too height it cut at the word
|
protected float stopTextPos = 0; // !< end of the alignment (when a string is too height it cut at the word
|
||||||
protected ResourceVirtualArrayObject vbo;
|
protected ResourceVirtualArrayObject vbo = null;
|
||||||
protected CompositingDrawing vectorialDraw = new CompositingDrawing();
|
protected CompositingDrawing vectorialDraw = new CompositingDrawing();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -130,10 +129,10 @@ public abstract class TextBase extends Compositing {
|
|||||||
return Vector3f.ZERO;
|
return Vector3f.ZERO;
|
||||||
}
|
}
|
||||||
|
|
||||||
String tmpData = "<html><body>\n";
|
final StringBuilder tmpData = new StringBuilder("<html><body>\n");
|
||||||
tmpData += text;
|
tmpData.append(text);
|
||||||
tmpData += "\n</body></html>\n";
|
tmpData.append("\n</body></html>\n");
|
||||||
return calculateSizeHTML(tmpData);
|
return calculateSizeHTML(tmpData.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -151,8 +150,9 @@ public abstract class TextBase extends Compositing {
|
|||||||
setPos(Vector3f.ZERO);
|
setPos(Vector3f.ZERO);
|
||||||
// same as print without the end display ...
|
// same as print without the end display ...
|
||||||
printHTML(text);
|
printHTML(text);
|
||||||
// Log.debug(" 1 Start pos=" + this.sizeDisplayStart);
|
//Log.error(" ]]]] position={}", this.position);
|
||||||
// Log.debug(" 1 Stop pos=" + this.sizeDisplayStop);
|
//Log.error(" ]]]] sizeDisplayStart={}", this.sizeDisplayStart);
|
||||||
|
//Log.error(" ]]]] sizeDisplayStop={}", this.sizeDisplayStop);
|
||||||
|
|
||||||
// get the last elements
|
// get the last elements
|
||||||
this.sizeDisplayStop = Vector3f.max(this.position, this.sizeDisplayStop);
|
this.sizeDisplayStop = Vector3f.max(this.position, this.sizeDisplayStop);
|
||||||
@ -340,6 +340,7 @@ public abstract class TextBase extends Compositing {
|
|||||||
* @param data The cuurent data to add.
|
* @param data The cuurent data to add.
|
||||||
*/
|
*/
|
||||||
public void htmlAddData(final String data) {
|
public void htmlAddData(final String data) {
|
||||||
|
//Log.error("Add data '{}' @pos=", data, this.position);
|
||||||
if (this.htmlCurrentLine.length() > 0 && this.htmlCurrentLine.charAt(this.htmlCurrentLine.length() - 1) != (char) Character.SPACE_SEPARATOR) {
|
if (this.htmlCurrentLine.length() > 0 && this.htmlCurrentLine.charAt(this.htmlCurrentLine.length() - 1) != (char) Character.SPACE_SEPARATOR) {
|
||||||
this.htmlCurrentLine += (char) Character.SPACE_SEPARATOR;
|
this.htmlCurrentLine += (char) Character.SPACE_SEPARATOR;
|
||||||
if (this.htmlDecoration.size() > 0) {
|
if (this.htmlDecoration.size() > 0) {
|
||||||
@ -498,6 +499,8 @@ public abstract class TextBase extends Compositing {
|
|||||||
} else {
|
} else {
|
||||||
Log.error("node not suported type: " + elem.getType() + " val='" + elem.getValue() + "'");
|
Log.error("node not suported type: " + elem.getType() + " val='" + elem.getValue() + "'");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Log.error("Add data elems... @pos=", this.position);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -521,8 +524,7 @@ public abstract class TextBase extends Compositing {
|
|||||||
Color tmpFg = this.color;
|
Color tmpFg = this.color;
|
||||||
Color tmpBg = this.colorBg;
|
Color tmpBg = this.colorBg;
|
||||||
if (this.alignment == AlignMode.DISABLE) {
|
if (this.alignment == AlignMode.DISABLE) {
|
||||||
// Log.debug(" 1 print in not alligned mode : start=" + this.sizeDisplayStart +
|
// Log.debug(" 1 print in not aligned mode : start=" + this.sizeDisplayStart + " stop=" + this.sizeDisplayStop + " pos=" + this.position);
|
||||||
// " stop=" + this.sizeDisplayStop + " pos=" + this.position);
|
|
||||||
// display the cursor if needed (if it is at the start position...)
|
// display the cursor if needed (if it is at the start position...)
|
||||||
if (this.needDisplay) {
|
if (this.needDisplay) {
|
||||||
if (0 == this.cursorPos) {
|
if (0 == this.cursorPos) {
|
||||||
@ -533,7 +535,7 @@ public abstract class TextBase extends Compositing {
|
|||||||
}
|
}
|
||||||
// note this is faster when nothing is requested ...
|
// note this is faster when nothing is requested ...
|
||||||
for (int iii = 0; iii < text.length(); iii++) {
|
for (int iii = 0; iii < text.length(); iii++) {
|
||||||
// check if ve have decoration
|
// check if we have decoration
|
||||||
if (iii < decoration.size()) {
|
if (iii < decoration.size()) {
|
||||||
tmpFg = decoration.get(iii).colorFG();
|
tmpFg = decoration.get(iii).colorFG();
|
||||||
tmpBg = decoration.get(iii).colorBG();
|
tmpBg = decoration.get(iii).colorBG();
|
||||||
@ -569,10 +571,10 @@ public abstract class TextBase extends Compositing {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Log.debug(" 2 print in not alligned mode : start=" + this.sizeDisplayStart +
|
// Log.debug(" 2 print in not aligned mode : start=" + this.sizeDisplayStart +
|
||||||
// " stop=" + this.sizeDisplayStop + " pos=" + this.position);
|
// " stop=" + this.sizeDisplayStop + " pos=" + this.position);
|
||||||
} else {
|
} else {
|
||||||
// Log.debug(" 3 print in not alligned mode : start=" + this.sizeDisplayStart +
|
// Log.debug(" 3 print in not aligned mode : start=" + this.sizeDisplayStart +
|
||||||
// " stop=" + this.sizeDisplayStop + " pos=" + this.position);
|
// " stop=" + this.sizeDisplayStop + " pos=" + this.position);
|
||||||
// special start case at the right of the endpoint :
|
// special start case at the right of the endpoint :
|
||||||
if (this.stopTextPos < this.position.x()) {
|
if (this.stopTextPos < this.position.x()) {
|
||||||
@ -580,9 +582,9 @@ public abstract class TextBase extends Compositing {
|
|||||||
}
|
}
|
||||||
final float basicSpaceWidth = calculateSize(' ').x();
|
final float basicSpaceWidth = calculateSize(' ').x();
|
||||||
int currentId = 0;
|
int currentId = 0;
|
||||||
final Dynamic<Integer> stop = new Dynamic<Integer>(0);
|
final Dynamic<Integer> stop = new Dynamic<>(0);
|
||||||
final Dynamic<Integer> space = new Dynamic<Integer>(0);
|
final Dynamic<Integer> space = new Dynamic<>(0);
|
||||||
final Dynamic<Integer> freeSpace = new Dynamic<Integer>(0);
|
final Dynamic<Integer> freeSpace = new Dynamic<>(0);
|
||||||
while (currentId < (long) text.length()) {
|
while (currentId < (long) text.length()) {
|
||||||
final boolean needNoJustify = extrapolateLastId(text, currentId, stop, space, freeSpace);
|
final boolean needNoJustify = extrapolateLastId(text, currentId, stop, space, freeSpace);
|
||||||
float interpolation = basicSpaceWidth;
|
float interpolation = basicSpaceWidth;
|
||||||
@ -743,11 +745,11 @@ public abstract class TextBase extends Compositing {
|
|||||||
* @TODO : implementation not done ....
|
* @TODO : implementation not done ....
|
||||||
*/
|
*/
|
||||||
public void printDecorated(final String text) {
|
public void printDecorated(final String text) {
|
||||||
String tmpData = "<html>\n<body>\n";
|
final StringBuilder tmpData = new StringBuilder("<html>\n<body>\n");
|
||||||
tmpData += text;
|
tmpData.append(text);
|
||||||
tmpData += "\n</body>\n</html>\n";
|
tmpData.append("\n</body>\n</html>\n");
|
||||||
// Log.debug("plop : " + tmpData);
|
// Log.debug("plop : " + tmpData);
|
||||||
printHTML(tmpData);
|
printHTML(tmpData.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -803,10 +805,7 @@ public abstract class TextBase extends Compositing {
|
|||||||
} catch (final ExmlBuilderException e) {
|
} catch (final ExmlBuilderException e) {
|
||||||
Log.error("Can not generate XML data in printHTML:" + e.getMessage());
|
Log.error("Can not generate XML data in printHTML:" + e.getMessage());
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} catch (final ExmlNodeDoesNotExist e) {
|
} catch (final ExmlException e) {
|
||||||
Log.error("Error in finding node from XML data in printHTML:" + e.getMessage());
|
|
||||||
e.printStackTrace();
|
|
||||||
} catch (ExmlException e) {
|
|
||||||
Log.error("Error in finding node from XML data in printHTML:" + e.getMessage());
|
Log.error("Error in finding node from XML data in printHTML:" + e.getMessage());
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
@ -74,6 +74,12 @@ public class EwolContext extends GaleApplication {
|
|||||||
final Vector2f size = getSize();
|
final Vector2f size = getSize();
|
||||||
this.windowsCurrent.setSize(new Vector3f((int) size.x(), (int) size.y(), 0));
|
this.windowsCurrent.setSize(new Vector3f((int) size.x(), (int) size.y(), 0));
|
||||||
this.windowsCurrent.onChangeSize();
|
this.windowsCurrent.onChangeSize();
|
||||||
|
/// Gale.getContext().aaaaaaaaaaaaaa();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void forceRedrawAllAsync() {
|
||||||
|
Log.warning("force redraw ALL (ASYNC):");
|
||||||
|
GaleContext.getContext().requestUpdateSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
public EwolApplication getApplication() {
|
public EwolApplication getApplication() {
|
||||||
|
@ -11,6 +11,7 @@ import org.atriasoft.esvg.EsvgFont;
|
|||||||
import org.atriasoft.esvg.font.Glyph;
|
import org.atriasoft.esvg.font.Glyph;
|
||||||
import org.atriasoft.esvg.render.Weight;
|
import org.atriasoft.esvg.render.Weight;
|
||||||
import org.atriasoft.etk.Uri;
|
import org.atriasoft.etk.Uri;
|
||||||
|
import org.atriasoft.etk.math.FMath;
|
||||||
import org.atriasoft.etk.math.Vector2f;
|
import org.atriasoft.etk.math.Vector2f;
|
||||||
import org.atriasoft.etk.math.Vector2i;
|
import org.atriasoft.etk.math.Vector2i;
|
||||||
import org.atriasoft.ewol.internal.Log;
|
import org.atriasoft.ewol.internal.Log;
|
||||||
@ -62,14 +63,23 @@ public class ResourceFontSvg extends Resource {
|
|||||||
Log.info(" number of glyph = " + this.font.getNumGlyphs());
|
Log.info(" number of glyph = " + this.font.getNumGlyphs());
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized boolean drawGlyph(final ImageByte imageOut, final int fontSize, final Vector2i glyphPosition, final GlyphProperty property, final int posInImage) {
|
public boolean drawGlyph(final ImageByte imageOut, final int fontSize, final Vector2i glyphPosition, final GlyphProperty property, final int posInImage) {
|
||||||
|
return drawGlyph(imageOut, fontSize, glyphPosition, property, posInImage, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
// the forceClimp is to generate a forcing of the rendering in small font, this permit to have a correct view of the font, otherwise it will be transparent.
|
||||||
|
public synchronized boolean drawGlyph(final ImageByte imageOut, final int fontSize, final Vector2i glyphPosition, final GlyphProperty property, final int posInImage, final boolean forceClimp) {
|
||||||
final Weight weight = this.font.render(property.glyph.getUnicodeValue(), fontSize);
|
final Weight weight = this.font.render(property.glyph.getUnicodeValue(), fontSize);
|
||||||
if (weight == null) {
|
if (weight == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
for (int yyy = 0; yyy < weight.getHeight(); yyy++) {
|
for (int yyy = 0; yyy < weight.getHeight(); yyy++) {
|
||||||
for (int xxx = 0; xxx < weight.getWidth(); xxx++) {
|
for (int xxx = 0; xxx < weight.getWidth(); xxx++) {
|
||||||
final float valueColor = weight.get(xxx, weight.getHeight() - 1 - yyy);
|
float valueColor = weight.get(xxx, weight.getHeight() - 1 - yyy);
|
||||||
|
if (forceClimp) {
|
||||||
|
valueColor = FMath.avg(-0.5f, ((valueColor - 0.2f) * 7.0f), 0.5f) + 0.5f;
|
||||||
|
//valueColor = FMath.avg(-0.5f, (valueColor * 20.0f), 0.5f) + 0.5f;
|
||||||
|
}
|
||||||
// set only alpha :
|
// set only alpha :
|
||||||
switch (posInImage) {
|
switch (posInImage) {
|
||||||
default:
|
default:
|
||||||
|
@ -53,13 +53,13 @@ public class ResourceTexturedFont extends ResourceTexture2 {
|
|||||||
public Vector2i[] lastGlyphPos = new Vector2i[4];
|
public Vector2i[] lastGlyphPos = new Vector2i[4];
|
||||||
public int[] lastRawHeigh = new int[4];
|
public int[] lastRawHeigh = new int[4];
|
||||||
public List<GlyphProperty>[] listElement = new ArrayList[4];
|
public List<GlyphProperty>[] listElement = new ArrayList[4];
|
||||||
|
private boolean forceClimp = false;
|
||||||
private final FontMode[] modeWraping = new FontMode[4]; // !< This is a wrapping mode to prevent the fact that no
|
private final FontMode[] modeWraping = new FontMode[4]; // !< This is a wrapping mode to prevent the fact that no
|
||||||
private int size = 10;
|
private int size = 10;
|
||||||
|
|
||||||
protected ResourceTexturedFont(final Uri fontBaseUri) {
|
protected ResourceTexturedFont(final Uri fontBaseUri) {
|
||||||
super("__TEXTURED_FONT__>>" + fontBaseUri.toString());
|
super("__TEXTURED_FONT__>>" + fontBaseUri.toString());
|
||||||
|
this.forceClimp = "true".equals(fontBaseUri.getProperty("FORCE_CLIMP"));
|
||||||
Log.debug("Load font : '" + fontBaseUri + "'");
|
Log.debug("Load font : '" + fontBaseUri + "'");
|
||||||
|
|
||||||
this.font[0] = null;
|
this.font[0] = null;
|
||||||
@ -222,8 +222,9 @@ public class ResourceTexturedFont extends ResourceTexture2 {
|
|||||||
this.listElement[iii].add(tmpchar);
|
this.listElement[iii].add(tmpchar);
|
||||||
}
|
}
|
||||||
if (hasChange) {
|
if (hasChange) {
|
||||||
|
Log.error("All gliph added ====> request a redraw of all the GUI");
|
||||||
flush();
|
flush();
|
||||||
Ewol.getContext().forceRedrawAll();
|
Ewol.getContext().forceRedrawAllAsync();
|
||||||
//IOgami.storePNG(new Uri("file", "fileFont.png"), this.data); // ==> for debug test only ...
|
//IOgami.storePNG(new Uri("file", "fileFont.png"), this.data); // ==> for debug test only ...
|
||||||
}
|
}
|
||||||
return hasChange;
|
return hasChange;
|
||||||
|
@ -139,6 +139,7 @@ public class Button extends ContainerToggle {
|
|||||||
padding = this.shape.getPadding();
|
padding = this.shape.getPadding();
|
||||||
}
|
}
|
||||||
calculateMinMaxSizePadded(padding);
|
calculateMinMaxSizePadded(padding);
|
||||||
|
Log.verbose("[{}] Result min size : {}", getId(), this.minSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void changeStatusIn(final GuiShapeMode newStatusId) {
|
protected void changeStatusIn(final GuiShapeMode newStatusId) {
|
||||||
@ -246,6 +247,7 @@ public class Button extends ContainerToggle {
|
|||||||
|
|
||||||
void onChangePropertyToggleMode() {
|
void onChangePropertyToggleMode() {
|
||||||
this.propertyValue = !this.propertyValue;
|
this.propertyValue = !this.propertyValue;
|
||||||
|
this.signalValue.emit(this.propertyValue);
|
||||||
if (!this.propertyToggleMode) {
|
if (!this.propertyToggleMode) {
|
||||||
this.idWidgetDisplayed = 0;
|
this.idWidgetDisplayed = 0;
|
||||||
} else {
|
} else {
|
||||||
@ -443,6 +445,7 @@ public class Button extends ContainerToggle {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.propertyValue = propertyValue;
|
this.propertyValue = propertyValue;
|
||||||
|
this.signalValue.emit(this.propertyValue);
|
||||||
onChangePropertyValue();
|
onChangePropertyValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,10 +30,10 @@ public class Container extends Widget {
|
|||||||
// call sub classes
|
// call sub classes
|
||||||
if (this.subWidget != null) {
|
if (this.subWidget != null) {
|
||||||
this.subWidget.calculateMinMaxSize();
|
this.subWidget.calculateMinMaxSize();
|
||||||
Vector3f min = this.subWidget.getCalculateMinSize();
|
final Vector3f min = this.subWidget.getCalculateMinSize();
|
||||||
this.minSize = Vector3f.max(this.minSize, min);
|
this.minSize = Vector3f.max(this.minSize, min);
|
||||||
}
|
}
|
||||||
//Log.error("[" + getId() + "] Result min size : " + this.minSize);
|
Log.warning("[{}] Result min size : {}", getId(), this.minSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -47,7 +47,7 @@ public class Container extends Widget {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EwolObject getSubObjectNamed(final String objectName) {
|
public EwolObject getSubObjectNamed(final String objectName) {
|
||||||
EwolObject tmpObject = super.getSubObjectNamed(objectName);
|
final EwolObject tmpObject = super.getSubObjectNamed(objectName);
|
||||||
if (tmpObject != null) {
|
if (tmpObject != null) {
|
||||||
return tmpObject;
|
return tmpObject;
|
||||||
}
|
}
|
||||||
@ -130,8 +130,8 @@ public class Container extends Widget {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Vector3f origin = this.origin.add(this.offset);
|
Vector3f origin = this.origin.add(this.offset);
|
||||||
Vector3f minSize = this.subWidget.getCalculateMinSize();
|
final Vector3f minSize = this.subWidget.getCalculateMinSize();
|
||||||
Vector3b expand = this.subWidget.getPropertyExpand();
|
final Vector3b expand = this.subWidget.getPropertyExpand();
|
||||||
origin = origin.add(this.propertyGravity.gravityGenerateDelta(minSize.less(this.size)));
|
origin = origin.add(this.propertyGravity.gravityGenerateDelta(minSize.less(this.size)));
|
||||||
this.subWidget.setOrigin(origin);
|
this.subWidget.setOrigin(origin);
|
||||||
this.subWidget.setSize(this.size);
|
this.subWidget.setSize(this.size);
|
||||||
@ -235,7 +235,7 @@ public class Container extends Widget {
|
|||||||
}
|
}
|
||||||
super.systemDraw(displayProp);
|
super.systemDraw(displayProp);
|
||||||
if (this.subWidget != null) {
|
if (this.subWidget != null) {
|
||||||
DrawProperty prop = displayProp.withLimit(this.origin, this.size);
|
final DrawProperty prop = displayProp.withLimit(this.origin, this.size);
|
||||||
//Log.info("Draw : [" + propertyName + "] t=" + getObjectType() + " o=" + this.origin + " s=" + this.size);
|
//Log.info("Draw : [" + propertyName + "] t=" + getObjectType() + " o=" + this.origin + " s=" + this.size);
|
||||||
this.subWidget.systemDraw(prop);
|
this.subWidget.systemDraw(prop);
|
||||||
} else {
|
} else {
|
||||||
|
@ -42,21 +42,21 @@ public class ContainerN extends Widget {
|
|||||||
this.minSize = Vector3f.ZERO;
|
this.minSize = Vector3f.ZERO;
|
||||||
this.maxSize = Vector3f.MAX_VALUE;
|
this.maxSize = Vector3f.MAX_VALUE;
|
||||||
//Log.error("[" + getId() + "] {" + getObjectType() + "} set min size : " + this.minSize);
|
//Log.error("[" + getId() + "] {" + getObjectType() + "} set min size : " + this.minSize);
|
||||||
for (Widget it : this.subWidget) {
|
for (final Widget it : this.subWidget) {
|
||||||
if (it != null) {
|
if (it != null) {
|
||||||
it.calculateMinMaxSize();
|
it.calculateMinMaxSize();
|
||||||
Vector3b subExpendProp = it.canExpand();
|
final Vector3b subExpendProp = it.canExpand();
|
||||||
if (subExpendProp.x()) {
|
if (subExpendProp.x()) {
|
||||||
this.subExpend = this.subExpend.withX(true);
|
this.subExpend = this.subExpend.withX(true);
|
||||||
}
|
}
|
||||||
if (subExpendProp.y()) {
|
if (subExpendProp.y()) {
|
||||||
this.subExpend = this.subExpend.withX(true);
|
this.subExpend = this.subExpend.withX(true);
|
||||||
}
|
}
|
||||||
Vector3f tmpSize = it.getCalculateMinSize();
|
final Vector3f tmpSize = it.getCalculateMinSize();
|
||||||
this.minSize = Vector3f.max(tmpSize, this.minSize);
|
this.minSize = Vector3f.max(tmpSize, this.minSize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//Log.error("[" + getId() + "] {" + getObjectType() + "} Result min size : " + this.minSize);
|
Log.warning("[{}] Result min size : {}", getId(), this.minSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
// herited function
|
// herited function
|
||||||
@ -81,7 +81,7 @@ public class ContainerN extends Widget {
|
|||||||
public void drawWidgetTree(int level) {
|
public void drawWidgetTree(int level) {
|
||||||
super.drawWidgetTree(level);
|
super.drawWidgetTree(level);
|
||||||
level++;
|
level++;
|
||||||
for (Widget it : this.subWidget) {
|
for (final Widget it : this.subWidget) {
|
||||||
if (it != null) {
|
if (it != null) {
|
||||||
it.drawWidgetTree(level);
|
it.drawWidgetTree(level);
|
||||||
}
|
}
|
||||||
@ -102,7 +102,7 @@ public class ContainerN extends Widget {
|
|||||||
if (tmpObject != null) {
|
if (tmpObject != null) {
|
||||||
return tmpObject;
|
return tmpObject;
|
||||||
}
|
}
|
||||||
for (Widget it : this.subWidget) {
|
for (final Widget it : this.subWidget) {
|
||||||
if (it != null) {
|
if (it != null) {
|
||||||
tmpObject = it.getSubObjectNamed(objectName);
|
tmpObject = it.getSubObjectNamed(objectName);
|
||||||
if (tmpObject != null) {
|
if (tmpObject != null) {
|
||||||
@ -126,12 +126,12 @@ public class ContainerN extends Widget {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
// for all element in the sizer ...
|
// for all element in the sizer ...
|
||||||
for (Widget it : this.subWidget) {
|
for (final Widget it : this.subWidget) {
|
||||||
if (it != null) {
|
if (it != null) {
|
||||||
Vector3f tmpSize = it.getSize();
|
final Vector3f tmpSize = it.getSize();
|
||||||
Vector3f tmpOrigin = it.getOrigin();
|
final Vector3f tmpOrigin = it.getOrigin();
|
||||||
if ((tmpOrigin.x() <= pos.x() && tmpOrigin.x() + tmpSize.x() >= pos.x()) && (tmpOrigin.y() <= pos.y() && tmpOrigin.y() + tmpSize.y() >= pos.y())) {
|
if ((tmpOrigin.x() <= pos.x() && tmpOrigin.x() + tmpSize.x() >= pos.x()) && (tmpOrigin.y() <= pos.y() && tmpOrigin.y() + tmpSize.y() >= pos.y())) {
|
||||||
Widget tmpWidget = it.getWidgetAtPos(pos);
|
final Widget tmpWidget = it.getWidgetAtPos(pos);
|
||||||
if (tmpWidget != null) {
|
if (tmpWidget != null) {
|
||||||
return tmpWidget;
|
return tmpWidget;
|
||||||
}
|
}
|
||||||
@ -145,7 +145,7 @@ public class ContainerN extends Widget {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onChangeSize() {
|
public void onChangeSize() {
|
||||||
for (Widget it : this.subWidget) {
|
for (final Widget it : this.subWidget) {
|
||||||
if (it == null) {
|
if (it == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -157,7 +157,7 @@ public class ContainerN extends Widget {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onRegenerateDisplay() {
|
public void onRegenerateDisplay() {
|
||||||
for (Widget it : this.subWidget) {
|
for (final Widget it : this.subWidget) {
|
||||||
if (it != null) {
|
if (it != null) {
|
||||||
it.systemRegenerateDisplay();
|
it.systemRegenerateDisplay();
|
||||||
}
|
}
|
||||||
@ -168,7 +168,7 @@ public class ContainerN extends Widget {
|
|||||||
public void requestDestroyFromChild(final EwolObject child) {
|
public void requestDestroyFromChild(final EwolObject child) {
|
||||||
ListIterator<Widget> it = this.subWidget.listIterator();
|
ListIterator<Widget> it = this.subWidget.listIterator();
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
Widget elem = it.next();
|
final Widget elem = it.next();
|
||||||
if (elem != child) {
|
if (elem != child) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -201,11 +201,11 @@ public class ContainerN extends Widget {
|
|||||||
requestUpdateSize();
|
requestUpdateSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSubWidgets(List<Widget> listData) {
|
public void setSubWidgets(final List<Widget> listData) {
|
||||||
// Clean all previous widget
|
// Clean all previous widget
|
||||||
this.subWidgetRemoveAll();
|
this.subWidgetRemoveAll();
|
||||||
// add separately all widgets
|
// add separately all widgets
|
||||||
for (Widget elem : listData) {
|
for (final Widget elem : listData) {
|
||||||
if (elem == null) {
|
if (elem == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -276,11 +276,11 @@ public class ContainerN extends Widget {
|
|||||||
if (newWidget == null) {
|
if (newWidget == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int errorControl = this.subWidget.size();
|
final int errorControl = this.subWidget.size();
|
||||||
|
|
||||||
ListIterator<Widget> it = this.subWidget.listIterator();
|
final ListIterator<Widget> it = this.subWidget.listIterator();
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
Widget elem = it.next();
|
final Widget elem = it.next();
|
||||||
if (newWidget == elem) {
|
if (newWidget == elem) {
|
||||||
elem.removeParent();
|
elem.removeParent();
|
||||||
it.remove();
|
it.remove();
|
||||||
@ -317,9 +317,9 @@ public class ContainerN extends Widget {
|
|||||||
*/
|
*/
|
||||||
public void subWidgetReplace(final Widget oldWidget, final Widget newWidget) {
|
public void subWidgetReplace(final Widget oldWidget, final Widget newWidget) {
|
||||||
boolean haveChange = false;
|
boolean haveChange = false;
|
||||||
ListIterator<Widget> it = this.subWidget.listIterator();
|
final ListIterator<Widget> it = this.subWidget.listIterator();
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
Widget elem = it.next();
|
final Widget elem = it.next();
|
||||||
if (elem != oldWidget) {
|
if (elem != oldWidget) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -346,9 +346,9 @@ public class ContainerN extends Widget {
|
|||||||
if (newWidget == null) {
|
if (newWidget == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ListIterator<Widget> it = this.subWidget.listIterator();
|
final ListIterator<Widget> it = this.subWidget.listIterator();
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
Widget elem = it.next();
|
final Widget elem = it.next();
|
||||||
if (newWidget == elem) {
|
if (newWidget == elem) {
|
||||||
elem.removeParent();
|
elem.removeParent();
|
||||||
it.remove();
|
it.remove();
|
||||||
@ -369,9 +369,9 @@ public class ContainerN extends Widget {
|
|||||||
// subwidget draw
|
// subwidget draw
|
||||||
DrawProperty prop = displayProp;
|
DrawProperty prop = displayProp;
|
||||||
prop = prop.withLimit(this.origin, this.size);
|
prop = prop.withLimit(this.origin, this.size);
|
||||||
ListIterator<Widget> it = this.subWidget.listIterator(this.subWidget.size());
|
final ListIterator<Widget> it = this.subWidget.listIterator(this.subWidget.size());
|
||||||
while (it.hasPrevious()) {
|
while (it.hasPrevious()) {
|
||||||
Widget elem = it.previous();
|
final Widget elem = it.previous();
|
||||||
if (elem != null) {
|
if (elem != null) {
|
||||||
//Log.info(" ***** : [" + (*it).propertyName + "] t=" + (*it).getObjectType() + " o=" + (*it).this.origin + " s=" + (*it).this.size);
|
//Log.info(" ***** : [" + (*it).propertyName + "] t=" + (*it).getObjectType() + " o=" + (*it).this.origin + " s=" + (*it).this.size);
|
||||||
elem.systemDraw(prop);
|
elem.systemDraw(prop);
|
||||||
|
@ -8,8 +8,11 @@ package org.atriasoft.ewol.widget;
|
|||||||
import org.atriasoft.etk.math.Vector3f;
|
import org.atriasoft.etk.math.Vector3f;
|
||||||
import org.atriasoft.ewol.DrawProperty;
|
import org.atriasoft.ewol.DrawProperty;
|
||||||
import org.atriasoft.ewol.Padding;
|
import org.atriasoft.ewol.Padding;
|
||||||
|
import org.atriasoft.ewol.annotation.EwolDescription;
|
||||||
import org.atriasoft.ewol.internal.Log;
|
import org.atriasoft.ewol.internal.Log;
|
||||||
import org.atriasoft.ewol.object.EwolObject;
|
import org.atriasoft.ewol.object.EwolObject;
|
||||||
|
import org.atriasoft.exml.annotation.XmlFactory;
|
||||||
|
import org.atriasoft.exml.annotation.XmlManaged;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @ingroup ewolWidgetGroup
|
* @ingroup ewolWidgetGroup
|
||||||
@ -87,7 +90,8 @@ public class ContainerToggle extends Widget {
|
|||||||
this.minSize = this.minSize.add(padding.x(), padding.y(), padding.z());
|
this.minSize = this.minSize.add(padding.x(), padding.y(), padding.z());
|
||||||
// verify the min max of the min size ...
|
// verify the min max of the min size ...
|
||||||
checkMinSize();
|
checkMinSize();
|
||||||
markToRedraw();
|
//markToRedraw();
|
||||||
|
Log.verbose("[{}] Result min size : {}", getId(), this.minSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -120,32 +124,42 @@ public class ContainerToggle extends Widget {
|
|||||||
return null;
|
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 Widget[] getSubWidgets() {
|
||||||
|
return this.subWidget;
|
||||||
|
}
|
||||||
|
|
||||||
public Padding onChangeSizePadded(final Padding padding) {
|
public Padding onChangeSizePadded(final Padding padding) {
|
||||||
super.onChangeSize();
|
super.onChangeSize();
|
||||||
final Vector3f localAvaillable = this.size.less(padding.x(), padding.y(), padding.z());
|
final Vector3f localAvaillable = this.size.less(padding.x(), padding.y(), padding.z());
|
||||||
// Checking the filling properties == > for the subElements:
|
// Checking the filling properties == > for the subElements:
|
||||||
Vector3f subElementSize = this.minSize;
|
Vector3f subElementSize = this.minSize.less(padding.x(), padding.y(), padding.z());
|
||||||
if (this.propertyFill.x()) {
|
if (this.propertyFill.x()) {
|
||||||
subElementSize = subElementSize.withX(this.size.x());
|
subElementSize = subElementSize.withX(this.size.x() - padding.x());
|
||||||
}
|
}
|
||||||
if (this.propertyFill.y()) {
|
if (this.propertyFill.y()) {
|
||||||
subElementSize = subElementSize.withY(this.size.y());
|
subElementSize = subElementSize.withY(this.size.y() - padding.y());
|
||||||
}
|
}
|
||||||
final Vector3f delta = this.propertyGravity.gravityGenerateDelta(this.size.less(subElementSize));
|
if (this.propertyFill.z()) {
|
||||||
final Vector3f origin = delta.add(padding.left(), padding.bottom(), padding.back());
|
subElementSize = subElementSize.withZ(this.size.z() - padding.z());
|
||||||
subElementSize = subElementSize.less(padding.x(), padding.y(), padding.z());
|
}
|
||||||
|
final Vector3f delta = this.propertyGravity.gravityGenerateDelta(this.size.less(subElementSize.add(padding.x(), padding.y(), padding.z())));
|
||||||
|
final Vector3f deltaPadded = delta.add(padding.left(), padding.bottom(), padding.back());
|
||||||
|
//subElementSize = subElementSize.less(padding.x(), padding.y(), padding.z());
|
||||||
for (int iii = 0; iii < 2; ++iii) {
|
for (int iii = 0; iii < 2; ++iii) {
|
||||||
if (this.subWidget[iii] != null) {
|
if (this.subWidget[iii] != null) {
|
||||||
Vector3f origin2 = origin.add(this.offset);
|
//final Vector3f origin2 = this.origin.add(this.offset);
|
||||||
final Vector3f minSize = this.subWidget[iii].getCalculateMinSize();
|
//final Vector3f minSize = this.subWidget[iii].getCalculateMinSize();
|
||||||
//Vector2b expand = this.subWidget[iii].propertyExpand.get();
|
//Vector2b expand = this.subWidget[iii].propertyExpand.get();
|
||||||
origin2 = origin2.add(this.propertyGravity.gravityGenerateDelta(minSize.less(localAvaillable)));
|
//origin2 = origin2.add(this.propertyGravity.gravityGenerateDelta(minSize.less(localAvaillable)));
|
||||||
this.subWidget[iii].setOrigin(this.origin.add(origin));
|
this.subWidget[iii].setOrigin(this.origin.add(deltaPadded));
|
||||||
this.subWidget[iii].setSize(subElementSize);
|
this.subWidget[iii].setSize(subElementSize);
|
||||||
this.subWidget[iii].onChangeSize();
|
this.subWidget[iii].onChangeSize();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
final Vector3f selectableAreaPos = origin.less(padding.left(), padding.bottom(), padding.back());
|
final Vector3f selectableAreaPos = this.origin.add(delta);//.less(padding.left(), padding.bottom(), padding.back());
|
||||||
final Vector3f selectableAreaEndPos = this.size.less(selectableAreaPos.add(subElementSize.add(padding.x(), padding.y(), padding.z())));
|
final Vector3f selectableAreaEndPos = this.size.less(selectableAreaPos.add(subElementSize.add(padding.x(), padding.y(), padding.z())));
|
||||||
markToRedraw();
|
markToRedraw();
|
||||||
return new Padding(selectableAreaPos.x(), selectableAreaEndPos.y(), selectableAreaEndPos.x(), selectableAreaPos.y());
|
return new Padding(selectableAreaPos.x(), selectableAreaEndPos.y(), selectableAreaEndPos.x(), selectableAreaPos.y());
|
||||||
|
@ -6,15 +6,13 @@ import java.util.regex.Pattern;
|
|||||||
import org.atriasoft.esignal.Connection;
|
import org.atriasoft.esignal.Connection;
|
||||||
import org.atriasoft.esignal.Signal;
|
import org.atriasoft.esignal.Signal;
|
||||||
import org.atriasoft.esignal.SignalEmpty;
|
import org.atriasoft.esignal.SignalEmpty;
|
||||||
import org.atriasoft.etk.Color;
|
|
||||||
import org.atriasoft.etk.Uri;
|
import org.atriasoft.etk.Uri;
|
||||||
import org.atriasoft.etk.math.FMath;
|
import org.atriasoft.etk.math.FMath;
|
||||||
import org.atriasoft.etk.math.Vector2f;
|
|
||||||
import org.atriasoft.etk.math.Vector3f;
|
import org.atriasoft.etk.math.Vector3f;
|
||||||
import org.atriasoft.ewol.Padding;
|
import org.atriasoft.ewol.Padding;
|
||||||
import org.atriasoft.ewol.annotation.EwolDescription;
|
import org.atriasoft.ewol.annotation.EwolDescription;
|
||||||
import org.atriasoft.ewol.annotation.EwolSignal;
|
import org.atriasoft.ewol.annotation.EwolSignal;
|
||||||
import org.atriasoft.ewol.compositing.CompositingGraphicContext;
|
import org.atriasoft.ewol.compositing.CompositingText;
|
||||||
import org.atriasoft.ewol.compositing.GuiShape;
|
import org.atriasoft.ewol.compositing.GuiShape;
|
||||||
import org.atriasoft.ewol.compositing.GuiShapeMode;
|
import org.atriasoft.ewol.compositing.GuiShapeMode;
|
||||||
import org.atriasoft.ewol.event.EventEntry;
|
import org.atriasoft.ewol.event.EventEntry;
|
||||||
@ -67,7 +65,7 @@ public class Entry extends Widget {
|
|||||||
/// offset in pixel of the display of the UString
|
/// offset in pixel of the display of the UString
|
||||||
private int displayCursorPositionPixel = 0;
|
private int displayCursorPositionPixel = 0;
|
||||||
/// text display this.text
|
/// text display this.text
|
||||||
private final CompositingGraphicContext gc = new CompositingGraphicContext();
|
private final CompositingText text = new CompositingText();
|
||||||
/// text position can have change
|
/// text position can have change
|
||||||
private boolean needUpdateTextPos = true;
|
private boolean needUpdateTextPos = true;
|
||||||
/// Periodic call handle to remove it when needed
|
/// Periodic call handle to remove it when needed
|
||||||
@ -130,7 +128,7 @@ public class Entry extends Widget {
|
|||||||
if (this.shape != null) {
|
if (this.shape != null) {
|
||||||
padding = this.shape.getPadding();
|
padding = this.shape.getPadding();
|
||||||
}
|
}
|
||||||
int minHeight = this.gc.getTextHeight();//calculateSize('A').y();
|
final int minHeight = (int) this.text.getHeight();//calculateSize('A').y();
|
||||||
|
|
||||||
Vector3f minimumSizeBase = new Vector3f(20, minHeight, 10);
|
Vector3f minimumSizeBase = new Vector3f(20, minHeight, 10);
|
||||||
// add padding :
|
// add padding :
|
||||||
@ -167,7 +165,7 @@ public class Entry extends Widget {
|
|||||||
pos1 = this.displayCursorPos;
|
pos1 = this.displayCursorPos;
|
||||||
}
|
}
|
||||||
// Copy
|
// Copy
|
||||||
String tmpData = this.propertyValue.substring(pos1, pos2);
|
final String tmpData = this.propertyValue.substring(pos1, pos2);
|
||||||
ClipBoard.set(clipboardID, tmpData);
|
ClipBoard.set(clipboardID, tmpData);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -304,8 +302,9 @@ public class Entry extends Widget {
|
|||||||
@Override
|
@Override
|
||||||
protected void onDraw() {
|
protected void onDraw() {
|
||||||
if (this.shape != null) {
|
if (this.shape != null) {
|
||||||
this.shape.draw(this.gc.getResourceTexture(), true);
|
this.shape.draw(true);
|
||||||
}
|
}
|
||||||
|
this.text.draw();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -313,10 +312,10 @@ public class Entry extends Widget {
|
|||||||
// remove curent selected data ...
|
// remove curent selected data ...
|
||||||
removeSelected();
|
removeSelected();
|
||||||
// get current selection / Copy :
|
// get current selection / Copy :
|
||||||
String tmpData = ClipBoard.get(clipboardID);
|
final String tmpData = ClipBoard.get(clipboardID);
|
||||||
// add it on the current display:
|
// add it on the current display:
|
||||||
if (tmpData.length() != 0) {
|
if (tmpData.length() != 0) {
|
||||||
StringBuilder newData = new StringBuilder(this.propertyValue);
|
final StringBuilder newData = new StringBuilder(this.propertyValue);
|
||||||
newData.insert(this.displayCursorPos, tmpData.charAt(0));
|
newData.insert(this.displayCursorPos, tmpData.charAt(0));
|
||||||
setInternalValue(newData.toString());
|
setInternalValue(newData.toString());
|
||||||
if (this.propertyValue.equals(newData.toString())) {
|
if (this.propertyValue.equals(newData.toString())) {
|
||||||
@ -346,7 +345,7 @@ public class Entry extends Widget {
|
|||||||
if (event.getChar() == 0x7F) {
|
if (event.getChar() == 0x7F) {
|
||||||
// SUPPR :
|
// SUPPR :
|
||||||
if (this.propertyValue.length() > 0 && this.displayCursorPos < (long) this.propertyValue.length()) {
|
if (this.propertyValue.length() > 0 && this.displayCursorPos < (long) this.propertyValue.length()) {
|
||||||
StringBuilder newData = new StringBuilder(this.propertyValue);
|
final StringBuilder newData = new StringBuilder(this.propertyValue);
|
||||||
newData.deleteCharAt(this.displayCursorPos);
|
newData.deleteCharAt(this.displayCursorPos);
|
||||||
this.propertyValue = newData.toString();
|
this.propertyValue = newData.toString();
|
||||||
this.displayCursorPos = Math.max(this.displayCursorPos, 0);
|
this.displayCursorPos = Math.max(this.displayCursorPos, 0);
|
||||||
@ -355,7 +354,7 @@ public class Entry extends Widget {
|
|||||||
} else if (event.getChar() == 0x08) {
|
} else if (event.getChar() == 0x08) {
|
||||||
// DEL :
|
// DEL :
|
||||||
if (this.propertyValue.length() > 0 && this.displayCursorPos != 0) {
|
if (this.propertyValue.length() > 0 && this.displayCursorPos != 0) {
|
||||||
StringBuilder newData = new StringBuilder(this.propertyValue);
|
final StringBuilder newData = new StringBuilder(this.propertyValue);
|
||||||
newData.deleteCharAt(this.displayCursorPos - 1);
|
newData.deleteCharAt(this.displayCursorPos - 1);
|
||||||
this.propertyValue = newData.toString();
|
this.propertyValue = newData.toString();
|
||||||
this.displayCursorPos--;
|
this.displayCursorPos--;
|
||||||
@ -367,9 +366,9 @@ public class Entry extends Widget {
|
|||||||
if ((long) this.propertyValue.length() > this.propertyMaxCharacter) {
|
if ((long) this.propertyValue.length() > this.propertyMaxCharacter) {
|
||||||
Log.info("Reject data for entry : '" + event.getChar() + "'");
|
Log.info("Reject data for entry : '" + event.getChar() + "'");
|
||||||
} else {
|
} else {
|
||||||
StringBuilder newData = new StringBuilder(this.propertyValue);
|
final StringBuilder newData = new StringBuilder(this.propertyValue);
|
||||||
newData.insert(this.displayCursorPos, event.getChar());
|
newData.insert(this.displayCursorPos, event.getChar());
|
||||||
String newDataGenerated = newData.toString();
|
final String newDataGenerated = newData.toString();
|
||||||
setInternalValue(newDataGenerated);
|
setInternalValue(newDataGenerated);
|
||||||
if (this.propertyValue.equals(newDataGenerated)) {
|
if (this.propertyValue.equals(newDataGenerated)) {
|
||||||
this.displayCursorPos += 1;//inputData.length();
|
this.displayCursorPos += 1;//inputData.length();
|
||||||
@ -410,8 +409,8 @@ public class Entry extends Widget {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onEventInput(final EventInput event) {
|
public boolean onEventInput(final EventInput event) {
|
||||||
Vector3f absolutePosition = new Vector3f(event.pos().x(), event.pos().y(), 0);
|
final Vector3f absolutePosition = new Vector3f(event.pos().x(), event.pos().y(), 0);
|
||||||
Vector3f relPos = relativePosition(absolutePosition);
|
final Vector3f relPos = relativePosition(absolutePosition);
|
||||||
Log.verbose("Event on Input ... " + event + " relPos = " + relPos);
|
Log.verbose("Event on Input ... " + event + " relPos = " + relPos);
|
||||||
if (event.inputId() == 0) {
|
if (event.inputId() == 0) {
|
||||||
if (!isFocused()) {
|
if (!isFocused()) {
|
||||||
@ -523,7 +522,7 @@ public class Entry extends Widget {
|
|||||||
}
|
}
|
||||||
//Log.verbose("Regenerate Display ==> is needed: '" + this.propertyValue + "'");
|
//Log.verbose("Regenerate Display ==> is needed: '" + this.propertyValue + "'");
|
||||||
this.shape.clear();
|
this.shape.clear();
|
||||||
this.gc.clear();
|
this.text.clear();
|
||||||
if (this.colorIdTextFg >= 0) {
|
if (this.colorIdTextFg >= 0) {
|
||||||
//this.text.setDefaultColorFg(this.shape.getColor(this.colorIdTextFg));
|
//this.text.setDefaultColorFg(this.shape.getColor(this.colorIdTextFg));
|
||||||
//this.text.setDefaultColorBg(this.shape.getColor(this.colorIdTextBg));
|
//this.text.setDefaultColorBg(this.shape.getColor(this.colorIdTextBg));
|
||||||
@ -531,7 +530,7 @@ public class Entry extends Widget {
|
|||||||
//this.text.setSelectionColor(this.shape.getColor(this.colorIdSelection));
|
//this.text.setSelectionColor(this.shape.getColor(this.colorIdSelection));
|
||||||
}
|
}
|
||||||
updateTextPosition();
|
updateTextPosition();
|
||||||
Padding padding = this.shape.getPadding();
|
final Padding padding = this.shape.getPadding();
|
||||||
|
|
||||||
Vector3f tmpSizeShaper = this.minSize;
|
Vector3f tmpSizeShaper = this.minSize;
|
||||||
if (this.propertyFill.x()) {
|
if (this.propertyFill.x()) {
|
||||||
@ -540,57 +539,51 @@ public class Entry extends Widget {
|
|||||||
if (this.propertyFill.y()) {
|
if (this.propertyFill.y()) {
|
||||||
tmpSizeShaper = tmpSizeShaper.withY(this.size.y());
|
tmpSizeShaper = tmpSizeShaper.withY(this.size.y());
|
||||||
}
|
}
|
||||||
|
if (this.propertyFill.z()) {
|
||||||
|
tmpSizeShaper = tmpSizeShaper.withZ(this.size.z());
|
||||||
|
}
|
||||||
|
|
||||||
Vector3f tmpOriginShaper = this.size.less(tmpSizeShaper).multiply(0.5f);
|
Vector3f tmpOriginShaper = this.size.less(tmpSizeShaper).multiply(0.5f);
|
||||||
Vector3f tmpSizeText = tmpSizeShaper.less(padding.x(), padding.y(), padding.z());
|
Vector3f tmpSizeText = tmpSizeShaper.less(padding.x(), padding.y(), padding.z());
|
||||||
//Vector3f tmpOriginText = this.size.less(tmpSizeText).multiply(0.5f);
|
Vector3f tmpOriginText = this.size.less(tmpSizeText).multiply(0.5f);
|
||||||
Vector3f tmpOriginText = new Vector3f(0, this.gc.getTextSize(), 0);
|
//Vector3f tmpOriginText = new Vector3f(0, this.text.getSize(), 0);
|
||||||
// sometimes, the user define an height bigger than the real size needed == > in this case we need to center the text in the shaper ...
|
// 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();
|
final int minHeight = (int) this.text.getHeight();
|
||||||
if (tmpSizeText.y() > minHeight) {
|
if (tmpSizeText.y() > minHeight) {
|
||||||
tmpOriginText = tmpOriginText.add(0, (tmpSizeText.y() - minHeight) * 0.5f);
|
tmpOriginText = tmpOriginText.add(0, (tmpSizeText.y() - minHeight) * 0.5f, 0);
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
// fix all the position in the int class:
|
// fix all the position in the int class:
|
||||||
tmpSizeShaper = Vector3f.clipInt(tmpSizeShaper);
|
tmpSizeShaper = Vector3f.clipInt(tmpSizeShaper);
|
||||||
tmpOriginShaper = Vector3f.clipInt(tmpOriginShaper);
|
tmpOriginShaper = Vector3f.clipInt(tmpOriginShaper);
|
||||||
tmpSizeText = Vector3f.clipInt(tmpSizeText);
|
tmpSizeText = Vector3f.clipInt(tmpSizeText);
|
||||||
tmpOriginText = Vector3f.clipInt(tmpOriginText);
|
tmpOriginText = Vector3f.clipInt(tmpOriginText);
|
||||||
|
|
||||||
this.gc.clear();
|
this.text.clear();
|
||||||
this.gc.setSize((int) tmpSizeText.x(), (int) tmpSizeText.y());
|
//this.text.setSize((int) tmpSizeText.x(), (int) tmpSizeText.y());
|
||||||
|
this.text.setClippingWidth(tmpOriginText, tmpSizeText);
|
||||||
// if (this.displayCursorPosSelection != this.displayCursorPos) {
|
this.text.setPos(tmpOriginText.add(this.displayStartPosition, 0, 0));
|
||||||
//
|
if (this.displayCursorPosSelection != this.displayCursorPos) {
|
||||||
// //this.text.setCursorSelection(this.displayCursorPos, this.displayCursorPosSelection);
|
this.text.setCursorSelection(this.displayCursorPos, this.displayCursorPosSelection);
|
||||||
// } else {
|
} else {
|
||||||
// this.text.setCursorPos(this.displayCursorPos);
|
this.text.setCursorPos(this.displayCursorPos);
|
||||||
// }
|
}
|
||||||
this.gc.setColorFill(Color.RED);
|
final char[] valueToDisplay = this.propertyValue.toCharArray();
|
||||||
this.gc.setColorStroke(Color.GREEN);
|
|
||||||
this.gc.setStrokeWidth(5);
|
|
||||||
//this.gc.rectangleRounded(new Vector3f(20, 2), new Vector3f(55, 70), new Vector3f(15, 15));
|
|
||||||
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);
|
|
||||||
this.gc.setStrokeWidth(1);
|
|
||||||
char[] valueToDisplay = this.propertyValue.toCharArray();
|
|
||||||
if (this.propertyPassword) {
|
if (this.propertyPassword) {
|
||||||
Arrays.fill(valueToDisplay, '*');
|
Arrays.fill(valueToDisplay, '*');
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector2f plop = new Vector2f(tmpOriginText.x() + this.displayStartPosition, tmpOriginText.y());
|
//final Vector2f plop = new Vector2f(tmpOriginText.x() + this.displayStartPosition, tmpOriginText.y());
|
||||||
if (valueToDisplay.length != 0) {
|
if (valueToDisplay.length != 0) {
|
||||||
this.gc.text(plop, new String(valueToDisplay));
|
this.text.print(new String(valueToDisplay));
|
||||||
} else if (this.propertyTextWhenNothing != null) {
|
} else if (this.propertyTextWhenNothing != null) {
|
||||||
this.gc.text(plop, this.propertyTextWhenNothing);
|
this.text.printDecorated(this.propertyTextWhenNothing);
|
||||||
}
|
}
|
||||||
|
this.text.setClippingMode(false);
|
||||||
this.overPositionStart = tmpOriginShaper;
|
this.overPositionStart = tmpOriginShaper;
|
||||||
this.overPositionStop = tmpOriginShaper.add(tmpSizeShaper);
|
this.overPositionStop = tmpOriginShaper.add(tmpSizeShaper);
|
||||||
this.shape.setShape(tmpOriginShaper, tmpSizeShaper, tmpOriginText, tmpSizeText);
|
this.shape.setShape(tmpOriginShaper, tmpSizeShaper, tmpOriginText, tmpSizeText);
|
||||||
this.gc.flush();
|
this.text.flush();
|
||||||
this.shape.flush();
|
this.shape.flush();
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -613,7 +606,7 @@ public class Entry extends Widget {
|
|||||||
// remove data ...
|
// remove data ...
|
||||||
this.displayCursorPos = pos1;
|
this.displayCursorPos = pos1;
|
||||||
this.displayCursorPosSelection = pos1;
|
this.displayCursorPosSelection = pos1;
|
||||||
StringBuilder tmp = new StringBuilder(this.propertyValue);
|
final StringBuilder tmp = new StringBuilder(this.propertyValue);
|
||||||
if (pos1 < pos2) {
|
if (pos1 < pos2) {
|
||||||
tmp.delete(pos1, pos2);
|
tmp.delete(pos1, pos2);
|
||||||
} else if (pos1 > pos2) {
|
} else if (pos1 > pos2) {
|
||||||
@ -628,7 +621,7 @@ public class Entry extends Widget {
|
|||||||
* @param newData The new string to display
|
* @param newData The new string to display
|
||||||
*/
|
*/
|
||||||
protected void setInternalValue(final String newData) {
|
protected void setInternalValue(final String newData) {
|
||||||
String previous = this.propertyValue;
|
final String previous = this.propertyValue;
|
||||||
// check the RegExp :
|
// check the RegExp :
|
||||||
if (newData.length() > 0) {
|
if (newData.length() > 0) {
|
||||||
/*
|
/*
|
||||||
@ -732,7 +725,7 @@ public class Entry extends Widget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void updateCursorPosition(final Vector3f pos, final boolean selection/*=false*/) {
|
protected void updateCursorPosition(final Vector3f pos, final boolean selection/*=false*/) {
|
||||||
Padding padding = this.shape.getPadding();
|
final Padding padding = this.shape.getPadding();
|
||||||
|
|
||||||
Vector3f relPos = relativePosition(pos);
|
Vector3f relPos = relativePosition(pos);
|
||||||
relPos = relPos.withX(relPos.x() - this.displayStartPosition - padding.left());
|
relPos = relPos.withX(relPos.x() - this.displayStartPosition - padding.left());
|
||||||
@ -745,13 +738,13 @@ public class Entry extends Widget {
|
|||||||
this.displayStartPosition = 0;
|
this.displayStartPosition = 0;
|
||||||
}
|
}
|
||||||
String tmpDisplay = this.propertyValue.substring(0, this.displayStartPosition);
|
String tmpDisplay = this.propertyValue.substring(0, this.displayStartPosition);
|
||||||
int displayHidenSize = this.gc.calculateTextSize(tmpDisplay).x();
|
final int displayHidenSize = (int) this.text.calculateSize(tmpDisplay).x();
|
||||||
//Log.debug("hidenSize : " + displayHidenSize);
|
//Log.debug("hidenSize : " + displayHidenSize);
|
||||||
int newCursorPosition = -1;
|
int newCursorPosition = -1;
|
||||||
int tmpTextOriginX = (int) padding.left();
|
final int tmpTextOriginX = (int) padding.left();
|
||||||
for (int iii = 0; iii < this.propertyValue.length(); iii++) {
|
for (int iii = 0; iii < this.propertyValue.length(); iii++) {
|
||||||
tmpDisplay = this.propertyValue.substring(0, iii);
|
tmpDisplay = this.propertyValue.substring(0, iii);
|
||||||
int tmpWidth = this.gc.calculateTextSize(tmpDisplay).x() - displayHidenSize;
|
final int tmpWidth = (int) (this.text.calculateSize(tmpDisplay).x() - displayHidenSize);
|
||||||
if (tmpWidth >= relPos.x() - tmpTextOriginX) {
|
if (tmpWidth >= relPos.x() - tmpTextOriginX) {
|
||||||
newCursorPosition = iii;
|
newCursorPosition = iii;
|
||||||
break;
|
break;
|
||||||
@ -782,27 +775,27 @@ public class Entry extends Widget {
|
|||||||
if (!this.needUpdateTextPos) {
|
if (!this.needUpdateTextPos) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Padding padding = this.shape.getPadding();
|
final Padding padding = this.shape.getPadding();
|
||||||
|
|
||||||
int tmpSizeX = (int) this.minSize.x();
|
int tmpSizeX = (int) this.minSize.x();
|
||||||
if (this.propertyFill.x()) {
|
if (this.propertyFill.x()) {
|
||||||
tmpSizeX = (int) this.size.x();
|
tmpSizeX = (int) this.size.x();
|
||||||
}
|
}
|
||||||
int tmpUserSize = (int) (tmpSizeX - padding.x());
|
final int tmpUserSize = (int) (tmpSizeX - padding.x());
|
||||||
int totalWidth = this.gc.calculateTextSize(this.propertyValue).x();
|
final int totalWidth = (int) this.text.calculateSize(this.propertyValue).x();
|
||||||
// all can not be set :
|
// all can not be set :
|
||||||
String tmpDisplay = this.propertyValue.substring(0, this.displayCursorPos);
|
final String tmpDisplay = this.propertyValue.substring(0, this.displayCursorPos);
|
||||||
this.displayCursorPositionPixel = this.gc.calculateTextSize(tmpDisplay).x();
|
this.displayCursorPositionPixel = (int) this.text.calculateSize(tmpDisplay).x();
|
||||||
// Check if the data inside the display can be contain in the entry box
|
// Check if the data inside the display can be contain in the entry box
|
||||||
if (totalWidth < tmpUserSize) {
|
if (totalWidth < tmpUserSize) {
|
||||||
// all can be display :
|
// all can be display :
|
||||||
this.displayStartPosition = 0;
|
this.displayStartPosition = 0;
|
||||||
} else {
|
} else {
|
||||||
// check if the Cursor is visible at 10px nearest the border :
|
// check if the Cursor is visible at 10px nearest the border :
|
||||||
int tmp1 = this.displayCursorPositionPixel + this.displayStartPosition;
|
final int tmp1 = this.displayCursorPositionPixel + this.displayStartPosition;
|
||||||
Log.debug("cursorPos=" + this.displayCursorPositionPixel + "px maxSize=" + tmpUserSize + "px tmp1=" + tmp1);
|
Log.debug("cursorPos=" + this.displayCursorPositionPixel + "px maxSize=" + tmpUserSize + "px tmp1=" + tmp1);
|
||||||
if (tmp1 < 10) {
|
if (tmp1 < 10) {
|
||||||
// set the cursor on le left
|
// set the cursor on the left
|
||||||
this.displayStartPosition = Math.min(-this.displayCursorPositionPixel + 10, 0);
|
this.displayStartPosition = Math.min(-this.displayCursorPositionPixel + 10, 0);
|
||||||
} else if (tmp1 > tmpUserSize - 10) {
|
} else if (tmp1 > tmpUserSize - 10) {
|
||||||
// set the cursor of the Right
|
// set the cursor of the Right
|
||||||
|
@ -53,21 +53,25 @@ public class Label extends Widget {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void calculateMinMaxSize() {
|
public void calculateMinMaxSize() {
|
||||||
|
Log.verbose("calculateMinMaxSize !!! data = '{}'", this.value);
|
||||||
final Vector3f tmpMax = this.propertyMaxSize.getPixel();
|
final Vector3f tmpMax = this.propertyMaxSize.getPixel();
|
||||||
final Vector3f tmpMin = this.propertyMinSize.getPixel();
|
final Vector3f tmpMin = this.propertyMinSize.getPixel();
|
||||||
//EWOL_DEBUG("[" + getId() + "] {" + getObjectType() + "} tmpMax : " + tmpMax);
|
//EWOL_DEBUG("[" + getId() + "] {" + getObjectType() + "} tmpMax : " + tmpMax);
|
||||||
if (tmpMax.x() <= 999999) {
|
if (tmpMax.x() <= 999999) {
|
||||||
this.textCompose.setTextAlignment(0, tmpMax.x() - 4, AlignMode.LEFT);
|
this.textCompose.setTextAlignment(0, tmpMax.x() - 4, AlignMode.LEFT);
|
||||||
//EWOL_DEBUG("[" + getId() + "] {" + getObjectType() + "} force Alignment ");
|
//EWOL_DEBUG("[" + getId() + "] {" + getObjectType() + "} force Alignment ");
|
||||||
|
} else {
|
||||||
|
this.textCompose.setTextAlignment(0, 0, AlignMode.LEFT);
|
||||||
}
|
}
|
||||||
Vector3f minSize = this.textCompose.calculateSizeDecorated(this.value);
|
Vector3f minSize = this.textCompose.calculateSizeDecorated(this.value);
|
||||||
|
this.textCompose.flush();
|
||||||
minSize = minSize.add(2, 2, 0);
|
minSize = minSize.add(2, 2, 0);
|
||||||
//EWOL_DEBUG("[" + getId() + "] {" + getObjectType() + "} minSize : " + minSize);
|
//EWOL_DEBUG("[" + getId() + "] {" + getObjectType() + "} minSize : " + minSize);
|
||||||
|
|
||||||
this.minSize = new Vector3f(FMath.avg(tmpMin.x(), 4 + minSize.x(), tmpMax.x()), //
|
this.minSize = new Vector3f(FMath.avg(tmpMin.x(), 4 + minSize.x(), tmpMax.x()), //
|
||||||
FMath.avg(tmpMin.y(), 4 + minSize.y(), tmpMax.y()), //
|
FMath.avg(tmpMin.y(), 4 + minSize.y(), tmpMax.y()), //
|
||||||
10);
|
10);
|
||||||
Log.verbose("[{}] Result min size : {} < {} < {}", getId(), tmpMin, this.minSize, tmpMax);
|
Log.verbose("[{}] Result min size : {}", getId(), this.minSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getPropertyFontSize() {
|
public int getPropertyFontSize() {
|
||||||
@ -135,7 +139,8 @@ public class Label extends Widget {
|
|||||||
tmpTextOrigin = tmpTextOrigin.add(paddingSize, paddingSize, 0);
|
tmpTextOrigin = tmpTextOrigin.add(paddingSize, paddingSize, 0);
|
||||||
localSize = localSize.less(2 * paddingSize, 2 * paddingSize, 0);
|
localSize = localSize.less(2 * paddingSize, 2 * paddingSize, 0);
|
||||||
|
|
||||||
tmpTextOrigin = tmpTextOrigin.withY(tmpTextOrigin.y() + (this.minSize.y() - 2 * paddingSize) - minSize.y());
|
//tmpTextOrigin = tmpTextOrigin.withY(tmpTextOrigin.y() + (this.minSize.y() - 2 * paddingSize) - minSize.y());
|
||||||
|
tmpTextOrigin = tmpTextOrigin.withY(tmpTextOrigin.y() + this.minSize.y() / 2 - this.textCompose.getHeight());// - this.minSize.y() - paddingSize);
|
||||||
tmpTextOrigin = tmpTextOrigin.withX(tmpTextOrigin.x() - curentTextSize.x() * 0.5f);
|
tmpTextOrigin = tmpTextOrigin.withX(tmpTextOrigin.x() - curentTextSize.x() * 0.5f);
|
||||||
|
|
||||||
final Vector3f textPos = new Vector3f(tmpTextOrigin.x(), tmpTextOrigin.y(), 0);
|
final Vector3f textPos = new Vector3f(tmpTextOrigin.x(), tmpTextOrigin.y(), 0);
|
||||||
@ -153,9 +158,9 @@ public class Label extends Widget {
|
|||||||
this.textCompose.setDefaultColorBg(this.colorProperty.get(this.colorDefaultBgText));
|
this.textCompose.setDefaultColorBg(this.colorProperty.get(this.colorDefaultBgText));
|
||||||
}
|
}
|
||||||
this.textCompose.setPos(tmpTextOrigin);
|
this.textCompose.setPos(tmpTextOrigin);
|
||||||
Log.error("[{}] '{}' display at pos={}, size={}", getId(), this.value, tmpTextOrigin, this.size);
|
Log.verbose("[{}] '{}' display at pos={}, size={}", getId(), this.value, tmpTextOrigin, this.size);
|
||||||
this.textCompose.setTextAlignment(tmpTextOrigin.x(), tmpTextOrigin.x() + localSize.x(), AlignMode.LEFT);
|
this.textCompose.setTextAlignment(tmpTextOrigin.x(), tmpTextOrigin.x() + localSize.x(), AlignMode.LEFT);
|
||||||
this.textCompose.setClipping(drawClippingPos, drawClippingSize);
|
//this.textCompose.setClipping(drawClippingPos, drawClippingSize);
|
||||||
this.textCompose.printDecorated(this.value);
|
this.textCompose.printDecorated(this.value);
|
||||||
this.textCompose.flush();
|
this.textCompose.flush();
|
||||||
}
|
}
|
||||||
|
@ -47,9 +47,9 @@ public class Sizer extends ContainerN {
|
|||||||
Log.verbose("[" + getId() + "] update minimum size");
|
Log.verbose("[" + getId() + "] update minimum size");
|
||||||
this.subExpend = Vector3b.FALSE;
|
this.subExpend = Vector3b.FALSE;
|
||||||
this.minSize = this.propertyMinSize.getPixel();
|
this.minSize = this.propertyMinSize.getPixel();
|
||||||
Vector3f tmpBorderSize = this.propertyBorderSize.getPixel();
|
final Vector3f tmpBorderSize = this.propertyBorderSize.getPixel();
|
||||||
Log.verbose("[" + getId() + "] {" + getClass().getCanonicalName() + "} set min size : " + this.minSize);
|
Log.verbose("[" + getId() + "] {" + getClass().getCanonicalName() + "} set min size : " + this.minSize);
|
||||||
for (Widget it : this.subWidget) {
|
for (final Widget it : this.subWidget) {
|
||||||
if (it == null) {
|
if (it == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -60,7 +60,7 @@ public class Sizer extends ContainerN {
|
|||||||
if (it.canExpand().y()) {
|
if (it.canExpand().y()) {
|
||||||
this.subExpend = this.subExpend.withY(true);
|
this.subExpend = this.subExpend.withY(true);
|
||||||
}
|
}
|
||||||
Vector3f tmpSize = it.getCalculateMinSize();
|
final Vector3f tmpSize = it.getCalculateMinSize();
|
||||||
Log.verbose("[" + getId() + "] NewMinSize=" + tmpSize);
|
Log.verbose("[" + getId() + "] NewMinSize=" + tmpSize);
|
||||||
Log.verbose("[" + getId() + "] {" + getClass().getCanonicalName() + "} Get minSize=" + tmpSize);
|
Log.verbose("[" + getId() + "] {" + getClass().getCanonicalName() + "} Get minSize=" + tmpSize);
|
||||||
if (this.propertyMode == DisplayMode.modeVert) {
|
if (this.propertyMode == DisplayMode.modeVert) {
|
||||||
@ -76,7 +76,7 @@ public class Sizer extends ContainerN {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.minSize = this.minSize.add(tmpBorderSize.multiply(2));
|
this.minSize = this.minSize.add(tmpBorderSize.multiply(2));
|
||||||
//Log.error("[" + getId() + "] {" + getObjectType() + "} Result min size : " + this.minSize);
|
Log.verbose("[{}] Result min size : {}", getId(), this.minSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
@XmlManaged
|
@XmlManaged
|
||||||
@ -100,23 +100,23 @@ public class Sizer extends ContainerN {
|
|||||||
@Override
|
@Override
|
||||||
public void onChangeSize() {
|
public void onChangeSize() {
|
||||||
super.onChangeSize();
|
super.onChangeSize();
|
||||||
Vector3f tmpBorderSize = this.propertyBorderSize.getPixel();
|
final Vector3f tmpBorderSize = this.propertyBorderSize.getPixel();
|
||||||
Log.verbose("[" + getId() + "] update size : " + this.size + " nbElement : " + this.subWidget.size() + " borderSize=" + tmpBorderSize + " from border=" + this.propertyBorderSize);
|
Log.verbose("[" + getId() + "] update size : " + this.size + " nbElement : " + this.subWidget.size() + " borderSize=" + tmpBorderSize + " from border=" + this.propertyBorderSize);
|
||||||
Vector3f localWidgetSize = this.size.less(tmpBorderSize.multiply(2.0f));
|
final Vector3f localWidgetSize = this.size.less(tmpBorderSize.multiply(2.0f));
|
||||||
// -1- calculate min-size and expand requested:
|
// -1- calculate min-size and expand requested:
|
||||||
Vector3f minSize = Vector3f.ZERO;
|
Vector3f minSize = Vector3f.ZERO;
|
||||||
Vector3i nbWidgetExpand = Vector3i.ZERO;
|
Vector3i nbWidgetExpand = Vector3i.ZERO;
|
||||||
for (Widget it : this.subWidget) {
|
for (final Widget it : this.subWidget) {
|
||||||
if (it == null) {
|
if (it == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
Vector3f tmpSize = it.getCalculateMinSize();
|
final Vector3f tmpSize = it.getCalculateMinSize();
|
||||||
if (this.propertyMode == DisplayMode.modeVert) {
|
if (this.propertyMode == DisplayMode.modeVert) {
|
||||||
minSize = new Vector3f(Math.max(minSize.x(), tmpSize.x()), minSize.y() + tmpSize.y(), Math.max(minSize.z(), tmpSize.z()));
|
minSize = new Vector3f(Math.max(minSize.x(), tmpSize.x()), minSize.y() + tmpSize.y(), Math.max(minSize.z(), tmpSize.z()));
|
||||||
} else {
|
} else {
|
||||||
minSize = new Vector3f(minSize.x() + tmpSize.x(), Math.max(minSize.y(), tmpSize.y()), Math.max(minSize.z(), tmpSize.z()));
|
minSize = new Vector3f(minSize.x() + tmpSize.x(), Math.max(minSize.y(), tmpSize.y()), Math.max(minSize.z(), tmpSize.z()));
|
||||||
}
|
}
|
||||||
Vector3b expand = it.canExpand();
|
final Vector3b expand = it.canExpand();
|
||||||
nbWidgetExpand = nbWidgetExpand.add(expand.x() ? 1 : 0, expand.y() ? 1 : 0, 0);
|
nbWidgetExpand = nbWidgetExpand.add(expand.x() ? 1 : 0, expand.y() ? 1 : 0, 0);
|
||||||
}
|
}
|
||||||
// -2- Calculate the size to add at every elements...
|
// -2- Calculate the size to add at every elements...
|
||||||
@ -132,7 +132,7 @@ public class Sizer extends ContainerN {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// -3- Configure all at the min size ...
|
// -3- Configure all at the min size ...
|
||||||
for (Widget it : this.subWidget) {
|
for (final Widget it : this.subWidget) {
|
||||||
if (it == null) {
|
if (it == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -151,12 +151,12 @@ public class Sizer extends ContainerN {
|
|||||||
if (!this.subWidget.isEmpty()) {
|
if (!this.subWidget.isEmpty()) {
|
||||||
lastWidget = this.subWidget.get(this.subWidget.size() - 1);
|
lastWidget = this.subWidget.get(this.subWidget.size() - 1);
|
||||||
}
|
}
|
||||||
for (Widget it : this.subWidget) {
|
for (final Widget it : this.subWidget) {
|
||||||
if (it == null) {
|
if (it == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
Vector3f tmpSizeMin = it.getSize();
|
Vector3f tmpSizeMin = it.getSize();
|
||||||
Vector3f tmpSizeMax = it.getCalculateMaxSize();
|
final Vector3f tmpSizeMax = it.getCalculateMaxSize();
|
||||||
// Now update his size his size in X and the current 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 (this.propertyMode == DisplayMode.modeVert) {
|
||||||
if (it.canExpand().y() || (it == lastWidget && it.canExpandIfFree().y())) {
|
if (it.canExpand().y() || (it == lastWidget && it.canExpandIfFree().y())) {
|
||||||
@ -201,7 +201,7 @@ public class Sizer extends ContainerN {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// -5- Update the expand in the second size if vert ==> X and if hori ==> Y
|
// -5- Update the expand in the second size if vert ==> X and if hori ==> Y
|
||||||
for (Widget it : this.subWidget) {
|
for (final Widget it : this.subWidget) {
|
||||||
if (it == null) {
|
if (it == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -223,7 +223,7 @@ public class Sizer extends ContainerN {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// -6- Force size at the entire number:
|
// -6- Force size at the entire number:
|
||||||
for (Widget it : this.subWidget) {
|
for (final Widget it : this.subWidget) {
|
||||||
if (it == null) {
|
if (it == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -231,28 +231,28 @@ public class Sizer extends ContainerN {
|
|||||||
}
|
}
|
||||||
// -7- get under Size
|
// -7- get under Size
|
||||||
Vector3f underSize = Vector3f.ZERO;
|
Vector3f underSize = Vector3f.ZERO;
|
||||||
for (Widget it : this.subWidget) {
|
for (final Widget it : this.subWidget) {
|
||||||
if (it == null) {
|
if (it == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
Vector3f size = it.getSize();
|
final Vector3f size = it.getSize();
|
||||||
if (this.propertyMode == DisplayMode.modeVert) {
|
if (this.propertyMode == DisplayMode.modeVert) {
|
||||||
underSize = new Vector3f(Math.max(underSize.x(), size.x()), underSize.y() + size.y(), Math.max(underSize.z(), size.z()));
|
underSize = new Vector3f(Math.max(underSize.x(), size.x()), underSize.y() + size.y(), Math.max(underSize.z(), size.z()));
|
||||||
} else {
|
} else {
|
||||||
underSize = new Vector3f(underSize.x() + size.x(), Math.max(underSize.y(), size.y()), Math.max(underSize.z(), size.z()));
|
underSize = new Vector3f(underSize.x() + size.x(), Math.max(underSize.y(), size.y()), Math.max(underSize.z(), size.z()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Vector3f deltas = localWidgetSize.less(underSize);
|
final Vector3f deltas = localWidgetSize.less(underSize);
|
||||||
|
|
||||||
// -8- Calculate the local origin, depending of the gravity:
|
// -8- Calculate the local origin, depending of the gravity:
|
||||||
Vector3f tmpOrigin = this.origin.add(tmpBorderSize).add(this.propertyGravity.gravityGenerateDelta(deltas));
|
Vector3f tmpOrigin = this.origin.add(tmpBorderSize).add(this.propertyGravity.gravityGenerateDelta(deltas));
|
||||||
// -9- Set sub widget origin:
|
// -9- Set sub widget origin:
|
||||||
for (Widget it : this.subWidget) {
|
for (final Widget it : this.subWidget) {
|
||||||
if (it == null) {
|
if (it == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
Vector3f origin;
|
Vector3f origin;
|
||||||
Vector3f size = it.getSize();
|
final Vector3f size = it.getSize();
|
||||||
if (this.propertyMode == DisplayMode.modeVert) {
|
if (this.propertyMode == DisplayMode.modeVert) {
|
||||||
origin = Vector3f.clipInt(tmpOrigin.add(this.offset).add(this.propertyGravity.gravityGenerateDelta(new Vector3f(underSize.x() - size.x(), 0.0f, 0.0f))));
|
origin = Vector3f.clipInt(tmpOrigin.add(this.offset).add(this.propertyGravity.gravityGenerateDelta(new Vector3f(underSize.x() - size.x(), 0.0f, 0.0f))));
|
||||||
} else {
|
} else {
|
||||||
@ -266,7 +266,7 @@ public class Sizer extends ContainerN {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// -10- Update all subSize at every element:
|
// -10- Update all subSize at every element:
|
||||||
for (Widget it : this.subWidget) {
|
for (final Widget it : this.subWidget) {
|
||||||
if (it == null) {
|
if (it == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user