feat(settings-panel): auto-realign toggle
This commit is contained in:
@@ -42,12 +42,14 @@ pub enum Axis {
|
||||
|
||||
#[derive(Deserialize, Clone)]
|
||||
pub enum HighlightTest {
|
||||
AutoRealign,
|
||||
NotificationSounds,
|
||||
Notifications,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Clone)]
|
||||
pub enum SystemAction {
|
||||
ToggleAutoRealign,
|
||||
ToggleNotificationSounds,
|
||||
ToggleNotifications,
|
||||
PlayspaceResetOffset,
|
||||
@@ -284,17 +286,14 @@ fn modular_button_highlight(
|
||||
};
|
||||
|
||||
if let Some(test) = &data.highlight {
|
||||
match test {
|
||||
HighlightTest::NotificationSounds => {
|
||||
if app.session.config.notifications_sound_enabled {
|
||||
return Some(Vec4::new(1.0, 1.0, 1.0, 0.5));
|
||||
}
|
||||
}
|
||||
HighlightTest::Notifications => {
|
||||
if app.session.config.notifications_enabled {
|
||||
return Some(Vec4::new(1.0, 1.0, 1.0, 0.5));
|
||||
}
|
||||
}
|
||||
let lit = match test {
|
||||
HighlightTest::AutoRealign => app.session.config.realign_on_showhide,
|
||||
HighlightTest::NotificationSounds => app.session.config.notifications_sound_enabled,
|
||||
HighlightTest::Notifications => app.session.config.notifications_enabled,
|
||||
};
|
||||
|
||||
if lit {
|
||||
return Some(Vec4::new(1.0, 1.0, 1.0, 0.5));
|
||||
}
|
||||
}
|
||||
None
|
||||
@@ -331,6 +330,23 @@ fn handle_action(action: &ButtonAction, press: &mut PressData, app: &mut AppStat
|
||||
|
||||
fn run_system(action: &SystemAction, app: &mut AppState) {
|
||||
match action {
|
||||
SystemAction::ToggleAutoRealign => {
|
||||
app.session.config.realign_on_showhide = !app.session.config.realign_on_showhide;
|
||||
Toast::new(
|
||||
ToastTopic::System,
|
||||
format!(
|
||||
"Auto realign is {}.",
|
||||
if app.session.config.realign_on_showhide {
|
||||
"enabled"
|
||||
} else {
|
||||
"disabled"
|
||||
}
|
||||
)
|
||||
.into(),
|
||||
"".into(),
|
||||
)
|
||||
.submit(app);
|
||||
}
|
||||
SystemAction::PlayspaceResetOffset => {
|
||||
app.tasks
|
||||
.enqueue(TaskType::System(SystemTask::ResetPlayspace));
|
||||
|
||||
@@ -546,6 +546,27 @@ elements:
|
||||
action: ToggleNotificationSounds
|
||||
highlight: NotificationSounds
|
||||
|
||||
####### Behavior Section #######
|
||||
- type: Label
|
||||
rect: [15, 490, 570, 24]
|
||||
font_size: 18
|
||||
fg_color: "#ffffff"
|
||||
source: Static
|
||||
text: Behavior
|
||||
|
||||
- type: Button
|
||||
rect: [30, 505, 220, 30]
|
||||
font_size: 12
|
||||
fg_color: "#ffffff"
|
||||
bg_color: "#401010"
|
||||
text: "Auto-Realign"
|
||||
click_down:
|
||||
- type: System
|
||||
action: ToggleAutoRealign
|
||||
highlight: AutoRealign
|
||||
|
||||
####### Footer Section #######
|
||||
|
||||
- type: Panel
|
||||
rect: [50, 605, 500, 1]
|
||||
bg_color: "#c0c0c0"
|
||||
|
||||
Reference in New Issue
Block a user