[DEV] set checkbox properties (basic)

This commit is contained in:
Edouard DUPIN 2022-04-12 22:21:50 +02:00
parent ce3e31743d
commit b75a5b383d
3 changed files with 85 additions and 13 deletions

View File

@ -13,7 +13,7 @@ public class MainWindows extends BasicWindows {
//! [ewol_sample_HW_windows_title]
setPropertyTitle("Simple CheckBox");
this.testWidget = new CheckBox();
this.testWidget = new CheckBox("<b>Hello, how Are</b> You?<br/>second-life?");
//this.testWidget.setPropertySource(new Uri("DATA", "mireA.png"));
this.testWidget.setPropertyExpand(Vector3b.TRUE);
this.testWidget.setPropertyFill(Vector3b.TRUE);

View File

@ -1,29 +1,100 @@
package org.atriasoft.ewol.widget;
import org.atriasoft.esignal.Signal;
import org.atriasoft.esignal.SignalEmpty;
import org.atriasoft.etk.math.Vector3b;
import org.atriasoft.ewol.Gravity;
import org.atriasoft.ewol.annotation.EwolDescription;
import org.atriasoft.ewol.annotation.EwolSignal;
import org.atriasoft.ewol.widget.Sizer.DisplayMode;
import org.atriasoft.exml.annotation.XmlAttribute;
import org.atriasoft.exml.annotation.XmlManaged;
import org.atriasoft.exml.annotation.XmlName;
public class CheckBox extends Container {
protected static void eventLabelClick(final CheckBox self) {
self.tick.setPropertyValue(!self.tick.getPropertyValue());
self.signalClick.emit();
}
protected static void eventTickClick(final CheckBox self) {
self.signalClick.emit();
}
protected static void eventTickDown(final CheckBox self) {
self.signalDown.emit();
}
protected static void eventTickUp(final CheckBox self) {
self.signalUp.emit();
}
protected static void eventTickValue(final CheckBox self, final Boolean value) {
self.signalValue.emit(value);
}
@EwolSignal(name = "down", description = "CheckBox is Down")
public SignalEmpty signalDown = new SignalEmpty();
@EwolSignal(name = "up", description = "CheckBox is Up")
public SignalEmpty signalUp = new SignalEmpty();
@EwolSignal(name = "click", description = "CheckBox is Clicked")
public SignalEmpty signalClick = new SignalEmpty();
@EwolSignal(name = "value", description = "CheckBox value change")
public Signal<Boolean> signalValue = new Signal<>();
final Tick tick;
final Label label;
public CheckBox() {
this("No Label");
}
public CheckBox(final String basicLabel) {
final Sizer subs = new Sizer(DisplayMode.modeHori);
subs.setPropertyLockExpand(Vector3b.TRUE);
subs.setPropertyGravity(Gravity.CENTER);
setSubWidget(subs);
final Tick tick = new Tick();
tick.setPropertyExpand(new Vector3b(false, true, true));
tick.setPropertyFill(Vector3b.FALSE);
tick.setPropertyGravity(Gravity.CENTER);
subs.subWidgetAdd(tick);
this.tick = new Tick();
this.tick.setPropertyExpand(new Vector3b(false, true, true));
this.tick.setPropertyFill(Vector3b.FALSE);
this.tick.setPropertyGravity(Gravity.CENTER);
subs.subWidgetAdd(this.tick);
this.tick.signalClick.connectAuto(this, CheckBox::eventTickClick);
this.tick.signalUp.connectAuto(this, CheckBox::eventTickUp);
this.tick.signalDown.connectAuto(this, CheckBox::eventTickDown);
this.tick.signalValue.connectAuto(this, CheckBox::eventTickValue);
final Label label = new Label("No Label");
label.setPropertyExpand(Vector3b.TRUE);
label.setPropertyFill(Vector3b.FALSE);
label.setPropertyGravity(Gravity.LEFT);
subs.subWidgetAdd(label);
this.label = new Label(basicLabel);
this.label.setPropertyExpand(Vector3b.TRUE);
this.label.setPropertyFill(Vector3b.FALSE);
this.label.setPropertyGravity(Gravity.LEFT);
subs.subWidgetAdd(this.label);
this.label.signalPressed.connectAuto(this, CheckBox::eventLabelClick);
}
@XmlManaged
@XmlAttribute
@XmlName(value = "label")
@EwolDescription(value = "value of the label")
public String getPropertyLabel() {
return this.label.getPropertyValue();
}
@XmlManaged
@XmlAttribute
@XmlName(value = "value")
@EwolDescription(value = "State of the checkbox")
public Boolean getPropertyValue() {
return this.tick.getPropertyValue();
}
public void setPropertyLabel(final String value) {
this.label.setPropertyValue(value);
}
public void setPropertyValue(final Boolean value) {
this.tick.setPropertyValue(value);
}
}

View File

@ -71,7 +71,7 @@ public class Tick extends Widget {
@EwolSignal(name = "click", description = "Tick is Clicked")
public SignalEmpty signalClick = new SignalEmpty();
@EwolSignal(name = "value", description = "Tick value change")
public Signal<Boolean> signalValue;
public Signal<Boolean> signalValue = new Signal<>();
// element over:
Vector3f overPositionStart = Vector3f.ZERO;
Vector3f overPositionStop = Vector3f.ZERO;
@ -305,6 +305,7 @@ public class Tick extends Widget {
return;
}
this.propertyValue = propertyValue;
this.signalValue.emit(this.propertyValue);
onChangePropertyValue();
}