mirror of
https://github.com/aNNiMON/HotaruFX.git
synced 2024-09-19 14:14:21 +03:00
Add visible property
This commit is contained in:
parent
09f5deb561
commit
094954794e
@ -48,6 +48,9 @@ public class NodeValue implements Value {
|
||||
val timeline = property.getProperty().get();
|
||||
val type = property.getType();
|
||||
switch (type) {
|
||||
case BOOLEAN:
|
||||
return type.<Boolean>getToHFX().apply(
|
||||
((PropertyTimeline<Boolean>) timeline).getProperty().getValue());
|
||||
case NUMBER:
|
||||
return type.<Number>getToHFX().apply(
|
||||
((PropertyTimeline<Number>) timeline).getProperty().getValue());
|
||||
@ -76,6 +79,10 @@ public class NodeValue implements Value {
|
||||
val timeline = property.getProperty().get();
|
||||
val type = property.getType();
|
||||
switch (type) {
|
||||
case BOOLEAN:
|
||||
((PropertyTimeline<Boolean>) timeline).getProperty().setValue(
|
||||
type.<Boolean>getFromHFX().apply(value));
|
||||
break;
|
||||
case NUMBER:
|
||||
((PropertyTimeline<Number>) timeline).getProperty().setValue(
|
||||
type.<Number>getFromHFX().apply(value));
|
||||
|
@ -44,6 +44,12 @@ public class PropertyValue implements Value {
|
||||
Validator.with(args).checkAtLeast(2);
|
||||
val type = property.getType();
|
||||
switch (type) {
|
||||
case BOOLEAN:
|
||||
((PropertyTimeline<Boolean>)property.getProperty().get()).add(
|
||||
KeyFrame.of(args[0].asInt()),
|
||||
type.<Boolean>getFromHFX().apply(args[1])
|
||||
);
|
||||
break;
|
||||
case NUMBER:
|
||||
((PropertyTimeline<Number>)property.getProperty().get()).add(
|
||||
KeyFrame.of(args[0].asInt()),
|
||||
|
@ -19,9 +19,11 @@ import lombok.AccessLevel;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.val;
|
||||
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
|
||||
public enum PropertyType {
|
||||
|
||||
BOOLEAN(v -> v.asInt() != 0, o -> NumberValue.fromBoolean(Boolean.TRUE.equals(o))),
|
||||
NUMBER(toNumber(), o -> NumberValue.of((Number) o)),
|
||||
STRING(Value::asString, o -> new StringValue(String.valueOf(o))),
|
||||
NODE(toNode(), fromNode()),
|
||||
|
@ -13,6 +13,7 @@ import static com.annimon.hotarufx.visual.PropertyType.*;
|
||||
public abstract class ObjectNode {
|
||||
|
||||
private final Node node;
|
||||
private PropertyTimelineHolder<Boolean> visible;
|
||||
private PropertyTimelineHolder<Node> clip;
|
||||
private PropertyTimelineHolder<Number> rotate;
|
||||
private PropertyTimelineHolder<Number> translateX, translateY, translateZ;
|
||||
@ -23,6 +24,7 @@ public abstract class ObjectNode {
|
||||
|
||||
public ObjectNode(Node node) {
|
||||
this.node = node;
|
||||
visible = PropertyTimelineHolder.empty();
|
||||
clip = PropertyTimelineHolder.empty();
|
||||
rotate = PropertyTimelineHolder.empty();
|
||||
translateX = PropertyTimelineHolder.empty();
|
||||
@ -40,6 +42,10 @@ public abstract class ObjectNode {
|
||||
return node;
|
||||
}
|
||||
|
||||
public PropertyTimeline<Boolean> visibleProperty() {
|
||||
return visible.setIfEmptyThenGet(node::visibleProperty);
|
||||
}
|
||||
|
||||
public PropertyTimeline<Node> clipProperty() {
|
||||
return clip.setIfEmptyThenGet(node::clipProperty);
|
||||
}
|
||||
@ -81,6 +87,7 @@ public abstract class ObjectNode {
|
||||
}
|
||||
|
||||
public void buildTimeline(TimeLine timeline) {
|
||||
visible.applyIfPresent(timeline);
|
||||
clip.applyIfPresent(timeline);
|
||||
rotate.applyIfPresent(timeline);
|
||||
translateX.applyIfPresent(timeline);
|
||||
@ -99,6 +106,7 @@ public abstract class ObjectNode {
|
||||
|
||||
protected PropertyBindings propertyBindings(PropertyBindings bindings) {
|
||||
return bindings
|
||||
.add("visible", BOOLEAN, this::visibleProperty)
|
||||
.add("clip", CLIP_NODE, this::clipProperty)
|
||||
.add("rotate", NUMBER, this::rotateProperty)
|
||||
.add("translateX", NUMBER, this::translateXProperty)
|
||||
|
@ -16,6 +16,7 @@ A@fill
|
||||
B = rectangle({
|
||||
x: -50,
|
||||
y: -50,
|
||||
visible: 0,
|
||||
width: 100,
|
||||
height: 100,
|
||||
fill: "green"
|
||||
|
Loading…
Reference in New Issue
Block a user