... for the duration of the session. How can we save those
colors?
Recent colors change a lot, we probably do not want that stored
inside the git repository hosting the slint files... and this is
probably "personal data" and nor "project data" in the first place.
This refactor is to help make future maintenance easier.
Items are now consistently named as brush instead of color.
Instead of one huge brush picker file, various elements such as gradients live in their own file.
The brush picker is also made a bit less 'smart' and doesn't have to fully understand how the current color or brush needs to be updated or if the data tab live preview needs to be updated. In turn the PickerData has been made smarter and looks after these updates.
This has fixed a few bug regarding gradient stops.
Although technically Slint hex colors are #RGBA values, it's common to not see the alpha when its 100% i.e. FF. So a color in code would look like #d1d1d1 and not #d1d1d1ff. However any hex color created by the live-preview components always shows the alpha even if it's 100%.
This change clips the FF from the values create via Slint code. However brush stops are created via Rust and need a separate fix.
Brush and color property widgets no longer show the default value of 'transparent' when a value has not been set. Instead the common symbol for no set color from other tools (a red diagonal line on a white background) is used.
When clicked the color picker is then shown and is populated with a default color that is 100% opaque.
Potential fix for a set of complex gradient stop re-ordering interactions.
Previously when dragging a gradient stop past other stops the items did not re-order as expcected. The current focused stop did not update. Stops could stick to the dragging stop. Stop sliders could disapear from view. These should be fixed but need more manual testing.
This also includes some minor bug fixes:
Floating panels block scroll wheel events to stop the underlying canvas being scrolled.
Hex color value should be applied when defocusing the TextEdit,
This is only exposed when internal types are exposed (such as in the lsp).
The plan is to make this public under a new name/global after the release.
Co-authored-by: Olivier Goffart <olivier.goffart@slint.dev>
live-preview: Keep gradient stops sorted
... when reading them from code and when inserting
new stops.
* live-preview: Add a API to move gradient stops
Gradient stops need to be sorted now, so we need to
have a new API for moving gradient stops -- so the
model can stay sorted as we drag stops around.
In dark mode the new picker looked fine, however in light mode text was misaligned and the brush mode icons were not visible. This PR fixes those issues.
Adds a table editor based on the color picker floating draggable panel.
This includes behaviours that keep the panel inside the bounds of the live preview window and light / dark mode.
The previous solution meant a hidden TouchArea the size of the live-preview handled dragging the color picker. This won't scale as now multiple pickers need to show for the brush picker gradient editor.
This change means the picker now handles the drag logic itself with it's own internal TouchArea.
This change also fixes an issue where moving the window very quickly showed a bug in the code that stops the window moving out side the bounds of the live-preview. It would stop, but too early with a few pixels to spare. Now the picker stops at the actual window bounds.