On Tue, 4 Jun 2024 16:31:49 GMT, Michael Strauß <mstra...@openjdk.org> wrote:
>> This PR completes the CSS Transitions story (see #870) by adding >> interpolation support for backgrounds and borders, making them targetable by >> transitions. >> >> `Background` and `Border` objects are deeply immutable, but not >> interpolatable. Consider the following `Background`, which describes the >> background of a `Region`: >> >> >> Background { >> fills = [ >> BackgroundFill { >> fill = Color.RED >> } >> ] >> } >> >> >> Since backgrounds are deeply immutable, changing the region's background to >> another color requires the construction of a new `Background`, containing a >> new `BackgroundFill`, containing the new `Color`. >> >> Animating the background color using a CSS transition therefore requires the >> entire Background object graph to be interpolatable in order to generate >> intermediate backgrounds. >> >> More specifically, the following types will now implement `Interpolatable`. >> >> - `Insets` >> - `Background` >> - `BackgroundFill` >> - `BackgroundImage` >> - `BackgroundPosition` >> - `BackgroundSize` >> - `Border` >> - `BorderImage` >> - `BorderStroke` >> - `BorderWidths` >> - `CornerRadii` >> - `ImagePattern` >> - `LinearGradient` >> - `RadialGradient` >> - `Stop` >> >> Note that this PR also changes the specification of `Interpolatable` to make >> users aware that they shouldn't assume any particular identity of the object >> returned from the `interpolate()` method. This allows the implementation to >> re-use objects and reduce the number of object allocations. > > Michael Strauß has updated the pull request incrementally with two additional > commits since the last revision: > > - clean up imports > - add since tags This seems like a reasonable enhancement. I'll review it (not immediately, though). @nlisker would you be willing to be the second reviewer? A couple general comments: 1. Since you propose interpolating objects that aren't simple sets of floating-point fields, the overridden interpolate method should specify the behavior of the fields that are not. For example, different types of Paint are sometimes interpolatable and sometimes return either the start or end; some fields of BackgroundImage are interpolatable and others (notably the image itself) return either the start or the end; and so forth. 2. I spotted at least one place where you override equals, but not hashCode, so you'll need to provide an override for that. ------------- PR Comment: https://git.openjdk.org/jfx/pull/1471#issuecomment-2148388868