settings ui: Add text field support to ui layer (#37868)

This is an initial implementation that isn't used for any settings yet,
but will be used once `Vec<String>` is implemented.

I also updated the window.with_state api to grant access to a
`Context<S>` app reference instead of just an App.

## Example

<img width="603" height="83" alt="Screenshot 2025-09-09 at 2 15 56 PM"
src="https://github.com/user-attachments/assets/7b3fc350-a157-431f-a4bc-80a1806a3147"
/>


Release Notes:

- N/A
This commit is contained in:
Anthony Eid
2025-09-09 18:48:22 +00:00
committed by GitHub
parent 46fb521333
commit 707d0e6ebd
7 changed files with 70 additions and 6 deletions
+13
View File
@@ -43,6 +43,7 @@ pub struct SettingsUiEntry {
#[derive(Clone)]
pub enum SettingsUiItemSingle {
SwitchField,
TextField,
/// A numeric stepper for a specific type of number
NumericStepper(NumType),
ToggleGroup {
@@ -150,6 +151,18 @@ impl SettingsUi for Option<bool> {
}
}
impl SettingsUi for String {
fn settings_ui_item() -> SettingsUiItem {
SettingsUiItem::Single(SettingsUiItemSingle::TextField)
}
}
impl SettingsUi for SettingsUiItem {
fn settings_ui_item() -> SettingsUiItem {
SettingsUiItem::Single(SettingsUiItemSingle::TextField)
}
}
#[repr(u8)]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum NumType {