-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
UI Slider Widget #7116
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
UI Slider Widget #7116
Changes from 20 commits
71056a3
d607e6b
83f2417
6da0e41
3500039
d823b1b
f68eb33
6ed303e
23a22ae
ac8f4dc
c19e507
2c432bf
a038156
13aff11
52bfd93
7b5c9be
ae51b05
4616e76
3957bff
7394000
e5ad68e
b208c9f
c35da65
0a013ac
625673f
841350f
8837a50
65bb68c
acb99e3
1d2bb26
db1564b
95506a2
e98d5a7
48986d1
92ff4f2
8084661
5e51efa
3cc3743
af5f7e7
f47bcfc
d35a9b5
5f6c73f
dd7371b
8d13a1a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,8 @@ | ||
| //! This module contains basic node bundles used to build UIs | ||
|
|
||
| use crate::{ | ||
| widget::Button, BackgroundColor, CalculatedSize, FocusPolicy, Interaction, Node, Style, | ||
| widget::{Button, Slider, SliderDragged, SliderHandle}, | ||
| BackgroundColor, CalculatedSize, FocusPolicy, Interaction, Node, RelativeCursorPosition, Style, | ||
| UiImage, ZIndex, | ||
| }; | ||
| use bevy_ecs::bundle::Bundle; | ||
|
|
@@ -213,3 +214,91 @@ pub struct ButtonBundle { | |
| /// Indicates the depth at which the node should appear in the UI | ||
| pub z_index: ZIndex, | ||
| } | ||
|
|
||
| /// A UI node that is a slider | ||
| #[derive(Bundle, Clone, Debug, Default)] | ||
| pub struct SliderBundle { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could we move this over to the
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm. Honestly think we should do the same with
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I kinda like having every bundles in a single file and not need to search around to find each bundle definition, but I understand that this won't scale super well.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't know if I want to do this in this PR. It was originally supposed to be a simple slider widget, but it's slowly turning into a widget rework.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, it's a case of it being the first "somewhat" advanced widget and will define the structure for all widgets. But I do agree with @IceSentry that we should split it apart into 3 PRs:
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's continue the |
||
| /// Describes the size of the node | ||
| pub node: Node, | ||
| /// Slider specific values | ||
| pub slider: Slider, | ||
| /// Describes the cursor position relative to the slider node | ||
| pub relative_cursor: RelativeCursorPosition, | ||
| /// Describes whether and how the slider has been interacted with by the input | ||
| pub interaction: Interaction, | ||
| /// Whether the slider is currently being dragged by the user | ||
| pub dragged: SliderDragged, | ||
| /// Describes the style including flexbox settings | ||
| pub style: Style, | ||
| /// The background color, which serves as a "fill" for this node | ||
| /// | ||
| /// When combined with `UiImage`, tints the provided image. | ||
| pub background_color: BackgroundColor, | ||
| /// The image of the node | ||
| pub image: UiImage, | ||
| /// The transform of the node | ||
| /// | ||
| /// This field is automatically managed by the UI layout system. | ||
| /// To alter the position of the `NodeBundle`, use the properties of the [`Style`] component. | ||
| pub transform: Transform, | ||
| /// The global transform of the node | ||
| /// | ||
| /// This field is automatically managed by the UI layout system. | ||
| /// To alter the position of the `NodeBundle`, use the properties of the [`Style`] component. | ||
| pub global_transform: GlobalTransform, | ||
| /// Describes the visibility properties of the node | ||
| pub visibility: Visibility, | ||
| /// Algorithmically-computed indication of whether an entity is visible and should be extracted for rendering | ||
| pub computed_visibility: ComputedVisibility, | ||
| } | ||
|
|
||
| /// A UI node that is a slider | ||
| #[derive(Bundle, Clone, Debug)] | ||
| pub struct SliderHandleBundle { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here |
||
| /// Describes the size of the node | ||
| pub node: Node, | ||
| /// Marker component that signals this node is a slider handle | ||
| pub slider_handle: SliderHandle, | ||
| /// Describes the style including flexbox settings | ||
| /// The Slider parent is responsible for managing the position field, all user-made changes will be overwritten. | ||
| pub style: Style, | ||
| /// Whether this node should block interaction with lower nodes | ||
| pub focus_policy: FocusPolicy, | ||
| /// The background color, which serves as a "fill" for this node | ||
| /// | ||
| /// When combined with `UiImage`, tints the provided image. | ||
| pub background_color: BackgroundColor, | ||
| /// The image of the node | ||
| pub image: UiImage, | ||
| /// The transform of the node | ||
| /// | ||
| /// This field is automatically managed by the UI layout system. | ||
| /// To alter the position of the `NodeBundle`, use the properties of the [`Style`] component. | ||
| pub transform: Transform, | ||
| /// The global transform of the node | ||
| /// | ||
| /// This field is automatically managed by the UI layout system. | ||
| /// To alter the position of the `NodeBundle`, use the properties of the [`Style`] component. | ||
| pub global_transform: GlobalTransform, | ||
| /// Describes the visibility properties of the node | ||
| pub visibility: Visibility, | ||
| /// Algorithmically-computed indication of whether an entity is visible and should be extracted for rendering | ||
| pub computed_visibility: ComputedVisibility, | ||
| } | ||
|
|
||
| impl Default for SliderHandleBundle { | ||
| fn default() -> Self { | ||
| Self { | ||
| node: Node::default(), | ||
| slider_handle: SliderHandle, | ||
| style: Style::default(), | ||
| focus_policy: FocusPolicy::Pass, | ||
| background_color: BackgroundColor::default(), | ||
| image: UiImage::default(), | ||
| transform: Transform::default(), | ||
| global_transform: GlobalTransform::default(), | ||
| visibility: Visibility::default(), | ||
| computed_visibility: ComputedVisibility::default(), | ||
| } | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.