feat(settings-panel): auto-realign toggle

This commit is contained in:
galister
2024-04-04 21:17:26 +09:00
parent 6cb683a86b
commit 2d0f733c67
2 changed files with 48 additions and 11 deletions

View File

@@ -42,12 +42,14 @@ pub enum Axis {
#[derive(Deserialize, Clone)] #[derive(Deserialize, Clone)]
pub enum HighlightTest { pub enum HighlightTest {
AutoRealign,
NotificationSounds, NotificationSounds,
Notifications, Notifications,
} }
#[derive(Deserialize, Clone)] #[derive(Deserialize, Clone)]
pub enum SystemAction { pub enum SystemAction {
ToggleAutoRealign,
ToggleNotificationSounds, ToggleNotificationSounds,
ToggleNotifications, ToggleNotifications,
PlayspaceResetOffset, PlayspaceResetOffset,
@@ -284,17 +286,14 @@ fn modular_button_highlight(
}; };
if let Some(test) = &data.highlight { if let Some(test) = &data.highlight {
match test { let lit = match test {
HighlightTest::NotificationSounds => { HighlightTest::AutoRealign => app.session.config.realign_on_showhide,
if app.session.config.notifications_sound_enabled { HighlightTest::NotificationSounds => app.session.config.notifications_sound_enabled,
return Some(Vec4::new(1.0, 1.0, 1.0, 0.5)); HighlightTest::Notifications => app.session.config.notifications_enabled,
} };
}
HighlightTest::Notifications => { if lit {
if app.session.config.notifications_enabled { return Some(Vec4::new(1.0, 1.0, 1.0, 0.5));
return Some(Vec4::new(1.0, 1.0, 1.0, 0.5));
}
}
} }
} }
None None
@@ -331,6 +330,23 @@ fn handle_action(action: &ButtonAction, press: &mut PressData, app: &mut AppStat
fn run_system(action: &SystemAction, app: &mut AppState) { fn run_system(action: &SystemAction, app: &mut AppState) {
match action { 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 => { SystemAction::PlayspaceResetOffset => {
app.tasks app.tasks
.enqueue(TaskType::System(SystemTask::ResetPlayspace)); .enqueue(TaskType::System(SystemTask::ResetPlayspace));

View File

@@ -546,6 +546,27 @@ elements:
action: ToggleNotificationSounds action: ToggleNotificationSounds
highlight: NotificationSounds 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 - type: Panel
rect: [50, 605, 500, 1] rect: [50, 605, 500, 1]
bg_color: "#c0c0c0" bg_color: "#c0c0c0"