Skip to content

Commit 4b0579b

Browse files
viridiaickshonpealice-i-cecile
authored
Add scrubbing / dragging to number_input widget. (#24636)
# Objective Part of #19236 This PR is a near-total rewrite of the feathers number input widget. This version adds the ability to edit the value by dragging, behaviorally similar to the widgets in Blender. ## Features * Click to edit textually * Drag to adjust * Adaptive drag speed heuristic * Conditional slider bar (only appears if soft limits are specified) * Soft and hard limits (ref. [Blender documentation](https://docs.blender.org/manual/en/latest/interface/controls/buttons/fields.html#number-fields)) * Precision and step options * Cursor shape changing * Support for different number formats: f32, f64, i32, i64 ## Backwards compatibility The method for programmatically updating the edited value has changed to be more consistent with other widgets - instead of sending an event, you now insert a `NumberInputValue` component with the new value. ## Testing - extensive manual testing via a new example, `feathers_number_input`. ## Additional Information Things left to do: * Visible increment / decrement arrows (only for fields with no soft limit) * Support for unit conversions and units display (meters, centimeters, degrees, etc.) * The theme colors are not final; there's some debate about whether we will need to implement multiple thematic variations of this widget in order to maintain sufficient contrast against different backgrounds. * Accessibility support needs work. * The example has some placeholder labels that we supposed to mirror the input value, but that has not been finished. * Does not enable drag capturing in CursorOption because bevy_picking doesn't work with captured pointers. Note: because of the complexity of this widget, it does not use the "slider" headless widget, and instead is based on the `EditableText` component, with slider-like behaviors layered on top. Also, this widget pretty much subsumes all of the functionality of the feathers slider, making the latter unnecessary. The only advantage of `FeathersSlider` is that, since it only supports `f32`, it has a simpler API. --------- Co-authored-by: ickshonpe <david.curthoys@googlemail.com> Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>
1 parent fa11904 commit 4b0579b

8 files changed

Lines changed: 1319 additions & 209 deletions

File tree

Cargo.toml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5497,6 +5497,18 @@ description = "Gallery of Feathers Widgets"
54975497
category = "UI (User Interface)"
54985498
wasm = true
54995499

5500+
[[example]]
5501+
name = "feathers_number_input"
5502+
path = "examples/ui/widgets/feathers_number_input.rs"
5503+
doc-scrape-examples = true
5504+
required-features = ["bevy_feathers"]
5505+
5506+
[package.metadata.example.feathers_number_input]
5507+
name = "Feathers Number Input"
5508+
description = "Feathers Number Input Options"
5509+
category = "UI (User Interface)"
5510+
wasm = true
5511+
55005512
[[example]]
55015513
name = "render_depth_to_texture"
55025514
path = "examples/shader_advanced/render_depth_to_texture.rs"

0 commit comments

Comments
 (0)