Add brush behavior binary operators kAndThen, kOrElse, and kXorElse#516
Merged
copybara-service[bot] merged 1 commit intomainfrom Feb 25, 2026
Merged
Add brush behavior binary operators kAndThen, kOrElse, and kXorElse#516copybara-service[bot] merged 1 commit intomainfrom
kAndThen, kOrElse, and kXorElse#516copybara-service[bot] merged 1 commit intomainfrom
Conversation
6e377eb to
fd97f36
Compare
…lse` These three operators allow for greater control over how to handle null values (e.g. unavailable source data) in brush behaviors: * `kOrElse` returns the first non-null input, allowing for fallback branches in a brush behavior. If a subtree based on some source (like stylus tilt) is unavailable, the behavior can fall back to a substitute implementation. * `kAndThen` returns the second input, but only if the first input is non-null. This can help when two separate behaviors are meant to work together, but one relies on a source that might be unavailable; `kAndThen` can be used in the other behavior to ensure that it also gets disabled when that source is unavailable. * `kXorElse` is more niche, but can be used to combine two subtrees where only one should normally be defined at a time, and there's no defined way to combine them if both are defined. It can also be used with a constant node to form a sort of "logical not" for null values. PiperOrigin-RevId: 875239647
fd97f36 to
40bfce5
Compare
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add brush behavior binary operators
kAndThen,kOrElse, andkXorElseThese three operators allow for greater control over how to handle null values (e.g. unavailable source data) in brush behaviors:
kOrElsereturns the first non-null input, allowing for fallback branches in a brush behavior. If a subtree based on some source (like stylus tilt) is unavailable, the behavior can fall back to a substitute implementation.kAndThenreturns the second input, but only if the first input is non-null. This can help when two separate behaviors are meant to work together, but one relies on a source that might be unavailable;kAndThencan be used in the other behavior to ensure that it also gets disabled when that source is unavailable.kXorElseis more niche, but can be used to combine two subtrees where only one should normally be defined at a time, and there's no defined way to combine them if both are defined. It can also be used with a constant node to form a sort of "logical not" for null values.