[FEAT] entry and box ready and finished
This commit is contained in:
parent
3bbe3afe23
commit
163e2e17ea
@ -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 TestWidgetEntry());
|
||||
this.testedElement.add(new TestWidgetBox());
|
||||
this.testedElement.add(new TestWidgetSlider());
|
||||
this.testedElement.add(new TestWidgetEntry());
|
||||
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();
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ public class TestWidgetBox implements TestWidgetInterface {
|
||||
innerWidget.setPropertyFill(Vector2b.TRUE);
|
||||
innerWidget.setPropertyColor(Color.PINK);
|
||||
innerWidget.setPropertyMinSize(new Dimension2f(new Vector2f(50, 80)));
|
||||
|
||||
|
||||
final var testWidget = new Box(innerWidget);
|
||||
testWidget.setPropertyExpand(Vector2b.FALSE);
|
||||
testWidget.setPropertyFill(Vector2b.FALSE);
|
||||
@ -27,12 +27,12 @@ public class TestWidgetBox implements TestWidgetInterface {
|
||||
testWidget.setPropertyBorderRadius(new DimensionBorderRadius(25));
|
||||
testWidget.setPropertyBorderColor(Color.BLACK);
|
||||
testWidget.setPropertyColor(Color.GREEN_YELLOW);
|
||||
testWidget.setPropertyPadding(new Dimension2f(new Vector2f(15, 15)));
|
||||
testWidget.setPropertyMargin(new Dimension2f(new Vector2f(25, 25)));
|
||||
|
||||
testWidget.setPropertyPadding(new DimensionInsets(15, 15));
|
||||
testWidget.setPropertyMargin(new DimensionInsets(25, 25));
|
||||
|
||||
return testWidget;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getTitle() {
|
||||
return "Simple CheckBox";
|
||||
|
@ -14,30 +14,30 @@ import org.slf4j.LoggerFactory;
|
||||
|
||||
public class CompositingGC extends CompositingDrawing {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(CompositingGC.class);
|
||||
|
||||
|
||||
@Override
|
||||
public void setPaintFillColor(final Color color) {
|
||||
setColor(color);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setPaintStrokeColor(final Color color) {
|
||||
setColorBg(color);
|
||||
}
|
||||
|
||||
|
||||
float strokeSize = 0;
|
||||
|
||||
|
||||
@Override
|
||||
public void setPaintStrokeWidth(final float width) {
|
||||
this.strokeSize = width;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void addLine(final Vector2f startPos, final Vector2f stopPos) {
|
||||
setPos(startPos);
|
||||
lineTo(stopPos);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void addRectangle(final Vector2f position, final Vector2f size) {
|
||||
setPos(position);
|
||||
@ -46,7 +46,7 @@ public class CompositingGC extends CompositingDrawing {
|
||||
rectangleBorder(position.add(size), this.strokeSize);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void addRectangle(final Vector2f position, final Vector2f size, final Vector2f roundedCorner) {
|
||||
if (roundedCorner == null || roundedCorner.x() <= 0) {
|
||||
@ -59,30 +59,30 @@ public class CompositingGC extends CompositingDrawing {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void addRectangle(
|
||||
final Vector2f position,
|
||||
final Vector2f size,
|
||||
final Vector2f positionStart,
|
||||
final Vector2f positionStop,
|
||||
final Insets thickness,
|
||||
final BorderRadius radius) {
|
||||
setPos(position);
|
||||
rectangleRadius(position.add(size), thickness, radius);
|
||||
setPos(positionStart);
|
||||
rectangleRadius(positionStop, thickness, radius);
|
||||
if (!thickness.isZero()) {
|
||||
rectangleBorderRadius(position.add(size), thickness, radius);
|
||||
rectangleBorderRadius(positionStop, thickness, radius);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void addCircle(final Vector2f position, final float radius) {
|
||||
setPos(position);
|
||||
circle(radius);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void addEllipse(final Vector2f center, final Vector2f radius) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
|
||||
}
|
||||
}
|
@ -5,12 +5,10 @@ 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.Dimension2f;
|
||||
import org.atriasoft.etk.DimensionBorderRadius;
|
||||
import org.atriasoft.etk.DimensionInsets;
|
||||
import org.atriasoft.etk.Insets;
|
||||
import org.atriasoft.etk.math.Vector2f;
|
||||
import org.atriasoft.etk.math.Vector2i;
|
||||
import org.atriasoft.ewol.compositing.CompositingGC;
|
||||
import org.atriasoft.ewol.event.EventTime;
|
||||
import org.slf4j.Logger;
|
||||
@ -38,14 +36,16 @@ public class Box extends Container {
|
||||
self.markToRedraw();
|
||||
}
|
||||
|
||||
Vector2i startPosition = Vector2i.ZERO;
|
||||
Vector2i endPosition = Vector2i.ZERO;
|
||||
Vector2f overPositionStart = Vector2f.ZERO;
|
||||
Vector2f overPositionStop = Vector2f.ZERO;
|
||||
Vector2f insidePositionStart = Vector2f.ZERO;
|
||||
Vector2f insidePositionStop = Vector2f.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();
|
||||
return value.x() > this.overPositionStart.x() //
|
||||
&& value.y() > this.overPositionStart.y() //
|
||||
&& value.x() < this.overPositionStop.x() //
|
||||
&& value.y() < this.overPositionStop.y();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -136,17 +136,17 @@ public class Box extends Container {
|
||||
requestUpdateSize();
|
||||
}
|
||||
|
||||
protected Dimension2f propertyMargin = Dimension2f.ZERO;
|
||||
protected DimensionInsets propertyMargin = DimensionInsets.ZERO;
|
||||
|
||||
@AknotManaged
|
||||
@AknotAttribute
|
||||
@AknotName(value = "margin")
|
||||
@AknotDescription(value = "margin of the box")
|
||||
public Dimension2f getPropertyMargin() {
|
||||
public DimensionInsets getPropertyMargin() {
|
||||
return this.propertyMargin;
|
||||
}
|
||||
|
||||
public void setPropertyMargin(final Dimension2f propertyMargin) {
|
||||
public void setPropertyMargin(final DimensionInsets propertyMargin) {
|
||||
if (this.propertyMargin.equals(propertyMargin)) {
|
||||
return;
|
||||
}
|
||||
@ -155,17 +155,17 @@ public class Box extends Container {
|
||||
requestUpdateSize();
|
||||
}
|
||||
|
||||
protected Dimension2f propertyPadding = Dimension2f.ZERO;
|
||||
protected DimensionInsets propertyPadding = DimensionInsets.ZERO;
|
||||
|
||||
@AknotManaged
|
||||
@AknotAttribute
|
||||
@AknotName(value = "padding")
|
||||
@AknotDescription(value = "Padding of the box")
|
||||
public Dimension2f getPropertyPadding() {
|
||||
public DimensionInsets getPropertyPadding() {
|
||||
return this.propertyPadding;
|
||||
}
|
||||
|
||||
public void setPropertyPadding(final Dimension2f propertyPadding) {
|
||||
public void setPropertyPadding(final DimensionInsets propertyPadding) {
|
||||
if (this.propertyPadding.equals(propertyPadding)) {
|
||||
return;
|
||||
}
|
||||
@ -174,23 +174,40 @@ public class Box extends Container {
|
||||
requestUpdateSize();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void calculateMinMaxSize() {
|
||||
protected void calculateMinMaxSizeChild(Vector2f childMinSize) {
|
||||
super.calculateMinMaxSize();
|
||||
final Vector2f childMinSize = new Vector2f(this.minSize.x(), this.minSize.y());
|
||||
|
||||
childMinSize = this.minSize.max(childMinSize);
|
||||
LOGGER.debug("calculate min size: border=" + this.propertyBorderWidth);
|
||||
final Insets borderSize = this.propertyBorderWidth.getPixel();
|
||||
|
||||
final Vector2f padding = this.propertyPadding.getPixel().multiply(2);
|
||||
final Vector2f margin = this.propertyMargin.getPixel().multiply(2);
|
||||
final Insets padding = this.propertyPadding.getPixel();
|
||||
final Insets margin = this.propertyMargin.getPixel();
|
||||
|
||||
final Vector2f calculatedBoxMinSize = childMinSize.add(margin).add(padding).add(borderSize.toVector2f());
|
||||
final Vector2f calculatedBoxMinSize = childMinSize.add(margin.toVector2f()).add(padding.toVector2f())
|
||||
.add(borderSize.toVector2f());
|
||||
|
||||
this.minSize = calculatedBoxMinSize;
|
||||
this.maxSize = Vector2f.max(this.minSize, this.propertyMaxSize.getPixel());
|
||||
markToRedraw();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void calculateMinMaxSize() {
|
||||
calculateMinMaxSizeChild(Vector2f.ZERO);
|
||||
}
|
||||
|
||||
public Insets getBorderAggregation() {
|
||||
final Insets localPadding = this.propertyPadding.getPixel();
|
||||
final Insets localMargin = this.propertyMargin.getPixel();
|
||||
final Insets localBorderSize = this.propertyBorderWidth.getPixel();
|
||||
return localPadding.add(localMargin).add(localBorderSize);
|
||||
}
|
||||
|
||||
public Insets getBorderInsideAggregation() {
|
||||
final Insets localPadding = this.propertyPadding.getPixel();
|
||||
final Insets localBorderSize = this.propertyBorderWidth.getPixel();
|
||||
return localPadding.add(localBorderSize);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChangeSize() {
|
||||
@ -198,36 +215,46 @@ public class Box extends Container {
|
||||
if (this.propertyHide) {
|
||||
return;
|
||||
}
|
||||
if (this.subWidget == null) {
|
||||
return;
|
||||
}
|
||||
final Vector2f localPadding = this.propertyPadding.getPixel();
|
||||
final Vector2f localMargin = this.propertyMargin.getPixel();
|
||||
final Insets localBorderSize = this.propertyBorderWidth.getPixel();
|
||||
final Vector2f offsetSubWidget = localPadding.add(localMargin).add(localBorderSize.toVector2f());
|
||||
|
||||
Vector2f subWidgetSize = this.subWidget.getCalculateMinSize();
|
||||
if (this.subWidget.canExpand().x() && this.propertyFill.x()) {
|
||||
subWidgetSize = subWidgetSize.withX(this.size.x());
|
||||
final Insets offsetSubWidget = getBorderAggregation();
|
||||
Vector2f subWidgetSize = Vector2f.ZERO;
|
||||
if (this.subWidget != null) {
|
||||
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());
|
||||
}
|
||||
} else {
|
||||
subWidgetSize = subWidgetSize.withX(this.minSize.x());
|
||||
if (canExpand().x() && this.propertyFill.x()) {
|
||||
subWidgetSize = subWidgetSize.withX(this.size.x());
|
||||
} else {
|
||||
subWidgetSize = subWidgetSize.withX(this.minSize.x());
|
||||
}
|
||||
if (canExpand().y() && this.propertyFill.y()) {
|
||||
subWidgetSize = subWidgetSize.withY(this.size.y());
|
||||
} else {
|
||||
subWidgetSize = subWidgetSize.withY(this.minSize.y());
|
||||
}
|
||||
}
|
||||
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.less(offsetSubWidget.toVector2f());
|
||||
subWidgetSize = subWidgetSize.clipInteger();
|
||||
|
||||
on a un pb ici car on double les margin, ce qui est normal, mai on redouble les border size
|
||||
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();
|
||||
final Vector2f freeSizeWithoutWidget = this.size.less(offsetSubWidget.toVector2f()).less(subWidgetSize);
|
||||
this.insidePositionStart = this.origin.add(this.propertyGravity.gravityGenerateDelta(freeSizeWithoutWidget));
|
||||
this.insidePositionStart = this.insidePositionStart.add(offsetSubWidget.getOrigin());
|
||||
this.insidePositionStart = this.insidePositionStart.clipInteger();
|
||||
this.insidePositionStop = this.insidePositionStart.add(subWidgetSize);
|
||||
|
||||
if (this.subWidget != null) {
|
||||
this.subWidget.setOrigin(this.insidePositionStart);
|
||||
this.subWidget.setSize(subWidgetSize);
|
||||
this.subWidget.onChangeSize();
|
||||
}
|
||||
}
|
||||
|
||||
private Vector2f calculateOriginRendering(final Vector2f renderSize) {
|
||||
@ -249,31 +276,35 @@ public class Box extends Container {
|
||||
public void onRegenerateDisplay() {
|
||||
super.onRegenerateDisplay();
|
||||
if (!needRedraw()) {
|
||||
//return;
|
||||
return;
|
||||
}
|
||||
final Vector2f localMargin = this.propertyMargin.size();
|
||||
|
||||
final Insets localMargin = this.propertyMargin.size();
|
||||
Vector2f renderSize = calculateSizeRendering();
|
||||
Vector2f renderOrigin = calculateOriginRendering(renderSize);
|
||||
|
||||
renderOrigin = renderOrigin.add(localMargin);
|
||||
renderSize = renderSize.less(localMargin.multiply(2));
|
||||
// not sure this is needed...
|
||||
renderSize = renderSize.clipInteger();
|
||||
renderOrigin = renderOrigin.clipInteger();
|
||||
|
||||
renderOrigin = renderOrigin.clipInteger();
|
||||
renderSize = renderSize.clipInteger();
|
||||
this.startPosition = renderOrigin.toVector2i();
|
||||
this.endPosition = renderSize.toVector2i();
|
||||
this.overPositionStart = calculateOriginRendering(renderSize);
|
||||
this.overPositionStart = this.overPositionStart.add(localMargin.getOrigin());
|
||||
renderSize = renderSize.less(localMargin.toVector2f());
|
||||
this.overPositionStart = this.overPositionStart.clipInteger();
|
||||
this.overPositionStop = this.overPositionStart.add(renderSize.clipInteger());
|
||||
final Insets offsetSubWidget = getBorderInsideAggregation();
|
||||
this.insidePositionStart = this.overPositionStart.add(offsetSubWidget.getOrigin());
|
||||
this.insidePositionStop = this.overPositionStop.less(offsetSubWidget.getEnd());
|
||||
|
||||
// remove data of the previous composition:
|
||||
this.vectorialDraw.clear();
|
||||
this.vectorialDraw.setPaintFillColor(this.propertyColor);
|
||||
this.vectorialDraw.setPaintStrokeColor(this.propertyBorderColor);
|
||||
//this.vectorialDraw.setPaintStrokeWidth(borderSize);
|
||||
this.vectorialDraw.addRectangle(renderOrigin, renderSize, this.propertyBorderWidth.getPixel(),
|
||||
this.propertyBorderRadius.getPixel());
|
||||
this.vectorialDraw.addRectangle(this.overPositionStart, this.overPositionStop,
|
||||
this.propertyBorderWidth.getPixel(), this.propertyBorderRadius.getPixel());
|
||||
// this.vectorialDraw.setPaintFillColor(Color.RED);
|
||||
// this.vectorialDraw.setPaintStrokeWidth(0);
|
||||
// this.vectorialDraw.addRectangle(this.overPositionStart, Vector2f.VALUE_4);
|
||||
// this.vectorialDraw.setPaintFillColor(Color.BLUE);
|
||||
// this.vectorialDraw.addRectangle(this.overPositionStop.less(Vector2f.VALUE_4), Vector2f.VALUE_4);
|
||||
// this.vectorialDraw.setPaintFillColor(Color.ORANGE);
|
||||
// this.vectorialDraw.setPaintStrokeWidth(0);
|
||||
// this.vectorialDraw.addRectangle(this.insidePositionStart, Vector2f.VALUE_4);
|
||||
// this.vectorialDraw.setPaintFillColor(Color.PURPLE);
|
||||
// this.vectorialDraw.addRectangle(this.insidePositionStop.less(Vector2f.VALUE_4), Vector2f.VALUE_4);
|
||||
this.vectorialDraw.flush();
|
||||
}
|
||||
|
||||
|
@ -8,7 +8,6 @@ import org.atriasoft.aknot.annotation.AknotSignal;
|
||||
import org.atriasoft.esignal.Connection;
|
||||
import org.atriasoft.esignal.SignalEmpty;
|
||||
import org.atriasoft.etk.Color;
|
||||
import org.atriasoft.etk.Dimension2f;
|
||||
import org.atriasoft.etk.DimensionInsets;
|
||||
import org.atriasoft.etk.Uri;
|
||||
import org.atriasoft.etk.math.Vector2b;
|
||||
@ -34,7 +33,7 @@ import org.slf4j.LoggerFactory;
|
||||
*/
|
||||
public class Button extends Box {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(Button.class);
|
||||
|
||||
|
||||
public static Button createLabelButton(final String label) {
|
||||
final Button out = new Button();
|
||||
final Label labelWidget = new Label();
|
||||
@ -46,7 +45,7 @@ public class Button extends Box {
|
||||
out.setSubWidget(labelWidget);
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Periodic call to update graphic display
|
||||
* @param event Time generic event
|
||||
@ -58,12 +57,12 @@ public class Button extends Box {
|
||||
// }
|
||||
self.markToRedraw();
|
||||
}
|
||||
|
||||
|
||||
/// Periodic call handle to remove it when needed
|
||||
protected Connection periodicConnectionHanble = new Connection();
|
||||
|
||||
|
||||
private Uri propertyConfig = new Uri("THEME", "shape/Button.json", "ewol");
|
||||
|
||||
|
||||
@AknotSignal
|
||||
@AknotName(value = "down")
|
||||
@AknotDescription("Button is Down")
|
||||
@ -84,10 +83,10 @@ public class Button extends Box {
|
||||
@AknotName(value = "leave")
|
||||
@AknotDescription("The cursor leave the button")
|
||||
public SignalEmpty signalLeave = new SignalEmpty();
|
||||
|
||||
|
||||
private boolean buttonPressed = false;
|
||||
private final boolean mouseHover = false;
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
@ -102,11 +101,11 @@ public class Button extends Box {
|
||||
//setPropertyBorderRadius(new Dimension1f(15));
|
||||
setPropertyBorderColor(Color.BLACK);
|
||||
setPropertyColor(Color.WHITE);
|
||||
setPropertyPadding(new Dimension2f(new Vector2f(3, 3)));
|
||||
setPropertyMargin(new Dimension2f(new Vector2f(0, 0)));
|
||||
|
||||
setPropertyPadding(new DimensionInsets(3));
|
||||
setPropertyMargin(new DimensionInsets(0));
|
||||
|
||||
}
|
||||
|
||||
|
||||
@AknotManaged
|
||||
@AknotAttribute
|
||||
@AknotName(value = "config")
|
||||
@ -114,7 +113,7 @@ public class Button extends Box {
|
||||
public Uri getPropertyConfig() {
|
||||
return this.propertyConfig;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected boolean onEventEntry(final EventEntry event) {
|
||||
//LOGGER.debug("BT PRESSED : \"" << UTF8_data << "\" size=" << strlen(UTF8_data));
|
||||
@ -124,7 +123,7 @@ public class Button extends Box {
|
||||
}
|
||||
return super.onEventEntry(event);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onEventInput(final EventInput event) {
|
||||
final Vector2f relPos = relativePosition(event.pos());
|
||||
@ -184,14 +183,14 @@ public class Button extends Box {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onLostFocus() {
|
||||
this.buttonPressed = false;
|
||||
LOGGER.trace(this.name + " : Remove Focus ...");
|
||||
//checkStatus();
|
||||
}
|
||||
|
||||
|
||||
public void setPropertyConfig(final Uri propertyConfig) {
|
||||
if (this.propertyConfig.equals(propertyConfig)) {
|
||||
return;
|
||||
|
@ -23,19 +23,19 @@ import org.slf4j.LoggerFactory;
|
||||
public class Container extends Widget {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(Container.class);
|
||||
protected Widget subWidget = null;
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public Container() {}
|
||||
|
||||
|
||||
/**
|
||||
* Constructor with his child
|
||||
*/
|
||||
public Container(final Widget subWidget) {
|
||||
this.subWidget = subWidget;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void calculateMinMaxSize() {
|
||||
// call main class
|
||||
@ -48,7 +48,7 @@ public class Container extends Widget {
|
||||
}
|
||||
LOGGER.trace("[{}] Result min size : {}", getId(), this.minSize);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void drawWidgetTree(int level) {
|
||||
super.drawWidgetTree(level);
|
||||
@ -57,7 +57,7 @@ public class Container extends Widget {
|
||||
this.subWidget.drawWidgetTree(level);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public EwolObject getSubObjectNamed(final String objectName) {
|
||||
final EwolObject tmpObject = super.getSubObjectNamed(objectName);
|
||||
@ -69,7 +69,7 @@ public class Container extends Widget {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* get the main node widget
|
||||
* @return the requested pointer on the node
|
||||
@ -81,17 +81,18 @@ public class Container extends Widget {
|
||||
public Widget getSubWidget() {
|
||||
return this.subWidget;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Widget getWidgetAtPos(final Vector2f pos) {
|
||||
if (!this.propertyHide) {
|
||||
if (this.subWidget != null) {
|
||||
return this.subWidget.getWidgetAtPos(pos);
|
||||
}
|
||||
if (this.propertyHide) {
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
if (this.subWidget != null) {
|
||||
return this.subWidget.getWidgetAtPos(pos);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
// @Override
|
||||
// public boolean loadXML(final XmlElement node) {
|
||||
// if (node == null) {
|
||||
@ -136,7 +137,7 @@ public class Container extends Widget {
|
||||
// }
|
||||
// return true;
|
||||
// }
|
||||
|
||||
|
||||
@Override
|
||||
public void onChangeSize() {
|
||||
super.onChangeSize();
|
||||
@ -154,14 +155,14 @@ public class Container extends Widget {
|
||||
this.subWidget.setSize(this.size);
|
||||
this.subWidget.onChangeSize();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onRegenerateDisplay() {
|
||||
if (this.subWidget != null) {
|
||||
this.subWidget.systemRegenerateDisplay();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void requestDestroyFromChild(final EwolObject child) {
|
||||
if (this.subWidget != child) {
|
||||
@ -174,7 +175,7 @@ public class Container extends Widget {
|
||||
this.subWidget = null;
|
||||
markToRedraw();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setOffset(final Vector2f newVal) {
|
||||
if (this.offset.equals(newVal)) {
|
||||
@ -183,9 +184,9 @@ public class Container extends Widget {
|
||||
super.setOffset(newVal);
|
||||
// recalculate the new sise and position of sub widget ...
|
||||
onChangeSize();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* set the subWidget node widget.
|
||||
* @param newWidget The widget to add.
|
||||
@ -202,7 +203,7 @@ public class Container extends Widget {
|
||||
markToRedraw();
|
||||
requestUpdateSize();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* remove the subWidget node (async).
|
||||
*/
|
||||
@ -214,7 +215,7 @@ public class Container extends Widget {
|
||||
requestUpdateSize();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Replace a old subwidget with a new one.
|
||||
* @param oldWidget The widget to replace.
|
||||
@ -233,7 +234,7 @@ public class Container extends Widget {
|
||||
markToRedraw();
|
||||
requestUpdateSize();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Unlink the subwidget Node.
|
||||
*/
|
||||
@ -243,7 +244,7 @@ public class Container extends Widget {
|
||||
}
|
||||
this.subWidget = null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void systemDraw(final DrawProperty displayProp) {
|
||||
if (this.propertyHide) {
|
||||
|
@ -11,12 +11,11 @@ import org.atriasoft.aknot.annotation.AknotSignal;
|
||||
import org.atriasoft.esignal.Connection;
|
||||
import org.atriasoft.esignal.Signal;
|
||||
import org.atriasoft.esignal.SignalEmpty;
|
||||
import org.atriasoft.etk.Uri;
|
||||
import org.atriasoft.etk.Color;
|
||||
import org.atriasoft.etk.DimensionInsets;
|
||||
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.CompositingSVG;
|
||||
import org.atriasoft.ewol.compositing.CompositingText;
|
||||
import org.atriasoft.ewol.compositing.GuiShapeMode;
|
||||
import org.atriasoft.ewol.event.EventEntry;
|
||||
@ -40,7 +39,7 @@ import org.slf4j.LoggerFactory;
|
||||
* ----------------------------------------------
|
||||
* ~~~~~~~~~~~~~~~~~~~~~~
|
||||
*/
|
||||
public class Entry extends Widget {
|
||||
public class Entry extends Box {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(Entry.class);
|
||||
|
||||
/**
|
||||
@ -69,12 +68,10 @@ public class Entry extends Widget {
|
||||
private int displayCursorPositionPixel = 0;
|
||||
/// text display this.text
|
||||
private final CompositingText text = new CompositingText();
|
||||
protected CompositingSVG vectorialDraw = new CompositingSVG();
|
||||
/// text position can have change
|
||||
private boolean needUpdateTextPos = true;
|
||||
/// Periodic call handle to remove it when needed
|
||||
protected Connection periodicConnectionHanble = new Connection();
|
||||
private Uri propertyConfig = new Uri("THEME", "shape/Entry.json", "ewol");
|
||||
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
|
||||
|
||||
@ -101,10 +98,6 @@ public class Entry extends Widget {
|
||||
@AknotName(value = "modify")
|
||||
@AknotDescription("Entry box value change")
|
||||
public Signal<String> signalModify = new Signal<>(); //!< data change
|
||||
// element over:
|
||||
Vector2f overPositionStart = Vector2f.ZERO;
|
||||
|
||||
Vector2f overPositionStop = Vector2f.ZERO;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
@ -126,23 +119,15 @@ public class Entry extends Widget {
|
||||
shortCutAdd("ctrl+a", "select:all");
|
||||
shortCutAdd("ctrl+shift+a", "select:none");
|
||||
//TODO this.signalShortcut.connect(this, Entry::onCallbackShortCut);
|
||||
setPropertyColor(Color.WHITE);
|
||||
setPropertyBorderColor(Color.BLACK);
|
||||
setPropertyBorderWidth(new DimensionInsets(2));
|
||||
setPropertyPadding(new DimensionInsets(4));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void calculateMinMaxSize() {
|
||||
// call main class
|
||||
super.calculateMinMaxSize();
|
||||
// get generic padding
|
||||
final Padding padding = Padding.ZERO;
|
||||
final int minHeight = (int) this.text.getHeight();//calculateSize('A').y();
|
||||
|
||||
Vector2f minimumSizeBase = new Vector2f(20, minHeight);
|
||||
// add padding :
|
||||
minimumSizeBase = minimumSizeBase.add(padding.x(), padding.y());
|
||||
this.minSize = Vector2f.max(this.minSize, minimumSizeBase);
|
||||
// verify the min max of the min size ...
|
||||
checkMinSize();
|
||||
//LOGGER.trace("min size = " + this.minSize);
|
||||
calculateMinMaxSizeChild(new Vector2f(25, this.text.getHeight()));
|
||||
}
|
||||
|
||||
protected void changeStatusIn(final GuiShapeMode newStatusId) {
|
||||
@ -175,11 +160,7 @@ public class Entry extends Widget {
|
||||
final String tmpData = this.propertyValue.substring(pos1, pos2);
|
||||
ClipBoard.set(clipboardID, tmpData);
|
||||
}
|
||||
|
||||
public Uri getPropertyConfig() {
|
||||
return this.propertyConfig;
|
||||
}
|
||||
|
||||
|
||||
public int getPropertyMaxCharacter() {
|
||||
return this.propertyMaxCharacter;
|
||||
}
|
||||
@ -296,15 +277,13 @@ public class Entry extends Widget {
|
||||
|
||||
@Override
|
||||
protected void onDraw() {
|
||||
if (this.vectorialDraw != null) {
|
||||
this.vectorialDraw.draw(true);
|
||||
}
|
||||
super.onDraw();
|
||||
this.text.draw();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEventClipboard(final ClipboardList clipboardID) {
|
||||
// remove curent selected data ...
|
||||
// remove current selected data ...
|
||||
removeSelected();
|
||||
// get current selection / Copy :
|
||||
final String tmpData = ClipBoard.get(clipboardID);
|
||||
@ -403,10 +382,10 @@ public class Entry extends Widget {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onEventInput(final EventInput event) {
|
||||
protected boolean onEventInput(final EventInput event) {
|
||||
final Vector2f absolutePosition = event.pos();
|
||||
final Vector2f relPos = relativePosition(absolutePosition);
|
||||
LOGGER.trace("Event on Input ... " + event + " relPos = " + relPos);
|
||||
LOGGER.error("Event on Input ... " + event + " relPos = " + relPos);
|
||||
if (event.inputId() == 0) {
|
||||
if (!isFocused()) {
|
||||
if (KeyStatus.leave == event.status()) {
|
||||
@ -422,8 +401,7 @@ public class Entry extends Widget {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (relPos.x() < this.overPositionStart.x() || relPos.y() < this.overPositionStart.y()
|
||||
|| relPos.x() > this.overPositionStop.x() || relPos.y() > this.overPositionStop.y()) {
|
||||
if (!isInside(relPos)) {
|
||||
LOGGER.warn("Reject {}", relPos);
|
||||
return false;
|
||||
}
|
||||
@ -520,55 +498,20 @@ public class Entry extends Widget {
|
||||
hideKeyboard();
|
||||
markToRedraw();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onRegenerateDisplay() {
|
||||
if (!needRedraw()) {
|
||||
return;
|
||||
}
|
||||
//LOGGER.trace("Regenerate Display ==> is needed: '" + this.propertyValue + "'");
|
||||
this.vectorialDraw.clear();
|
||||
super.onRegenerateDisplay();
|
||||
// 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();
|
||||
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));
|
||||
}
|
||||
updateTextPosition();
|
||||
final Padding padding = Padding.ZERO;
|
||||
|
||||
Vector2f tmpSizeShaper = this.minSize;
|
||||
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);
|
||||
}
|
||||
if (this.propertyFill.y()) {
|
||||
tmpSizeShaper = tmpSizeShaper.withY(this.size.y());
|
||||
delta = delta.withY(0.0f);
|
||||
}
|
||||
Vector2f tmpOriginShaper = delta;
|
||||
//Vector2f tmpOriginShaper = this.size.less(tmpSizeShaper).multiply(0.5f);
|
||||
Vector2f tmpSizeText = tmpSizeShaper.less(padding.x(), padding.y());
|
||||
Vector2f tmpOriginText = tmpOriginShaper.add(padding.bottom(), padding.left()); //this.size.less(tmpSizeText).multiply(0.5f);
|
||||
//Vector2f tmpOriginText = new Vector2f(0, this.text.getSize(), 0);
|
||||
// sometimes, the user define an height bigger than the real size needed == > in this case we need to center the text in the shaper ...
|
||||
|
||||
final int minHeight = (int) this.text.getHeight();
|
||||
if (tmpSizeText.y() > minHeight) {
|
||||
tmpOriginText = tmpOriginText.add(0, (tmpSizeText.y() - minHeight) * 0.5f);
|
||||
}
|
||||
// fix all the position in the int class:
|
||||
tmpSizeShaper = Vector2f.clipInt(tmpSizeShaper);
|
||||
tmpOriginShaper = Vector2f.clipInt(tmpOriginShaper);
|
||||
tmpSizeText = Vector2f.clipInt(tmpSizeText);
|
||||
tmpOriginText = Vector2f.clipInt(tmpOriginText);
|
||||
|
||||
this.text.clear();
|
||||
//this.text.setSize((int) tmpSizeText.x(), (int) tmpSizeText.y());
|
||||
this.text.setClippingWidth(tmpOriginText, tmpSizeText);
|
||||
this.text.setPos(tmpOriginText.add(this.displayStartPosition, 0));
|
||||
//this.text.setClippingWidth(this.insidePositionStart, this.insidePositionStop);
|
||||
this.text.setPos(this.insidePositionStart.add(0, offsetCenter));
|
||||
if (this.displayCursorPosSelection != this.displayCursorPos) {
|
||||
this.text.setCursorSelection(this.displayCursorPos, this.displayCursorPosSelection);
|
||||
} else {
|
||||
@ -586,29 +529,7 @@ public class Entry extends Widget {
|
||||
this.text.printDecorated(this.propertyTextWhenNothing);
|
||||
}
|
||||
this.text.setClippingMode(false);
|
||||
this.overPositionStart = tmpOriginShaper;
|
||||
this.overPositionStop = tmpOriginShaper.add(tmpSizeShaper);
|
||||
//this.shape.setShape(tmpOriginShaper, tmpSizeShaper, tmpOriginText, tmpSizeText);
|
||||
this.vectorialDraw.setSource("""
|
||||
<svg width="%d" height="%d">
|
||||
<rect
|
||||
x="0.5"
|
||||
y="0.5"
|
||||
width="%f"
|
||||
height="%f"
|
||||
fill="white"
|
||||
stroke="black"
|
||||
stroke-width="1"
|
||||
/>
|
||||
</svg>""".formatted( //
|
||||
(int) tmpSizeShaper.x(), (int) tmpSizeShaper.y(), //
|
||||
tmpSizeShaper.x() - 0.5, tmpSizeShaper.y() - 0.5//
|
||||
), new Vector2i((int) tmpSizeShaper.x(), (int) tmpSizeShaper.y()));
|
||||
this.vectorialDraw.setPos(tmpOriginShaper);
|
||||
this.vectorialDraw.print(new Vector2f(tmpSizeShaper.x(), tmpSizeShaper.y()));
|
||||
this.text.flush();
|
||||
this.vectorialDraw.flush();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -666,18 +587,6 @@ public class Entry extends Widget {
|
||||
markToRedraw();
|
||||
}
|
||||
|
||||
@AknotManaged
|
||||
@AknotAttribute
|
||||
@AknotName(value = "config")
|
||||
@AknotDescription(value = "configuration of the widget")
|
||||
public void setPropertyConfig(final Uri propertyConfig) {
|
||||
if (this.propertyConfig.equals(propertyConfig)) {
|
||||
return;
|
||||
}
|
||||
this.propertyConfig = propertyConfig;
|
||||
//onChangePropertyShaper();
|
||||
}
|
||||
|
||||
@AknotManaged
|
||||
@AknotAttribute
|
||||
@AknotName(value = "max")
|
||||
|
@ -95,8 +95,8 @@ public class Tick extends Box {
|
||||
//setPropertyBorderRadius(new Dimension1f(15));
|
||||
setPropertyBorderColor(Color.BLACK);
|
||||
setPropertyColor(Color.WHITE);
|
||||
setPropertyPadding(new Dimension2f(new Vector2f(3, 3)));
|
||||
setPropertyMargin(new Dimension2f(new Vector2f(0, 0)));
|
||||
setPropertyPadding(new DimensionInsets(3));
|
||||
setPropertyMargin(new DimensionInsets(0));
|
||||
|
||||
}
|
||||
|
||||
@ -231,9 +231,9 @@ public class Tick extends Box {
|
||||
if (!needRedraw()) {
|
||||
//return;
|
||||
}
|
||||
this.compositingTick.setSource(Uri.getAllDataString(this.uriCheckGreen), this.startPosition.less(4));
|
||||
this.compositingTick.setPos(this.propertyMargin.size().add(2));
|
||||
this.compositingTick.print(this.startPosition.less(4).toVector2f());
|
||||
this.compositingTick.setSource(Uri.getAllDataString(this.uriCheckGreen));//, this.overPositionStart.less(4));
|
||||
this.compositingTick.setPos(this.overPositionStart.add(2));
|
||||
this.compositingTick.print(this.overPositionStop.less(this.overPositionStart).less(4));
|
||||
this.compositingTick.flush();
|
||||
}
|
||||
|
||||
|
@ -111,15 +111,11 @@ public class SpinBase extends Sizer {
|
||||
requestUpdateSize();
|
||||
if (this.widgetEntry == null) {
|
||||
this.widgetEntry = new Entry();
|
||||
if (this.config != null) {
|
||||
final String shaper = this.config.getString(this.confIdEntryShaper);
|
||||
LOGGER.trace("shaper entry : " + shaper);
|
||||
if (!shaper.isEmpty()) {
|
||||
this.widgetEntry.setPropertyConfig(Uri.valueOf(shaper));
|
||||
}
|
||||
}
|
||||
this.widgetEntry.setPropertyExpand(Vector2b.TRUE_FALSE);
|
||||
this.widgetEntry.setPropertyFill(Vector2b.TRUE);
|
||||
this.widgetEntry.setPropertyPadding(new DimensionInsets(6f, 4f, 6f, 4f));
|
||||
this.widgetEntry.setPropertyBorderWidth(new DimensionInsets(2f, 1f, 2f, 2f));
|
||||
this.widgetEntry.setPropertyBorderRadius(new DimensionBorderRadius(8, 0, 0, 8));
|
||||
}
|
||||
if (this.widgetButtonDown == null) {
|
||||
this.widgetButtonDown = new Button();
|
||||
|
Loading…
x
Reference in New Issue
Block a user