Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
/**
     * Used to notify that a pseudo-class has changed. Typically, this method is called from the invalidated
     * method of a property that is used as a pseudo-class.
     * <code>
     * private static final PseudoClass.State MY_PSEUDO_CLASS_STATE = PseudoClass.getState("my-state");
     *
     * BooleanProperty myPseudoClassState = new BooleanPropertyBase(false) {
     *
     *           @Override public void invalidated() {
     *                pseudoClassStateChanged(MY_PSEUDO_CLASS_STATE);
     *           }
     *
     *           @Override public Object getBean() {
     *               return MyControl.this;
     *           }
     *
     *           @Override public String getName() {
     *               return "myPseudoClassState";
     *           }
     *       };
     * <code>
     * @param pseudoClassState The PseudoClass.State that has changed.
     */
    protected void pseudoClassStateChanged(PseudoClass.State pseudoClassState) {
       // if there are styles that use the given pseudoClassState, mark this node as needing css update
    }

    /**
     * The pseudo-class state of a Node is the state pertaining to this class and all of its super classes. This method is
     * implemented by getting the pseudo-class state of the super class and then or'ing in the pseudo-class state of this class.
     * <code>
     * private static final PseudoClass.State MY_PSEUDO_CLASS_STATE = PseudoClass.getState("my-state");
     *
     * @Override public PseudoClass.States getPseudoClassStates() {
     *      PseudoClass.States states = super.getPseudoClassStates();
     *      if (isMyPseudoClassState()) { states.addState(MY_PSEUDO_CLASS_STATE); }
     *      return state;
     * }
     * <code>
     * @return PseudoClass.States representing the pseudo-class state of this node and the state of its super classes.
     *
     */
    public PseudoClass.States getPseudoClassStates() {
        PseudoClass.States states = PseudoClass.createStatesInstance(); ??[TBD - better to have a instance member and just clear it?]??
        if(isHover()) states.addState(HOVER_PSEUDOCLASS_STATE);
        if(isPressed()) states.addState(PRESSED_PSEUDOCLASS_STATE);
        if(isDisabled()) states.addState(DISABLED_PSEUDOCLASS_STATE);
        if(isFocused()) states.addState(FOCUSED_PSEUDOCLASS_STATE);
        if(impl_isShowMnemonics()) states.addState(SHOW_MNEMONICS_PSEUDOCLASS_STATE);
        return states;
    }

...

Footnotes

  1. Anchor
    1
    1
    Further explanation of property expansion. Consider something like opacityProperty which starts out null. If nothing ever touches it, it stays null. CSS wants to know if opacity can be set before it goes off looking for styles. If it can't be set, then it is skipped. If it can, and no styles for it are found, then opacityProperty should still be null, otherwise every time CSS touches a property it would be expanded - not a good thing. So the isSettable check basically says, the property is settable if it is null or isn't bound. The only time the property is expanded is if there is actually a style for it.