Created
September 13, 2012 04:37
-
-
Save shemnon/3711882 to your computer and use it in GitHub Desktop.
Annotated Styleable CSS Musing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Approach A - Just annotate the property method | |
StyleableDoubleProperty size = new StyleableDoubleProperty(this, "size", 1.0); | |
StyleableDoubleProperty weight = new StyleableDoubleProperty(this, "weight", 200); | |
@Styleable("-x-weight", initial="200pt") | |
public DoubleProperty weightProperty() {return weight;} | |
@Styleable("-x-size") | |
public StyleableDoubleProperty sizeProperty() {return size;} | |
{ // somewhere in the constructor | |
sizeProperty().addInvalidationListener(updateNodeListener); | |
weightProperty().addInvalidationListener(updateNodeListener); | |
} | |
// Approach B - Multiple Annotations | |
StyleableDoubleProperty size = new StyleableDoubleProperty(this, "size", 1.0); | |
StyleableDoubleProperty weight = new StyleableDoubleProperty(this, "weight", 200); | |
@Styleable("-x-weight", initial="200pt") | |
public DoubleProperty weightProperty() {return weight;} | |
@Styleable("-x-size") | |
public StyleableDoubleProperty sizeProperty() {return size;} | |
@StyleUpdate("-x-size") | |
@StyleUpdate("-x-weight") | |
public void noArgsMethod() { | |
... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment