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