[DEV] some updates
This commit is contained in:
parent
163e2e17ea
commit
df65afb204
@ -18,20 +18,20 @@ import org.slf4j.LoggerFactory;
|
||||
|
||||
public class BasicWindows extends Windows {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(BasicWindows.class);
|
||||
|
||||
|
||||
private int index = -1;
|
||||
private final List<TestWidgetInterface> testedElement = new ArrayList<>();
|
||||
private Container container = null;
|
||||
private Label title = null;
|
||||
|
||||
|
||||
public static void staticRequestNext(final BasicWindows self) {
|
||||
self.requestNext();
|
||||
}
|
||||
|
||||
|
||||
public static void staticRequestPrevious(final BasicWindows self) {
|
||||
self.requestPrevious();
|
||||
}
|
||||
|
||||
|
||||
public void requestNext() {
|
||||
LOGGER.info("Request Next");
|
||||
this.index++;
|
||||
@ -40,7 +40,7 @@ public class BasicWindows extends Windows {
|
||||
}
|
||||
updateDisplay();
|
||||
}
|
||||
|
||||
|
||||
public void requestPrevious() {
|
||||
LOGGER.info("Request Previous");
|
||||
this.index--;
|
||||
@ -49,7 +49,7 @@ public class BasicWindows extends Windows {
|
||||
}
|
||||
updateDisplay();
|
||||
}
|
||||
|
||||
|
||||
public void updateDisplay() {
|
||||
final var test = this.testedElement.get(this.index);
|
||||
final var titlegenerated = "<b>[" + (this.index + 1) + "/" + this.testedElement.size() + "] " + test.getTitle()
|
||||
@ -58,14 +58,14 @@ public class BasicWindows extends Windows {
|
||||
setPropertyTitle(titlegenerated);
|
||||
this.container.setSubWidget(new ModelWidget(test));
|
||||
}
|
||||
|
||||
|
||||
public BasicWindows() {
|
||||
|
||||
|
||||
final var sizerMain = new Sizer(DisplayMode.VERTICAL);
|
||||
sizerMain.setPropertyExpand(Vector2b.TRUE);
|
||||
sizerMain.setPropertyFill(Vector2b.TRUE);
|
||||
setSubWidget(sizerMain);
|
||||
|
||||
|
||||
final var menu = new Sizer(DisplayMode.HORIZONTAL);
|
||||
menu.setPropertyExpand(Vector2b.TRUE_FALSE);
|
||||
menu.setPropertyExpandIfFree(Vector2b.TRUE_FALSE);
|
||||
@ -73,40 +73,40 @@ public class BasicWindows extends Windows {
|
||||
menu.setPropertyLockExpand(Vector2b.TRUE);
|
||||
menu.setPropertyMaxSize(new Dimension2f(new Vector2f(9999, 3), Distance.CENTIMETER));
|
||||
sizerMain.subWidgetAdd(menu);
|
||||
|
||||
|
||||
this.container = new Container();
|
||||
this.container.setPropertyExpand(Vector2b.TRUE);
|
||||
this.container.setPropertyFill(Vector2b.TRUE);
|
||||
sizerMain.subWidgetAdd(this.container);
|
||||
|
||||
|
||||
final var next = Button.createLabelButton("<< Previous");
|
||||
next.setPropertyMaxSize(new Dimension2f(new Vector2f(9999, 2), Distance.CENTIMETER));
|
||||
menu.subWidgetAdd(next);
|
||||
next.signalClick.connectAuto(this, BasicWindows::staticRequestNext);
|
||||
|
||||
|
||||
this.title = new Label("unknown");
|
||||
this.title.setPropertyFill(Vector2b.FALSE);
|
||||
this.title.setPropertyExpand(Vector2b.TRUE);
|
||||
menu.subWidgetAdd(this.title);
|
||||
|
||||
|
||||
final var previous = Button.createLabelButton("Next >>");
|
||||
previous.setPropertyMaxSize(new Dimension2f(new Vector2f(9999, 2), Distance.CENTIMETER));
|
||||
menu.subWidgetAdd(previous);
|
||||
previous.signalClick.connectAuto(this, BasicWindows::staticRequestPrevious);
|
||||
|
||||
|
||||
this.container.setPropertyExpand(Vector2b.TRUE);
|
||||
this.container.setPropertyFill(Vector2b.TRUE);
|
||||
this.container.setPropertyExpandIfFree(Vector2b.TRUE);
|
||||
|
||||
|
||||
this.testedElement.add(new TestWidgetSlider());
|
||||
this.testedElement.add(new TestWidgetEntry());
|
||||
this.testedElement.add(new TestWidgetBox());
|
||||
this.testedElement.add(new TestWidgetSlider());
|
||||
this.testedElement.add(new TestWidgetButton());
|
||||
this.testedElement.add(new TestWidgetButtonToggle());
|
||||
this.testedElement.add(new TestWidgetCheckBox());
|
||||
this.testedElement.add(new TestWidgetImage());
|
||||
this.testedElement.add(new TestWidgetLabel());
|
||||
requestNext();
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -8,23 +8,13 @@ package org.atriasoft.ewol.compositing;
|
||||
import org.atriasoft.egami.ImageByte;
|
||||
import org.atriasoft.egami.ImageByteRGBA;
|
||||
import org.atriasoft.egami.ToolImage;
|
||||
import org.atriasoft.esvg.CapMode;
|
||||
import org.atriasoft.esvg.Circle;
|
||||
import org.atriasoft.esvg.Ellipse;
|
||||
import org.atriasoft.esvg.EsvgDocument;
|
||||
import org.atriasoft.esvg.JoinMode;
|
||||
import org.atriasoft.esvg.Line;
|
||||
import org.atriasoft.esvg.PaintState;
|
||||
import org.atriasoft.esvg.Rectangle;
|
||||
import org.atriasoft.etk.BorderRadius;
|
||||
import org.atriasoft.etk.Color;
|
||||
import org.atriasoft.etk.Insets;
|
||||
import org.atriasoft.etk.Uri;
|
||||
import org.atriasoft.etk.math.Matrix4f;
|
||||
import org.atriasoft.etk.math.Vector2f;
|
||||
import org.atriasoft.etk.math.Vector2i;
|
||||
import org.atriasoft.etk.math.Vector3f;
|
||||
import org.atriasoft.etk.util.Pair;
|
||||
import org.atriasoft.gale.backend3d.OpenGL;
|
||||
import org.atriasoft.gale.backend3d.OpenGL.RenderMode;
|
||||
import org.atriasoft.gale.resource.ResourceProgram;
|
||||
@ -33,7 +23,7 @@ import org.atriasoft.gale.resource.ResourceVirtualArrayObject;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class CompositingSVG extends CompositingDraw {
|
||||
public class CompositingSVG extends Compositing {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(CompositingSVG.class);
|
||||
public static final int NB_VBO = 3;
|
||||
public static final int SIZE_AUTO = 0;
|
||||
@ -51,20 +41,20 @@ public class CompositingSVG extends CompositingDraw {
|
||||
private ResourceProgram oGLprogram = null; //!< pointer on the opengl display program
|
||||
private Vector3f position = Vector3f.ZERO; //!< The current position to draw
|
||||
private Vector2i requestSize = new Vector2i(2, 2);
|
||||
|
||||
|
||||
private ResourceTexture2 resource = null; //!< texture resources
|
||||
private ResourceVirtualArrayObject vbo = null;
|
||||
|
||||
|
||||
private Color[] vboDataColors = null;
|
||||
private Vector3f[] vboDataCoords = null;
|
||||
private Vector2f[] vboDataCoordsTex = null;
|
||||
|
||||
|
||||
public CompositingSVG() {
|
||||
this("""
|
||||
<svg width="10" height="10"></svg>
|
||||
""", CompositingSVG.SIZE_AUTO);
|
||||
}
|
||||
|
||||
|
||||
public CompositingSVG(final String data, final int size) {
|
||||
this.svgData = data;
|
||||
// Create the VBO:
|
||||
@ -78,7 +68,7 @@ public class CompositingSVG extends CompositingDraw {
|
||||
setSource(this.svgData, size);
|
||||
loadProgram();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* clear alll tre registered element in the current element
|
||||
*/
|
||||
@ -93,7 +83,7 @@ public class CompositingSVG extends CompositingDraw {
|
||||
this.color = Color.WHITE;
|
||||
this.angle = 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* draw All the registered text in the current element on openGL
|
||||
* @param disableDepthTest disable the Depth test for display
|
||||
@ -133,19 +123,16 @@ public class CompositingSVG extends CompositingDraw {
|
||||
this.vbo.unBindForRendering();
|
||||
this.oGLprogram.unUse();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void flush() {
|
||||
generate();
|
||||
if (this.vboDataCoords != null) {
|
||||
this.vbo.setPosition(this.vboDataCoords);
|
||||
this.vbo.setTextureCoordinate(this.vboDataCoordsTex);
|
||||
this.vbo.setColors(this.vboDataColors);
|
||||
this.vbo.setVertexCount(this.vboDataCoords.length);
|
||||
this.vbo.flush();
|
||||
}
|
||||
this.vbo.setPosition(this.vboDataCoords);
|
||||
this.vbo.setTextureCoordinate(this.vboDataCoordsTex);
|
||||
this.vbo.setColors(this.vboDataColors);
|
||||
this.vbo.setVertexCount(this.vboDataCoords.length);
|
||||
this.vbo.flush();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* get the current display position (sometime needed in the gui control)
|
||||
* @return the current position.
|
||||
@ -153,7 +140,7 @@ public class CompositingSVG extends CompositingDraw {
|
||||
public Vector3f getPos() {
|
||||
return this.position;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* get the source image registered size in the file (<0 when multiple size image)
|
||||
* @return tre image registered size
|
||||
@ -164,7 +151,7 @@ public class CompositingSVG extends CompositingDraw {
|
||||
}
|
||||
return this.resource.getUsableSize();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sometimes the user declare an image but not allocate the resources all the time, this is to know it ..
|
||||
* @return the validity of the resources.
|
||||
@ -172,7 +159,7 @@ public class CompositingSVG extends CompositingDraw {
|
||||
public boolean hasSources() {
|
||||
return this.resource != null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* load the openGL program and get all the ID needed
|
||||
*/
|
||||
@ -186,11 +173,11 @@ public class CompositingSVG extends CompositingDraw {
|
||||
this.oGLMatrixView = this.oGLprogram.getUniform("in_matrixView");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void print(final Vector2f size) {
|
||||
printPart(size, Vector2f.ZERO, Vector2f.ONE);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* add a compleate of the image to display with the requested size
|
||||
* @param size size of the output image
|
||||
@ -198,7 +185,7 @@ public class CompositingSVG extends CompositingDraw {
|
||||
public void print(final Vector2i size) {
|
||||
print(new Vector2f(size.x(), size.y()));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* add a part of the image to display with the requested size
|
||||
* @param size size of the output image
|
||||
@ -220,69 +207,69 @@ public class CompositingSVG extends CompositingDraw {
|
||||
this.vboDataColors = new Color[6];
|
||||
this.vboDataCoords = new Vector3f[6];
|
||||
this.vboDataCoordsTex = new Vector2f[6];
|
||||
|
||||
|
||||
if (this.angle == 0.0f) {
|
||||
Vector3f point = this.position;
|
||||
int indexElem = 0;
|
||||
|
||||
|
||||
Vector2f tex = new Vector2f(sourcePosStart.x(), sourcePosStop.y());
|
||||
this.vboDataCoords[indexElem] = point;
|
||||
this.vboDataCoordsTex[indexElem] = tex;
|
||||
this.vboDataColors[indexElem] = this.color;
|
||||
indexElem++;
|
||||
|
||||
|
||||
tex = new Vector2f(sourcePosStop.x(), sourcePosStop.y());
|
||||
point = new Vector3f(this.position.x() + size.x(), this.position.y(), 0);
|
||||
this.vboDataCoords[indexElem] = point;
|
||||
this.vboDataCoordsTex[indexElem] = tex;
|
||||
this.vboDataColors[indexElem] = this.color;
|
||||
indexElem++;
|
||||
|
||||
|
||||
tex = new Vector2f(sourcePosStop.x(), sourcePosStart.y());
|
||||
point = new Vector3f(this.position.x() + size.x(), this.position.y() + size.y(), 0);
|
||||
this.vboDataCoords[indexElem] = point;
|
||||
this.vboDataCoordsTex[indexElem] = tex;
|
||||
this.vboDataColors[indexElem] = this.color;
|
||||
indexElem++;
|
||||
|
||||
|
||||
this.vboDataCoords[indexElem] = point;
|
||||
this.vboDataCoordsTex[indexElem] = tex;
|
||||
this.vboDataColors[indexElem] = this.color;
|
||||
indexElem++;
|
||||
|
||||
|
||||
tex = new Vector2f(sourcePosStart.x(), sourcePosStart.y());
|
||||
point = new Vector3f(this.position.x(), this.position.y() + size.y(), 0);
|
||||
this.vboDataCoords[indexElem] = point;
|
||||
this.vboDataCoordsTex[indexElem] = tex;
|
||||
this.vboDataColors[indexElem] = this.color;
|
||||
indexElem++;
|
||||
|
||||
|
||||
tex = new Vector2f(sourcePosStart.x(), sourcePosStop.y());
|
||||
point = new Vector3f(this.position.x(), this.position.y(), 0);
|
||||
this.vboDataCoords[indexElem] = point;
|
||||
this.vboDataCoordsTex[indexElem] = tex;
|
||||
this.vboDataColors[indexElem] = this.color;
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
final Vector3f center = this.position.add(new Vector3f(size.x(), size.y(), 0)).divide(2.0f);
|
||||
|
||||
|
||||
final Vector3f limitedSize = new Vector3f(size.x() * 0.5f, size.y() * 0.5f, 0.0f);
|
||||
|
||||
|
||||
Vector3f point = Vector3f.ZERO;
|
||||
|
||||
|
||||
Vector2f tex = new Vector2f(sourcePosStart.x(), sourcePosStop.y());
|
||||
|
||||
|
||||
int indexElem = 0;
|
||||
|
||||
|
||||
point = new Vector3f(-limitedSize.x(), -limitedSize.y(), 0);
|
||||
point = point.rotateNew(new Vector3f(0, 0, 1), this.angle).add(center);
|
||||
this.vboDataCoords[indexElem] = point;
|
||||
this.vboDataCoordsTex[indexElem] = tex;
|
||||
this.vboDataColors[indexElem] = this.color;
|
||||
indexElem++;
|
||||
|
||||
|
||||
tex = new Vector2f(sourcePosStop.x(), sourcePosStop.y());
|
||||
point = new Vector3f(limitedSize.x(), -limitedSize.y(), 0);
|
||||
point = point.rotateNew(new Vector3f(0, 0, 1), this.angle).add(center);
|
||||
@ -290,7 +277,7 @@ public class CompositingSVG extends CompositingDraw {
|
||||
this.vboDataCoordsTex[indexElem] = tex;
|
||||
this.vboDataColors[indexElem] = this.color;
|
||||
indexElem++;
|
||||
|
||||
|
||||
tex = new Vector2f(sourcePosStop.x(), sourcePosStart.y());
|
||||
point = new Vector3f(limitedSize.x(), limitedSize.y(), 0);
|
||||
point = point.rotateNew(new Vector3f(0, 0, 1), this.angle).add(center);
|
||||
@ -298,12 +285,12 @@ public class CompositingSVG extends CompositingDraw {
|
||||
this.vboDataCoordsTex[indexElem] = tex;
|
||||
this.vboDataColors[indexElem] = this.color;
|
||||
indexElem++;
|
||||
|
||||
|
||||
this.vboDataCoords[indexElem] = point;
|
||||
this.vboDataCoordsTex[indexElem] = tex;
|
||||
this.vboDataColors[indexElem] = this.color;
|
||||
indexElem++;
|
||||
|
||||
|
||||
tex = new Vector2f(sourcePosStart.x(), sourcePosStart.y());
|
||||
point = new Vector3f(-limitedSize.x(), limitedSize.y(), 0);
|
||||
point = point.rotateNew(new Vector3f(0, 0, 1), this.angle).add(center);
|
||||
@ -311,16 +298,16 @@ public class CompositingSVG extends CompositingDraw {
|
||||
this.vboDataCoordsTex[indexElem] = tex;
|
||||
this.vboDataColors[indexElem] = this.color;
|
||||
indexElem++;
|
||||
|
||||
|
||||
tex = new Vector2f(sourcePosStart.x(), sourcePosStop.y());
|
||||
point = new Vector3f(-limitedSize.x(), -limitedSize.y(), 0);
|
||||
point = point.rotateNew(new Vector3f(0, 0, 1), this.angle).add(center);
|
||||
this.vboDataCoords[indexElem] = point;
|
||||
this.vboDataCoordsTex[indexElem] = tex;
|
||||
this.vboDataColors[indexElem] = this.color;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* set a unique rotation of this element (not set in the rotate Generic system)
|
||||
* @param angleRad Angle to set in radiant.
|
||||
@ -328,7 +315,7 @@ public class CompositingSVG extends CompositingDraw {
|
||||
public void setAngle(final float angleRad) {
|
||||
this.angle = angleRad;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* set the Color of the current foreground font
|
||||
* @param color Color to set on foreground (for next print)
|
||||
@ -336,15 +323,15 @@ public class CompositingSVG extends CompositingDraw {
|
||||
public void setColor(final Color color) {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
|
||||
public void setPos(final Vector2f pos) {
|
||||
setPos(new Vector3f(pos.x(), pos.y(), 0));
|
||||
}
|
||||
|
||||
|
||||
public void setPos(final Vector2i pos) {
|
||||
setPos(new Vector3f(pos.x(), pos.y(), 0));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* set position for the next text written
|
||||
* @param pos Position of the text (in 3D)
|
||||
@ -352,11 +339,11 @@ public class CompositingSVG extends CompositingDraw {
|
||||
public void setPos(final Vector3f pos) {
|
||||
this.position = pos;
|
||||
}
|
||||
|
||||
|
||||
public void setRelPos(final Vector2f pos) {
|
||||
setRelPos(new Vector3f(pos.x(), pos.y(), 0));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* set relative position for the next text written
|
||||
* @param pos offset apply of the text (in 3D)
|
||||
@ -364,7 +351,7 @@ public class CompositingSVG extends CompositingDraw {
|
||||
public void setRelPos(final Vector3f pos) {
|
||||
this.position = this.position.add(pos);
|
||||
}
|
||||
|
||||
|
||||
public void setSource(final ImageByteRGBA image) {
|
||||
clear();
|
||||
this.svgData = null;
|
||||
@ -372,11 +359,11 @@ public class CompositingSVG extends CompositingDraw {
|
||||
this.resource = new ResourceTexture2();
|
||||
this.resource.set(image);
|
||||
}
|
||||
|
||||
|
||||
public void setSource(final String data) {
|
||||
setSource(data, 32);
|
||||
}
|
||||
|
||||
|
||||
public void setSource(final String data, final int size) {
|
||||
setSource(data, new Vector2i(size, size));
|
||||
}
|
||||
@ -385,7 +372,7 @@ public class CompositingSVG extends CompositingDraw {
|
||||
// data
|
||||
// setSource
|
||||
// }
|
||||
|
||||
|
||||
public void setSource(final String data, final Vector2i size) {
|
||||
if (data == null) {
|
||||
LOGGER.error("try to set NULL data in svg");
|
||||
@ -413,153 +400,25 @@ public class CompositingSVG extends CompositingDraw {
|
||||
this.svgData = data;
|
||||
this.requestSize = size;
|
||||
}
|
||||
|
||||
|
||||
public void setSource(final EsvgDocument data, final Vector2i size) {
|
||||
if (this.svgData == null && this.svgDoc.equals(data) && this.requestSize.x() == size.x()
|
||||
&& this.requestSize.y() == size.y()) {
|
||||
// Nothing to do ...
|
||||
return;
|
||||
}
|
||||
this.svgData = null;
|
||||
clear();
|
||||
final ImageByte tmp = ToolImage.convertImageByte(data.renderImageFloatRGBA(size));
|
||||
if (tmp == null) {
|
||||
LOGGER.error("Can not load the Raw SVG ... ");
|
||||
return;
|
||||
}
|
||||
if (this.resource == null) {
|
||||
this.resource = new ResourceTexture2();
|
||||
}
|
||||
this.resource.set(tmp);
|
||||
this.svgDoc = data;
|
||||
this.requestSize = size;
|
||||
generate();
|
||||
}
|
||||
|
||||
protected void generate() {
|
||||
final Vector2i size = this.requestSize;
|
||||
if (this.svgDoc != null) {
|
||||
final ImageByte tmp = ToolImage.convertImageByte(this.svgDoc.renderImageFloatRGBA(size));
|
||||
if (tmp == null) {
|
||||
LOGGER.error("Can not load the Raw SVG ... ");
|
||||
return;
|
||||
}
|
||||
if (this.resource == null) {
|
||||
this.resource = new ResourceTexture2();
|
||||
}
|
||||
this.resource.set(tmp);
|
||||
}
|
||||
}
|
||||
|
||||
PaintState paint = new PaintState();
|
||||
|
||||
public void clearPaint() {
|
||||
this.paint.clear();
|
||||
}
|
||||
|
||||
public void createSize(final Vector2i size) {
|
||||
clear();
|
||||
this.paint.clear();
|
||||
if (this.svgDoc == null) {
|
||||
this.svgDoc = new EsvgDocument(size);
|
||||
}
|
||||
this.requestSize = size;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPaintFillColor(final Color color) {
|
||||
this.paint.fill = new Pair<>(color, "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPaintStrokeColor(final Color color) {
|
||||
this.paint.stroke = new Pair<>(color, "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPaintStrokeWidth(final float width) {
|
||||
this.paint.strokeWidth = width;
|
||||
}
|
||||
|
||||
public void setPaintLineJoin(final JoinMode lineJoin) {
|
||||
this.paint.lineJoin = lineJoin;
|
||||
}
|
||||
|
||||
public void setPaintLineCap(final CapMode lineCap) {
|
||||
this.paint.lineCap = lineCap;
|
||||
}
|
||||
|
||||
public void setPaintMiterLimit(final float miterLimit) {
|
||||
this.paint.miterLimit = miterLimit;
|
||||
}
|
||||
|
||||
public void setPaintOpacity(final float opacity) {
|
||||
this.paint.opacity = opacity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addLine(final Vector2f startPos, final Vector2f stopPos) {
|
||||
if (this.svgDoc == null) {
|
||||
this.svgDoc = new EsvgDocument();
|
||||
}
|
||||
this.svgDoc.addElement(new Line(startPos, stopPos, this.paint));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addRectangle(final Vector2f position, final Vector2f size) {
|
||||
if (this.svgDoc == null) {
|
||||
this.svgDoc = new EsvgDocument();
|
||||
}
|
||||
this.svgDoc.addElement(new Rectangle(position, size, this.paint));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addRectangle(final Vector2f position, final Vector2f size, final Vector2f roundedCorner) {
|
||||
if (this.svgDoc == null) {
|
||||
this.svgDoc = new EsvgDocument();
|
||||
}
|
||||
this.svgDoc.addElement(new Rectangle(position, size, roundedCorner, this.paint));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCircle(final Vector2f position, final float radius) {
|
||||
if (this.svgDoc == null) {
|
||||
this.svgDoc = new EsvgDocument();
|
||||
}
|
||||
this.svgDoc.addElement(new Circle(position, radius, this.paint));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addEllipse(final Vector2f center, final Vector2f radius) {
|
||||
if (this.svgDoc == null) {
|
||||
this.svgDoc = new EsvgDocument();
|
||||
}
|
||||
this.svgDoc.addElement(new Ellipse(center, radius, this.paint));
|
||||
}
|
||||
|
||||
public void setRectangleAsSource(final int sizeX, final int sizeY, final Color color) {
|
||||
createSize(new Vector2i(sizeX, sizeY)); // specific for SVG
|
||||
setPaintFillColor(color);
|
||||
addRectangle(Vector2f.ZERO, new Vector2f(sizeX, sizeY));
|
||||
flush();
|
||||
}
|
||||
|
||||
public void setRectangleBorderAsSource(
|
||||
final int sizeX,
|
||||
final int sizeY,
|
||||
final Color color,
|
||||
final int borderSize,
|
||||
final int borderRadius,
|
||||
final Color borderColor) {
|
||||
|
||||
final int paddingCompensateBorder = Math.round(borderSize * 0.5f);
|
||||
createSize(new Vector2i(sizeX, sizeY)); // specific for SVG
|
||||
setPaintFillColor(color);
|
||||
setPaintStrokeColor(borderColor);
|
||||
setPaintStrokeWidth(borderSize);
|
||||
addRectangle(new Vector2f(paddingCompensateBorder, paddingCompensateBorder), //
|
||||
new Vector2f(sizeX - 2 * paddingCompensateBorder, sizeY - 2 * paddingCompensateBorder), //
|
||||
new Vector2f(borderRadius, borderRadius));
|
||||
flush();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addRectangle(
|
||||
final Vector2f position,
|
||||
final Vector2f size,
|
||||
final Insets thickness,
|
||||
final BorderRadius radius) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -274,10 +274,15 @@ public class Box extends Container {
|
||||
|
||||
@Override
|
||||
public void onRegenerateDisplay() {
|
||||
super.onRegenerateDisplay();
|
||||
if (!needRedraw()) {
|
||||
return;
|
||||
}
|
||||
regenerateDisplay();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void regenerateDisplay() {
|
||||
super.regenerateDisplay();
|
||||
final Insets localMargin = this.propertyMargin.size();
|
||||
Vector2f renderSize = calculateSizeRendering();
|
||||
this.overPositionStart = calculateOriginRendering(renderSize);
|
||||
|
@ -1,293 +0,0 @@
|
||||
package org.atriasoft.ewol.widget;
|
||||
|
||||
import org.atriasoft.aknot.annotation.AknotAttribute;
|
||||
import org.atriasoft.aknot.annotation.AknotDescription;
|
||||
import org.atriasoft.aknot.annotation.AknotManaged;
|
||||
import org.atriasoft.aknot.annotation.AknotName;
|
||||
import org.atriasoft.etk.Color;
|
||||
import org.atriasoft.etk.Dimension1f;
|
||||
import org.atriasoft.etk.Dimension2f;
|
||||
import org.atriasoft.etk.math.Vector2f;
|
||||
import org.atriasoft.etk.math.Vector2i;
|
||||
import org.atriasoft.ewol.compositing.CompositingSVG;
|
||||
import org.atriasoft.ewol.event.EventTime;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class BoxSVG extends Container {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(BoxSVG.class);
|
||||
protected CompositingSVG vectorialDraw = new CompositingSVG();
|
||||
|
||||
public static class BoxParameter {
|
||||
public Float margin;
|
||||
public Float padding;
|
||||
public Float borderWidth;
|
||||
public Float borderRadius;
|
||||
public String borderColor;
|
||||
public String color;
|
||||
}
|
||||
|
||||
/**
|
||||
* Periodic call to update grapgic display
|
||||
* @param event Time generic event
|
||||
*/
|
||||
protected static void periodicCall(final BoxSVG self, final EventTime event) {
|
||||
LOGGER.trace("Periodic call on Entry(" + event + ")");
|
||||
self.markToRedraw();
|
||||
}
|
||||
|
||||
Vector2i startPosition = Vector2i.ZERO;
|
||||
Vector2i endPosition = Vector2i.ZERO;
|
||||
|
||||
public boolean isInside(final Vector2f value) {
|
||||
return value.x() > this.startPosition.x() //
|
||||
&& value.y() > this.startPosition.y() //
|
||||
&& value.x() < this.endPosition.x() //
|
||||
&& value.y() < this.endPosition.y();
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public BoxSVG() {}
|
||||
|
||||
/**
|
||||
* Constructor with his subWidget
|
||||
*/
|
||||
public BoxSVG(final Widget subWidget) {
|
||||
super(subWidget);
|
||||
}
|
||||
|
||||
protected Dimension1f propertyBorderWidth = Dimension1f.ZERO;
|
||||
|
||||
@AknotManaged
|
||||
@AknotAttribute
|
||||
@AknotName(value = "border-width")
|
||||
@AknotDescription(value = "Border of the box")
|
||||
public Dimension1f getPropertyBorderWidth() {
|
||||
return this.propertyBorderWidth;
|
||||
}
|
||||
|
||||
public void setPropertyBorderWidth(final Dimension1f propertyBorder) {
|
||||
if (this.propertyBorderWidth.equals(propertyBorder)) {
|
||||
return;
|
||||
}
|
||||
this.propertyBorderWidth = propertyBorder;
|
||||
markToRedraw();
|
||||
requestUpdateSize();
|
||||
}
|
||||
|
||||
protected Dimension1f propertyBorderRadius = new Dimension1f(0);
|
||||
|
||||
@AknotManaged
|
||||
@AknotAttribute
|
||||
@AknotName(value = "border-radius")
|
||||
@AknotDescription(value = "Border radius of the box")
|
||||
public Dimension1f getPropertyBorderRadius() {
|
||||
return this.propertyBorderRadius;
|
||||
}
|
||||
|
||||
public void setPropertyBorderRadius(final Dimension1f propertyBorderRadius) {
|
||||
if (this.propertyBorderRadius.equals(propertyBorderRadius)) {
|
||||
return;
|
||||
}
|
||||
this.propertyBorderRadius = propertyBorderRadius;
|
||||
markToRedraw();
|
||||
requestUpdateSize();
|
||||
}
|
||||
|
||||
protected Color propertyBorderColor = Color.NONE;
|
||||
|
||||
@AknotManaged
|
||||
@AknotAttribute
|
||||
@AknotName(value = "border-color")
|
||||
@AknotDescription(value = "Border color of the box")
|
||||
public Color getPropertyBorderColor() {
|
||||
return this.propertyBorderColor;
|
||||
}
|
||||
|
||||
public void setPropertyBorderColor(final Color propertyBorderColor) {
|
||||
if (this.propertyBorderColor.equals(propertyBorderColor)) {
|
||||
return;
|
||||
}
|
||||
this.propertyBorderColor = propertyBorderColor;
|
||||
markToRedraw();
|
||||
requestUpdateSize();
|
||||
}
|
||||
|
||||
protected Color propertyColor = Color.NONE;
|
||||
|
||||
@AknotManaged
|
||||
@AknotAttribute
|
||||
@AknotName(value = "color")
|
||||
@AknotDescription(value = "Border color of the box")
|
||||
public Color getPropertyColor() {
|
||||
return this.propertyColor;
|
||||
}
|
||||
|
||||
public void setPropertyColor(final Color propertyColor) {
|
||||
if (this.propertyColor.equals(propertyColor)) {
|
||||
return;
|
||||
}
|
||||
this.propertyColor = propertyColor;
|
||||
markToRedraw();
|
||||
requestUpdateSize();
|
||||
}
|
||||
|
||||
protected Dimension2f propertyMargin = Dimension2f.ZERO;
|
||||
|
||||
@AknotManaged
|
||||
@AknotAttribute
|
||||
@AknotName(value = "margin")
|
||||
@AknotDescription(value = "margin of the box")
|
||||
public Dimension2f getPropertyMargin() {
|
||||
return this.propertyMargin;
|
||||
}
|
||||
|
||||
public void setPropertyMargin(final Dimension2f propertyMargin) {
|
||||
if (this.propertyMargin.equals(propertyMargin)) {
|
||||
return;
|
||||
}
|
||||
this.propertyMargin = propertyMargin;
|
||||
markToRedraw();
|
||||
requestUpdateSize();
|
||||
}
|
||||
|
||||
protected Dimension2f propertyPadding = Dimension2f.ZERO;
|
||||
|
||||
@AknotManaged
|
||||
@AknotAttribute
|
||||
@AknotName(value = "padding")
|
||||
@AknotDescription(value = "Padding of the box")
|
||||
public Dimension2f getPropertyPadding() {
|
||||
return this.propertyPadding;
|
||||
}
|
||||
|
||||
public void setPropertyPadding(final Dimension2f propertyPadding) {
|
||||
if (this.propertyPadding.equals(propertyPadding)) {
|
||||
return;
|
||||
}
|
||||
this.propertyPadding = propertyPadding;
|
||||
markToRedraw();
|
||||
requestUpdateSize();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void calculateMinMaxSize() {
|
||||
super.calculateMinMaxSize();
|
||||
final Vector2f childMinSize = new Vector2f(this.minSize.x(), this.minSize.y());
|
||||
|
||||
LOGGER.debug("calculate min size: border=" + this.propertyBorderWidth);
|
||||
final Vector2f borderSize = new Vector2f(this.propertyBorderWidth.size() * 2.0f,
|
||||
this.propertyBorderWidth.size() * 2.0f);
|
||||
final Vector2f padding = this.propertyPadding.size().multiply(2);
|
||||
final Vector2f margin = this.propertyMargin.size().multiply(2);
|
||||
final Vector2f calculatedBoxMinSize = childMinSize.add(margin).add(padding).add(borderSize);
|
||||
|
||||
this.minSize = calculatedBoxMinSize;
|
||||
this.maxSize = Vector2f.max(this.minSize, this.propertyMaxSize.size());
|
||||
markToRedraw();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChangeSize() {
|
||||
markToRedraw();
|
||||
if (this.propertyHide) {
|
||||
return;
|
||||
}
|
||||
if (this.subWidget == null) {
|
||||
return;
|
||||
}
|
||||
final Vector2f localPadding = this.propertyPadding.size();
|
||||
final Vector2f localMargin = this.propertyMargin.size();
|
||||
final float localBorderSize = this.propertyBorderWidth.size();
|
||||
final Vector2f offsetSubWidget = localPadding.add(localMargin).add(localBorderSize);
|
||||
|
||||
Vector2f subWidgetSize = this.subWidget.getCalculateMinSize();
|
||||
if (this.subWidget.canExpand().x() && this.propertyFill.x()) {
|
||||
subWidgetSize = subWidgetSize.withX(this.size.x());
|
||||
} else {
|
||||
subWidgetSize = subWidgetSize.withX(this.minSize.x());
|
||||
}
|
||||
if (this.subWidget.canExpand().y() && this.propertyFill.y()) {
|
||||
subWidgetSize = subWidgetSize.withY(this.size.y());
|
||||
} else {
|
||||
subWidgetSize = subWidgetSize.withY(this.minSize.y());
|
||||
}
|
||||
subWidgetSize = subWidgetSize.less(offsetSubWidget.multiply(2));
|
||||
subWidgetSize = subWidgetSize.clipInteger();
|
||||
|
||||
final Vector2f freeSizeWithoutWidget = this.size.less(offsetSubWidget.multiply(2)).less(subWidgetSize);
|
||||
Vector2f subWidgetOrigin = this.origin.add(this.propertyGravity.gravityGenerateDelta(freeSizeWithoutWidget));
|
||||
subWidgetOrigin = subWidgetOrigin.add(offsetSubWidget);
|
||||
subWidgetOrigin = subWidgetOrigin.clipInteger();
|
||||
this.subWidget.setOrigin(subWidgetOrigin);
|
||||
this.subWidget.setSize(subWidgetSize);
|
||||
this.subWidget.onChangeSize();
|
||||
}
|
||||
|
||||
protected Vector2i renderOrigin;
|
||||
protected Vector2i renderSize;
|
||||
|
||||
private Vector2f calculateOriginRendering(final Vector2f renderSize) {
|
||||
return this.propertyGravity.gravityGenerateDelta(this.size.less(renderSize));
|
||||
}
|
||||
|
||||
private Vector2f calculateSizeRendering() {
|
||||
Vector2f tmpRenderSize = this.minSize;
|
||||
if (this.propertyFill.x()) {
|
||||
tmpRenderSize = tmpRenderSize.withX(this.size.x());
|
||||
}
|
||||
if (this.propertyFill.y()) {
|
||||
tmpRenderSize = tmpRenderSize.withY(this.size.y());
|
||||
}
|
||||
return tmpRenderSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRegenerateDisplay() {
|
||||
super.onRegenerateDisplay();
|
||||
if (!needRedraw()) {
|
||||
return;
|
||||
}
|
||||
final Vector2f localMargin = this.propertyMargin.size();
|
||||
|
||||
Vector2f tmpRenderSize = calculateSizeRendering();
|
||||
Vector2f tmpRenderOrigin = calculateOriginRendering(tmpRenderSize);
|
||||
|
||||
tmpRenderOrigin = tmpRenderOrigin.add(localMargin);
|
||||
tmpRenderSize = tmpRenderSize.less(localMargin.multiply(2));
|
||||
// not sure this is needed...
|
||||
tmpRenderSize = tmpRenderSize.clipInteger();
|
||||
tmpRenderOrigin = tmpRenderOrigin.clipInteger();
|
||||
|
||||
this.renderOrigin = new Vector2i((int) tmpRenderOrigin.x(), (int) tmpRenderOrigin.y());
|
||||
this.renderSize = new Vector2i((int) tmpRenderSize.x(), (int) tmpRenderSize.y());
|
||||
//System.out.println("renderSize: " + this.renderSize);
|
||||
// remove data of the previous composition :
|
||||
this.vectorialDraw.clear();
|
||||
final int borderSize = (int) this.propertyBorderWidth.size();
|
||||
final int paddingCompensateBorder = Math.round(borderSize * 0.5f);
|
||||
if (borderSize > 0.0f) {
|
||||
this.vectorialDraw.setRectangleBorderAsSource(this.renderSize.x(), this.renderSize.y(), this.propertyColor,
|
||||
borderSize, (int) this.propertyBorderRadius.size(), this.propertyBorderColor);
|
||||
} else {
|
||||
this.vectorialDraw.setRectangleAsSource(this.renderSize.x(), this.renderSize.y(), this.propertyColor);
|
||||
}
|
||||
this.vectorialDraw.setPos(this.renderOrigin);
|
||||
// For events:
|
||||
this.startPosition = this.renderOrigin;
|
||||
this.endPosition = this.renderOrigin.add(this.renderSize);
|
||||
this.vectorialDraw.print(this.renderSize);
|
||||
this.vectorialDraw.flush();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDraw() {
|
||||
if (this.vectorialDraw != null) {
|
||||
this.vectorialDraw.draw(true);
|
||||
}
|
||||
super.onDraw();
|
||||
}
|
||||
|
||||
}
|
@ -32,11 +32,11 @@ import org.slf4j.LoggerFactory;
|
||||
*/
|
||||
public class Composer extends Container {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(Composer.class);
|
||||
|
||||
|
||||
public static Widget composerGenerateFile(final Uri data) {
|
||||
return composerGenerateFile(data, 0);
|
||||
}
|
||||
|
||||
|
||||
public static Widget composerGenerateFile(final Uri uri, final long id) {
|
||||
final byte[] elemData = Uri.getAllData(uri);
|
||||
if (elemData == null) {
|
||||
@ -50,11 +50,11 @@ public class Composer extends Container {
|
||||
}
|
||||
return tmp;
|
||||
}
|
||||
|
||||
|
||||
public static Widget composerGenerateString(final String data) {
|
||||
return composerGenerateString(data, 0);
|
||||
}
|
||||
|
||||
|
||||
public static Widget composerGenerateString(String data, final long id) {
|
||||
boolean requestComposer = true;
|
||||
if (!data.startsWith("<Composer>")) {
|
||||
@ -78,19 +78,19 @@ public class Composer extends Container {
|
||||
}
|
||||
return result.getSubWidget();
|
||||
}
|
||||
|
||||
|
||||
protected boolean propertyRemoveIfUnderRemove; //!< Remove the composer if sub element request a remove
|
||||
|
||||
|
||||
protected Uri propertySubFile; //!< If loading a sub-file, we must do it here ==> permit to configure it in the xml and not have wrong display
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public Composer() {
|
||||
// nothing to do...
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void calculateMinMaxSize() {
|
||||
if (this.subWidget != null) {
|
||||
@ -99,44 +99,44 @@ public class Composer extends Container {
|
||||
}
|
||||
super.calculateMinMaxSize();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void calculateSize() {
|
||||
|
||||
|
||||
if (this.subWidget != null) {
|
||||
this.subWidget.calculateSize();
|
||||
return;
|
||||
}
|
||||
super.calculateSize();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Vector2b canExpand() {
|
||||
|
||||
|
||||
if (this.subWidget != null) {
|
||||
return this.subWidget.canExpand();
|
||||
}
|
||||
return super.canExpand();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Vector2b canExpandIfFree() {
|
||||
|
||||
|
||||
if (this.subWidget != null) {
|
||||
return this.subWidget.canExpandIfFree();
|
||||
}
|
||||
return super.canExpandIfFree();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Vector2b canFill() {
|
||||
|
||||
|
||||
if (this.subWidget != null) {
|
||||
return this.subWidget.canFill();
|
||||
}
|
||||
return super.canFill();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
void changeZoom(final float range) {
|
||||
if (this.subWidget != null) {
|
||||
@ -145,7 +145,7 @@ public class Composer extends Container {
|
||||
}
|
||||
super.changeZoom(range);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void checkMaxSize() {
|
||||
if (this.subWidget != null) {
|
||||
@ -154,71 +154,71 @@ public class Composer extends Container {
|
||||
}
|
||||
super.checkMaxSize();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void checkMinSize() {
|
||||
|
||||
|
||||
if (this.subWidget != null) {
|
||||
this.subWidget.checkMinSize();
|
||||
return;
|
||||
}
|
||||
super.checkMinSize();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Vector2f getCalculateMaxSize() {
|
||||
|
||||
|
||||
if (this.subWidget != null) {
|
||||
return this.subWidget.getCalculateMaxSize();
|
||||
}
|
||||
return super.getCalculateMaxSize();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Vector2f getCalculateMinSize() {
|
||||
|
||||
|
||||
if (this.subWidget != null) {
|
||||
return this.subWidget.getCalculateMinSize();
|
||||
}
|
||||
return super.getCalculateMinSize();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Cursor getCursor() {
|
||||
|
||||
|
||||
if (this.subWidget != null) {
|
||||
return this.subWidget.getCursor();
|
||||
}
|
||||
return super.getCursor();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean getGrabStatus() {
|
||||
|
||||
|
||||
if (this.subWidget != null) {
|
||||
return this.subWidget.getGrabStatus();
|
||||
}
|
||||
return super.getGrabStatus();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean getKeyboardRepeat() {
|
||||
|
||||
|
||||
if (this.subWidget != null) {
|
||||
return this.subWidget.getKeyboardRepeat();
|
||||
}
|
||||
return super.getKeyboardRepeat();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getMouseLimit() {
|
||||
|
||||
|
||||
if (this.subWidget != null) {
|
||||
return this.subWidget.getMouseLimit();
|
||||
}
|
||||
return super.getMouseLimit();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
Vector2f getOffset() {
|
||||
if (this.subWidget != null) {
|
||||
@ -226,7 +226,7 @@ public class Composer extends Container {
|
||||
}
|
||||
return super.getOffset();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Vector2f getOrigin() {
|
||||
if (this.subWidget != null) {
|
||||
@ -234,79 +234,79 @@ public class Composer extends Container {
|
||||
}
|
||||
return super.getOrigin();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean getPropertyCanFocus() {
|
||||
|
||||
|
||||
if (this.subWidget != null) {
|
||||
return this.subWidget.getPropertyCanFocus();
|
||||
}
|
||||
return super.getPropertyCanFocus();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Vector2b getPropertyExpand() {
|
||||
|
||||
|
||||
if (this.subWidget != null) {
|
||||
return this.subWidget.getPropertyExpand();
|
||||
}
|
||||
return super.getPropertyExpand();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Vector2b getPropertyExpandIfFree() {
|
||||
|
||||
|
||||
if (this.subWidget != null) {
|
||||
return this.subWidget.getPropertyExpandIfFree();
|
||||
}
|
||||
return super.getPropertyExpandIfFree();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Vector2b getPropertyFill() {
|
||||
|
||||
|
||||
if (this.subWidget != null) {
|
||||
return this.subWidget.getPropertyFill();
|
||||
}
|
||||
return super.getPropertyFill();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Gravity getPropertyGravity() {
|
||||
|
||||
|
||||
if (this.subWidget != null) {
|
||||
return this.subWidget.getPropertyGravity();
|
||||
}
|
||||
return super.getPropertyGravity();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean getPropertyHide() {
|
||||
|
||||
|
||||
if (this.subWidget != null) {
|
||||
return this.subWidget.getPropertyHide();
|
||||
}
|
||||
return super.getPropertyHide();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Dimension2f getPropertyMaxSize() {
|
||||
|
||||
|
||||
if (this.subWidget != null) {
|
||||
return this.subWidget.getPropertyMaxSize();
|
||||
}
|
||||
return super.getPropertyMaxSize();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Dimension2f getPropertyMinSize() {
|
||||
|
||||
|
||||
if (this.subWidget != null) {
|
||||
return this.subWidget.getPropertyMinSize();
|
||||
}
|
||||
return super.getPropertyMinSize();
|
||||
}
|
||||
|
||||
|
||||
@AknotManaged
|
||||
@AknotAttribute
|
||||
@AknotName(value = "sub-file")
|
||||
@ -314,16 +314,16 @@ public class Composer extends Container {
|
||||
public Uri getPropertySubFile() {
|
||||
return this.propertySubFile;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Vector2f getSize() {
|
||||
|
||||
|
||||
if (this.subWidget != null) {
|
||||
return this.subWidget.getSize();
|
||||
}
|
||||
return super.getSize();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public EwolObject getSubObjectNamed(final String objectName) {
|
||||
if (this.subWidget != null) {
|
||||
@ -331,7 +331,7 @@ public class Composer extends Container {
|
||||
}
|
||||
return super.getSubObjectNamed(objectName);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public float getZoom() {
|
||||
if (this.subWidget != null) {
|
||||
@ -339,7 +339,7 @@ public class Composer extends Container {
|
||||
}
|
||||
return super.getZoom();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void grabCursor() {
|
||||
if (this.subWidget != null) {
|
||||
@ -348,7 +348,7 @@ public class Composer extends Container {
|
||||
}
|
||||
super.grabCursor();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isFocused() {
|
||||
if (this.subWidget != null) {
|
||||
@ -356,7 +356,7 @@ public class Composer extends Container {
|
||||
}
|
||||
return super.isFocused();
|
||||
}
|
||||
|
||||
|
||||
@AknotManaged
|
||||
@AknotAttribute
|
||||
@AknotName(value = "remove-if-under-remove")
|
||||
@ -364,7 +364,7 @@ public class Composer extends Container {
|
||||
public boolean isPropertyRemoveIfUnderRemove() {
|
||||
return this.propertyRemoveIfUnderRemove;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void keepFocus() {
|
||||
if (this.subWidget != null) {
|
||||
@ -373,7 +373,7 @@ public class Composer extends Container {
|
||||
}
|
||||
super.keepFocus();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* load a composition with a file
|
||||
* @param _uri Name of the file
|
||||
@ -396,7 +396,7 @@ public class Composer extends Container {
|
||||
// T O D O: Change this with a throw.a..a
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* load a composition with a file
|
||||
* @param composerXmlString xml to parse directly
|
||||
@ -419,17 +419,17 @@ public class Composer extends Container {
|
||||
// T O D O: Change this with a throw.a..a
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void markToRedraw() {
|
||||
|
||||
|
||||
if (this.subWidget != null) {
|
||||
this.subWidget.calculateMinMaxSize();
|
||||
return;
|
||||
}
|
||||
super.markToRedraw();
|
||||
}
|
||||
|
||||
|
||||
protected void onChangePropertySubFile() {
|
||||
LOGGER.info("Load compositing form external file : " + this.propertySubFile);
|
||||
if (this.propertySubFile.isEmpty()) {
|
||||
@ -441,7 +441,7 @@ public class Composer extends Container {
|
||||
LOGGER.error("Can not load Player GUI from file ... " + this.propertySubFile);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onChangeSize() {
|
||||
if (this.subWidget != null) {
|
||||
@ -450,7 +450,7 @@ public class Composer extends Container {
|
||||
}
|
||||
super.onChangeSize();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onEventClipboard(final ClipboardList clipboardID) {
|
||||
if (this.subWidget != null) {
|
||||
@ -459,7 +459,7 @@ public class Composer extends Container {
|
||||
}
|
||||
super.onEventClipboard(clipboardID);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onEventShortCut(
|
||||
final KeySpecial special,
|
||||
@ -471,7 +471,7 @@ public class Composer extends Container {
|
||||
}
|
||||
return super.onEventShortCut(special, unicodeValue, kbMove, isDown);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onRegenerateDisplay() {
|
||||
if (this.subWidget != null) {
|
||||
@ -480,7 +480,7 @@ public class Composer extends Container {
|
||||
}
|
||||
super.onRegenerateDisplay();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Vector2f relativePosition(final Vector2f pos) {
|
||||
if (this.subWidget != null) {
|
||||
@ -488,7 +488,7 @@ public class Composer extends Container {
|
||||
}
|
||||
return super.relativePosition(pos);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void requestDestroyFromChild(final EwolObject child) {
|
||||
super.requestDestroyFromChild(child);
|
||||
@ -497,7 +497,7 @@ public class Composer extends Container {
|
||||
autoDestroy();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void requestUpdateSize() {
|
||||
if (this.subWidget != null) {
|
||||
@ -506,7 +506,7 @@ public class Composer extends Container {
|
||||
}
|
||||
super.requestUpdateSize();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean rmFocus() {
|
||||
if (this.subWidget != null) {
|
||||
@ -514,7 +514,7 @@ public class Composer extends Container {
|
||||
}
|
||||
return super.rmFocus();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setCursor(final Cursor newCursor) {
|
||||
if (this.subWidget != null) {
|
||||
@ -523,7 +523,7 @@ public class Composer extends Container {
|
||||
}
|
||||
super.setCursor(newCursor);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean setFocus() {
|
||||
if (this.subWidget != null) {
|
||||
@ -531,7 +531,7 @@ public class Composer extends Container {
|
||||
}
|
||||
return super.setFocus();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setMouseLimit(final int numberState) {
|
||||
if (this.subWidget != null) {
|
||||
@ -540,7 +540,7 @@ public class Composer extends Container {
|
||||
}
|
||||
super.setMouseLimit(numberState);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setNoMaxSize() {
|
||||
if (this.subWidget != null) {
|
||||
@ -549,7 +549,7 @@ public class Composer extends Container {
|
||||
}
|
||||
super.setNoMaxSize();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setNoMinSize() {
|
||||
if (this.subWidget != null) {
|
||||
@ -558,7 +558,7 @@ public class Composer extends Container {
|
||||
}
|
||||
super.setNoMinSize();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setOffset(final Vector2f newVal) {
|
||||
if (this.subWidget != null) {
|
||||
@ -567,7 +567,7 @@ public class Composer extends Container {
|
||||
}
|
||||
super.setOffset(newVal);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setOrigin(final Vector2f pos) {
|
||||
if (this.subWidget != null) {
|
||||
@ -576,7 +576,7 @@ public class Composer extends Container {
|
||||
}
|
||||
super.setOrigin(pos);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setPropertyCanFocus(final boolean canFocus) {
|
||||
if (this.subWidget != null) {
|
||||
@ -585,7 +585,7 @@ public class Composer extends Container {
|
||||
}
|
||||
super.setPropertyCanFocus(canFocus);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setPropertyExpand(final Vector2b value) {
|
||||
if (this.subWidget != null) {
|
||||
@ -594,7 +594,7 @@ public class Composer extends Container {
|
||||
}
|
||||
super.setPropertyExpand(value);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setPropertyExpandIfFree(final Vector2b value) {
|
||||
if (this.subWidget != null) {
|
||||
@ -603,7 +603,7 @@ public class Composer extends Container {
|
||||
}
|
||||
super.setPropertyExpandIfFree(value);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setPropertyFill(final Vector2b value) {
|
||||
if (this.subWidget != null) {
|
||||
@ -612,7 +612,7 @@ public class Composer extends Container {
|
||||
}
|
||||
super.setPropertyFill(value);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setPropertyGravity(final Gravity gravity) {
|
||||
if (this.subWidget != null) {
|
||||
@ -621,7 +621,7 @@ public class Composer extends Container {
|
||||
}
|
||||
super.setPropertyGravity(gravity);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setPropertyHide(final boolean value) {
|
||||
if (this.subWidget != null) {
|
||||
@ -630,7 +630,7 @@ public class Composer extends Container {
|
||||
}
|
||||
super.setPropertyHide(value);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setPropertyMaxSize(final Dimension2f value) {
|
||||
if (this.subWidget != null) {
|
||||
@ -639,7 +639,7 @@ public class Composer extends Container {
|
||||
}
|
||||
super.setPropertyMaxSize(value);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setPropertyMinSize(final Dimension2f value) {
|
||||
if (this.subWidget != null) {
|
||||
@ -648,14 +648,14 @@ public class Composer extends Container {
|
||||
}
|
||||
super.setPropertyMinSize(value);
|
||||
}
|
||||
|
||||
|
||||
public void setPropertyRemoveIfUnderRemove(final boolean propertyRemoveIfUnderRemove) {
|
||||
if (this.propertyRemoveIfUnderRemove == propertyRemoveIfUnderRemove) {
|
||||
return;
|
||||
}
|
||||
this.propertyRemoveIfUnderRemove = propertyRemoveIfUnderRemove;
|
||||
}
|
||||
|
||||
|
||||
public void setPropertySubFile(final Uri propertySubFile) {
|
||||
if (this.propertySubFile.equals(propertySubFile)) {
|
||||
return;
|
||||
@ -663,7 +663,7 @@ public class Composer extends Container {
|
||||
this.propertySubFile = propertySubFile;
|
||||
onChangePropertySubFile();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setSize(final Vector2f value) {
|
||||
if (this.subWidget != null) {
|
||||
@ -672,7 +672,7 @@ public class Composer extends Container {
|
||||
}
|
||||
super.setSize(value);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setZoom(final float newVal) {
|
||||
if (this.subWidget != null) {
|
||||
@ -681,7 +681,7 @@ public class Composer extends Container {
|
||||
}
|
||||
super.setZoom(newVal);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void systemDraw(final DrawProperty displayProp) {
|
||||
if (this.subWidget != null) {
|
||||
@ -690,7 +690,7 @@ public class Composer extends Container {
|
||||
}
|
||||
super.systemDraw(displayProp);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void unGrabCursor() {
|
||||
if (this.subWidget != null) {
|
||||
@ -699,5 +699,5 @@ public class Composer extends Container {
|
||||
}
|
||||
super.unGrabCursor();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -158,11 +158,15 @@ public class Container extends Widget {
|
||||
|
||||
@Override
|
||||
public void onRegenerateDisplay() {
|
||||
regenerateDisplay();
|
||||
}
|
||||
|
||||
public void regenerateDisplay() {
|
||||
if (this.subWidget != null) {
|
||||
this.subWidget.systemRegenerateDisplay();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void requestDestroyFromChild(final EwolObject child) {
|
||||
if (this.subWidget != child) {
|
||||
|
@ -160,6 +160,10 @@ public class ContainerN extends Widget {
|
||||
|
||||
@Override
|
||||
public void onRegenerateDisplay() {
|
||||
regenerateDisplay();
|
||||
}
|
||||
|
||||
public void regenerateDisplay() {
|
||||
for (final Widget it : this.subWidget) {
|
||||
if (it != null) {
|
||||
it.systemRegenerateDisplay();
|
||||
|
@ -23,7 +23,7 @@ public class ContainerToggle extends Widget {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(ContainerToggle.class);
|
||||
protected Widget[] subWidget = new Widget[2];
|
||||
int idWidgetDisplayed = 0; //!< current widget displayed
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
@ -31,7 +31,7 @@ public class ContainerToggle extends Widget {
|
||||
this.subWidget[0] = null;
|
||||
this.subWidget[1] = null;
|
||||
}
|
||||
|
||||
|
||||
void calculateMinMaxSizePadded(final Padding padding) {
|
||||
// call main class
|
||||
this.minSize = Vector2f.ZERO;
|
||||
@ -50,7 +50,7 @@ public class ContainerToggle extends Widget {
|
||||
//markToRedraw();
|
||||
LOGGER.trace("[{}] Result min size : {}", getId(), this.minSize);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void drawWidgetTree(int level) {
|
||||
super.drawWidgetTree(level);
|
||||
@ -62,7 +62,7 @@ public class ContainerToggle extends Widget {
|
||||
this.subWidget[1].drawWidgetTree(level);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public EwolObject getSubObjectNamed(final String widgetName) {
|
||||
EwolObject tmpObject = super.getSubObjectNamed(widgetName);
|
||||
@ -80,14 +80,14 @@ public class ContainerToggle extends Widget {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@AknotManaged
|
||||
@AknotFactory(value = WidgetXmlFactory.class)
|
||||
@AknotDescription(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 Vector2f localAvaillable = this.size.less(padding.x(), padding.y());
|
||||
@ -121,14 +121,14 @@ public class ContainerToggle extends Widget {
|
||||
return new Padding(selectableAreaPos.x(), selectableAreaEndPos.y(), selectableAreaEndPos.x(),
|
||||
selectableAreaPos.y());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onRegenerateDisplay() {
|
||||
if (this.subWidget[this.idWidgetDisplayed] != null) {
|
||||
this.subWidget[this.idWidgetDisplayed].onRegenerateDisplay();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void requestDestroyFromChild(final EwolObject child) {
|
||||
if (this.subWidget[0] == child) {
|
||||
@ -148,7 +148,7 @@ public class ContainerToggle extends Widget {
|
||||
markToRedraw();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setOffset(final Vector2f newVal) {
|
||||
if (this.offset.equals(newVal)) {
|
||||
@ -158,12 +158,12 @@ public class ContainerToggle extends Widget {
|
||||
// recalculate the new size and position of sub widget ...
|
||||
onChangeSize();
|
||||
}
|
||||
|
||||
|
||||
@AknotManaged(value = false)
|
||||
public void setSubWidget(final Widget newWidget) {
|
||||
setSubWidget(newWidget, 0);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* set the subWidget node widget.
|
||||
* @param newWidget The widget to add.
|
||||
@ -178,13 +178,13 @@ public class ContainerToggle extends Widget {
|
||||
markToRedraw();
|
||||
requestUpdateSize();
|
||||
}
|
||||
|
||||
|
||||
public void setSubWidgets(final Widget[] newWidget) {
|
||||
for (int iii = 0; iii < Math.min(newWidget.length, this.subWidget.length); iii++) {
|
||||
setSubWidget(newWidget[iii], iii);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void subWidgetRemove(final int idWidget) {
|
||||
if (this.subWidget[idWidget] != null) {
|
||||
LOGGER.trace("Remove widget : " + idWidget);
|
||||
@ -194,7 +194,7 @@ public class ContainerToggle extends Widget {
|
||||
requestUpdateSize();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void subWidgetReplace(final Widget oldWidget, final Widget newWidget) {
|
||||
boolean haveChange = false;
|
||||
for (int iii = 0; iii < this.subWidget.length; ++iii) {
|
||||
@ -215,7 +215,7 @@ public class ContainerToggle extends Widget {
|
||||
markToRedraw();
|
||||
requestUpdateSize();
|
||||
}
|
||||
|
||||
|
||||
public void subWidgetUnLink(final int idWidget) {
|
||||
if (this.subWidget[idWidget] != null) {
|
||||
this.subWidget[idWidget].removeParent();
|
||||
@ -223,7 +223,7 @@ public class ContainerToggle extends Widget {
|
||||
}
|
||||
this.subWidget[idWidget] = null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void systemDraw(final DrawProperty displayProp) {
|
||||
if (this.propertyHide) {
|
||||
|
@ -41,7 +41,7 @@ import org.slf4j.LoggerFactory;
|
||||
*/
|
||||
public class Entry extends Box {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(Entry.class);
|
||||
|
||||
|
||||
/**
|
||||
* Periodic call to update graphic display
|
||||
* @param _event Time generic event
|
||||
@ -53,7 +53,7 @@ public class Entry extends Box {
|
||||
// }
|
||||
self.markToRedraw();
|
||||
}
|
||||
|
||||
|
||||
/// color property of the text foreground
|
||||
private int colorIdTextFg;
|
||||
/// Cursor must be display only when the widget has the focus
|
||||
@ -74,16 +74,16 @@ public class Entry extends Box {
|
||||
protected Connection periodicConnectionHanble = new Connection();
|
||||
private int propertyMaxCharacter = Integer.MAX_VALUE; //!< number max of Character in the list
|
||||
private boolean propertyPassword = false; //!< Disable display of the content of the entry
|
||||
|
||||
|
||||
/// regular expression value
|
||||
private String propertyRegex = ".*";
|
||||
|
||||
|
||||
/// Text to display when nothing in in the entry (decorated text...)
|
||||
private String propertyTextWhenNothing = null;
|
||||
|
||||
|
||||
private String propertyValue = "Test Text..."; //!< string that must be displayed
|
||||
private Pattern regex = null; //!< regular expression to check content
|
||||
|
||||
|
||||
//.create()
|
||||
@AknotSignal
|
||||
@AknotName(value = "click")
|
||||
@ -93,12 +93,12 @@ public class Entry extends Box {
|
||||
@AknotName(value = "enter")
|
||||
@AknotDescription("The cursor enter inside the button")
|
||||
public Signal<String> signalEnter = new Signal<>(); //!< Enter key is pressed
|
||||
|
||||
|
||||
@AknotSignal
|
||||
@AknotName(value = "modify")
|
||||
@AknotDescription("Entry box value change")
|
||||
public Signal<String> signalModify = new Signal<>(); //!< data change
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param _newData The USting that might be set in the Entry box (no event generation!!)
|
||||
@ -106,7 +106,7 @@ public class Entry extends Box {
|
||||
public Entry() {
|
||||
this.propertyCanFocus = true;
|
||||
//onChangePropertyShaper();
|
||||
|
||||
|
||||
this.regex = Pattern.compile(this.propertyRegex);
|
||||
if (this.regex == null) {
|
||||
LOGGER.error("can not parse regex for : " + this.propertyRegex);
|
||||
@ -124,12 +124,12 @@ public class Entry extends Box {
|
||||
setPropertyBorderWidth(new DimensionInsets(2));
|
||||
setPropertyPadding(new DimensionInsets(4));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void calculateMinMaxSize() {
|
||||
calculateMinMaxSizeChild(new Vector2f(25, this.text.getHeight()));
|
||||
}
|
||||
|
||||
|
||||
protected void changeStatusIn(final GuiShapeMode newStatusId) {
|
||||
// if (this.shape.changeStatusIn(newStatusId)) {
|
||||
// if (!this.periodicConnectionHanble.isConnected()) {
|
||||
@ -140,7 +140,7 @@ public class Entry extends Box {
|
||||
// markToRedraw();
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Copy the selected data on the specify clipboard
|
||||
* @param clipboardID Selected clipboard
|
||||
@ -160,44 +160,44 @@ public class Entry extends Box {
|
||||
final String tmpData = this.propertyValue.substring(pos1, pos2);
|
||||
ClipBoard.set(clipboardID, tmpData);
|
||||
}
|
||||
|
||||
|
||||
public int getPropertyMaxCharacter() {
|
||||
return this.propertyMaxCharacter;
|
||||
}
|
||||
|
||||
|
||||
public String getPropertyRegex() {
|
||||
return this.propertyRegex;
|
||||
}
|
||||
|
||||
|
||||
public String getPropertyTextWhenNothing() {
|
||||
return this.propertyTextWhenNothing;
|
||||
}
|
||||
|
||||
|
||||
public String getPropertyValue() {
|
||||
return this.propertyValue;
|
||||
}
|
||||
|
||||
|
||||
public boolean isPropertyPassword() {
|
||||
return this.propertyPassword;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* informe the system thet the text change and the start position change
|
||||
*/
|
||||
protected void markToUpdateTextPosition() {
|
||||
this.needUpdateTextPos = true;
|
||||
}
|
||||
|
||||
|
||||
private void onCallbackCopy() {
|
||||
copySelectionToClipBoard(ClipboardList.CLIPBOARD_STD);
|
||||
}
|
||||
|
||||
|
||||
private void onCallbackCut() {
|
||||
copySelectionToClipBoard(ClipboardList.CLIPBOARD_STD);
|
||||
removeSelected();
|
||||
this.signalModify.emit(this.propertyValue);
|
||||
}
|
||||
|
||||
|
||||
private void onCallbackEntryClean() {
|
||||
this.propertyValue = "";
|
||||
this.displayStartPosition = 0;
|
||||
@ -205,11 +205,11 @@ public class Entry extends Box {
|
||||
this.displayCursorPosSelection = this.displayCursorPos;
|
||||
markToRedraw();
|
||||
}
|
||||
|
||||
|
||||
private void onCallbackPaste() {
|
||||
ClipBoard.request(ClipboardList.CLIPBOARD_STD);
|
||||
}
|
||||
|
||||
|
||||
private void onCallbackSelect(final boolean all) {
|
||||
if (all) {
|
||||
this.displayCursorPosSelection = 0;
|
||||
@ -219,7 +219,7 @@ public class Entry extends Box {
|
||||
}
|
||||
markToRedraw();
|
||||
}
|
||||
|
||||
|
||||
private void onCallbackShortCut(final String value) {
|
||||
if (value.equals("clean")) {
|
||||
onCallbackEntryClean();
|
||||
@ -238,15 +238,15 @@ public class Entry extends Box {
|
||||
LOGGER.warn("Unknow event from ShortCut : " + value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected void onChangePropertyMaxCharacter() {
|
||||
// TODO : check number of char in the data
|
||||
}
|
||||
|
||||
|
||||
protected void onChangePropertyPassword() {
|
||||
markToRedraw();
|
||||
}
|
||||
|
||||
|
||||
protected void onChangePropertyRegex() {
|
||||
this.regex = Pattern.compile(this.propertyRegex);
|
||||
if (this.regex != null) {
|
||||
@ -254,11 +254,11 @@ public class Entry extends Box {
|
||||
}
|
||||
markToRedraw();
|
||||
}
|
||||
|
||||
|
||||
protected void onChangePropertyTextWhenNothing() {
|
||||
markToRedraw();
|
||||
}
|
||||
|
||||
|
||||
protected void onChangePropertyValue() {
|
||||
String newData = this.propertyValue;
|
||||
if ((long) newData.length() > this.propertyMaxCharacter) {
|
||||
@ -274,13 +274,13 @@ public class Entry extends Box {
|
||||
}
|
||||
markToRedraw();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onDraw() {
|
||||
super.onDraw();
|
||||
this.text.draw();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onEventClipboard(final ClipboardList clipboardID) {
|
||||
// remove current selected data ...
|
||||
@ -304,7 +304,7 @@ public class Entry extends Box {
|
||||
}
|
||||
this.signalModify.emit(this.propertyValue);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onEventEntry(final EventEntry event) {
|
||||
LOGGER.trace("Event on Entry ... " + event);
|
||||
@ -380,7 +380,7 @@ public class Entry extends Box {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected boolean onEventInput(final EventInput event) {
|
||||
final Vector2f absolutePosition = event.pos();
|
||||
@ -482,7 +482,7 @@ public class Entry extends Box {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onGetFocus() {
|
||||
this.displayCursor = true;
|
||||
@ -490,7 +490,7 @@ public class Entry extends Box {
|
||||
showKeyboard();
|
||||
markToRedraw();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onLostFocus() {
|
||||
this.displayCursor = false;
|
||||
@ -498,17 +498,22 @@ public class Entry extends Box {
|
||||
hideKeyboard();
|
||||
markToRedraw();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onRegenerateDisplay() {
|
||||
if (!needRedraw()) {
|
||||
return;
|
||||
}
|
||||
super.onRegenerateDisplay();
|
||||
regenerateDisplay();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void regenerateDisplay() {
|
||||
super.regenerateDisplay();
|
||||
// calculate the vertical offset to center the text:
|
||||
final float offsetCenter = FMath.max(0.0f,
|
||||
(FMath.abs(this.insidePositionStop.y() - this.insidePositionStart.y()) - this.text.getHeight()) * 0.5f);
|
||||
|
||||
|
||||
this.text.clear();
|
||||
//this.text.setClippingWidth(this.insidePositionStart, this.insidePositionStop);
|
||||
this.text.setPos(this.insidePositionStart.add(0, offsetCenter));
|
||||
@ -521,7 +526,7 @@ public class Entry extends Box {
|
||||
if (this.propertyPassword) {
|
||||
Arrays.fill(valueToDisplay, '*');
|
||||
}
|
||||
|
||||
|
||||
//final Vector2f plop = new Vector2f(tmpOriginText.x() + this.displayStartPosition, tmpOriginText.y());
|
||||
if (valueToDisplay.length != 0) {
|
||||
this.text.print(new String(valueToDisplay));
|
||||
@ -531,7 +536,7 @@ public class Entry extends Box {
|
||||
this.text.setClippingMode(false);
|
||||
this.text.flush();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* remove the selected area
|
||||
* @note This request a regeneration of the display
|
||||
@ -559,7 +564,7 @@ public class Entry extends Box {
|
||||
this.propertyValue = tmp.toString();
|
||||
markToRedraw();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* internal check the value with RegExp checking
|
||||
* @param newData The new string to display
|
||||
@ -586,7 +591,7 @@ public class Entry extends Box {
|
||||
this.propertyValue = newData;
|
||||
markToRedraw();
|
||||
}
|
||||
|
||||
|
||||
@AknotManaged
|
||||
@AknotAttribute
|
||||
@AknotName(value = "max")
|
||||
@ -598,7 +603,7 @@ public class Entry extends Box {
|
||||
this.propertyMaxCharacter = propertyMaxCharacter;
|
||||
onChangePropertyMaxCharacter();
|
||||
}
|
||||
|
||||
|
||||
@AknotManaged
|
||||
@AknotAttribute
|
||||
@AknotName(value = "password")
|
||||
@ -610,7 +615,7 @@ public class Entry extends Box {
|
||||
this.propertyPassword = propertyPassword;
|
||||
onChangePropertyPassword();
|
||||
}
|
||||
|
||||
|
||||
@AknotManaged
|
||||
@AknotAttribute
|
||||
@AknotName(value = "regex")
|
||||
@ -622,7 +627,7 @@ public class Entry extends Box {
|
||||
this.propertyRegex = propertyRegex;
|
||||
onChangePropertyRegex();
|
||||
}
|
||||
|
||||
|
||||
@AknotManaged
|
||||
@AknotAttribute
|
||||
@AknotName(value = "empty-text")
|
||||
@ -634,7 +639,7 @@ public class Entry extends Box {
|
||||
this.propertyTextWhenNothing = propertyTextWhenNothing;
|
||||
onChangePropertyTextWhenNothing();
|
||||
}
|
||||
|
||||
|
||||
@AknotManaged
|
||||
@AknotAttribute
|
||||
@AknotName(value = "value")
|
||||
@ -646,22 +651,22 @@ public class Entry extends Box {
|
||||
this.propertyValue = propertyValue;
|
||||
onChangePropertyValue();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* change the cursor position with the curent position requested on the display
|
||||
* change the cursor position with the current position requested on the display
|
||||
* @param pos Absolute position of the event
|
||||
* @note The display is automaticly requested when change apear.
|
||||
* @note The display is automatically requested when change appear.
|
||||
*/
|
||||
protected void updateCursorPosition(final Vector2f pos) {
|
||||
updateCursorPosition(pos, false);
|
||||
}
|
||||
|
||||
|
||||
protected void updateCursorPosition(final Vector2f pos, final boolean selection/*=false*/) {
|
||||
final Padding padding = Padding.ZERO;
|
||||
|
||||
|
||||
final Vector2f relPos = relativePosition(pos).less(this.overPositionStart);
|
||||
// reject when outside ...
|
||||
|
||||
|
||||
// try to find the new cursor position :
|
||||
if (this.displayStartPosition > this.propertyValue.length()) {
|
||||
this.displayStartPosition = this.propertyValue.length();
|
||||
@ -699,7 +704,7 @@ public class Entry extends Box {
|
||||
}
|
||||
markToUpdateTextPosition();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* update the display position start == > depending of the position of the Cursor and the size of the Data inside
|
||||
* @change this.displayStartPosition < == updated
|
||||
@ -709,7 +714,7 @@ public class Entry extends Box {
|
||||
return;
|
||||
}
|
||||
final Padding padding = Padding.ZERO;
|
||||
|
||||
|
||||
int tmpSizeX = (int) this.minSize.x();
|
||||
if (this.propertyFill.x()) {
|
||||
tmpSizeX = (int) this.size.x();
|
||||
@ -739,5 +744,5 @@ public class Entry extends Box {
|
||||
//this.displayStartPosition = -totalWidth + tmpUserSize;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -18,29 +18,29 @@ import org.slf4j.LoggerFactory;
|
||||
*/
|
||||
class Gird extends Widget {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(Gird.class);
|
||||
|
||||
|
||||
protected class GirdProperties {
|
||||
public Widget widget;
|
||||
public int row;
|
||||
public int col;
|
||||
}
|
||||
|
||||
|
||||
protected int sizeRow = 0; //!< size of all lines (row) (if set (otherwise 0)) == > we have a only one size ==> multiple size will have no use ...
|
||||
protected int uniformSizeRow = 0;
|
||||
protected List<Integer> sizeCol = new ArrayList<>(); //!< size of all colomn (if set (otherwise 0))
|
||||
protected List<GirdProperties> subWidget = new ArrayList<>(); //!< all sub widget are contained in this element
|
||||
protected Widget tmpWidget = null; //!< use when replace a widget ...
|
||||
protected boolean gavityButtom = true;
|
||||
|
||||
|
||||
protected Vector2f propertyBorderSize = Vector2f.ZERO; //!< Border size needed for all the display
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public Gird() {
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void calculateMinMaxSize() {
|
||||
for (int iii = 0; iii < this.sizeCol.size(); iii++) {
|
||||
@ -72,7 +72,7 @@ class Gird extends Widget {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (this.sizeRow > 0) {
|
||||
this.uniformSizeRow = this.sizeRow;
|
||||
}
|
||||
@ -83,12 +83,12 @@ class Gird extends Widget {
|
||||
LOGGER.debug(" tmpSizeWidth=" + tmpSizeWidth);
|
||||
LOGGER.debug(" this.uniformSizeRow=" + this.uniformSizeRow);
|
||||
this.minSize = this.minSize.add(tmpSizeWidth, (lastLineID + 1) * this.uniformSizeRow);
|
||||
|
||||
|
||||
LOGGER.debug("Calculate min size : " + this.minSize);
|
||||
|
||||
|
||||
//LOGGER.debug("Vert Result : expand="+ this.userExpand + " minSize="+ this.minSize);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* get the current border size of the current element:
|
||||
* @return the border size (0 if not used)
|
||||
@ -96,7 +96,7 @@ class Gird extends Widget {
|
||||
public Vector2f getBorderSize() {
|
||||
return this.propertyBorderSize;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* get the size view of a colomn.
|
||||
* @param colId Id of the colomn [0..x].
|
||||
@ -112,11 +112,11 @@ class Gird extends Widget {
|
||||
LOGGER.error("Can not get the Colomn size : " + colId + 1 + " we have " + this.sizeCol.size() + " colomn");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
public Vector2f getPropertyBorderSize() {
|
||||
return this.propertyBorderSize;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* get the size view of the lines.
|
||||
* @return The size of the lines.
|
||||
@ -124,7 +124,7 @@ class Gird extends Widget {
|
||||
public int getRowSize() {
|
||||
return this.sizeRow;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Widget getWidgetAtPos(final Vector2f pos) {
|
||||
if (this.propertyHide) {
|
||||
@ -149,12 +149,12 @@ class Gird extends Widget {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onChangeSize() {
|
||||
//LOGGER.debug("Update size");
|
||||
this.size = this.size.less(this.propertyBorderSize.multiply(2));
|
||||
|
||||
|
||||
for (int iii = 0; iii < this.subWidget.size(); iii++) {
|
||||
if (this.subWidget.get(iii).widget != null) {
|
||||
//calculate the origin :
|
||||
@ -162,7 +162,7 @@ class Gird extends Widget {
|
||||
if (!this.gavityButtom) {
|
||||
tmpOrigin = tmpOrigin.add(0, this.size.y() - this.propertyBorderSize.y());
|
||||
}
|
||||
|
||||
|
||||
int tmpSizeWidth = 0;
|
||||
for (int jjj = 0; jjj < this.subWidget.get(iii).col; jjj++) {
|
||||
tmpSizeWidth += Math.abs(this.sizeCol.get(jjj));
|
||||
@ -175,7 +175,7 @@ class Gird extends Widget {
|
||||
addingPos = -(this.subWidget.get(iii).row + 1) * this.uniformSizeRow;
|
||||
}
|
||||
tmpOrigin = tmpOrigin.add(tmpSizeWidth, addingPos);
|
||||
|
||||
|
||||
LOGGER.debug(" [{}] set subwidget origin={} size={}", iii, tmpOrigin,
|
||||
new Vector2f(Math.abs(this.sizeCol.get(this.subWidget.get(iii).col)), this.uniformSizeRow));
|
||||
// set the origin :
|
||||
@ -191,7 +191,7 @@ class Gird extends Widget {
|
||||
LOGGER.debug("Calculate size : " + this.size);
|
||||
markToRedraw();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onRegenerateDisplay() {
|
||||
for (final GirdProperties it : this.subWidget) {
|
||||
@ -200,7 +200,7 @@ class Gird extends Widget {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* set the current border size of the current element:
|
||||
* @param newBorderSize The border size to set (0 if not used)
|
||||
@ -208,7 +208,7 @@ class Gird extends Widget {
|
||||
public void setBorderSize(final Vector2f newBorderSize) {
|
||||
this.propertyBorderSize = newBorderSize;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* set the number of colomn
|
||||
* @param colNumber Nuber of colomn
|
||||
@ -244,7 +244,7 @@ class Gird extends Widget {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* change a size view of a colomn.
|
||||
* @param colId Id of the colomn [0..x].
|
||||
@ -258,7 +258,7 @@ class Gird extends Widget {
|
||||
+ this.sizeCol.size() + " colomn");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* set the gravity of the widget on the Button (index 0 is on buttom)
|
||||
*/
|
||||
@ -266,7 +266,7 @@ class Gird extends Widget {
|
||||
this.gavityButtom = true;
|
||||
markToRedraw();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* set the gravity of the widget on the Top (index 0 is on top)
|
||||
*/
|
||||
@ -274,7 +274,7 @@ class Gird extends Widget {
|
||||
this.gavityButtom = false;
|
||||
markToRedraw();
|
||||
}
|
||||
|
||||
|
||||
public void setPropertyBorderSize(final Vector2f propertyBorderSize) {
|
||||
this.propertyBorderSize = propertyBorderSize;
|
||||
if (this.propertyBorderSize.x() < 0) {
|
||||
@ -288,7 +288,7 @@ class Gird extends Widget {
|
||||
markToRedraw();
|
||||
requestUpdateSize();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* change a size view of a line.
|
||||
* @param size size of the line.
|
||||
@ -296,7 +296,7 @@ class Gird extends Widget {
|
||||
public void setRowSize(final int size) {
|
||||
this.sizeRow = size;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* add at end position a Widget (note : This system use an inverted phylisophie (button to top, and left to right)
|
||||
* @param colId Id of the colomn [0..x].
|
||||
@ -311,7 +311,7 @@ class Gird extends Widget {
|
||||
prop.row = rowId;
|
||||
prop.col = colId;
|
||||
prop.widget = newWidget;
|
||||
|
||||
|
||||
// need to find the correct position :
|
||||
for (int iii = 0; iii < this.subWidget.size(); iii++) {
|
||||
if (this.subWidget.get(iii).row < prop.row) {
|
||||
@ -336,7 +336,7 @@ class Gird extends Widget {
|
||||
// not find == > just adding it ...
|
||||
this.subWidget.add(prop);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* remove definitly a widget from the system and this Gird.
|
||||
* @param colId Id of the colomn [0..x].
|
||||
@ -357,7 +357,7 @@ class Gird extends Widget {
|
||||
}
|
||||
LOGGER.warn("[" + getId() + "] Can not remove unExistant widget");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* remove definitly a widget from the system and this Gird.
|
||||
* @param newWidget the element pointer.
|
||||
@ -371,7 +371,7 @@ class Gird extends Widget {
|
||||
}
|
||||
LOGGER.warn("[" + getId() + "] Can not remove unExistant widget");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* remove all sub element from the widget.
|
||||
*/
|
||||
@ -379,7 +379,7 @@ class Gird extends Widget {
|
||||
final int errorControl = this.subWidget.size();
|
||||
this.subWidget.clear();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Just unlick the specify widget, this function does not remove it from the system (if you can, do nt use it ...).
|
||||
* @param colId Id of the colomn [0..x].
|
||||
@ -399,7 +399,7 @@ class Gird extends Widget {
|
||||
}
|
||||
LOGGER.warn("[" + getId() + "] Can not unLink unExistant widget");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Just unlick the specify widget, this function does not remove it from the system (if you can, do nt use it ...).
|
||||
* @param newWidget the element pointer.
|
||||
@ -415,7 +415,7 @@ class Gird extends Widget {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void systemDraw(final DrawProperty displayProp) {
|
||||
super.systemDraw(displayProp);
|
||||
|
@ -16,7 +16,6 @@ import org.atriasoft.etk.Dimension2f;
|
||||
import org.atriasoft.etk.Uri;
|
||||
import org.atriasoft.etk.math.Vector2f;
|
||||
import org.atriasoft.etk.math.Vector2i;
|
||||
import org.atriasoft.etk.math.Vector2f;
|
||||
import org.atriasoft.ewol.compositing.CompositingImage;
|
||||
import org.atriasoft.ewol.event.EventInput;
|
||||
import org.atriasoft.ewol.resource.ResourceColorFile;
|
||||
@ -30,13 +29,13 @@ public class ImageDisplay extends Widget {
|
||||
protected ResourceColorFile colorProperty = null; //!< theme color property
|
||||
protected CompositingImage compositing = new CompositingImage(); //!< compositing element of the image.
|
||||
protected Vector2f imageRenderSize = Vector2f.ZERO; //!< size of the image when we render it
|
||||
|
||||
|
||||
protected Dimension2f propertyBorder = Dimension2f.ZERO; //!< border to add at the image.
|
||||
protected Dimension2f propertyImageSize = Dimension2f.ZERO; //!< border to add at the image.
|
||||
protected boolean propertyKeepRatio = true; //!< keep the image ratio between width and height
|
||||
protected Vector2f propertyPosStart = Vector2f.ZERO; //!< position in the image to start the display (when we want not to display all the image)
|
||||
protected Vector2f propertyPosStop = Vector2f.ONE; //!< position in the image to start the display (when we want not to display all the image)
|
||||
|
||||
|
||||
protected boolean propertySmooth = true; //!< display is done in the pixel approximation if false
|
||||
protected Uri propertySource = null; //!< file name of the image.
|
||||
protected boolean propertyUseThemeColor = false; //!< Use the themo color management ("THEMECOLOR:///Image.json?lib=ewol") default false
|
||||
@ -44,12 +43,12 @@ public class ImageDisplay extends Widget {
|
||||
@AknotName("pressed")
|
||||
@AknotDescription(value = "Image is pressed")
|
||||
public final SignalEmpty signalPressed = new SignalEmpty();
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public ImageDisplay() {}
|
||||
|
||||
|
||||
@Override
|
||||
public void calculateMinMaxSize() {
|
||||
LOGGER.debug("calculate min size: border=" + this.propertyBorder + " size=" + this.propertyImageSize
|
||||
@ -80,7 +79,7 @@ public class ImageDisplay extends Widget {
|
||||
+ this.imageRenderSize + " img size=" + imageSize + " " + this.propertyImageSize);
|
||||
markToRedraw();
|
||||
}
|
||||
|
||||
|
||||
@AknotManaged
|
||||
@AknotAttribute
|
||||
@AknotName(value = "image-border")
|
||||
@ -88,7 +87,7 @@ public class ImageDisplay extends Widget {
|
||||
public Dimension2f getPropertyBorder() {
|
||||
return this.propertyBorder;
|
||||
}
|
||||
|
||||
|
||||
@AknotManaged
|
||||
@AknotAttribute
|
||||
@AknotName(value = "image-size")
|
||||
@ -96,7 +95,7 @@ public class ImageDisplay extends Widget {
|
||||
public Dimension2f getPropertyImageSize() {
|
||||
return this.propertyImageSize;
|
||||
}
|
||||
|
||||
|
||||
@AknotManaged
|
||||
@AknotAttribute
|
||||
@AknotName(value = "part-start")
|
||||
@ -104,7 +103,7 @@ public class ImageDisplay extends Widget {
|
||||
public Vector2f getPropertyPosStart() {
|
||||
return this.propertyPosStart;
|
||||
}
|
||||
|
||||
|
||||
@AknotManaged
|
||||
@AknotAttribute
|
||||
@AknotName(value = "part-stop")
|
||||
@ -112,7 +111,7 @@ public class ImageDisplay extends Widget {
|
||||
public Vector2f getPropertyPosStop() {
|
||||
return this.propertyPosStop;
|
||||
}
|
||||
|
||||
|
||||
@AknotManaged
|
||||
@AknotAttribute
|
||||
@AknotName(value = "src")
|
||||
@ -120,7 +119,7 @@ public class ImageDisplay extends Widget {
|
||||
public Uri getPropertySource() {
|
||||
return this.propertySource;
|
||||
}
|
||||
|
||||
|
||||
@AknotManaged
|
||||
@AknotAttribute
|
||||
@AknotName(value = "ratio")
|
||||
@ -128,7 +127,7 @@ public class ImageDisplay extends Widget {
|
||||
public boolean isPropertyKeepRatio() {
|
||||
return this.propertyKeepRatio;
|
||||
}
|
||||
|
||||
|
||||
@AknotManaged
|
||||
@AknotAttribute
|
||||
@AknotName(value = "smooth")
|
||||
@ -136,7 +135,7 @@ public class ImageDisplay extends Widget {
|
||||
public boolean isPropertySmooth() {
|
||||
return this.propertySmooth;
|
||||
}
|
||||
|
||||
|
||||
@AknotManaged
|
||||
@AknotAttribute
|
||||
@AknotName(value = "use-theme-color")
|
||||
@ -144,12 +143,12 @@ public class ImageDisplay extends Widget {
|
||||
public boolean isPropertyUseThemeColor() {
|
||||
return this.propertyUseThemeColor;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onDraw() {
|
||||
this.compositing.draw();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onEventInput(final EventInput event) {
|
||||
//LOGGER.debug("Event on BT ...");
|
||||
@ -161,7 +160,7 @@ public class ImageDisplay extends Widget {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onRegenerateDisplay() {
|
||||
if (!needRedraw()) {
|
||||
@ -178,10 +177,10 @@ public class ImageDisplay extends Widget {
|
||||
imageBoder = imageBoder.multiply(2.0f);
|
||||
Vector2f imageRealSize = this.imageRenderSize.less(imageBoder);
|
||||
final Vector2f imageRealSizeMax = this.size.less(imageBoder.x(), imageBoder.y());
|
||||
|
||||
|
||||
final Vector2f ratioSizeDisplayRequested = this.propertyPosStop.less(this.propertyPosStart);
|
||||
//imageRealSizeMax *= ratioSizeDisplayRequested;
|
||||
|
||||
|
||||
Vector2f delta = this.propertyGravity
|
||||
.gravityGenerateDelta(this.size.less(this.imageRenderSize.x(), this.imageRenderSize.y()));
|
||||
if (this.propertyFill.x()) {
|
||||
@ -193,7 +192,7 @@ public class ImageDisplay extends Widget {
|
||||
delta = delta.withY(0.0f);
|
||||
}
|
||||
origin = origin.add(delta);
|
||||
|
||||
|
||||
if (this.propertyKeepRatio) {
|
||||
final Vector2i tmpSize = this.compositing.getRealSize();
|
||||
//float ratio = tmpSize.x() / tmpSize.y();
|
||||
@ -213,7 +212,7 @@ public class ImageDisplay extends Widget {
|
||||
origin = origin.add(0, (oldY - imageRealSize.y()) * 0.5f);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// set the somposition properties :
|
||||
if (this.propertySmooth) {
|
||||
this.compositing.setPos(origin);
|
||||
@ -227,7 +226,7 @@ public class ImageDisplay extends Widget {
|
||||
LOGGER.debug(" start=" + this.propertyPosStart + " stop=" + this.propertyPosStop);
|
||||
this.compositing.flush();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* set All the configuration of the current image
|
||||
* @param uri URI of the new image
|
||||
@ -238,7 +237,7 @@ public class ImageDisplay extends Widget {
|
||||
setPropertyBorder(border);
|
||||
setPropertySource(uri);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set an image with direct elements
|
||||
* @param image Image to set in the display
|
||||
@ -249,7 +248,7 @@ public class ImageDisplay extends Widget {
|
||||
markToRedraw();
|
||||
requestUpdateSize();
|
||||
}
|
||||
|
||||
|
||||
public void setPropertyBorder(final Dimension2f propertyBorder) {
|
||||
if (this.propertyBorder.equals(propertyBorder)) {
|
||||
return;
|
||||
@ -258,7 +257,7 @@ public class ImageDisplay extends Widget {
|
||||
markToRedraw();
|
||||
requestUpdateSize();
|
||||
}
|
||||
|
||||
|
||||
public void setPropertyImageSize(final Dimension2f propertyImageSize) {
|
||||
if (this.propertyImageSize.equals(propertyImageSize)) {
|
||||
return;
|
||||
@ -269,7 +268,7 @@ public class ImageDisplay extends Widget {
|
||||
LOGGER.trace("Set sources : " + this.propertySource + " size=" + propertyImageSize);
|
||||
this.compositing.setSource(this.propertySource, propertyImageSize.getPixeli());
|
||||
}
|
||||
|
||||
|
||||
public void setPropertyKeepRatio(final boolean propertyKeepRatio) {
|
||||
if (this.propertyKeepRatio == propertyKeepRatio) {
|
||||
return;
|
||||
@ -278,7 +277,7 @@ public class ImageDisplay extends Widget {
|
||||
markToRedraw();
|
||||
requestUpdateSize();
|
||||
}
|
||||
|
||||
|
||||
public void setPropertyPosStart(final Vector2f propertyPosStart) {
|
||||
if (this.propertyPosStart.equals(propertyPosStart)) {
|
||||
return;
|
||||
@ -287,7 +286,7 @@ public class ImageDisplay extends Widget {
|
||||
markToRedraw();
|
||||
requestUpdateSize();
|
||||
}
|
||||
|
||||
|
||||
public void setPropertyPosStop(final Vector2f propertyPosStop) {
|
||||
if (this.propertyPosStop.equals(propertyPosStop)) {
|
||||
return;
|
||||
@ -296,7 +295,7 @@ public class ImageDisplay extends Widget {
|
||||
markToRedraw();
|
||||
requestUpdateSize();
|
||||
}
|
||||
|
||||
|
||||
public void setPropertySmooth(final boolean propertySmooth) {
|
||||
if (this.propertySmooth == propertySmooth) {
|
||||
return;
|
||||
@ -304,7 +303,7 @@ public class ImageDisplay extends Widget {
|
||||
this.propertySmooth = propertySmooth;
|
||||
markToRedraw();
|
||||
}
|
||||
|
||||
|
||||
public void setPropertySource(final Uri propertySource) {
|
||||
if (this.propertySource != null && this.propertySource.equals(propertySource)) {
|
||||
return;
|
||||
@ -315,7 +314,7 @@ public class ImageDisplay extends Widget {
|
||||
LOGGER.trace("Set sources : " + propertySource + " size=" + this.propertyImageSize);
|
||||
this.compositing.setSource(propertySource, this.propertyImageSize.getPixeli());
|
||||
}
|
||||
|
||||
|
||||
public void setPropertyUseThemeColor(final boolean propertyUseThemeColor) {
|
||||
if (this.propertyUseThemeColor == propertyUseThemeColor) {
|
||||
return;
|
||||
|
@ -35,16 +35,16 @@ public class Label extends Widget {
|
||||
private int propertyFontSize = 0; //!< default size of the font.
|
||||
private final CompositingText textCompose = new CompositingText(); //!< Compositing text element.
|
||||
private String value = "";
|
||||
|
||||
|
||||
protected int colorDefaultBgText = -1; //!< Default Background color of the text
|
||||
protected int colorDefaultFgText = -1; //!< Default color of the text
|
||||
protected ResourceColorFile colorProperty; //!< theme color property
|
||||
protected boolean propertyAutoTranslate = true; //!< if at true the data is translate automaticaly translate.
|
||||
|
||||
|
||||
public Label() {
|
||||
this("---");
|
||||
}
|
||||
|
||||
|
||||
public Label(final String label) {
|
||||
this.colorProperty = ResourceColorFile.create(new Uri("THEME", "/color/Label.json", "ewol"));
|
||||
if (this.colorProperty != null) {
|
||||
@ -55,7 +55,7 @@ public class Label extends Widget {
|
||||
setPropertyCanFocus(false);
|
||||
setPropertyValue(label);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void calculateMinMaxSize() {
|
||||
LOGGER.trace("calculateMinMaxSize !!! data = '{}'", this.value);
|
||||
@ -72,29 +72,29 @@ public class Label extends Widget {
|
||||
this.textCompose.flush();
|
||||
minSize = minSize.add(2, 2);
|
||||
//EWOL_DEBUG("[" + getId() + "] {" + getObjectType() + "} minSize : " + minSize);
|
||||
|
||||
|
||||
this.minSize = new Vector2f(FMath.avg(tmpMin.x(), 4 + minSize.x(), tmpMax.x()), //
|
||||
FMath.avg(tmpMin.y(), 4 + minSize.y(), tmpMax.y()));
|
||||
LOGGER.trace("[{}] Result min size : {}", getId(), this.minSize);
|
||||
}
|
||||
|
||||
|
||||
public int getPropertyFontSize() {
|
||||
return this.propertyFontSize;
|
||||
}
|
||||
|
||||
|
||||
public String getPropertyValue() {
|
||||
return this.propertyValue;
|
||||
}
|
||||
|
||||
|
||||
public boolean isPropertyAutoTranslate() {
|
||||
return this.propertyAutoTranslate;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onDraw() {
|
||||
this.textCompose.draw();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onEventInput(final EventInput event) {
|
||||
//LOGGER.debug("Event on Label ...");
|
||||
@ -107,7 +107,7 @@ public class Label extends Widget {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onRegenerateDisplay() {
|
||||
if (!needRedraw()) {
|
||||
@ -116,26 +116,26 @@ public class Label extends Widget {
|
||||
this.textCompose.clear();
|
||||
//final int paddingSize = 2;
|
||||
final Padding padding = new Padding(2, 2, 2, 2);
|
||||
|
||||
|
||||
final Vector2f tmpMax = this.propertyMaxSize.getPixel();
|
||||
// to know the size of one line :
|
||||
final Vector2f minSize = this.textCompose.calculateSize('A');
|
||||
|
||||
|
||||
//minSize.setX(etk::max(minSize.x(), this.minSize.x()));
|
||||
//minSize.setY(etk::max(minSize.y(), this.minSize.y()));
|
||||
if (tmpMax.x() <= 999999) {
|
||||
this.textCompose.setTextAlignment(0, tmpMax.x() - padding.x(), AlignMode.LEFT);
|
||||
}
|
||||
final Vector2f curentTextSize = this.textCompose.calculateSizeDecorated(this.value);
|
||||
|
||||
|
||||
//Vector2f localSize = this.minSize.clipInteger();
|
||||
Vector2f tmpSizeShaper = this.minSize;
|
||||
|
||||
|
||||
// no change for the text origin :
|
||||
Vector2f tmpTextOrigin = new Vector2f((this.size.x() - minSize.x()) * 0.5f,
|
||||
(this.size.y() - minSize.y()) * 0.5f);
|
||||
Vector2f delta = this.propertyGravity.gravityGenerateDelta(this.size.less(this.minSize));
|
||||
|
||||
|
||||
if (this.propertyFill.x()) {
|
||||
tmpSizeShaper = tmpSizeShaper.withX(this.size.x());
|
||||
delta = delta.withX(0.0f);
|
||||
@ -148,21 +148,20 @@ public class Label extends Widget {
|
||||
}
|
||||
final Vector2f tmpOriginShaper = delta;
|
||||
final Vector2f tmpSizeText = tmpSizeShaper.less(padding.x(), padding.y());
|
||||
|
||||
|
||||
tmpTextOrigin = tmpOriginShaper;//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() - this.textCompose.getHeight() - padding.top());// - this.minSize.y() - paddingSize);
|
||||
tmpTextOrigin = tmpTextOrigin.withX(tmpTextOrigin.x() + padding.left());
|
||||
|
||||
|
||||
final Vector2f textPos = new Vector2f(tmpTextOrigin.x(), tmpTextOrigin.y());
|
||||
|
||||
final Vector2f drawClippingPos = tmpOriginShaper
|
||||
.less(new Vector2f(padding.left(), padding.bottom()));
|
||||
|
||||
final Vector2f drawClippingPos = tmpOriginShaper.less(new Vector2f(padding.left(), padding.bottom()));
|
||||
final Vector2f drawClippingSize = tmpOriginShaper.add(tmpSizeShaper); /// new Vector2f((this.size.x() - paddingSize), (this.size.y() - paddingSize), 1);
|
||||
|
||||
|
||||
// clean the element
|
||||
this.textCompose.reset();
|
||||
if (this.propertyFontSize != 0) {
|
||||
@ -179,7 +178,7 @@ public class Label extends Widget {
|
||||
this.textCompose.printDecorated(this.value);
|
||||
this.textCompose.flush();
|
||||
}
|
||||
|
||||
|
||||
@AknotManaged
|
||||
@AknotAttribute
|
||||
@AknotName(value = "auto-translate")
|
||||
@ -197,7 +196,7 @@ public class Label extends Widget {
|
||||
markToRedraw();
|
||||
requestUpdateSize();
|
||||
}
|
||||
|
||||
|
||||
@AknotManaged
|
||||
@AknotAttribute
|
||||
@AknotName(value = "font-size")
|
||||
@ -210,7 +209,7 @@ public class Label extends Widget {
|
||||
markToRedraw();
|
||||
requestUpdateSize();
|
||||
}
|
||||
|
||||
|
||||
@AknotManaged
|
||||
@AknotText
|
||||
@AknotName(value = "value")
|
||||
@ -228,5 +227,5 @@ public class Label extends Widget {
|
||||
requestUpdateSize();
|
||||
this.propertyValue = propertyValue;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ public class LabelOnSVG extends Widget {
|
||||
protected int colorDefaultFgText = -1; //!< Default color of the text
|
||||
protected ResourceColorFile colorProperty; //!< theme color property
|
||||
protected boolean propertyAutoTranslate = true; //!< if at true the data is translate automaticaly translate.
|
||||
|
||||
|
||||
protected int propertyFontSize = 0; //!< default size of the font.
|
||||
protected String propertyValue = ""; //!< decorated text to display.
|
||||
@AknotSignal
|
||||
@ -39,7 +39,7 @@ public class LabelOnSVG extends Widget {
|
||||
public SignalEmpty signalPressed = new SignalEmpty();
|
||||
protected CompositingText text = new CompositingText(); //!< Compositing text element.
|
||||
protected String value = "";
|
||||
|
||||
|
||||
public LabelOnSVG() {
|
||||
this.colorProperty = ResourceColorFile.create(new Uri("THEME", "/color/Label.json", "ewol"));
|
||||
if (this.colorProperty != null) {
|
||||
@ -49,7 +49,7 @@ public class LabelOnSVG extends Widget {
|
||||
setMouseLimit(1);
|
||||
setPropertyCanFocus(false);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param newLabel The displayed decorated text.
|
||||
@ -64,7 +64,7 @@ public class LabelOnSVG extends Widget {
|
||||
setPropertyCanFocus(false);
|
||||
setPropertyValue(newLabel);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void calculateMinMaxSize() {
|
||||
final Vector2f tmpMax = this.propertyMaxSize.getPixel();
|
||||
@ -76,30 +76,30 @@ public class LabelOnSVG extends Widget {
|
||||
}
|
||||
final Vector2f minSize = this.text.calculateSizeDecorated(this.value);
|
||||
LOGGER.debug("[" + getId() + "] {" + getClass().getCanonicalName() + "} minSize : " + minSize);
|
||||
|
||||
|
||||
this.minSize = new Vector2f(FMath.avg(tmpMin.x(), 4 + minSize.x(), tmpMax.x()),
|
||||
FMath.avg(tmpMin.y(), 4 + minSize.y(), tmpMax.y()));
|
||||
LOGGER.trace("[" + getId() + "] {" + getClass().getCanonicalName() + "} Result min size : " + tmpMin + " < "
|
||||
+ this.minSize + " < " + tmpMax);
|
||||
}
|
||||
|
||||
|
||||
public int getPropertyFontSize() {
|
||||
return this.propertyFontSize;
|
||||
}
|
||||
|
||||
|
||||
public String getPropertyValue() {
|
||||
return this.propertyValue;
|
||||
}
|
||||
|
||||
|
||||
public boolean isPropertyAutoTranslate() {
|
||||
return this.propertyAutoTranslate;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onDraw() {
|
||||
this.text.draw();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onEventInput(final EventInput event) {
|
||||
//LOGGER.debug("Event on Label ...");
|
||||
@ -112,7 +112,7 @@ public class LabelOnSVG extends Widget {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onRegenerateDisplay() {
|
||||
if (!needRedraw()) {
|
||||
@ -120,24 +120,24 @@ public class LabelOnSVG extends Widget {
|
||||
}
|
||||
this.text.clear();
|
||||
final int paddingSize = 2;
|
||||
|
||||
|
||||
final Vector2f tmpMax = this.propertyMaxSize.getPixel();
|
||||
// to know the size of one line :
|
||||
final Vector2f minSize = this.text.calculateSize('A');
|
||||
|
||||
|
||||
//minSize.setX(etk::max(minSize.x(), this.minSize.x()));
|
||||
//minSize.setY(etk::max(minSize.y(), this.minSize.y()));
|
||||
if (tmpMax.x() <= 999999) {
|
||||
this.text.setTextAlignment(0, tmpMax.x() - 2 * paddingSize, AlignMode.LEFT);
|
||||
}
|
||||
final Vector2f currentTextSize = this.text.calculateSizeDecorated(this.value);
|
||||
|
||||
|
||||
Vector2i localSize = new Vector2i((int) this.minSize.x(), (int) this.minSize.y());
|
||||
|
||||
|
||||
// no change for the text origin :
|
||||
Vector2f tmpTextOrigin = new Vector2f((this.size.x() - this.minSize.x()) / 2.0f,
|
||||
(this.size.y() - this.minSize.y()) / 2.0f);
|
||||
|
||||
|
||||
if (this.propertyFill.x()) {
|
||||
localSize = localSize.withX((int) this.size.x());
|
||||
tmpTextOrigin = tmpTextOrigin.withX(0);
|
||||
@ -148,14 +148,14 @@ public class LabelOnSVG extends Widget {
|
||||
}
|
||||
tmpTextOrigin = tmpTextOrigin.add(paddingSize, paddingSize);
|
||||
localSize = localSize.less(2 * paddingSize, 2 * paddingSize);
|
||||
|
||||
|
||||
tmpTextOrigin = tmpTextOrigin.withY(tmpTextOrigin.y() + (this.minSize.y() - 2 * paddingSize) - minSize.y());
|
||||
|
||||
|
||||
final Vector2f textPos = new Vector2f(tmpTextOrigin.x(), tmpTextOrigin.y());
|
||||
|
||||
|
||||
final Vector2f drawClippingPos = new Vector2f(paddingSize, paddingSize);
|
||||
final Vector2f drawClippingSize = new Vector2f((this.size.x() - paddingSize), (this.size.y() - paddingSize));
|
||||
|
||||
|
||||
// clean the element
|
||||
this.text.reset();
|
||||
if (this.propertyFontSize != 0) {
|
||||
@ -170,10 +170,10 @@ public class LabelOnSVG extends Widget {
|
||||
this.text.setTextAlignment(tmpTextOrigin.x(), tmpTextOrigin.x() + localSize.x(), AlignMode.LEFT);
|
||||
this.text.setClipping(drawClippingPos, drawClippingSize);
|
||||
this.text.printDecorated(this.value);
|
||||
|
||||
|
||||
this.text.flush();
|
||||
}
|
||||
|
||||
|
||||
@AknotManaged
|
||||
@AknotAttribute
|
||||
@AknotName("auto-translate")
|
||||
@ -191,7 +191,7 @@ public class LabelOnSVG extends Widget {
|
||||
markToRedraw();
|
||||
requestUpdateSize();
|
||||
}
|
||||
|
||||
|
||||
@AknotManaged
|
||||
@AknotAttribute
|
||||
@AknotName("font-size")
|
||||
@ -204,7 +204,7 @@ public class LabelOnSVG extends Widget {
|
||||
markToRedraw();
|
||||
requestUpdateSize();
|
||||
}
|
||||
|
||||
|
||||
@AknotManaged
|
||||
@AknotAttribute
|
||||
@AknotName("value")
|
||||
@ -222,5 +222,5 @@ public class LabelOnSVG extends Widget {
|
||||
requestUpdateSize();
|
||||
this.propertyValue = propertyValue;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -17,23 +17,23 @@ import org.atriasoft.ewol.compositing.CompositingGC;
|
||||
class ProgressBar extends Widget {
|
||||
private static final int DOT_RADIUS = 6;
|
||||
private final CompositingDrawing vectorialDraw = new CompositingGC(); // basic drawing element
|
||||
|
||||
|
||||
protected Color propertyTextColorBgOff = Color.NONE;
|
||||
protected Color propertyTextColorBgOn = Color.GREEN;
|
||||
protected Color propertyTextColorFg = Color.BLACK;
|
||||
protected float propertyValue = 0;
|
||||
|
||||
|
||||
public ProgressBar() {
|
||||
setPropertyCanFocus(true);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void calculateMinMaxSize() {
|
||||
final Vector2f tmpMin = this.propertyMinSize.getPixel();
|
||||
this.minSize = new Vector2f(Math.max(tmpMin.x(), 40.0f), Math.max(tmpMin.y(), ProgressBar.DOT_RADIUS * 2.0f));
|
||||
markToRedraw();
|
||||
}
|
||||
|
||||
|
||||
@AknotManaged
|
||||
@AknotAttribute
|
||||
@AknotName(value = "color-off")
|
||||
@ -41,7 +41,7 @@ class ProgressBar extends Widget {
|
||||
public Color getPropertyTextColorBgOff() {
|
||||
return this.propertyTextColorBgOff;
|
||||
}
|
||||
|
||||
|
||||
@AknotManaged
|
||||
@AknotAttribute
|
||||
@AknotName(value = "color-on")
|
||||
@ -49,7 +49,7 @@ class ProgressBar extends Widget {
|
||||
public Color getPropertyTextColorBgOn() {
|
||||
return this.propertyTextColorBgOn;
|
||||
}
|
||||
|
||||
|
||||
@AknotManaged
|
||||
@AknotAttribute
|
||||
@AknotName(value = "color-bg")
|
||||
@ -57,7 +57,7 @@ class ProgressBar extends Widget {
|
||||
public Color getPropertyTextColorFg() {
|
||||
return this.propertyTextColorFg;
|
||||
}
|
||||
|
||||
|
||||
@AknotManaged
|
||||
@AknotAttribute
|
||||
@AknotName(value = "value")
|
||||
@ -65,12 +65,12 @@ class ProgressBar extends Widget {
|
||||
public float getPropertyValue() {
|
||||
return this.propertyValue;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onDraw() {
|
||||
this.vectorialDraw.draw();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onRegenerateDisplay() {
|
||||
if (!needRedraw()) {
|
||||
@ -78,9 +78,9 @@ class ProgressBar extends Widget {
|
||||
}
|
||||
// clean the object list ...
|
||||
this.vectorialDraw.clear();
|
||||
|
||||
|
||||
this.vectorialDraw.setColor(this.propertyTextColorFg);
|
||||
|
||||
|
||||
final int tmpSizeX = (int) (this.size.x() - 10);
|
||||
final int tmpSizeY = (int) (this.size.y() - 10);
|
||||
final int tmpOriginX = 5;
|
||||
@ -91,12 +91,12 @@ class ProgressBar extends Widget {
|
||||
this.vectorialDraw.setColor(this.propertyTextColorBgOff);
|
||||
this.vectorialDraw.setPos(new Vector2f(tmpOriginX + tmpSizeX * this.propertyValue, tmpOriginY));
|
||||
this.vectorialDraw.rectangleWidth(new Vector2f(tmpSizeX * (1.0f - this.propertyValue), tmpSizeY));
|
||||
|
||||
|
||||
// TODO : Create a better progress Bar ...
|
||||
//this.draw.setColor(propertyTextColorFg);
|
||||
//this.draw.rectangleBorder( tmpOriginX, tmpOriginY, tmpSizeX, tmpSizeY, 1);
|
||||
}
|
||||
|
||||
|
||||
public void setPropertyTextColorBgOff(final Color propertyTextColorBgOff) {
|
||||
if (propertyTextColorBgOff.equals(this.propertyTextColorBgOff)) {
|
||||
return;
|
||||
@ -104,7 +104,7 @@ class ProgressBar extends Widget {
|
||||
this.propertyTextColorBgOff = propertyTextColorBgOff;
|
||||
markToRedraw();
|
||||
}
|
||||
|
||||
|
||||
public void setPropertyTextColorBgOn(final Color propertyTextColorBgOn) {
|
||||
if (propertyTextColorBgOn.equals(this.propertyTextColorBgOn)) {
|
||||
return;
|
||||
@ -112,7 +112,7 @@ class ProgressBar extends Widget {
|
||||
this.propertyTextColorBgOn = propertyTextColorBgOn;
|
||||
markToRedraw();
|
||||
}
|
||||
|
||||
|
||||
public void setPropertyTextColorFg(final Color propertyTextColorFg) {
|
||||
if (propertyTextColorFg.equals(this.propertyTextColorFg)) {
|
||||
return;
|
||||
@ -120,7 +120,7 @@ class ProgressBar extends Widget {
|
||||
this.propertyTextColorFg = propertyTextColorFg;
|
||||
markToRedraw();
|
||||
}
|
||||
|
||||
|
||||
public void setPropertyValue(final float propertyValue) {
|
||||
if (propertyValue == this.propertyValue) {
|
||||
return;
|
||||
|
@ -9,10 +9,8 @@ import org.atriasoft.aknot.annotation.AknotAttribute;
|
||||
import org.atriasoft.aknot.annotation.AknotDescription;
|
||||
import org.atriasoft.aknot.annotation.AknotManaged;
|
||||
import org.atriasoft.aknot.annotation.AknotName;
|
||||
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.Vector2b;
|
||||
import org.atriasoft.etk.math.Vector2f;
|
||||
import org.atriasoft.ewol.DrawProperty;
|
||||
@ -30,13 +28,13 @@ class Scroll extends Container {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(Scroll.class);
|
||||
protected static final int SCROLL_BAR_SPACE = 15;
|
||||
protected Vector2f propertyLimit = new Vector2f(0.15f, 0.5f); //!< Set the limitation of the ratio in the screen
|
||||
|
||||
|
||||
protected Uri propertyShapeVert = new Uri("THEME_GUI", "WidgetScrolled.json", "ewol"); //!< Vertical shaper name
|
||||
|
||||
|
||||
protected Uri propertyShapeHori = new Uri("THEME_GUI", "WidgetScrolled.json", "ewol"); //!< Horizontal shaper name
|
||||
|
||||
|
||||
protected boolean propertyHover = true; //!< Horizontal shaper name
|
||||
|
||||
|
||||
protected CompositingSVG compositingH = new CompositingSVG();
|
||||
protected CompositingSVG compositingV = new CompositingSVG();
|
||||
protected float pixelScrolling = 20;
|
||||
@ -44,12 +42,12 @@ class Scroll extends Container {
|
||||
protected HighSpeedMode highSpeedMode = HighSpeedMode.speedModeDisable;
|
||||
protected int highSpeedButton = -1;
|
||||
protected KeyType highSpeedType = KeyType.unknow;
|
||||
|
||||
|
||||
public Scroll() {
|
||||
onChangePropertyShapeVert();
|
||||
onChangePropertyShapeHori();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void calculateMinMaxSize() {
|
||||
// Note: No call of container ==> normal case ...
|
||||
@ -59,7 +57,7 @@ class Scroll extends Container {
|
||||
this.subWidget.calculateMinMaxSize();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@AknotManaged
|
||||
@AknotAttribute
|
||||
@AknotName(value = "limit")
|
||||
@ -67,7 +65,7 @@ class Scroll extends Container {
|
||||
public Vector2f getPropertyLimit() {
|
||||
return this.propertyLimit;
|
||||
}
|
||||
|
||||
|
||||
@AknotManaged
|
||||
@AknotAttribute
|
||||
@AknotName(value = "shape-hori")
|
||||
@ -75,7 +73,7 @@ class Scroll extends Container {
|
||||
public Uri getPropertyShapeHori() {
|
||||
return this.propertyShapeHori;
|
||||
}
|
||||
|
||||
|
||||
@AknotManaged
|
||||
@AknotAttribute
|
||||
@AknotName(value = "shape-vert")
|
||||
@ -83,7 +81,7 @@ class Scroll extends Container {
|
||||
public Uri getPropertyShapeVert() {
|
||||
return this.propertyShapeVert;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Widget getWidgetAtPos(final Vector2f pos) {
|
||||
final Widget tmpWidget = super.getWidgetAtPos(pos);
|
||||
@ -92,7 +90,7 @@ class Scroll extends Container {
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@AknotManaged
|
||||
@AknotAttribute
|
||||
@AknotName(value = "hover")
|
||||
@ -100,21 +98,21 @@ class Scroll extends Container {
|
||||
public boolean isPropertyHover() {
|
||||
return this.propertyHover;
|
||||
}
|
||||
|
||||
|
||||
void onChangePropertyLimit() {
|
||||
markToRedraw();
|
||||
}
|
||||
|
||||
|
||||
protected void onChangePropertyShapeHori() {
|
||||
//TODO: this.shaperH.setSource(this.propertyShapeHori);
|
||||
markToRedraw();
|
||||
}
|
||||
|
||||
|
||||
protected void onChangePropertyShapeVert() {
|
||||
//TODO: this.shaperV.setSource(this.propertyShapeVert);
|
||||
markToRedraw();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onChangeSize() {
|
||||
// Note: No call of container ==> normal case ...
|
||||
@ -130,7 +128,7 @@ class Scroll extends Container {
|
||||
if (!this.propertyHover) {
|
||||
basicSize = basicSize.less(SCROLL_BAR_SPACE, SCROLL_BAR_SPACE);
|
||||
}
|
||||
|
||||
|
||||
Vector2f origin = this.origin.add(this.offset);
|
||||
Vector2f minSize = this.subWidget.getCalculateMinSize();
|
||||
final Vector2b expand = this.subWidget.propertyExpand;
|
||||
@ -156,13 +154,13 @@ class Scroll extends Container {
|
||||
this.subWidget.setOrigin(origin);
|
||||
this.subWidget.onChangeSize();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onDraw() {
|
||||
this.compositingH.draw();
|
||||
this.compositingV.draw();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onEventInput(final EventInput event) {
|
||||
//ewol::event::Input _event = event;
|
||||
@ -404,7 +402,7 @@ class Scroll extends Container {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onRegenerateDisplay() {
|
||||
if (this.propertyHide) {
|
||||
@ -432,13 +430,13 @@ class Scroll extends Container {
|
||||
float originScrollBar = scrollOffset.y() / (scrollSize.y() - this.size.y() * this.propertyLimit.y());
|
||||
originScrollBar = FMath.avg(0.0f, originScrollBar, 1.0f);
|
||||
originScrollBar *= (this.size.y() - lenScrollBar);
|
||||
|
||||
|
||||
final Vector2f renderOrigin = new Vector2f(this.size.x() - paddingVert.x(), 0);
|
||||
final Vector2f renderSize = new Vector2f(paddingVert.x(), this.size.y());
|
||||
this.compositingV.setRectangleAsSource((int) renderSize.x(), (int) renderSize.y(), Color.GREEN);
|
||||
this.compositingV.setPos(renderOrigin);
|
||||
this.compositingV.print(renderSize);
|
||||
this.compositingV.flush();
|
||||
// this.compositingV.setRectangleAsSource((int) renderSize.x(), (int) renderSize.y(), Color.GREEN);
|
||||
// this.compositingV.setPos(renderOrigin);
|
||||
// this.compositingV.print(renderSize);
|
||||
// this.compositingV.flush();
|
||||
/*
|
||||
this.shaperV.setShape(new Vector2f(this.size.x() - paddingVert.x(), 0),
|
||||
new Vector2f(paddingVert.x(), this.size.y()),
|
||||
@ -453,27 +451,27 @@ class Scroll extends Container {
|
||||
float originScrollBar = scrollOffset.x() / (scrollSize.x() - this.size.x() * this.propertyLimit.x());
|
||||
originScrollBar = FMath.avg(0.0f, originScrollBar, 1.0f);
|
||||
originScrollBar *= (this.size.x() - paddingHori.right() - lenScrollBar);
|
||||
|
||||
|
||||
final Vector2f renderOrigin = Vector2f.ZERO;
|
||||
final Vector2f renderSize = new Vector2f(this.size.x() - paddingVert.x(), paddingHori.y());
|
||||
this.compositingH.setRectangleAsSource((int) renderSize.x(), (int) renderSize.y(), Color.GREEN);
|
||||
this.compositingH.setPos(renderOrigin);
|
||||
this.compositingH.print(renderSize);
|
||||
this.compositingH.flush();
|
||||
// this.compositingH.setRectangleAsSource((int) renderSize.x(), (int) renderSize.y(), Color.GREEN);
|
||||
// this.compositingH.setPos(renderOrigin);
|
||||
// this.compositingH.print(renderSize);
|
||||
// this.compositingH.flush();
|
||||
/*
|
||||
this.shaperH.setShape(Vector2f.ZERO, new Vector2f(this.size.x() - paddingVert.x(), paddingHori.y()),
|
||||
new Vector2f(originScrollBar, paddingHori.bottom()), new Vector2f(lenScrollBar, 0));
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void setPropertyHover(final boolean propertyHover) {
|
||||
if (propertyHover == this.propertyHover) {
|
||||
return;
|
||||
}
|
||||
this.propertyHover = propertyHover;
|
||||
}
|
||||
|
||||
|
||||
public void setPropertyLimit(final Vector2f propertyLimit) {
|
||||
final Vector2f tmp = Vector2f.avg(Vector2f.ZERO, propertyLimit, Vector2f.ONE);
|
||||
if (tmp.equals(this.propertyLimit)) {
|
||||
@ -482,7 +480,7 @@ class Scroll extends Container {
|
||||
this.propertyLimit = propertyLimit;
|
||||
onChangePropertyLimit();
|
||||
}
|
||||
|
||||
|
||||
public void setPropertyShapeHori(final Uri value) {
|
||||
if (this.propertyShapeHori.equals(value)) {
|
||||
return;
|
||||
@ -490,7 +488,7 @@ class Scroll extends Container {
|
||||
this.propertyShapeHori = value;
|
||||
onChangePropertyShapeHori();
|
||||
}
|
||||
|
||||
|
||||
public void setPropertyShapeVert(final Uri value) {
|
||||
if (this.propertyShapeVert.equals(value)) {
|
||||
return;
|
||||
@ -498,7 +496,7 @@ class Scroll extends Container {
|
||||
this.propertyShapeVert = value;
|
||||
onChangePropertyShapeVert();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void systemDraw(final DrawProperty displayProp) {
|
||||
if (this.propertyHide) {
|
||||
|
@ -6,13 +6,15 @@ import org.atriasoft.aknot.annotation.AknotManaged;
|
||||
import org.atriasoft.aknot.annotation.AknotName;
|
||||
import org.atriasoft.aknot.annotation.AknotSignal;
|
||||
import org.atriasoft.esignal.Signal;
|
||||
import org.atriasoft.etk.BorderRadius;
|
||||
import org.atriasoft.etk.Color;
|
||||
import org.atriasoft.etk.Dimension1f;
|
||||
import org.atriasoft.etk.Insets;
|
||||
import org.atriasoft.etk.math.FMath;
|
||||
import org.atriasoft.etk.math.Vector2f;
|
||||
import org.atriasoft.etk.math.Vector2i;
|
||||
import org.atriasoft.ewol.Padding;
|
||||
import org.atriasoft.ewol.compositing.CompositingGC;
|
||||
import org.atriasoft.ewol.compositing.CompositingSVG;
|
||||
import org.atriasoft.ewol.event.EventInput;
|
||||
import org.atriasoft.gale.key.KeyStatus;
|
||||
import org.slf4j.Logger;
|
||||
@ -31,7 +33,6 @@ public class Slider extends Widget {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(Slider.class);
|
||||
|
||||
private Float propertyValue = 0.0f; //!< string that must be displayed
|
||||
protected CompositingSVG compositing = new CompositingSVG();
|
||||
@AknotSignal
|
||||
@AknotName("value")
|
||||
@AknotDescription("Tick value change")
|
||||
@ -56,6 +57,8 @@ public class Slider extends Widget {
|
||||
private final Color textColorBg = Color.BLACK.withA(0x3F); //!< Background color
|
||||
|
||||
CompositingGC vectorialDraw = new CompositingGC(); //!< drawing tool.
|
||||
|
||||
private final Dimension1f propertyLineWidth = new Dimension1f(20);
|
||||
|
||||
public Slider() {
|
||||
this.propertyCanFocus = true;
|
||||
@ -168,7 +171,7 @@ public class Slider extends Widget {
|
||||
|
||||
@Override
|
||||
public void onDraw() {
|
||||
this.compositing.draw();
|
||||
this.vectorialDraw.draw();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -234,48 +237,35 @@ public class Slider extends Widget {
|
||||
@Override
|
||||
public void onRegenerateDisplay() {
|
||||
if (!needRedraw()) {
|
||||
return;
|
||||
//return;
|
||||
}
|
||||
//LOGGER.trace("Regenerate Display ==> is needed: '" + this.propertyValue + "'");
|
||||
this.compositing.clear();
|
||||
//this.gc.clear();
|
||||
/*
|
||||
if (this.colorIdTextFg >= 0) {
|
||||
//this.text.setDefaultColorFg(this.shape.getColor(this.colorIdTextFg));
|
||||
//this.text.setDefaultColorBg(this.shape.getColor(this.colorIdTextBg));
|
||||
//this.text.setCursorColor(this.shape.getColor(this.colorIdCursor));
|
||||
//this.text.setSelectionColor(this.shape.getColor(this.colorIdSelection));
|
||||
}
|
||||
*/
|
||||
this.vectorialDraw.clear();
|
||||
final Padding padding = Padding.ZERO;//this.shape.getPadding();
|
||||
{
|
||||
// Manage external shape:
|
||||
Vector2f tmpSizeShaper = this.minSize;
|
||||
Vector2f sizeInsideRender = this.minSize;
|
||||
Vector2f delta = this.propertyGravity.gravityGenerateDelta(this.size.less(this.minSize));
|
||||
if (this.propertyFill.x()) {
|
||||
tmpSizeShaper = tmpSizeShaper.withX(this.size.x());
|
||||
sizeInsideRender = sizeInsideRender.withX(this.size.x());
|
||||
delta = delta.withX(0.0f);
|
||||
}
|
||||
if (this.propertyFill.y()) {
|
||||
tmpSizeShaper = tmpSizeShaper.withY(this.size.y());
|
||||
sizeInsideRender = sizeInsideRender.withY(this.size.y());
|
||||
delta = delta.withY(0.0f);
|
||||
}
|
||||
|
||||
Vector2f tmpOriginShaper = delta;
|
||||
Vector2f tmpSizeInside = tmpSizeShaper.less(padding.x(), padding.y());
|
||||
//Vector2f tmpOriginText = this.size.less(tmpSizeText).multiply(0.5f);
|
||||
Vector2f tmpOriginInside = Vector2f.ZERO;
|
||||
// sometimes, the user define an height bigger than the real size needed == > in this case we need to center the text in the shaper ...
|
||||
// fix all the position in the int class:
|
||||
tmpSizeShaper = Vector2f.clipInt(tmpSizeShaper);
|
||||
tmpOriginShaper = Vector2f.clipInt(tmpOriginShaper);
|
||||
tmpSizeInside = Vector2f.clipInt(tmpSizeInside);
|
||||
tmpOriginInside = Vector2f.clipInt(tmpOriginInside);
|
||||
sizeInsideRender = Vector2f.clipInt(sizeInsideRender);
|
||||
tmpOriginShaper = Vector2f
|
||||
.clipInt(tmpOriginShaper.addY(sizeInsideRender.y() * 0.5f - this.propertyLineWidth.size() * 0.5f));
|
||||
|
||||
this.overPositionStart = tmpOriginShaper;
|
||||
this.overPositionSize = tmpSizeShaper;
|
||||
this.overPositionStop = tmpOriginShaper.add(tmpSizeShaper);
|
||||
//this.shape.setShape(0, tmpOriginShaper, tmpSizeShaper, tmpOriginInside, tmpSizeInside);
|
||||
this.overPositionSize = sizeInsideRender.withY(this.propertyLineWidth.size());
|
||||
this.overPositionStop = tmpOriginShaper.add(this.overPositionSize);
|
||||
this.vectorialDraw.setPaintFillColor(this.textColorBg);
|
||||
this.vectorialDraw.addRectangle(this.overPositionStart, this.overPositionStop, new Insets(0),
|
||||
new BorderRadius(this.propertyLineWidth.size() * 0.5f));
|
||||
}
|
||||
{
|
||||
// Manage cursor:
|
||||
@ -287,7 +277,8 @@ public class Slider extends Widget {
|
||||
}
|
||||
|
||||
Vector2f tmpOriginShaper = delta;
|
||||
Vector2f tmpSizeInside = tmpSizeShaper.less(padding.x(), padding.y());
|
||||
Vector2f tmpSizeInside = new Vector2f(this.propertyLineWidth.size() * 2.0f,
|
||||
this.propertyLineWidth.size() * 2.0f);
|
||||
//Vector2f tmpOriginText = this.size.less(tmpSizeText).multiply(0.5f);
|
||||
Vector2f tmpOriginInside = Vector2f.ZERO;
|
||||
|
||||
@ -304,17 +295,11 @@ public class Slider extends Widget {
|
||||
|
||||
this.overCursorPositionStart = tmpOriginShaper;
|
||||
this.overCursorPositionSize = tmpSizeShaper;
|
||||
this.overCursorPositionStop = tmpOriginShaper.add(tmpSizeShaper);
|
||||
//this.shape.setShape(1, tmpOriginShaper, tmpSizeShaper, tmpOriginInside, tmpSizeInside);
|
||||
this.overCursorPositionStop = tmpOriginShaper.add(this.overCursorPositionSize);
|
||||
this.vectorialDraw.addRectangle(this.overCursorPositionStart, this.overCursorPositionStop, new Insets(0),
|
||||
new BorderRadius(this.propertyLineWidth.size() * 2.0f));
|
||||
}
|
||||
LOGGER.error("REQUEST display an immage with size={}x{}", (int) this.overPositionSize.x(),
|
||||
(int) this.overPositionSize.y());
|
||||
this.compositing.setRectangleAsSource((int) this.overPositionSize.x(), (int) this.overPositionSize.y(),
|
||||
Color.GREEN);
|
||||
// TODO: Refaire le design de cet affichage...
|
||||
this.compositing.setPos(this.overPositionStart);
|
||||
this.compositing.print(new Vector2f(this.overPositionSize.x(), this.overPositionSize.y()));
|
||||
this.compositing.flush();
|
||||
this.vectorialDraw.flush();
|
||||
|
||||
}
|
||||
|
||||
|
@ -53,7 +53,6 @@ public class Tick extends Box {
|
||||
/// Periodic call handle to remove it when needed
|
||||
protected Connection periodicConnectionHanble = new Connection();
|
||||
|
||||
private final Uri propertyConfig = new Uri("THEME", "shape/Tick.json", "ewol");
|
||||
private final Uri uriCheckGreen = new Uri("THEME", "CheckBoxCrossRed.svg", "ewol");
|
||||
|
||||
private Boolean propertyValue = false; //!< string that must be displayed
|
||||
@ -74,9 +73,6 @@ public class Tick extends Box {
|
||||
@AknotName("value")
|
||||
@AknotDescription("Tick value change")
|
||||
public Signal<Boolean> signalValue = new Signal<>();
|
||||
// element over:
|
||||
Vector2f overPositionStart = Vector2f.ZERO;
|
||||
Vector2f overPositionStop = Vector2f.ZERO;
|
||||
|
||||
private boolean isDown;
|
||||
|
||||
@ -153,14 +149,10 @@ public class Tick extends Box {
|
||||
@Override
|
||||
protected void onDraw() {
|
||||
super.onDraw();
|
||||
if (this.propertyValue) {
|
||||
if (this.compositingTick != null) {
|
||||
this.compositingTick.draw(true);
|
||||
}
|
||||
//if (this.propertyValue) {
|
||||
if (this.compositingTick != null && this.propertyValue) {
|
||||
this.compositingTick.draw(true);
|
||||
}
|
||||
// if (this.shape != null) {
|
||||
// this.shape.draw(true, this.propertyValue ? 0 : 1);
|
||||
// }
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -227,13 +219,19 @@ public class Tick extends Box {
|
||||
|
||||
@Override
|
||||
public void onRegenerateDisplay() {
|
||||
super.onRegenerateDisplay();
|
||||
if (!needRedraw()) {
|
||||
//return;
|
||||
}
|
||||
this.compositingTick.setSource(Uri.getAllDataString(this.uriCheckGreen));//, this.overPositionStart.less(4));
|
||||
regenerateDisplay();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void regenerateDisplay() {
|
||||
super.regenerateDisplay();
|
||||
final Vector2f size = this.overPositionStop.less(this.overPositionStart);
|
||||
this.compositingTick.setSource(Uri.getAllDataString(this.uriCheckGreen), size.toVector2i());
|
||||
this.compositingTick.setPos(this.overPositionStart.add(2));
|
||||
this.compositingTick.print(this.overPositionStop.less(this.overPositionStart).less(4));
|
||||
this.compositingTick.print(size.less(4));
|
||||
this.compositingTick.flush();
|
||||
}
|
||||
|
||||
|
@ -20,9 +20,9 @@ import org.atriasoft.etk.Dimension2f;
|
||||
import org.atriasoft.etk.Distance;
|
||||
import org.atriasoft.etk.math.FMath;
|
||||
import org.atriasoft.etk.math.Matrix4f;
|
||||
import org.atriasoft.etk.math.Vector2i;
|
||||
import org.atriasoft.etk.math.Vector2b;
|
||||
import org.atriasoft.etk.math.Vector2f;
|
||||
import org.atriasoft.etk.math.Vector2i;
|
||||
import org.atriasoft.etk.math.Vector3f;
|
||||
import org.atriasoft.ewol.DrawProperty;
|
||||
import org.atriasoft.ewol.Gravity;
|
||||
@ -57,26 +57,26 @@ public class Widget extends EwolObject {
|
||||
// ----------------------------------------------------------------------------------------------------------------
|
||||
private boolean allowRepeatKeyboardEvent = true; //!< This remove the repeating keybord event due to the ant pressing key.
|
||||
private Cursor cursorDisplay = Cursor.arrow;
|
||||
|
||||
|
||||
private final CompositingDrawing drawDebugBorder = null;//new CompositingDrawing(); //!< Compositing drawing element
|
||||
|
||||
|
||||
// grab cursor mode
|
||||
private boolean grabCursor = false;
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------------------------------------------
|
||||
// -- focus Area
|
||||
// ----------------------------------------------------------------------------------------------------------------
|
||||
private boolean hasFocus = false; //!< set the focus on this widget
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------------------------------------------
|
||||
// -- Mouse event properties Area
|
||||
// ----------------------------------------------------------------------------------------------------------------
|
||||
private int limitMouseEvent = 3; //!< this is to limit the number of mouse event that the widget can supported
|
||||
|
||||
|
||||
private final List<EventShortCut> localShortcut = new ArrayList<>(); //!< list of all shortcut in the widget
|
||||
|
||||
|
||||
protected Vector2f maxSize = Vector2f.MAX_VALUE; //!< internal: maximum size of the widget
|
||||
|
||||
|
||||
protected Vector2f minSize = Vector2f.ZERO; //!< internal: minimum size of the widget
|
||||
// ----------------------------------------------------------------------------------------------------------------
|
||||
// -- drawing : All drawing must be done in 2 separate buffer 1 for the current display and 1 for the working...
|
||||
@ -92,28 +92,28 @@ public class Widget extends EwolObject {
|
||||
protected boolean propertyHide = false; //!< hide a widget on the display
|
||||
protected Dimension2f propertyMaxSize = new Dimension2f(Vector2f.MAX_VALUE, Distance.PIXEL); //!< user define the maximum size of the widget
|
||||
protected Dimension2f propertyMinSize = new Dimension2f(Vector2f.ZERO, Distance.PIXEL); //!< user define the minimum size of the widget
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------------------------------------------
|
||||
// -- Shortcut : management of the shortcut
|
||||
// ----------------------------------------------------------------------------------------------------------------
|
||||
@AknotSignal
|
||||
@AknotName("shortcut")
|
||||
public Signal<String> signalShortcut; //!< signal handle of the message
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------------------------------------------
|
||||
// -- Widget size:
|
||||
// ----------------------------------------------------------------------------------------------------------------
|
||||
protected Vector2f size = Vector2f.VALUE_16; //!< internal: current size of the widget
|
||||
|
||||
|
||||
// internal element calculated by the system
|
||||
protected float zoom = 1.0f; //!< generic widget zoom
|
||||
|
||||
|
||||
/**
|
||||
* Constructor of the widget classes
|
||||
* @return (no exception generated (not managed in embedded platform))
|
||||
*/
|
||||
public Widget() {}
|
||||
|
||||
|
||||
/**
|
||||
* calculate the minimum and maximum size (need to estimate expend properties of the widget)
|
||||
* @note : INTERNAL EWOL SYSTEM
|
||||
@ -121,16 +121,16 @@ public class Widget extends EwolObject {
|
||||
public void calculateMinMaxSize() {
|
||||
calculateMinMaxSizeWidget();
|
||||
}
|
||||
|
||||
|
||||
protected void calculateMinMaxSizeWidget() {
|
||||
this.minSize = this.propertyMinSize.getPixel();
|
||||
//LOGGER.error("[" + getId() + "] convert in min size : " + propertyMinSize + " out=" + this.minSize);
|
||||
this.maxSize = this.propertyMaxSize.getPixel();
|
||||
markToRedraw();
|
||||
}
|
||||
|
||||
|
||||
public void calculateSize() {}
|
||||
|
||||
|
||||
/**
|
||||
* get the expend capabilities (xy)
|
||||
* @return 2D boolean represents the capacity to expend
|
||||
@ -142,7 +142,7 @@ public class Widget extends EwolObject {
|
||||
}
|
||||
return Vector2b.FALSE;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* get the expend if free capabilities (xy)
|
||||
* @return 2D boolean represents the capacity to expend (if some free space is available)
|
||||
@ -154,7 +154,7 @@ public class Widget extends EwolObject {
|
||||
}
|
||||
return Vector2b.FALSE;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* get the filling capabilities xy
|
||||
* @return Vector2b repensent the capacity to xy filling
|
||||
@ -163,15 +163,15 @@ public class Widget extends EwolObject {
|
||||
public Vector2b canFill() {
|
||||
return this.propertyFill;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Change Zoom property.
|
||||
* @param range Range of the zoom change.
|
||||
*/
|
||||
void changeZoom(final float range) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check if the current max size is compatible with the user maximum size
|
||||
* If it is not the user maximum size will overWrite the maximum size set.
|
||||
@ -181,7 +181,7 @@ public class Widget extends EwolObject {
|
||||
final Vector2f pixelSize = this.propertyMaxSize.getPixel();
|
||||
this.maxSize = Vector2f.min(this.maxSize, pixelSize);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check if the current min size is compatible with the user minimum size
|
||||
* If it is not the user minimum size will overWrite the minimum size set.
|
||||
@ -191,7 +191,7 @@ public class Widget extends EwolObject {
|
||||
final Vector2f pixelSize = this.propertyMinSize.getPixel();
|
||||
this.minSize = Vector2f.max(this.minSize, pixelSize);
|
||||
}
|
||||
|
||||
|
||||
public void drawWidgetTree(final int level) {
|
||||
final StringBuilder space = new StringBuilder();
|
||||
for (int iii = 0; iii < level; ++iii) {
|
||||
@ -201,7 +201,7 @@ public class Widget extends EwolObject {
|
||||
.append(getClass().getCanonicalName()).append(" o=").append(this.origin).append(" s=")
|
||||
.append(this.size).append(" hide=").append(this.propertyHide).toString());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* get the widget maximum size calculated
|
||||
* @return Requested size
|
||||
@ -213,7 +213,7 @@ public class Widget extends EwolObject {
|
||||
}
|
||||
return Vector2f.MAX_VALUE;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* get the widget minimum size calculated
|
||||
* @return Requested size
|
||||
@ -225,7 +225,7 @@ public class Widget extends EwolObject {
|
||||
}
|
||||
return Vector2f.ZERO;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* get the current cursor.
|
||||
* @return the type of the cursor.
|
||||
@ -233,7 +233,7 @@ public class Widget extends EwolObject {
|
||||
public Cursor getCursor() {
|
||||
return this.cursorDisplay;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* get the grabbing status of the cursor.
|
||||
* @return true if the cursor is currently grabbed
|
||||
@ -241,7 +241,7 @@ public class Widget extends EwolObject {
|
||||
public boolean getGrabStatus() {
|
||||
return this.grabCursor;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* get the keyboard repeating event supporting.
|
||||
* @return true : the event can be repeated.
|
||||
@ -250,7 +250,7 @@ public class Widget extends EwolObject {
|
||||
public boolean getKeyboardRepeat() {
|
||||
return this.allowRepeatKeyboardEvent;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* get the number of mouse event supported
|
||||
* @return return the number of event that the mouse supported [0..3]
|
||||
@ -258,7 +258,7 @@ public class Widget extends EwolObject {
|
||||
public int getMouseLimit() {
|
||||
return this.limitMouseEvent;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* get the offset property of the widget.
|
||||
* @return The current offset value.
|
||||
@ -266,7 +266,7 @@ public class Widget extends EwolObject {
|
||||
Vector2f getOffset() {
|
||||
return this.offset;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the origin (absolute position in the windows).
|
||||
* @return Coordinate of the origin requested.
|
||||
@ -274,7 +274,7 @@ public class Widget extends EwolObject {
|
||||
public Vector2f getOrigin() {
|
||||
return this.origin;
|
||||
}
|
||||
|
||||
|
||||
@AknotManaged
|
||||
@AknotAttribute
|
||||
@AknotName("focus")
|
||||
@ -282,7 +282,7 @@ public class Widget extends EwolObject {
|
||||
public boolean getPropertyCanFocus() {
|
||||
return this.propertyCanFocus;
|
||||
}
|
||||
|
||||
|
||||
@AknotManaged
|
||||
@AknotAttribute
|
||||
@AknotName("expand")
|
||||
@ -290,7 +290,7 @@ public class Widget extends EwolObject {
|
||||
public Vector2b getPropertyExpand() {
|
||||
return this.propertyExpand;
|
||||
}
|
||||
|
||||
|
||||
@AknotManaged
|
||||
@AknotAttribute
|
||||
@AknotName("expand-free")
|
||||
@ -298,7 +298,7 @@ public class Widget extends EwolObject {
|
||||
public Vector2b getPropertyExpandIfFree() {
|
||||
return this.propertyExpandIfFree;
|
||||
}
|
||||
|
||||
|
||||
@AknotManaged
|
||||
@AknotAttribute
|
||||
@AknotName("fill")
|
||||
@ -306,7 +306,7 @@ public class Widget extends EwolObject {
|
||||
public Vector2b getPropertyFill() {
|
||||
return this.propertyFill;
|
||||
}
|
||||
|
||||
|
||||
@AknotManaged
|
||||
@AknotAttribute
|
||||
@AknotName("gravity")
|
||||
@ -314,7 +314,7 @@ public class Widget extends EwolObject {
|
||||
public Gravity getPropertyGravity() {
|
||||
return this.propertyGravity;
|
||||
}
|
||||
|
||||
|
||||
@AknotManaged
|
||||
@AknotAttribute
|
||||
@AknotName("hide")
|
||||
@ -322,7 +322,7 @@ public class Widget extends EwolObject {
|
||||
public boolean getPropertyHide() {
|
||||
return this.propertyHide;
|
||||
}
|
||||
|
||||
|
||||
@AknotManaged
|
||||
@AknotAttribute
|
||||
@AknotName("max-size")
|
||||
@ -330,7 +330,7 @@ public class Widget extends EwolObject {
|
||||
public Dimension2f getPropertyMaxSize() {
|
||||
return this.propertyMaxSize;
|
||||
}
|
||||
|
||||
|
||||
@AknotManaged
|
||||
@AknotAttribute
|
||||
@AknotName("min-size")
|
||||
@ -338,7 +338,7 @@ public class Widget extends EwolObject {
|
||||
public Dimension2f getPropertyMinSize() {
|
||||
return this.propertyMinSize;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* get the widget size
|
||||
* @return Requested size
|
||||
@ -350,7 +350,7 @@ public class Widget extends EwolObject {
|
||||
}
|
||||
return Vector2f.ZERO;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* get the widget at the specific windows absolute position
|
||||
* @param pos gAbsolute position of the requested widget knowledge
|
||||
@ -364,21 +364,21 @@ public class Widget extends EwolObject {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the current Widget Manager.
|
||||
*/
|
||||
public WidgetManager getWidgetManager() {
|
||||
return EwolObject.getContext().getWidgetManager();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the current Windows.
|
||||
*/
|
||||
public Windows getWindows() {
|
||||
return EwolObject.getContext().getWindows();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* get the zoom property of the widget
|
||||
* @return the current zoom value
|
||||
@ -386,7 +386,7 @@ public class Widget extends EwolObject {
|
||||
public float getZoom() {
|
||||
return this.zoom;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Grab the cursor : This get all the movement of the mouse in PC mode, and generate an offset instead of a position.
|
||||
* @note : the generation of the offset is due to the fact the cursor position is forced at the center of the widget.
|
||||
@ -398,14 +398,14 @@ public class Widget extends EwolObject {
|
||||
this.grabCursor = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Hide the keyboard (if needed)
|
||||
*/
|
||||
protected void hideKeyboard() {
|
||||
EwolObject.getContext().keyboardHide();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* get the focus state of the widget
|
||||
* @return focus state
|
||||
@ -413,14 +413,14 @@ public class Widget extends EwolObject {
|
||||
public boolean isFocused() {
|
||||
return this.hasFocus;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* keep the focus on this widget == > this remove the previous focus on all other widget
|
||||
*/
|
||||
public void keepFocus() {
|
||||
getWidgetManager().focusKeep(this);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The widget mark itself that it need to regenerate the nest time.
|
||||
*/
|
||||
@ -431,7 +431,7 @@ public class Widget extends EwolObject {
|
||||
this.needRegenerateDisplay = true;
|
||||
getWidgetManager().markDrawingIsNeeded();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* get the need of the redrawing of the widget and reset it to false
|
||||
* @return true if we need to redraw
|
||||
@ -442,7 +442,7 @@ public class Widget extends EwolObject {
|
||||
this.needRegenerateDisplay = false;
|
||||
return tmpData;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Parent have set the size and the origin. The container need to update the child widget property
|
||||
* @note INTERNAL EWOL SYSTEM
|
||||
@ -451,19 +451,19 @@ public class Widget extends EwolObject {
|
||||
LOGGER.trace("[" + getId() + "] {" + getClass().getCanonicalName() + "} update size : " + this.size);
|
||||
markToRedraw();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Common widget drawing function (called by the drawing thread [Android, X11, ...])
|
||||
*/
|
||||
protected void onDraw() {}
|
||||
|
||||
|
||||
/**
|
||||
* Event on a past event == > this event is asynchronous due to all system does not support direct getting data.
|
||||
* @note : need to have focus ...
|
||||
* @param clipboardID Mode of data requested
|
||||
*/
|
||||
public void onEventClipboard(final ClipboardList clipboardID) {}
|
||||
|
||||
|
||||
/**
|
||||
* Entry event.
|
||||
* represent the physical event :
|
||||
@ -477,7 +477,7 @@ public class Widget extends EwolObject {
|
||||
protected boolean onEventEntry(final EventEntry event) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Event on an input of this Widget (finger, mouse, stylet)
|
||||
* @param event Event properties
|
||||
@ -487,7 +487,7 @@ public class Widget extends EwolObject {
|
||||
protected boolean onEventInput(final EventInput event) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Event on a short-cut of this Widget (in case of return false, the event on the keyevent will arrive in the function @ref onEventKb).
|
||||
* @param special All the special kay pressed at this time.
|
||||
@ -541,19 +541,19 @@ public class Widget extends EwolObject {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Event of the focus has been grabed by the current widget
|
||||
*/
|
||||
protected void onGetFocus() {}
|
||||
|
||||
|
||||
/**
|
||||
* Event of the focus has been lost by the current widget
|
||||
*/
|
||||
protected void onLostFocus() {}
|
||||
|
||||
|
||||
protected void onRegenerateDisplay() {}
|
||||
|
||||
|
||||
protected void onUpdateMinMaxSize() {
|
||||
final Vector2f pixelMin = this.propertyMinSize.getPixel();
|
||||
final Vector2f pixelMax = this.propertyMaxSize.getPixel();
|
||||
@ -564,7 +564,7 @@ public class Widget extends EwolObject {
|
||||
}
|
||||
requestUpdateSize();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Convert the absolute position in the local Position (Relative)
|
||||
* @param pos Absolute position that you request conversion.
|
||||
@ -573,14 +573,14 @@ public class Widget extends EwolObject {
|
||||
public Vector2f relativePosition(final Vector2f pos) {
|
||||
return pos.less(this.origin);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Need to be call When the size of the current widget have change ==> this force the system to recalculate all the widget positions.
|
||||
*/
|
||||
public void requestUpdateSize() {
|
||||
EwolObject.getContext().requestUpdateSize();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* remove the focus on this widget
|
||||
* @return return true if the widget have release his focus (if he has it)
|
||||
@ -595,7 +595,7 @@ public class Widget extends EwolObject {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* set the cursor display type.
|
||||
* @param newCursor selected new cursor.
|
||||
@ -605,7 +605,7 @@ public class Widget extends EwolObject {
|
||||
this.cursorDisplay = newCursor;
|
||||
EwolObject.getContext().setCursor(this.cursorDisplay);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* set focus on this widget
|
||||
* @return return true if the widget keep the focus
|
||||
@ -624,7 +624,7 @@ public class Widget extends EwolObject {
|
||||
LOGGER.trace("set focus (stop) ret false");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* set the keyboard repeating event supporting.
|
||||
* @param state The repeating status (true: enable, false disable).
|
||||
@ -632,7 +632,7 @@ public class Widget extends EwolObject {
|
||||
protected void setKeyboardRepeat(final boolean state) {
|
||||
this.allowRepeatKeyboardEvent = state;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* get the number of mouse event supported
|
||||
* @param numberState The number of event that the mouse supported [0..3]
|
||||
@ -640,21 +640,21 @@ public class Widget extends EwolObject {
|
||||
public void setMouseLimit(final int numberState) {
|
||||
this.limitMouseEvent = numberState;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* User set No maximum size.
|
||||
*/
|
||||
public void setNoMaxSize() {
|
||||
setPropertyMaxSize(new Dimension2f(Vector2f.MAX_VALUE, Distance.PIXEL));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* User set No minimum size.
|
||||
*/
|
||||
public void setNoMinSize() {
|
||||
setPropertyMinSize(new Dimension2f(Vector2f.ZERO, Distance.PIXEL));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* set the zoom property of the widget.
|
||||
* @param newVal offset value.
|
||||
@ -666,7 +666,7 @@ public class Widget extends EwolObject {
|
||||
markToRedraw();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set origin at the widget (must be an parent widget that set this parameter).
|
||||
* This represent the absolute origin in the program windows.
|
||||
@ -676,7 +676,7 @@ public class Widget extends EwolObject {
|
||||
public void setOrigin(final Vector2f pos) {
|
||||
this.origin = pos;
|
||||
}
|
||||
|
||||
|
||||
public void setPropertyCanFocus(final boolean canFocus) {
|
||||
if (this.propertyCanFocus == canFocus) {
|
||||
return;
|
||||
@ -689,7 +689,7 @@ public class Widget extends EwolObject {
|
||||
rmFocus();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void setPropertyExpand(final Vector2b value) {
|
||||
if (this.propertyExpand.equals(value)) {
|
||||
return;
|
||||
@ -698,7 +698,7 @@ public class Widget extends EwolObject {
|
||||
markToRedraw();
|
||||
requestUpdateSize();
|
||||
}
|
||||
|
||||
|
||||
public void setPropertyExpandIfFree(final Vector2b value) {
|
||||
if (this.propertyExpandIfFree.equals(value)) {
|
||||
return;
|
||||
@ -707,7 +707,7 @@ public class Widget extends EwolObject {
|
||||
markToRedraw();
|
||||
requestUpdateSize();
|
||||
}
|
||||
|
||||
|
||||
public void setPropertyFill(final Vector2b value) {
|
||||
if (this.propertyFill.equals(value)) {
|
||||
return;
|
||||
@ -716,7 +716,7 @@ public class Widget extends EwolObject {
|
||||
markToRedraw();
|
||||
requestUpdateSize();
|
||||
}
|
||||
|
||||
|
||||
public void setPropertyGravity(final Gravity gravity) {
|
||||
if (this.propertyGravity.equals(gravity)) {
|
||||
return;
|
||||
@ -725,7 +725,7 @@ public class Widget extends EwolObject {
|
||||
markToRedraw();
|
||||
requestUpdateSize();
|
||||
}
|
||||
|
||||
|
||||
public void setPropertyHide(final boolean value) {
|
||||
if (this.propertyHide == value) {
|
||||
return;
|
||||
@ -734,7 +734,7 @@ public class Widget extends EwolObject {
|
||||
markToRedraw();
|
||||
requestUpdateSize();
|
||||
}
|
||||
|
||||
|
||||
public void setPropertyMaxSize(final Dimension2f value) {
|
||||
if (this.propertyMaxSize.equals(value)) {
|
||||
return;
|
||||
@ -742,7 +742,7 @@ public class Widget extends EwolObject {
|
||||
this.propertyMaxSize = value;
|
||||
onUpdateMinMaxSize();
|
||||
}
|
||||
|
||||
|
||||
public void setPropertyMinSize(final Dimension2f value) {
|
||||
if (this.propertyMinSize.equals(value)) {
|
||||
return;
|
||||
@ -750,7 +750,7 @@ public class Widget extends EwolObject {
|
||||
this.propertyMinSize = value;
|
||||
onUpdateMinMaxSize();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* set the widget size
|
||||
* @return Requested size
|
||||
@ -762,7 +762,7 @@ public class Widget extends EwolObject {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* set the zoom property of the widget
|
||||
* @param newVal newZoom value
|
||||
@ -774,7 +774,7 @@ public class Widget extends EwolObject {
|
||||
this.zoom = FMath.avg(0.0000001f, newVal, 1000000.0f);
|
||||
markToRedraw();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* add a specific shortcut with his description
|
||||
* @param descriptiveString Description string of the shortcut
|
||||
@ -782,7 +782,7 @@ public class Widget extends EwolObject {
|
||||
protected void shortCutAdd(final String descriptiveString) {
|
||||
shortCutAdd(descriptiveString, "");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* add a specific shortcut with his description
|
||||
* @param descriptiveString Description string of the shortcut
|
||||
@ -876,14 +876,14 @@ public class Widget extends EwolObject {
|
||||
// add it on the List ...
|
||||
this.localShortcut.add(new EventShortCut(message, specialKey, unicodeValue, keyboardMoveValue, true));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* remove all current shortCut
|
||||
*/
|
||||
protected void shortCutClean() {
|
||||
this.localShortcut.clear();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* remove a specific shortCut with his event name
|
||||
* @param message generated event name
|
||||
@ -891,14 +891,14 @@ public class Widget extends EwolObject {
|
||||
protected void shortCutRemove(final String message) {
|
||||
this.localShortcut.removeIf(eventShortCut -> eventShortCut.message().contentEquals(message));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* display the keyboard (if needed)
|
||||
*/
|
||||
protected void showKeyboard() {
|
||||
EwolObject.getContext().keyboardShow();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {SYSTEM} extern interface to request a draw ... (called by the drawing thread [Android, X11, ...])
|
||||
* This function generate a clipping with the view-port openGL system. Like this a widget draw can not draw over an other widget
|
||||
@ -934,7 +934,7 @@ public class Widget extends EwolObject {
|
||||
public void systemDraw(final DrawProperty displayProp) {
|
||||
systemDrawWidget(displayProp);
|
||||
}
|
||||
|
||||
|
||||
protected void systemDrawWidget(final DrawProperty displayProp) {
|
||||
//LOGGER.info("[" + getId() + "] Draw : [" + propertyName + "] t=" + getObjectType() + " o=" + this.origin + " s=" << this.size << " hide=" << propertyHide);
|
||||
if (this.propertyHide) {
|
||||
@ -942,13 +942,13 @@ public class Widget extends EwolObject {
|
||||
return;
|
||||
}
|
||||
final Vector2f displayOrigin = this.origin.add(this.offset);
|
||||
|
||||
|
||||
// check if the element is displayable in the windows :
|
||||
if (displayProp.windowsSize().x() < this.origin.x() || displayProp.windowsSize().y() < this.origin.y()) {
|
||||
// out of the windows == > nothing to display ...
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
final DrawProperty tmpSize = displayProp.withLimit(this.origin, this.size);
|
||||
if (tmpSize.size().x() <= 0 || tmpSize.size().y() <= 0) {
|
||||
return;
|
||||
@ -971,7 +971,7 @@ public class Widget extends EwolObject {
|
||||
final Matrix4f tmpProjection = Matrix4f.createMatrixOrtho(-tmpSize.size().x() / 2, tmpSize.size().x() / 2,
|
||||
-tmpSize.size().y() / 2, tmpSize.size().y() / 2, -500, 500);
|
||||
//Matrix4f tmpMat = tmpProjection.multiply(tmpScale).multiply(tmpTranslate);
|
||||
|
||||
|
||||
OpenGL.push();
|
||||
// set internal matrix system :
|
||||
//OpenGL.setMatrix(tmpMat);
|
||||
@ -985,7 +985,7 @@ public class Widget extends EwolObject {
|
||||
OpenGL.pop();
|
||||
GL11.glFinish();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {SYSTEM} Entry event (only meta widget might overwrite this function).
|
||||
* @param event Event properties
|
||||
@ -1000,7 +1000,7 @@ public class Widget extends EwolObject {
|
||||
}
|
||||
return onEventEntry(event.event());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {SYSTEM} system event input (only meta widget might overwrite this function).
|
||||
* @param event Event properties
|
||||
@ -1018,7 +1018,7 @@ public class Widget extends EwolObject {
|
||||
}
|
||||
return onEventInput(event.event());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Event generated when a redraw is needed
|
||||
*/
|
||||
@ -1044,7 +1044,7 @@ public class Widget extends EwolObject {
|
||||
}
|
||||
onRegenerateDisplay();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Un-Grab the cursor (default mode cursor offset)
|
||||
*/
|
||||
|
@ -4,12 +4,10 @@ import org.atriasoft.aknot.annotation.AknotAttribute;
|
||||
import org.atriasoft.aknot.annotation.AknotDescription;
|
||||
import org.atriasoft.aknot.annotation.AknotManaged;
|
||||
import org.atriasoft.aknot.annotation.AknotName;
|
||||
import org.atriasoft.etk.Color;
|
||||
import org.atriasoft.etk.Uri;
|
||||
import org.atriasoft.etk.math.FMath;
|
||||
import org.atriasoft.etk.math.Matrix4f;
|
||||
import org.atriasoft.etk.math.Vector2f;
|
||||
import org.atriasoft.etk.math.Vector2f;
|
||||
import org.atriasoft.ewol.DrawProperty;
|
||||
import org.atriasoft.ewol.HighSpeedMode;
|
||||
import org.atriasoft.ewol.Padding;
|
||||
@ -26,17 +24,17 @@ import org.slf4j.LoggerFactory;
|
||||
*/
|
||||
class WidgetScrolled extends Widget {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(WidgetScrolled.class);
|
||||
|
||||
|
||||
public enum ScrollingMode {
|
||||
scroolModeNormal, //!< No Zoom , can UP and down, left and right
|
||||
scroolModeCenter, //!< Zoom enable, no move left and right
|
||||
scroolModeGame, //!< Zoom enable, no move left and right
|
||||
}
|
||||
|
||||
|
||||
public static final int CALCULATE_SIMULTANEOUS_FINGER = 5;
|
||||
protected Uri propertyShapeVert = new Uri("THEME", "shape/WidgetScrolled.json", "ewol"); //!< Vertical shaper name
|
||||
protected Uri propertyShapeHori = new Uri("THEME", "shape/WidgetScrolled.json", "ewol"); //!< Horizontal shaper name
|
||||
|
||||
|
||||
protected CompositingSVG compositingH = new CompositingSVG();
|
||||
protected CompositingSVG compositingV = new CompositingSVG();
|
||||
protected Vector2f originScrooled = Vector2f.ZERO; //!< pixel distance from the origin of the display (Bottum left)
|
||||
@ -54,7 +52,7 @@ class WidgetScrolled extends Widget {
|
||||
private final boolean[] fingerPresent = { false, false, false, false, false };
|
||||
private boolean fingerScoolActivated = false;
|
||||
private final Vector2f[] fingerMoveStartPos = new Vector2f[CALCULATE_SIMULTANEOUS_FINGER];
|
||||
|
||||
|
||||
/**
|
||||
* Scroll Widget main constructor to be inherited from an other widget (this is not a stand-alone widget)
|
||||
* @param _shaperName Shaper name if the scrolled widget.
|
||||
@ -63,7 +61,7 @@ class WidgetScrolled extends Widget {
|
||||
onChangePropertyShapeVert();
|
||||
onChangePropertyShapeHori();
|
||||
}
|
||||
|
||||
|
||||
@AknotManaged
|
||||
@AknotAttribute
|
||||
@AknotName("shape-hori")
|
||||
@ -71,7 +69,7 @@ class WidgetScrolled extends Widget {
|
||||
public Uri getPropertyShapeHori() {
|
||||
return this.propertyShapeHori;
|
||||
}
|
||||
|
||||
|
||||
@AknotManaged
|
||||
@AknotAttribute
|
||||
@AknotName("shape-vert")
|
||||
@ -79,7 +77,7 @@ class WidgetScrolled extends Widget {
|
||||
public Uri getPropertyShapeVert() {
|
||||
return this.propertyShapeVert;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the single finger capabilities
|
||||
* @return true The single finger mode is active
|
||||
@ -88,7 +86,7 @@ class WidgetScrolled extends Widget {
|
||||
public boolean getSingleFinger() {
|
||||
return this.singleFingerMode;
|
||||
}
|
||||
|
||||
|
||||
protected void onChangePropertyShapeHori() {
|
||||
// if (this.shaperH == null) {
|
||||
// this.shaperH = new GuiShape(this.propertyShapeHori);
|
||||
@ -97,7 +95,7 @@ class WidgetScrolled extends Widget {
|
||||
// }
|
||||
markToRedraw();
|
||||
}
|
||||
|
||||
|
||||
protected void onChangePropertyShapeVert() {
|
||||
// if (this.shaperV == null) {
|
||||
// this.shaperV = new GuiShape(this.propertyShapeVert);
|
||||
@ -106,13 +104,13 @@ class WidgetScrolled extends Widget {
|
||||
// }
|
||||
markToRedraw();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onDraw() {
|
||||
this.compositingH.draw();
|
||||
this.compositingV.draw();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onEventInput(final EventInput event) {
|
||||
LOGGER.trace("event XXX {}", event);
|
||||
@ -436,13 +434,13 @@ class WidgetScrolled extends Widget {
|
||||
}
|
||||
}
|
||||
} else if (this.scroollingMode == ScrollingMode.scroolModeGame) {
|
||||
|
||||
|
||||
} else {
|
||||
LOGGER.error("Scrolling mode unknow ... " + this.scroollingMode);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onRegenerateDisplay() {
|
||||
this.compositingH.clear();
|
||||
@ -460,14 +458,14 @@ class WidgetScrolled extends Widget {
|
||||
/ (this.maxSize.y() - this.size.y() * this.limitScrolling.y());
|
||||
originScrollBar = FMath.avg(0.0f, originScrollBar, 1.0f);
|
||||
originScrollBar *= (this.size.y() - lenScrollBar);
|
||||
|
||||
|
||||
final Vector2f renderOrigin = new Vector2f(this.size.x() - paddingVert.x(), 0);
|
||||
final Vector2f renderSize = new Vector2f(paddingVert.x(), this.size.y());
|
||||
this.compositingV.setRectangleAsSource((int) renderSize.x(), (int) renderSize.y(), Color.GREEN);
|
||||
this.compositingV.setPos(renderOrigin);
|
||||
this.compositingV.print(renderSize);
|
||||
this.compositingV.flush();
|
||||
|
||||
// this.compositingV.setRectangleAsSource((int) renderSize.x(), (int) renderSize.y(), Color.GREEN);
|
||||
// this.compositingV.setPos(renderOrigin);
|
||||
// this.compositingV.print(renderSize);
|
||||
// this.compositingV.flush();
|
||||
|
||||
// this.shaperV.setShape(new Vector2f(this.size.x() - paddingVert.x(), 0),
|
||||
// new Vector2f(paddingVert.x(), this.size.y()),
|
||||
// new Vector2f(this.size.x() - paddingVert.right(), this.size.y() - originScrollBar - lenScrollBar),
|
||||
@ -481,26 +479,26 @@ class WidgetScrolled extends Widget {
|
||||
/ (this.maxSize.x() - this.size.x() * this.limitScrolling.x());
|
||||
originScrollBar = FMath.avg(0.0f, originScrollBar, 1.0f);
|
||||
originScrollBar *= (this.size.x() - paddingHori.right() - lenScrollBar);
|
||||
|
||||
|
||||
final Vector2f renderOrigin = Vector2f.ZERO;
|
||||
final Vector2f renderSize = new Vector2f(this.size.x() - paddingVert.x(), paddingHori.y());
|
||||
this.compositingH.setRectangleAsSource((int) renderSize.x(), (int) renderSize.y(), Color.GREEN);
|
||||
this.compositingH.setPos(renderOrigin);
|
||||
this.compositingH.print(renderSize);
|
||||
this.compositingH.flush();
|
||||
|
||||
// this.compositingH.setRectangleAsSource((int) renderSize.x(), (int) renderSize.y(), Color.GREEN);
|
||||
// this.compositingH.setPos(renderOrigin);
|
||||
// this.compositingH.print(renderSize);
|
||||
// this.compositingH.flush();
|
||||
//
|
||||
// this.shaperH.setShape(new Vector2f(0, 0), new Vector2f(this.size.x() - paddingVert.x(), paddingHori.y()),
|
||||
// new Vector2f(originScrollBar, paddingHori.bottom()), new Vector2f(lenScrollBar, 0));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Reset the scoll of the subWidget
|
||||
*/
|
||||
public void resetScrollOrigin() {
|
||||
this.originScrooled = new Vector2f(0, 0);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Specify the mode of scrolling for this windows
|
||||
* @param newMode the selected mode for the scrolling...
|
||||
@ -513,7 +511,7 @@ class WidgetScrolled extends Widget {
|
||||
this.zoom = 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* set the scrolling limit when arriving at he end of the widget
|
||||
* @param poucentageLimit pourcent of the limit of view nothing in the widget when arriving at the end ...
|
||||
@ -522,7 +520,7 @@ class WidgetScrolled extends Widget {
|
||||
poucentageLimit = FMath.avg(0.1f, poucentageLimit, 1.0f);
|
||||
this.limitScrolling = new Vector2f(poucentageLimit, poucentageLimit);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* set the scrolling limit when arriving at he end of the widget
|
||||
* @param poucentageLimit pourcent of the limit of view nothing in the widget when arriving at the end for axis specific...
|
||||
@ -531,7 +529,7 @@ class WidgetScrolled extends Widget {
|
||||
this.limitScrolling = new Vector2f(FMath.avg(0.1f, poucentageLimit.x(), 1.0f),
|
||||
FMath.avg(0.1f, poucentageLimit.y(), 1.0f));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* set the specific mawimum size of the widget
|
||||
* @param localSize new Maximum size
|
||||
@ -539,7 +537,7 @@ class WidgetScrolled extends Widget {
|
||||
protected void setMaxSize(final Vector2f localSize) {
|
||||
this.maxSize = localSize;
|
||||
}
|
||||
|
||||
|
||||
public void setPropertyShapeHori(final Uri value) {
|
||||
if (this.propertyShapeHori.equals(value)) {
|
||||
return;
|
||||
@ -547,7 +545,7 @@ class WidgetScrolled extends Widget {
|
||||
this.propertyShapeHori = value;
|
||||
onChangePropertyShapeHori();
|
||||
}
|
||||
|
||||
|
||||
public void setPropertyShapeVert(final Uri value) {
|
||||
if (this.propertyShapeVert.equals(value)) {
|
||||
return;
|
||||
@ -555,7 +553,7 @@ class WidgetScrolled extends Widget {
|
||||
this.propertyShapeVert = value;
|
||||
onChangePropertyShapeVert();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Request a specific position for the scrolling of the current windows.
|
||||
* @param borderWidth size of the border that requested the element might not to be
|
||||
@ -565,7 +563,7 @@ class WidgetScrolled extends Widget {
|
||||
protected void setScrollingPositionDynamic(final Vector2f borderWidth, final Vector2f currentPosition) {
|
||||
setScrollingPositionDynamic(borderWidth, currentPosition, false);
|
||||
}
|
||||
|
||||
|
||||
protected void setScrollingPositionDynamic(
|
||||
Vector2f borderWidth,
|
||||
final Vector2f currentPosition,
|
||||
@ -590,7 +588,7 @@ class WidgetScrolled extends Widget {
|
||||
this.originScrooled = this.originScrooled.withY(FMath.max(0.0f, this.originScrooled.y()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* For mouse event when we have a scrolling UP and dows, specify the number of pixel that we scrooled
|
||||
* @param nbPixel number of pixel scrolling
|
||||
@ -598,7 +596,7 @@ class WidgetScrolled extends Widget {
|
||||
protected void setScrollingSize(final float nbPixel) {
|
||||
this.pixelScrolling = nbPixel;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the single finger capabilities/
|
||||
* @param status True if single inger mode, two otherwise/
|
||||
@ -609,7 +607,7 @@ class WidgetScrolled extends Widget {
|
||||
}
|
||||
this.singleFingerMode = status;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void systemDraw(final DrawProperty displayProp) {
|
||||
OpenGL.push();
|
||||
|
@ -31,11 +31,11 @@ import org.slf4j.LoggerFactory;
|
||||
*/
|
||||
public class Windows extends Widget {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(Windows.class);
|
||||
|
||||
|
||||
protected int colorBg = -1; //!< Default background color of the windows
|
||||
|
||||
|
||||
protected List<Widget> popUpWidgetList = new ArrayList<>();
|
||||
|
||||
|
||||
@AknotManaged
|
||||
@AknotAttribute
|
||||
@AknotName("file-color")
|
||||
@ -46,16 +46,16 @@ public class Windows extends Widget {
|
||||
@AknotName("title")
|
||||
@AknotDescription("Title of the windows")
|
||||
public String propertyTitle = "No title"; //!< Current title of the windows
|
||||
|
||||
protected ResourceColorFile resourceColor = null; //!< theme color property (name of file in @ref propertyColorConfiguration)
|
||||
|
||||
protected Widget subWidget;
|
||||
|
||||
protected ResourceColorFile resourceColor = null; //!< theme color property (name of file in @ref propertyColorConfiguration)
|
||||
|
||||
protected Widget subWidget;
|
||||
|
||||
protected Windows() {
|
||||
this.propertyCanFocus = true;
|
||||
onChangePropertyColor();
|
||||
}
|
||||
|
||||
|
||||
//!< List of pop-up displayed
|
||||
@Override
|
||||
public void drawWidgetTree(int level) {
|
||||
@ -70,15 +70,15 @@ public class Windows extends Widget {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public Uri getPropertyColorConfiguration() {
|
||||
return this.propertyColorConfiguration;
|
||||
}
|
||||
|
||||
|
||||
public String getPropertyTitle() {
|
||||
return this.propertyTitle;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public EwolObject getSubObjectNamed(final String objectName) {
|
||||
EwolObject tmpObject = super.getSubObjectNamed(objectName);
|
||||
@ -104,7 +104,7 @@ public class Windows extends Widget {
|
||||
// not find ...
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Widget getWidgetAtPos(final Vector2f pos) {
|
||||
LOGGER.trace("Get widget at pos : " + pos);
|
||||
@ -121,7 +121,7 @@ public class Windows extends Widget {
|
||||
// otherwise the event go to this widget ...
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
protected void onChangePropertyColor() {
|
||||
this.resourceColor = ResourceColorFile.create(this.propertyColorConfiguration);
|
||||
if (this.resourceColor != null) {
|
||||
@ -131,7 +131,7 @@ public class Windows extends Widget {
|
||||
+ this.propertyColorConfiguration);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onChangeSize() {
|
||||
super.onChangeSize();
|
||||
@ -151,7 +151,7 @@ public class Windows extends Widget {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onRegenerateDisplay() {
|
||||
if (this.subWidget != null) {
|
||||
@ -163,7 +163,7 @@ public class Windows extends Widget {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the number of pop-up
|
||||
* @return Count of pop-up
|
||||
@ -171,7 +171,7 @@ public class Windows extends Widget {
|
||||
public int popUpCount() {
|
||||
return this.popUpWidgetList.size();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Remove the pop-up on top.
|
||||
*/
|
||||
@ -181,7 +181,7 @@ public class Windows extends Widget {
|
||||
}
|
||||
this.popUpWidgetList.remove(this.popUpWidgetList.size() - 1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add a pop-up on the Windows.
|
||||
* @param widget Widget to set on top of the pop-up.
|
||||
@ -201,7 +201,7 @@ public class Windows extends Widget {
|
||||
// TODO : it is dangerous to access directly to the system ...
|
||||
EwolObject.getContext().resetIOEvent();
|
||||
}
|
||||
|
||||
|
||||
//!< main sub-widget of the Windows.
|
||||
@Override
|
||||
public void requestDestroyFromChild(final EwolObject child) {
|
||||
@ -229,7 +229,7 @@ public class Windows extends Widget {
|
||||
markToRedraw();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void setPropertyColorConfiguration(final Uri propertyColorConfiguration) {
|
||||
if (this.propertyColorConfiguration.equals(propertyColorConfiguration)) {
|
||||
return;
|
||||
@ -237,7 +237,7 @@ public class Windows extends Widget {
|
||||
this.propertyColorConfiguration = propertyColorConfiguration;
|
||||
onChangePropertyColor();
|
||||
}
|
||||
|
||||
|
||||
public void setPropertyTitle(final String propertyTitle) {
|
||||
if (this.propertyTitle.contentEquals(propertyTitle)) {
|
||||
return;
|
||||
@ -250,7 +250,7 @@ public class Windows extends Widget {
|
||||
LOGGER.info("Set title is delayed ...");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the main widget of the application.
|
||||
* @param widget Widget to set in the windows.
|
||||
@ -268,7 +268,7 @@ public class Windows extends Widget {
|
||||
// Regenerate the size calculation :
|
||||
onChangeSize();
|
||||
}
|
||||
|
||||
|
||||
public void sysDraw() {
|
||||
//LOGGER.trace("Draw on " + this.size);
|
||||
// set the size of the open GL system
|
||||
@ -281,11 +281,11 @@ public class Windows extends Widget {
|
||||
OpenGL.disable(OpenGL.Flag.flag_texture2D);
|
||||
OpenGL.disable(OpenGL.Flag.flag_depthTest);
|
||||
OpenGL.disable(OpenGL.Flag.flag_cullFace);
|
||||
|
||||
|
||||
OpenGL.enable(OpenGL.Flag.flag_blend);
|
||||
//OpenGL.enable(OpenGL.Flag.flag_cullFace);
|
||||
OpenGL.blendFuncAuto();
|
||||
|
||||
|
||||
// clear the matrix system :
|
||||
OpenGL.setBasicMatrix(Matrix4f.IDENTITY);
|
||||
final Vector2i tmpSize = new Vector2i((int) this.size.x(), (int) this.size.y());
|
||||
@ -293,7 +293,7 @@ public class Windows extends Widget {
|
||||
systemDraw(displayProp);
|
||||
OpenGL.disable(OpenGL.Flag.flag_blend);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void systemDraw(final DrawProperty displayProp) {
|
||||
super.systemDraw(displayProp);
|
||||
@ -306,14 +306,14 @@ public class Windows extends Widget {
|
||||
OpenGL.clearColor(Color.PURPLE);
|
||||
OpenGL.clear(OpenGL.ClearFlag.clearFlag_colorBuffer);
|
||||
OpenGL.clear(OpenGL.ClearFlag.clearFlag_depthBuffer);
|
||||
|
||||
|
||||
//LOGGER.warn(" WINDOWS draw on " + this.currentDrawId);
|
||||
// first display the windows on the display
|
||||
if (this.subWidget != null) {
|
||||
this.subWidget.systemDraw(displayProp);
|
||||
//LOGGER.debug("Draw Windows");
|
||||
}
|
||||
|
||||
|
||||
// second display the pop-up
|
||||
for (final Widget it : this.popUpWidgetList) {
|
||||
if (it != null) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user