[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 {
|
public class BasicWindows extends Windows {
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(BasicWindows.class);
|
private static final Logger LOGGER = LoggerFactory.getLogger(BasicWindows.class);
|
||||||
|
|
||||||
private int index = -1;
|
private int index = -1;
|
||||||
private final List<TestWidgetInterface> testedElement = new ArrayList<>();
|
private final List<TestWidgetInterface> testedElement = new ArrayList<>();
|
||||||
private Container container = null;
|
private Container container = null;
|
||||||
private Label title = null;
|
private Label title = null;
|
||||||
|
|
||||||
public static void staticRequestNext(final BasicWindows self) {
|
public static void staticRequestNext(final BasicWindows self) {
|
||||||
self.requestNext();
|
self.requestNext();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void staticRequestPrevious(final BasicWindows self) {
|
public static void staticRequestPrevious(final BasicWindows self) {
|
||||||
self.requestPrevious();
|
self.requestPrevious();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void requestNext() {
|
public void requestNext() {
|
||||||
LOGGER.info("Request Next");
|
LOGGER.info("Request Next");
|
||||||
this.index++;
|
this.index++;
|
||||||
@ -40,7 +40,7 @@ public class BasicWindows extends Windows {
|
|||||||
}
|
}
|
||||||
updateDisplay();
|
updateDisplay();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void requestPrevious() {
|
public void requestPrevious() {
|
||||||
LOGGER.info("Request Previous");
|
LOGGER.info("Request Previous");
|
||||||
this.index--;
|
this.index--;
|
||||||
@ -49,7 +49,7 @@ public class BasicWindows extends Windows {
|
|||||||
}
|
}
|
||||||
updateDisplay();
|
updateDisplay();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateDisplay() {
|
public void updateDisplay() {
|
||||||
final var test = this.testedElement.get(this.index);
|
final var test = this.testedElement.get(this.index);
|
||||||
final var titlegenerated = "<b>[" + (this.index + 1) + "/" + this.testedElement.size() + "] " + test.getTitle()
|
final var titlegenerated = "<b>[" + (this.index + 1) + "/" + this.testedElement.size() + "] " + test.getTitle()
|
||||||
@ -58,14 +58,14 @@ public class BasicWindows extends Windows {
|
|||||||
setPropertyTitle(titlegenerated);
|
setPropertyTitle(titlegenerated);
|
||||||
this.container.setSubWidget(new ModelWidget(test));
|
this.container.setSubWidget(new ModelWidget(test));
|
||||||
}
|
}
|
||||||
|
|
||||||
public BasicWindows() {
|
public BasicWindows() {
|
||||||
|
|
||||||
final var sizerMain = new Sizer(DisplayMode.VERTICAL);
|
final var sizerMain = new Sizer(DisplayMode.VERTICAL);
|
||||||
sizerMain.setPropertyExpand(Vector2b.TRUE);
|
sizerMain.setPropertyExpand(Vector2b.TRUE);
|
||||||
sizerMain.setPropertyFill(Vector2b.TRUE);
|
sizerMain.setPropertyFill(Vector2b.TRUE);
|
||||||
setSubWidget(sizerMain);
|
setSubWidget(sizerMain);
|
||||||
|
|
||||||
final var menu = new Sizer(DisplayMode.HORIZONTAL);
|
final var menu = new Sizer(DisplayMode.HORIZONTAL);
|
||||||
menu.setPropertyExpand(Vector2b.TRUE_FALSE);
|
menu.setPropertyExpand(Vector2b.TRUE_FALSE);
|
||||||
menu.setPropertyExpandIfFree(Vector2b.TRUE_FALSE);
|
menu.setPropertyExpandIfFree(Vector2b.TRUE_FALSE);
|
||||||
@ -73,40 +73,40 @@ public class BasicWindows extends Windows {
|
|||||||
menu.setPropertyLockExpand(Vector2b.TRUE);
|
menu.setPropertyLockExpand(Vector2b.TRUE);
|
||||||
menu.setPropertyMaxSize(new Dimension2f(new Vector2f(9999, 3), Distance.CENTIMETER));
|
menu.setPropertyMaxSize(new Dimension2f(new Vector2f(9999, 3), Distance.CENTIMETER));
|
||||||
sizerMain.subWidgetAdd(menu);
|
sizerMain.subWidgetAdd(menu);
|
||||||
|
|
||||||
this.container = new Container();
|
this.container = new Container();
|
||||||
this.container.setPropertyExpand(Vector2b.TRUE);
|
this.container.setPropertyExpand(Vector2b.TRUE);
|
||||||
this.container.setPropertyFill(Vector2b.TRUE);
|
this.container.setPropertyFill(Vector2b.TRUE);
|
||||||
sizerMain.subWidgetAdd(this.container);
|
sizerMain.subWidgetAdd(this.container);
|
||||||
|
|
||||||
final var next = Button.createLabelButton("<< Previous");
|
final var next = Button.createLabelButton("<< Previous");
|
||||||
next.setPropertyMaxSize(new Dimension2f(new Vector2f(9999, 2), Distance.CENTIMETER));
|
next.setPropertyMaxSize(new Dimension2f(new Vector2f(9999, 2), Distance.CENTIMETER));
|
||||||
menu.subWidgetAdd(next);
|
menu.subWidgetAdd(next);
|
||||||
next.signalClick.connectAuto(this, BasicWindows::staticRequestNext);
|
next.signalClick.connectAuto(this, BasicWindows::staticRequestNext);
|
||||||
|
|
||||||
this.title = new Label("unknown");
|
this.title = new Label("unknown");
|
||||||
this.title.setPropertyFill(Vector2b.FALSE);
|
this.title.setPropertyFill(Vector2b.FALSE);
|
||||||
this.title.setPropertyExpand(Vector2b.TRUE);
|
this.title.setPropertyExpand(Vector2b.TRUE);
|
||||||
menu.subWidgetAdd(this.title);
|
menu.subWidgetAdd(this.title);
|
||||||
|
|
||||||
final var previous = Button.createLabelButton("Next >>");
|
final var previous = Button.createLabelButton("Next >>");
|
||||||
previous.setPropertyMaxSize(new Dimension2f(new Vector2f(9999, 2), Distance.CENTIMETER));
|
previous.setPropertyMaxSize(new Dimension2f(new Vector2f(9999, 2), Distance.CENTIMETER));
|
||||||
menu.subWidgetAdd(previous);
|
menu.subWidgetAdd(previous);
|
||||||
previous.signalClick.connectAuto(this, BasicWindows::staticRequestPrevious);
|
previous.signalClick.connectAuto(this, BasicWindows::staticRequestPrevious);
|
||||||
|
|
||||||
this.container.setPropertyExpand(Vector2b.TRUE);
|
this.container.setPropertyExpand(Vector2b.TRUE);
|
||||||
this.container.setPropertyFill(Vector2b.TRUE);
|
this.container.setPropertyFill(Vector2b.TRUE);
|
||||||
this.container.setPropertyExpandIfFree(Vector2b.TRUE);
|
this.container.setPropertyExpandIfFree(Vector2b.TRUE);
|
||||||
|
|
||||||
|
this.testedElement.add(new TestWidgetEntry());
|
||||||
this.testedElement.add(new TestWidgetBox());
|
this.testedElement.add(new TestWidgetBox());
|
||||||
this.testedElement.add(new TestWidgetSlider());
|
this.testedElement.add(new TestWidgetSlider());
|
||||||
this.testedElement.add(new TestWidgetEntry());
|
|
||||||
this.testedElement.add(new TestWidgetButton());
|
this.testedElement.add(new TestWidgetButton());
|
||||||
this.testedElement.add(new TestWidgetButtonToggle());
|
this.testedElement.add(new TestWidgetButtonToggle());
|
||||||
this.testedElement.add(new TestWidgetCheckBox());
|
this.testedElement.add(new TestWidgetCheckBox());
|
||||||
this.testedElement.add(new TestWidgetImage());
|
this.testedElement.add(new TestWidgetImage());
|
||||||
this.testedElement.add(new TestWidgetLabel());
|
this.testedElement.add(new TestWidgetLabel());
|
||||||
requestNext();
|
requestNext();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@ public class TestWidgetBox implements TestWidgetInterface {
|
|||||||
innerWidget.setPropertyFill(Vector2b.TRUE);
|
innerWidget.setPropertyFill(Vector2b.TRUE);
|
||||||
innerWidget.setPropertyColor(Color.PINK);
|
innerWidget.setPropertyColor(Color.PINK);
|
||||||
innerWidget.setPropertyMinSize(new Dimension2f(new Vector2f(50, 80)));
|
innerWidget.setPropertyMinSize(new Dimension2f(new Vector2f(50, 80)));
|
||||||
|
|
||||||
final var testWidget = new Box(innerWidget);
|
final var testWidget = new Box(innerWidget);
|
||||||
testWidget.setPropertyExpand(Vector2b.FALSE);
|
testWidget.setPropertyExpand(Vector2b.FALSE);
|
||||||
testWidget.setPropertyFill(Vector2b.FALSE);
|
testWidget.setPropertyFill(Vector2b.FALSE);
|
||||||
@ -27,12 +27,12 @@ public class TestWidgetBox implements TestWidgetInterface {
|
|||||||
testWidget.setPropertyBorderRadius(new DimensionBorderRadius(25));
|
testWidget.setPropertyBorderRadius(new DimensionBorderRadius(25));
|
||||||
testWidget.setPropertyBorderColor(Color.BLACK);
|
testWidget.setPropertyBorderColor(Color.BLACK);
|
||||||
testWidget.setPropertyColor(Color.GREEN_YELLOW);
|
testWidget.setPropertyColor(Color.GREEN_YELLOW);
|
||||||
testWidget.setPropertyPadding(new Dimension2f(new Vector2f(15, 15)));
|
testWidget.setPropertyPadding(new DimensionInsets(15, 15));
|
||||||
testWidget.setPropertyMargin(new Dimension2f(new Vector2f(25, 25)));
|
testWidget.setPropertyMargin(new DimensionInsets(25, 25));
|
||||||
|
|
||||||
return testWidget;
|
return testWidget;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getTitle() {
|
public String getTitle() {
|
||||||
return "Simple CheckBox";
|
return "Simple CheckBox";
|
||||||
|
@ -14,30 +14,30 @@ import org.slf4j.LoggerFactory;
|
|||||||
|
|
||||||
public class CompositingGC extends CompositingDrawing {
|
public class CompositingGC extends CompositingDrawing {
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(CompositingGC.class);
|
private static final Logger LOGGER = LoggerFactory.getLogger(CompositingGC.class);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setPaintFillColor(final Color color) {
|
public void setPaintFillColor(final Color color) {
|
||||||
setColor(color);
|
setColor(color);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setPaintStrokeColor(final Color color) {
|
public void setPaintStrokeColor(final Color color) {
|
||||||
setColorBg(color);
|
setColorBg(color);
|
||||||
}
|
}
|
||||||
|
|
||||||
float strokeSize = 0;
|
float strokeSize = 0;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setPaintStrokeWidth(final float width) {
|
public void setPaintStrokeWidth(final float width) {
|
||||||
this.strokeSize = width;
|
this.strokeSize = width;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addLine(final Vector2f startPos, final Vector2f stopPos) {
|
public void addLine(final Vector2f startPos, final Vector2f stopPos) {
|
||||||
setPos(startPos);
|
setPos(startPos);
|
||||||
lineTo(stopPos);
|
lineTo(stopPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addRectangle(final Vector2f position, final Vector2f size) {
|
public void addRectangle(final Vector2f position, final Vector2f size) {
|
||||||
setPos(position);
|
setPos(position);
|
||||||
@ -46,7 +46,7 @@ public class CompositingGC extends CompositingDrawing {
|
|||||||
rectangleBorder(position.add(size), this.strokeSize);
|
rectangleBorder(position.add(size), this.strokeSize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addRectangle(final Vector2f position, final Vector2f size, final Vector2f roundedCorner) {
|
public void addRectangle(final Vector2f position, final Vector2f size, final Vector2f roundedCorner) {
|
||||||
if (roundedCorner == null || roundedCorner.x() <= 0) {
|
if (roundedCorner == null || roundedCorner.x() <= 0) {
|
||||||
@ -59,30 +59,30 @@ public class CompositingGC extends CompositingDrawing {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addRectangle(
|
public void addRectangle(
|
||||||
final Vector2f position,
|
final Vector2f positionStart,
|
||||||
final Vector2f size,
|
final Vector2f positionStop,
|
||||||
final Insets thickness,
|
final Insets thickness,
|
||||||
final BorderRadius radius) {
|
final BorderRadius radius) {
|
||||||
setPos(position);
|
setPos(positionStart);
|
||||||
rectangleRadius(position.add(size), thickness, radius);
|
rectangleRadius(positionStop, thickness, radius);
|
||||||
if (!thickness.isZero()) {
|
if (!thickness.isZero()) {
|
||||||
rectangleBorderRadius(position.add(size), thickness, radius);
|
rectangleBorderRadius(positionStop, thickness, radius);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addCircle(final Vector2f position, final float radius) {
|
public void addCircle(final Vector2f position, final float radius) {
|
||||||
setPos(position);
|
setPos(position);
|
||||||
circle(radius);
|
circle(radius);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addEllipse(final Vector2f center, final Vector2f radius) {
|
public void addEllipse(final Vector2f center, final Vector2f radius) {
|
||||||
// TODO Auto-generated method stub
|
// 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.AknotManaged;
|
||||||
import org.atriasoft.aknot.annotation.AknotName;
|
import org.atriasoft.aknot.annotation.AknotName;
|
||||||
import org.atriasoft.etk.Color;
|
import org.atriasoft.etk.Color;
|
||||||
import org.atriasoft.etk.Dimension2f;
|
|
||||||
import org.atriasoft.etk.DimensionBorderRadius;
|
import org.atriasoft.etk.DimensionBorderRadius;
|
||||||
import org.atriasoft.etk.DimensionInsets;
|
import org.atriasoft.etk.DimensionInsets;
|
||||||
import org.atriasoft.etk.Insets;
|
import org.atriasoft.etk.Insets;
|
||||||
import org.atriasoft.etk.math.Vector2f;
|
import org.atriasoft.etk.math.Vector2f;
|
||||||
import org.atriasoft.etk.math.Vector2i;
|
|
||||||
import org.atriasoft.ewol.compositing.CompositingGC;
|
import org.atriasoft.ewol.compositing.CompositingGC;
|
||||||
import org.atriasoft.ewol.event.EventTime;
|
import org.atriasoft.ewol.event.EventTime;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
@ -38,14 +36,16 @@ public class Box extends Container {
|
|||||||
self.markToRedraw();
|
self.markToRedraw();
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector2i startPosition = Vector2i.ZERO;
|
Vector2f overPositionStart = Vector2f.ZERO;
|
||||||
Vector2i endPosition = Vector2i.ZERO;
|
Vector2f overPositionStop = Vector2f.ZERO;
|
||||||
|
Vector2f insidePositionStart = Vector2f.ZERO;
|
||||||
|
Vector2f insidePositionStop = Vector2f.ZERO;
|
||||||
|
|
||||||
public boolean isInside(final Vector2f value) {
|
public boolean isInside(final Vector2f value) {
|
||||||
return value.x() > this.startPosition.x() //
|
return value.x() > this.overPositionStart.x() //
|
||||||
&& value.y() > this.startPosition.y() //
|
&& value.y() > this.overPositionStart.y() //
|
||||||
&& value.x() < this.endPosition.x() //
|
&& value.x() < this.overPositionStop.x() //
|
||||||
&& value.y() < this.endPosition.y();
|
&& value.y() < this.overPositionStop.y();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -136,17 +136,17 @@ public class Box extends Container {
|
|||||||
requestUpdateSize();
|
requestUpdateSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Dimension2f propertyMargin = Dimension2f.ZERO;
|
protected DimensionInsets propertyMargin = DimensionInsets.ZERO;
|
||||||
|
|
||||||
@AknotManaged
|
@AknotManaged
|
||||||
@AknotAttribute
|
@AknotAttribute
|
||||||
@AknotName(value = "margin")
|
@AknotName(value = "margin")
|
||||||
@AknotDescription(value = "margin of the box")
|
@AknotDescription(value = "margin of the box")
|
||||||
public Dimension2f getPropertyMargin() {
|
public DimensionInsets getPropertyMargin() {
|
||||||
return this.propertyMargin;
|
return this.propertyMargin;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPropertyMargin(final Dimension2f propertyMargin) {
|
public void setPropertyMargin(final DimensionInsets propertyMargin) {
|
||||||
if (this.propertyMargin.equals(propertyMargin)) {
|
if (this.propertyMargin.equals(propertyMargin)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -155,17 +155,17 @@ public class Box extends Container {
|
|||||||
requestUpdateSize();
|
requestUpdateSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Dimension2f propertyPadding = Dimension2f.ZERO;
|
protected DimensionInsets propertyPadding = DimensionInsets.ZERO;
|
||||||
|
|
||||||
@AknotManaged
|
@AknotManaged
|
||||||
@AknotAttribute
|
@AknotAttribute
|
||||||
@AknotName(value = "padding")
|
@AknotName(value = "padding")
|
||||||
@AknotDescription(value = "Padding of the box")
|
@AknotDescription(value = "Padding of the box")
|
||||||
public Dimension2f getPropertyPadding() {
|
public DimensionInsets getPropertyPadding() {
|
||||||
return this.propertyPadding;
|
return this.propertyPadding;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPropertyPadding(final Dimension2f propertyPadding) {
|
public void setPropertyPadding(final DimensionInsets propertyPadding) {
|
||||||
if (this.propertyPadding.equals(propertyPadding)) {
|
if (this.propertyPadding.equals(propertyPadding)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -174,23 +174,40 @@ public class Box extends Container {
|
|||||||
requestUpdateSize();
|
requestUpdateSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
protected void calculateMinMaxSizeChild(Vector2f childMinSize) {
|
||||||
public void calculateMinMaxSize() {
|
|
||||||
super.calculateMinMaxSize();
|
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);
|
LOGGER.debug("calculate min size: border=" + this.propertyBorderWidth);
|
||||||
final Insets borderSize = this.propertyBorderWidth.getPixel();
|
final Insets borderSize = this.propertyBorderWidth.getPixel();
|
||||||
|
|
||||||
final Vector2f padding = this.propertyPadding.getPixel().multiply(2);
|
final Insets padding = this.propertyPadding.getPixel();
|
||||||
final Vector2f margin = this.propertyMargin.getPixel().multiply(2);
|
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.minSize = calculatedBoxMinSize;
|
||||||
this.maxSize = Vector2f.max(this.minSize, this.propertyMaxSize.getPixel());
|
this.maxSize = Vector2f.max(this.minSize, this.propertyMaxSize.getPixel());
|
||||||
markToRedraw();
|
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
|
@Override
|
||||||
public void onChangeSize() {
|
public void onChangeSize() {
|
||||||
@ -198,36 +215,46 @@ public class Box extends Container {
|
|||||||
if (this.propertyHide) {
|
if (this.propertyHide) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (this.subWidget == null) {
|
final Insets offsetSubWidget = getBorderAggregation();
|
||||||
return;
|
Vector2f subWidgetSize = Vector2f.ZERO;
|
||||||
}
|
if (this.subWidget != null) {
|
||||||
final Vector2f localPadding = this.propertyPadding.getPixel();
|
subWidgetSize = this.subWidget.getCalculateMinSize();
|
||||||
final Vector2f localMargin = this.propertyMargin.getPixel();
|
if (this.subWidget.canExpand().x() && this.propertyFill.x()) {
|
||||||
final Insets localBorderSize = this.propertyBorderWidth.getPixel();
|
subWidgetSize = subWidgetSize.withX(this.size.x());
|
||||||
final Vector2f offsetSubWidget = localPadding.add(localMargin).add(localBorderSize.toVector2f());
|
} else {
|
||||||
|
subWidgetSize = subWidgetSize.withX(this.minSize.x());
|
||||||
Vector2f subWidgetSize = this.subWidget.getCalculateMinSize();
|
}
|
||||||
if (this.subWidget.canExpand().x() && this.propertyFill.x()) {
|
if (this.subWidget.canExpand().y() && this.propertyFill.y()) {
|
||||||
subWidgetSize = subWidgetSize.withX(this.size.x());
|
subWidgetSize = subWidgetSize.withY(this.size.y());
|
||||||
|
} else {
|
||||||
|
subWidgetSize = subWidgetSize.withY(this.minSize.y());
|
||||||
|
}
|
||||||
} else {
|
} 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.less(offsetSubWidget.toVector2f());
|
||||||
subWidgetSize = subWidgetSize.withY(this.size.y());
|
|
||||||
} else {
|
|
||||||
subWidgetSize = subWidgetSize.withY(this.minSize.y());
|
|
||||||
}
|
|
||||||
subWidgetSize = subWidgetSize.less(offsetSubWidget.multiply(2));
|
|
||||||
subWidgetSize = subWidgetSize.clipInteger();
|
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.toVector2f()).less(subWidgetSize);
|
||||||
final Vector2f freeSizeWithoutWidget = this.size.less(offsetSubWidget.multiply(2)).less(subWidgetSize);
|
this.insidePositionStart = this.origin.add(this.propertyGravity.gravityGenerateDelta(freeSizeWithoutWidget));
|
||||||
Vector2f subWidgetOrigin = this.origin.add(this.propertyGravity.gravityGenerateDelta(freeSizeWithoutWidget));
|
this.insidePositionStart = this.insidePositionStart.add(offsetSubWidget.getOrigin());
|
||||||
subWidgetOrigin = subWidgetOrigin.add(offsetSubWidget);
|
this.insidePositionStart = this.insidePositionStart.clipInteger();
|
||||||
subWidgetOrigin = subWidgetOrigin.clipInteger();
|
this.insidePositionStop = this.insidePositionStart.add(subWidgetSize);
|
||||||
this.subWidget.setOrigin(subWidgetOrigin);
|
|
||||||
this.subWidget.setSize(subWidgetSize);
|
if (this.subWidget != null) {
|
||||||
this.subWidget.onChangeSize();
|
this.subWidget.setOrigin(this.insidePositionStart);
|
||||||
|
this.subWidget.setSize(subWidgetSize);
|
||||||
|
this.subWidget.onChangeSize();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Vector2f calculateOriginRendering(final Vector2f renderSize) {
|
private Vector2f calculateOriginRendering(final Vector2f renderSize) {
|
||||||
@ -249,31 +276,35 @@ public class Box extends Container {
|
|||||||
public void onRegenerateDisplay() {
|
public void onRegenerateDisplay() {
|
||||||
super.onRegenerateDisplay();
|
super.onRegenerateDisplay();
|
||||||
if (!needRedraw()) {
|
if (!needRedraw()) {
|
||||||
//return;
|
return;
|
||||||
}
|
}
|
||||||
final Vector2f localMargin = this.propertyMargin.size();
|
final Insets localMargin = this.propertyMargin.size();
|
||||||
|
|
||||||
Vector2f renderSize = calculateSizeRendering();
|
Vector2f renderSize = calculateSizeRendering();
|
||||||
Vector2f renderOrigin = calculateOriginRendering(renderSize);
|
this.overPositionStart = calculateOriginRendering(renderSize);
|
||||||
|
this.overPositionStart = this.overPositionStart.add(localMargin.getOrigin());
|
||||||
renderOrigin = renderOrigin.add(localMargin);
|
renderSize = renderSize.less(localMargin.toVector2f());
|
||||||
renderSize = renderSize.less(localMargin.multiply(2));
|
this.overPositionStart = this.overPositionStart.clipInteger();
|
||||||
// not sure this is needed...
|
this.overPositionStop = this.overPositionStart.add(renderSize.clipInteger());
|
||||||
renderSize = renderSize.clipInteger();
|
final Insets offsetSubWidget = getBorderInsideAggregation();
|
||||||
renderOrigin = renderOrigin.clipInteger();
|
this.insidePositionStart = this.overPositionStart.add(offsetSubWidget.getOrigin());
|
||||||
|
this.insidePositionStop = this.overPositionStop.less(offsetSubWidget.getEnd());
|
||||||
renderOrigin = renderOrigin.clipInteger();
|
|
||||||
renderSize = renderSize.clipInteger();
|
|
||||||
this.startPosition = renderOrigin.toVector2i();
|
|
||||||
this.endPosition = renderSize.toVector2i();
|
|
||||||
|
|
||||||
// remove data of the previous composition:
|
// remove data of the previous composition:
|
||||||
this.vectorialDraw.clear();
|
this.vectorialDraw.clear();
|
||||||
this.vectorialDraw.setPaintFillColor(this.propertyColor);
|
this.vectorialDraw.setPaintFillColor(this.propertyColor);
|
||||||
this.vectorialDraw.setPaintStrokeColor(this.propertyBorderColor);
|
this.vectorialDraw.setPaintStrokeColor(this.propertyBorderColor);
|
||||||
//this.vectorialDraw.setPaintStrokeWidth(borderSize);
|
this.vectorialDraw.addRectangle(this.overPositionStart, this.overPositionStop,
|
||||||
this.vectorialDraw.addRectangle(renderOrigin, renderSize, this.propertyBorderWidth.getPixel(),
|
this.propertyBorderWidth.getPixel(), this.propertyBorderRadius.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();
|
this.vectorialDraw.flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,7 +8,6 @@ import org.atriasoft.aknot.annotation.AknotSignal;
|
|||||||
import org.atriasoft.esignal.Connection;
|
import org.atriasoft.esignal.Connection;
|
||||||
import org.atriasoft.esignal.SignalEmpty;
|
import org.atriasoft.esignal.SignalEmpty;
|
||||||
import org.atriasoft.etk.Color;
|
import org.atriasoft.etk.Color;
|
||||||
import org.atriasoft.etk.Dimension2f;
|
|
||||||
import org.atriasoft.etk.DimensionInsets;
|
import org.atriasoft.etk.DimensionInsets;
|
||||||
import org.atriasoft.etk.Uri;
|
import org.atriasoft.etk.Uri;
|
||||||
import org.atriasoft.etk.math.Vector2b;
|
import org.atriasoft.etk.math.Vector2b;
|
||||||
@ -34,7 +33,7 @@ import org.slf4j.LoggerFactory;
|
|||||||
*/
|
*/
|
||||||
public class Button extends Box {
|
public class Button extends Box {
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(Button.class);
|
private static final Logger LOGGER = LoggerFactory.getLogger(Button.class);
|
||||||
|
|
||||||
public static Button createLabelButton(final String label) {
|
public static Button createLabelButton(final String label) {
|
||||||
final Button out = new Button();
|
final Button out = new Button();
|
||||||
final Label labelWidget = new Label();
|
final Label labelWidget = new Label();
|
||||||
@ -46,7 +45,7 @@ public class Button extends Box {
|
|||||||
out.setSubWidget(labelWidget);
|
out.setSubWidget(labelWidget);
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Periodic call to update graphic display
|
* Periodic call to update graphic display
|
||||||
* @param event Time generic event
|
* @param event Time generic event
|
||||||
@ -58,12 +57,12 @@ public class Button extends Box {
|
|||||||
// }
|
// }
|
||||||
self.markToRedraw();
|
self.markToRedraw();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Periodic call handle to remove it when needed
|
/// Periodic call handle to remove it when needed
|
||||||
protected Connection periodicConnectionHanble = new Connection();
|
protected Connection periodicConnectionHanble = new Connection();
|
||||||
|
|
||||||
private Uri propertyConfig = new Uri("THEME", "shape/Button.json", "ewol");
|
private Uri propertyConfig = new Uri("THEME", "shape/Button.json", "ewol");
|
||||||
|
|
||||||
@AknotSignal
|
@AknotSignal
|
||||||
@AknotName(value = "down")
|
@AknotName(value = "down")
|
||||||
@AknotDescription("Button is Down")
|
@AknotDescription("Button is Down")
|
||||||
@ -84,10 +83,10 @@ public class Button extends Box {
|
|||||||
@AknotName(value = "leave")
|
@AknotName(value = "leave")
|
||||||
@AknotDescription("The cursor leave the button")
|
@AknotDescription("The cursor leave the button")
|
||||||
public SignalEmpty signalLeave = new SignalEmpty();
|
public SignalEmpty signalLeave = new SignalEmpty();
|
||||||
|
|
||||||
private boolean buttonPressed = false;
|
private boolean buttonPressed = false;
|
||||||
private final boolean mouseHover = false;
|
private final boolean mouseHover = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*/
|
*/
|
||||||
@ -102,11 +101,11 @@ public class Button extends Box {
|
|||||||
//setPropertyBorderRadius(new Dimension1f(15));
|
//setPropertyBorderRadius(new Dimension1f(15));
|
||||||
setPropertyBorderColor(Color.BLACK);
|
setPropertyBorderColor(Color.BLACK);
|
||||||
setPropertyColor(Color.WHITE);
|
setPropertyColor(Color.WHITE);
|
||||||
setPropertyPadding(new Dimension2f(new Vector2f(3, 3)));
|
setPropertyPadding(new DimensionInsets(3));
|
||||||
setPropertyMargin(new Dimension2f(new Vector2f(0, 0)));
|
setPropertyMargin(new DimensionInsets(0));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@AknotManaged
|
@AknotManaged
|
||||||
@AknotAttribute
|
@AknotAttribute
|
||||||
@AknotName(value = "config")
|
@AknotName(value = "config")
|
||||||
@ -114,7 +113,7 @@ public class Button extends Box {
|
|||||||
public Uri getPropertyConfig() {
|
public Uri getPropertyConfig() {
|
||||||
return this.propertyConfig;
|
return this.propertyConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean onEventEntry(final EventEntry event) {
|
protected boolean onEventEntry(final EventEntry event) {
|
||||||
//LOGGER.debug("BT PRESSED : \"" << UTF8_data << "\" size=" << strlen(UTF8_data));
|
//LOGGER.debug("BT PRESSED : \"" << UTF8_data << "\" size=" << strlen(UTF8_data));
|
||||||
@ -124,7 +123,7 @@ public class Button extends Box {
|
|||||||
}
|
}
|
||||||
return super.onEventEntry(event);
|
return super.onEventEntry(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onEventInput(final EventInput event) {
|
public boolean onEventInput(final EventInput event) {
|
||||||
final Vector2f relPos = relativePosition(event.pos());
|
final Vector2f relPos = relativePosition(event.pos());
|
||||||
@ -184,14 +183,14 @@ public class Button extends Box {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onLostFocus() {
|
protected void onLostFocus() {
|
||||||
this.buttonPressed = false;
|
this.buttonPressed = false;
|
||||||
LOGGER.trace(this.name + " : Remove Focus ...");
|
LOGGER.trace(this.name + " : Remove Focus ...");
|
||||||
//checkStatus();
|
//checkStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPropertyConfig(final Uri propertyConfig) {
|
public void setPropertyConfig(final Uri propertyConfig) {
|
||||||
if (this.propertyConfig.equals(propertyConfig)) {
|
if (this.propertyConfig.equals(propertyConfig)) {
|
||||||
return;
|
return;
|
||||||
|
@ -23,19 +23,19 @@ import org.slf4j.LoggerFactory;
|
|||||||
public class Container extends Widget {
|
public class Container extends Widget {
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(Container.class);
|
private static final Logger LOGGER = LoggerFactory.getLogger(Container.class);
|
||||||
protected Widget subWidget = null;
|
protected Widget subWidget = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*/
|
*/
|
||||||
public Container() {}
|
public Container() {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor with his child
|
* Constructor with his child
|
||||||
*/
|
*/
|
||||||
public Container(final Widget subWidget) {
|
public Container(final Widget subWidget) {
|
||||||
this.subWidget = subWidget;
|
this.subWidget = subWidget;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void calculateMinMaxSize() {
|
public void calculateMinMaxSize() {
|
||||||
// call main class
|
// call main class
|
||||||
@ -48,7 +48,7 @@ public class Container extends Widget {
|
|||||||
}
|
}
|
||||||
LOGGER.trace("[{}] Result min size : {}", getId(), this.minSize);
|
LOGGER.trace("[{}] Result min size : {}", getId(), this.minSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void drawWidgetTree(int level) {
|
public void drawWidgetTree(int level) {
|
||||||
super.drawWidgetTree(level);
|
super.drawWidgetTree(level);
|
||||||
@ -57,7 +57,7 @@ public class Container extends Widget {
|
|||||||
this.subWidget.drawWidgetTree(level);
|
this.subWidget.drawWidgetTree(level);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EwolObject getSubObjectNamed(final String objectName) {
|
public EwolObject getSubObjectNamed(final String objectName) {
|
||||||
final EwolObject tmpObject = super.getSubObjectNamed(objectName);
|
final EwolObject tmpObject = super.getSubObjectNamed(objectName);
|
||||||
@ -69,7 +69,7 @@ public class Container extends Widget {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get the main node widget
|
* get the main node widget
|
||||||
* @return the requested pointer on the node
|
* @return the requested pointer on the node
|
||||||
@ -81,17 +81,18 @@ public class Container extends Widget {
|
|||||||
public Widget getSubWidget() {
|
public Widget getSubWidget() {
|
||||||
return this.subWidget;
|
return this.subWidget;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Widget getWidgetAtPos(final Vector2f pos) {
|
public Widget getWidgetAtPos(final Vector2f pos) {
|
||||||
if (!this.propertyHide) {
|
if (this.propertyHide) {
|
||||||
if (this.subWidget != null) {
|
return null;
|
||||||
return this.subWidget.getWidgetAtPos(pos);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return null;
|
if (this.subWidget != null) {
|
||||||
|
return this.subWidget.getWidgetAtPos(pos);
|
||||||
|
}
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Override
|
// @Override
|
||||||
// public boolean loadXML(final XmlElement node) {
|
// public boolean loadXML(final XmlElement node) {
|
||||||
// if (node == null) {
|
// if (node == null) {
|
||||||
@ -136,7 +137,7 @@ public class Container extends Widget {
|
|||||||
// }
|
// }
|
||||||
// return true;
|
// return true;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onChangeSize() {
|
public void onChangeSize() {
|
||||||
super.onChangeSize();
|
super.onChangeSize();
|
||||||
@ -154,14 +155,14 @@ public class Container extends Widget {
|
|||||||
this.subWidget.setSize(this.size);
|
this.subWidget.setSize(this.size);
|
||||||
this.subWidget.onChangeSize();
|
this.subWidget.onChangeSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onRegenerateDisplay() {
|
public void onRegenerateDisplay() {
|
||||||
if (this.subWidget != null) {
|
if (this.subWidget != null) {
|
||||||
this.subWidget.systemRegenerateDisplay();
|
this.subWidget.systemRegenerateDisplay();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void requestDestroyFromChild(final EwolObject child) {
|
public void requestDestroyFromChild(final EwolObject child) {
|
||||||
if (this.subWidget != child) {
|
if (this.subWidget != child) {
|
||||||
@ -174,7 +175,7 @@ public class Container extends Widget {
|
|||||||
this.subWidget = null;
|
this.subWidget = null;
|
||||||
markToRedraw();
|
markToRedraw();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setOffset(final Vector2f newVal) {
|
public void setOffset(final Vector2f newVal) {
|
||||||
if (this.offset.equals(newVal)) {
|
if (this.offset.equals(newVal)) {
|
||||||
@ -183,9 +184,9 @@ public class Container extends Widget {
|
|||||||
super.setOffset(newVal);
|
super.setOffset(newVal);
|
||||||
// recalculate the new sise and position of sub widget ...
|
// recalculate the new sise and position of sub widget ...
|
||||||
onChangeSize();
|
onChangeSize();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* set the subWidget node widget.
|
* set the subWidget node widget.
|
||||||
* @param newWidget The widget to add.
|
* @param newWidget The widget to add.
|
||||||
@ -202,7 +203,7 @@ public class Container extends Widget {
|
|||||||
markToRedraw();
|
markToRedraw();
|
||||||
requestUpdateSize();
|
requestUpdateSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* remove the subWidget node (async).
|
* remove the subWidget node (async).
|
||||||
*/
|
*/
|
||||||
@ -214,7 +215,7 @@ public class Container extends Widget {
|
|||||||
requestUpdateSize();
|
requestUpdateSize();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Replace a old subwidget with a new one.
|
* Replace a old subwidget with a new one.
|
||||||
* @param oldWidget The widget to replace.
|
* @param oldWidget The widget to replace.
|
||||||
@ -233,7 +234,7 @@ public class Container extends Widget {
|
|||||||
markToRedraw();
|
markToRedraw();
|
||||||
requestUpdateSize();
|
requestUpdateSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unlink the subwidget Node.
|
* Unlink the subwidget Node.
|
||||||
*/
|
*/
|
||||||
@ -243,7 +244,7 @@ public class Container extends Widget {
|
|||||||
}
|
}
|
||||||
this.subWidget = null;
|
this.subWidget = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void systemDraw(final DrawProperty displayProp) {
|
public void systemDraw(final DrawProperty displayProp) {
|
||||||
if (this.propertyHide) {
|
if (this.propertyHide) {
|
||||||
|
@ -11,12 +11,11 @@ import org.atriasoft.aknot.annotation.AknotSignal;
|
|||||||
import org.atriasoft.esignal.Connection;
|
import org.atriasoft.esignal.Connection;
|
||||||
import org.atriasoft.esignal.Signal;
|
import org.atriasoft.esignal.Signal;
|
||||||
import org.atriasoft.esignal.SignalEmpty;
|
import org.atriasoft.esignal.SignalEmpty;
|
||||||
import org.atriasoft.etk.Uri;
|
import org.atriasoft.etk.Color;
|
||||||
|
import org.atriasoft.etk.DimensionInsets;
|
||||||
import org.atriasoft.etk.math.FMath;
|
import org.atriasoft.etk.math.FMath;
|
||||||
import org.atriasoft.etk.math.Vector2f;
|
import org.atriasoft.etk.math.Vector2f;
|
||||||
import org.atriasoft.etk.math.Vector2i;
|
|
||||||
import org.atriasoft.ewol.Padding;
|
import org.atriasoft.ewol.Padding;
|
||||||
import org.atriasoft.ewol.compositing.CompositingSVG;
|
|
||||||
import org.atriasoft.ewol.compositing.CompositingText;
|
import org.atriasoft.ewol.compositing.CompositingText;
|
||||||
import org.atriasoft.ewol.compositing.GuiShapeMode;
|
import org.atriasoft.ewol.compositing.GuiShapeMode;
|
||||||
import org.atriasoft.ewol.event.EventEntry;
|
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);
|
private static final Logger LOGGER = LoggerFactory.getLogger(Entry.class);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -69,12 +68,10 @@ public class Entry extends Widget {
|
|||||||
private int displayCursorPositionPixel = 0;
|
private int displayCursorPositionPixel = 0;
|
||||||
/// text display this.text
|
/// text display this.text
|
||||||
private final CompositingText text = new CompositingText();
|
private final CompositingText text = new CompositingText();
|
||||||
protected CompositingSVG vectorialDraw = new CompositingSVG();
|
|
||||||
/// text position can have change
|
/// text position can have change
|
||||||
private boolean needUpdateTextPos = true;
|
private boolean needUpdateTextPos = true;
|
||||||
/// Periodic call handle to remove it when needed
|
/// Periodic call handle to remove it when needed
|
||||||
protected Connection periodicConnectionHanble = new Connection();
|
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 int propertyMaxCharacter = Integer.MAX_VALUE; //!< number max of Character in the list
|
||||||
private boolean propertyPassword = false; //!< Disable display of the content of the entry
|
private boolean propertyPassword = false; //!< Disable display of the content of the entry
|
||||||
|
|
||||||
@ -101,10 +98,6 @@ public class Entry extends Widget {
|
|||||||
@AknotName(value = "modify")
|
@AknotName(value = "modify")
|
||||||
@AknotDescription("Entry box value change")
|
@AknotDescription("Entry box value change")
|
||||||
public Signal<String> signalModify = new Signal<>(); //!< data change
|
public Signal<String> signalModify = new Signal<>(); //!< data change
|
||||||
// element over:
|
|
||||||
Vector2f overPositionStart = Vector2f.ZERO;
|
|
||||||
|
|
||||||
Vector2f overPositionStop = Vector2f.ZERO;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
@ -126,23 +119,15 @@ public class Entry extends Widget {
|
|||||||
shortCutAdd("ctrl+a", "select:all");
|
shortCutAdd("ctrl+a", "select:all");
|
||||||
shortCutAdd("ctrl+shift+a", "select:none");
|
shortCutAdd("ctrl+shift+a", "select:none");
|
||||||
//TODO this.signalShortcut.connect(this, Entry::onCallbackShortCut);
|
//TODO this.signalShortcut.connect(this, Entry::onCallbackShortCut);
|
||||||
|
setPropertyColor(Color.WHITE);
|
||||||
|
setPropertyBorderColor(Color.BLACK);
|
||||||
|
setPropertyBorderWidth(new DimensionInsets(2));
|
||||||
|
setPropertyPadding(new DimensionInsets(4));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void calculateMinMaxSize() {
|
public void calculateMinMaxSize() {
|
||||||
// call main class
|
calculateMinMaxSizeChild(new Vector2f(25, this.text.getHeight()));
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void changeStatusIn(final GuiShapeMode newStatusId) {
|
protected void changeStatusIn(final GuiShapeMode newStatusId) {
|
||||||
@ -175,11 +160,7 @@ public class Entry extends Widget {
|
|||||||
final String tmpData = this.propertyValue.substring(pos1, pos2);
|
final String tmpData = this.propertyValue.substring(pos1, pos2);
|
||||||
ClipBoard.set(clipboardID, tmpData);
|
ClipBoard.set(clipboardID, tmpData);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Uri getPropertyConfig() {
|
|
||||||
return this.propertyConfig;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getPropertyMaxCharacter() {
|
public int getPropertyMaxCharacter() {
|
||||||
return this.propertyMaxCharacter;
|
return this.propertyMaxCharacter;
|
||||||
}
|
}
|
||||||
@ -296,15 +277,13 @@ public class Entry extends Widget {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onDraw() {
|
protected void onDraw() {
|
||||||
if (this.vectorialDraw != null) {
|
super.onDraw();
|
||||||
this.vectorialDraw.draw(true);
|
|
||||||
}
|
|
||||||
this.text.draw();
|
this.text.draw();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEventClipboard(final ClipboardList clipboardID) {
|
public void onEventClipboard(final ClipboardList clipboardID) {
|
||||||
// remove curent selected data ...
|
// remove current selected data ...
|
||||||
removeSelected();
|
removeSelected();
|
||||||
// get current selection / Copy :
|
// get current selection / Copy :
|
||||||
final String tmpData = ClipBoard.get(clipboardID);
|
final String tmpData = ClipBoard.get(clipboardID);
|
||||||
@ -403,10 +382,10 @@ public class Entry extends Widget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onEventInput(final EventInput event) {
|
protected boolean onEventInput(final EventInput event) {
|
||||||
final Vector2f absolutePosition = event.pos();
|
final Vector2f absolutePosition = event.pos();
|
||||||
final Vector2f relPos = relativePosition(absolutePosition);
|
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 (event.inputId() == 0) {
|
||||||
if (!isFocused()) {
|
if (!isFocused()) {
|
||||||
if (KeyStatus.leave == event.status()) {
|
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()
|
if (!isInside(relPos)) {
|
||||||
|| relPos.x() > this.overPositionStop.x() || relPos.y() > this.overPositionStop.y()) {
|
|
||||||
LOGGER.warn("Reject {}", relPos);
|
LOGGER.warn("Reject {}", relPos);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -520,55 +498,20 @@ public class Entry extends Widget {
|
|||||||
hideKeyboard();
|
hideKeyboard();
|
||||||
markToRedraw();
|
markToRedraw();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onRegenerateDisplay() {
|
public void onRegenerateDisplay() {
|
||||||
if (!needRedraw()) {
|
if (!needRedraw()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//LOGGER.trace("Regenerate Display ==> is needed: '" + this.propertyValue + "'");
|
super.onRegenerateDisplay();
|
||||||
this.vectorialDraw.clear();
|
// 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.clear();
|
||||||
if (this.colorIdTextFg >= 0) {
|
//this.text.setClippingWidth(this.insidePositionStart, this.insidePositionStop);
|
||||||
//this.text.setDefaultColorFg(this.shape.getColor(this.colorIdTextFg));
|
this.text.setPos(this.insidePositionStart.add(0, offsetCenter));
|
||||||
//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));
|
|
||||||
if (this.displayCursorPosSelection != this.displayCursorPos) {
|
if (this.displayCursorPosSelection != this.displayCursorPos) {
|
||||||
this.text.setCursorSelection(this.displayCursorPos, this.displayCursorPosSelection);
|
this.text.setCursorSelection(this.displayCursorPos, this.displayCursorPosSelection);
|
||||||
} else {
|
} else {
|
||||||
@ -586,29 +529,7 @@ public class Entry extends Widget {
|
|||||||
this.text.printDecorated(this.propertyTextWhenNothing);
|
this.text.printDecorated(this.propertyTextWhenNothing);
|
||||||
}
|
}
|
||||||
this.text.setClippingMode(false);
|
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.text.flush();
|
||||||
this.vectorialDraw.flush();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -666,18 +587,6 @@ public class Entry extends Widget {
|
|||||||
markToRedraw();
|
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
|
@AknotManaged
|
||||||
@AknotAttribute
|
@AknotAttribute
|
||||||
@AknotName(value = "max")
|
@AknotName(value = "max")
|
||||||
|
@ -95,8 +95,8 @@ public class Tick extends Box {
|
|||||||
//setPropertyBorderRadius(new Dimension1f(15));
|
//setPropertyBorderRadius(new Dimension1f(15));
|
||||||
setPropertyBorderColor(Color.BLACK);
|
setPropertyBorderColor(Color.BLACK);
|
||||||
setPropertyColor(Color.WHITE);
|
setPropertyColor(Color.WHITE);
|
||||||
setPropertyPadding(new Dimension2f(new Vector2f(3, 3)));
|
setPropertyPadding(new DimensionInsets(3));
|
||||||
setPropertyMargin(new Dimension2f(new Vector2f(0, 0)));
|
setPropertyMargin(new DimensionInsets(0));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -231,9 +231,9 @@ public class Tick extends Box {
|
|||||||
if (!needRedraw()) {
|
if (!needRedraw()) {
|
||||||
//return;
|
//return;
|
||||||
}
|
}
|
||||||
this.compositingTick.setSource(Uri.getAllDataString(this.uriCheckGreen), this.startPosition.less(4));
|
this.compositingTick.setSource(Uri.getAllDataString(this.uriCheckGreen));//, this.overPositionStart.less(4));
|
||||||
this.compositingTick.setPos(this.propertyMargin.size().add(2));
|
this.compositingTick.setPos(this.overPositionStart.add(2));
|
||||||
this.compositingTick.print(this.startPosition.less(4).toVector2f());
|
this.compositingTick.print(this.overPositionStop.less(this.overPositionStart).less(4));
|
||||||
this.compositingTick.flush();
|
this.compositingTick.flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -111,15 +111,11 @@ public class SpinBase extends Sizer {
|
|||||||
requestUpdateSize();
|
requestUpdateSize();
|
||||||
if (this.widgetEntry == null) {
|
if (this.widgetEntry == null) {
|
||||||
this.widgetEntry = new Entry();
|
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.setPropertyExpand(Vector2b.TRUE_FALSE);
|
||||||
this.widgetEntry.setPropertyFill(Vector2b.TRUE);
|
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) {
|
if (this.widgetButtonDown == null) {
|
||||||
this.widgetButtonDown = new Button();
|
this.widgetButtonDown = new Button();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user