Skip to content

Commit

Permalink
#102 Various fixes
Browse files Browse the repository at this point in the history
* Add observe to ui_builder
* Fix linting
  • Loading branch information
Alex Parlett authored and eidloi committed Sep 3, 2024
1 parent 4b5e2dd commit 83ed461
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
9 changes: 4 additions & 5 deletions crates/sickle_ui_scaffold/src/theme/dynamic_style.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,9 @@ fn update_dynamic_style_on_flux_change(

fn tick_dynamic_style_stopwatch(
time: Res<Time<Real>>,
mut q_stopwatches: Query<(Entity, &mut DynamicStyleStopwatch)>,
mut commands: Commands,
mut q_stopwatches: Query<&mut DynamicStyleStopwatch>,
) {
for (entity, mut style_stopwatch) in &mut q_stopwatches {
for mut style_stopwatch in &mut q_stopwatches {
style_stopwatch.0.tick(time.delta());
}
}
Expand Down Expand Up @@ -228,10 +227,10 @@ fn update_dynamic_style_on_stopwatch_change(
}

fn cleanup_dynamic_style_stopwatch(
mut q_stopwatches: Query<(Entity, &mut DynamicStyleStopwatch)>,
mut q_stopwatches: Query<(Entity, &DynamicStyleStopwatch)>,
mut commands: Commands,
) {
for (entity, mut style_stopwatch) in &mut q_stopwatches {
for (entity, style_stopwatch) in &mut q_stopwatches {
let remove_stopwatch = match style_stopwatch.1 {
StopwatchLock::None => true,
StopwatchLock::Infinite => false,
Expand Down
7 changes: 6 additions & 1 deletion crates/sickle_ui_scaffold/src/ui_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use bevy::{
hierarchy::BuildChildren,
prelude::*,
};

use bevy::ecs::system::IntoObserverSystem;
use crate::{
ui_commands::EntityCommandsNamedExt,
ui_style::{UiStyle, UiStyleExt, UiStyleUnchecked, UiStyleUncheckedExt},
Expand Down Expand Up @@ -107,6 +107,11 @@ impl UiBuilder<'_, Entity> {
self.entity_commands().named(name);
self
}

pub fn observe<E: Event, B: Bundle, M>(&mut self, system: impl IntoObserverSystem<E, B, M>) -> &mut Self {
self.entity_commands().observe(system);
self
}
}

pub trait UiBuilderExt {
Expand Down
2 changes: 1 addition & 1 deletion src/widgets/inputs/slider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use crate::widgets::layout::{
#[cfg(feature = "observable")]
#[derive(Event, Copy, Clone, Debug)]
pub struct SliderChanged {
ratio: f32
pub ratio: f32
}

pub struct SliderPlugin;
Expand Down

0 comments on commit 83ed461

Please sign in to comment.