Skip to content

Commit

Permalink
Reordered some code to conform to HSBK
Browse files Browse the repository at this point in the history
  • Loading branch information
samclane committed Oct 28, 2024
1 parent dac05f9 commit ca1f005
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
26 changes: 13 additions & 13 deletions src/action.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,18 @@ pub enum UserAction {
SetPower {
power: bool,
},
SetBrightness {
brightness: u16,
SetHue {
hue: u16,
},
SetSaturation {
saturation: u16,
},
SetBrightness {
brightness: u16,
},
SetKelvin {
kelvin: u16,
},
SetHue {
hue: u16,
},
}

impl UserAction {
Expand Down Expand Up @@ -207,10 +207,10 @@ impl UserAction {
UserAction::Refresh,
UserAction::TogglePower,
UserAction::SetPower { power: true },
UserAction::SetBrightness { brightness: 1 },
UserAction::SetHue { hue: 0 },
UserAction::SetSaturation { saturation: 1 },
UserAction::SetBrightness { brightness: 1 },
UserAction::SetKelvin { kelvin: 3500 },
UserAction::SetHue { hue: 0 },
UserAction::SetColor {
hue: 0,
saturation: 1,
Expand All @@ -231,12 +231,13 @@ impl UserAction {
kelvin,
} => {
if let Some(device) = device {
hsbk_sliders(ui, hue, saturation, brightness, &device, kelvin)
hsbk_sliders(ui, hue, saturation, brightness, kelvin, &device)
} else {
ui.label("No device selected")
}
}
UserAction::SetPower { power } => ui.checkbox(power, "Power"),
UserAction::SetHue { hue } => hue_slider(ui, hue),
UserAction::SetBrightness { brightness } => brightness_slider(ui, brightness),
UserAction::SetSaturation { saturation } => saturation_slider(ui, saturation),
UserAction::SetKelvin { kelvin } => {
Expand All @@ -246,7 +247,6 @@ impl UserAction {
ui.label("No device selected")
}
}
UserAction::SetHue { hue } => hue_slider(ui, hue),
}
}
}
Expand All @@ -267,14 +267,14 @@ impl Display for UserAction {
hue, saturation, brightness, kelvin
),
UserAction::SetPower { power } => write!(f, "Set Power: {}", power),
UserAction::SetBrightness { brightness } => {
write!(f, "Set Brightness: {}", brightness)
}
UserAction::SetHue { hue } => write!(f, "Set Hue: {}", hue),
UserAction::SetSaturation { saturation } => {
write!(f, "Set Saturation: {}", saturation)
}
UserAction::SetBrightness { brightness } => {
write!(f, "Set Brightness: {}", brightness)
}
UserAction::SetKelvin { kelvin } => write!(f, "Set Kelvin: {}", kelvin),
UserAction::SetHue { hue } => write!(f, "Set Hue: {}", hue),
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,8 @@ impl MantleApp {
&mut hue,
&mut saturation,
&mut brightness,
device,
&mut kelvin,
device,
);
DeltaColor {
next: HSBK {
Expand Down
2 changes: 1 addition & 1 deletion src/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -611,8 +611,8 @@ pub fn hsbk_sliders(
hue: &mut u16,
saturation: &mut u16,
brightness: &mut u16,
device: &DeviceInfo,
kelvin: &mut u16,
device: &DeviceInfo,
) -> egui::Response {
ui.vertical(|ui| {
ui.horizontal(|ui| {
Expand Down

0 comments on commit ca1f005

Please sign in to comment.