diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 085c8be..8b9d21f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -30,10 +30,10 @@ jobs: steps: - name: Checkout Commit - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Install Rust - uses: hecrj/setup-rust-action@v1 + uses: hecrj/setup-rust-action@v2 with: rust-version: ${{ matrix.toolchain || 'stable' }} @@ -67,10 +67,10 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout Commit - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Install Rust - uses: hecrj/setup-rust-action@v1 + uses: hecrj/setup-rust-action@v2 with: components: clippy @@ -82,10 +82,10 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout Commit - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Install Rust - uses: hecrj/setup-rust-action@v1 + uses: hecrj/setup-rust-action@v2 with: components: rustfmt diff --git a/src/runtime/settings/gui.rs b/src/runtime/settings/gui.rs index 03134b5..19418ca 100644 --- a/src/runtime/settings/gui.rs +++ b/src/runtime/settings/gui.rs @@ -4,7 +4,7 @@ #[cfg(feature = "derive")] pub use asr_derive::Gui; -use crate::runtime::sys; +use crate::{runtime::sys, watcher::Pair}; use super::map::Map; @@ -78,9 +78,7 @@ pub trait Gui { fn update_from(&mut self, settings_map: &Map); } -/// A settings widget that can be added to the settings GUI. This is an internal -/// trait that you don't need to worry about. -#[doc(hidden)] +/// A settings widget that can be used as a field when defining a settings [`Gui`]. pub trait Widget { /// The arguments that are needed to register the widget. type Args: Default; @@ -146,3 +144,20 @@ impl Widget for Title { #[inline] fn update_from(&mut self, _settings_map: &Map, _key: &str, _args: Self::Args) {} } + +impl Widget for Pair { + type Args = T::Args; + + fn register(key: &str, description: &str, settings_map: &Map, args: Self::Args) -> Self { + let value = T::register(key, description, settings_map, args); + Pair { + old: value, + current: value, + } + } + + fn update_from(&mut self, settings_map: &Map, key: &str, args: Self::Args) { + self.old = self.current; + self.current.update_from(settings_map, key, args); + } +}