Skip to content

Instantly share code, notes, and snippets.

@shemnon
Created September 13, 2012 04:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shemnon/3711882 to your computer and use it in GitHub Desktop.
Save shemnon/3711882 to your computer and use it in GitHub Desktop.
Annotated Styleable CSS Musing
// 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