-
-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Loading status checks…
Control the effect options UI inside Effects
Showing
21 changed files
with
151 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
use eframe::egui::{ComboBox, Slider, Ui}; | ||
use legion_rgb_driver::SPEED_RANGE; | ||
use strum::IntoEnumIterator; | ||
|
||
use crate::{ | ||
enums::{Brightness, Direction}, | ||
gui::style::SpacingStyle, | ||
profile::Profile, | ||
}; | ||
|
||
const COMBOBOX_WIDTH: f32 = 20.0; | ||
|
||
pub fn show(ui: &mut Ui, profile: &mut Profile, update_lights: &mut bool, spacing: &SpacingStyle) { | ||
ui.scope(|ui| { | ||
ui.style_mut().spacing.item_spacing = spacing.default; | ||
|
||
show_brightness(ui, profile, update_lights); | ||
show_direction(ui, profile, update_lights); | ||
show_effect_settings(ui, profile, update_lights); | ||
}); | ||
} | ||
|
||
pub fn show_brightness(ui: &mut Ui, profile: &mut Profile, update_lights: &mut bool) { | ||
ComboBox::from_label("Brightness") | ||
.width(COMBOBOX_WIDTH) | ||
.selected_text({ | ||
let text: &'static str = profile.brightness.into(); | ||
text | ||
}) | ||
.show_ui(ui, |ui| { | ||
for val in Brightness::iter() { | ||
let text: &'static str = val.into(); | ||
*update_lights |= ui.selectable_value(&mut profile.brightness, val, text).changed(); | ||
} | ||
}); | ||
} | ||
|
||
pub fn show_direction(ui: &mut Ui, profile: &mut Profile, update_lights: &mut bool) { | ||
ui.add_enabled_ui(profile.effect.takes_direction(), |ui| { | ||
ComboBox::from_label("Direction") | ||
.width(COMBOBOX_WIDTH) | ||
.selected_text({ | ||
let text: &'static str = profile.direction.into(); | ||
text | ||
}) | ||
.show_ui(ui, |ui| { | ||
for val in Direction::iter() { | ||
let text: &'static str = val.into(); | ||
*update_lights |= ui.selectable_value(&mut profile.direction, val, text).changed(); | ||
} | ||
}); | ||
}); | ||
} | ||
|
||
pub fn show_effect_settings(ui: &mut Ui, profile: &mut Profile, update_lights: &mut bool) { | ||
let range = if profile.effect.is_built_in() { SPEED_RANGE } else { 1..=10 }; | ||
|
||
ui.horizontal(|ui| { | ||
*update_lights |= ui.add_enabled(profile.effect.takes_speed(), Slider::new(&mut profile.speed, range)).changed(); | ||
ui.label("Speed"); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
use default_ui::{show_brightness, show_direction}; | ||
use eframe::egui::{self, Slider}; | ||
|
||
use crate::{enums::Effects, profile::Profile}; | ||
|
||
pub mod ambient; | ||
pub mod christmas; | ||
pub mod default_ui; | ||
pub mod disco; | ||
pub mod fade; | ||
pub mod lightning; | ||
pub mod ripple; | ||
pub mod swipe; | ||
pub mod temperature; | ||
pub mod zones; | ||
|
||
impl Effects { | ||
pub fn show_ui(&mut self, ui: &mut egui::Ui, profile: &mut Profile, update_lights: &mut bool, theme: &crate::gui::style::Theme) { | ||
match self { | ||
Effects::AmbientLight { fps, saturation_boost } => { | ||
ui.scope(|ui| { | ||
ui.style_mut().spacing.item_spacing = theme.spacing.default; | ||
|
||
show_brightness(ui, profile, update_lights); | ||
show_direction(ui, profile, update_lights); | ||
|
||
ui.horizontal(|ui| { | ||
*update_lights |= ui.add(Slider::new(fps, 1..=60)).changed(); | ||
ui.label("FPS"); | ||
}); | ||
ui.horizontal(|ui| { | ||
*update_lights |= ui.add(Slider::new(saturation_boost, 0.0..=1.0)).changed(); | ||
ui.label("Saturation Boost"); | ||
}); | ||
}); | ||
} | ||
_ => { | ||
default_ui::show(ui, profile, update_lights, &theme.spacing); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.