diff --git a/resources/Togdown.png b/resources/Togdown.png index 5529e0b..9bbd16e 100644 Binary files a/resources/Togdown.png and b/resources/Togdown.png differ diff --git a/resources/Togneut.png b/resources/Togneut.png index 9cfc71a..52d3180 100644 Binary files a/resources/Togneut.png and b/resources/Togneut.png differ diff --git a/resources/Togup.png b/resources/Togup.png index 67dd7f6..ba4f946 100644 Binary files a/resources/Togup.png and b/resources/Togup.png differ diff --git a/src/frontpanel.rs b/src/frontpanel.rs index 81b1e4e..5d5de3b 100644 --- a/src/frontpanel.rs +++ b/src/frontpanel.rs @@ -89,7 +89,7 @@ impl Widget for Frontpanel<'_> { pos.y *= y_scale; pos += fp_rect.left_top().to_vec2(); if i == 0 { - ui.allocate_ui_at_rect(Rect::from_center_size(pos, vec2(32.0, 32.0)), |ui| { + ui.allocate_ui_at_rect(Rect::from_center_size(pos, vec2(11.0, 25.0)), |ui| { let mut power_inv = !state.power; if ui .add(switch::ToggleSwitch::new(&mut power_inv, &sw_textures)) @@ -108,7 +108,7 @@ impl Widget for Frontpanel<'_> { if (1..17).contains(&i) { let bit_mask = 1 << (16 - i); let mut sw_state = state.ad_sws & bit_mask > 0; - ui.allocate_ui_at_rect(Rect::from_center_size(pos, vec2(32.0, 32.0)), |ui| { + ui.allocate_ui_at_rect(Rect::from_center_size(pos, vec2(11.0, 25.0)), |ui| { if ui.add(switch::ToggleSwitch::new(&mut sw_state, &sw_textures)).drag_started() { self.audio_tx.send(AudioMessage::PlaySwitchClick).unwrap(); }; @@ -127,7 +127,7 @@ impl Widget for Frontpanel<'_> { 24 => &mut state.aux2, _ => unreachable!(), }; - ui.allocate_ui_at_rect(Rect::from_center_size(pos, vec2(32.0, 32.0)), |ui| { + ui.allocate_ui_at_rect(Rect::from_center_size(pos, vec2(11.0, 25.0)), |ui| { if ui.add(switch::ThreePosSwitch::new(state, &sw_textures)).drag_started() { self.audio_tx.send(AudioMessage::PlaySwitchClick).unwrap(); }; diff --git a/src/frontpanel/switch.rs b/src/frontpanel/switch.rs index 04087d5..2d8b5dc 100644 --- a/src/frontpanel/switch.rs +++ b/src/frontpanel/switch.rs @@ -64,23 +64,21 @@ impl<'a> ThreePosSwitch<'a> { impl Widget for ThreePosSwitch<'_> { fn ui(self, ui: &mut eframe::egui::Ui) -> eframe::egui::Response { - let (resp, painter) = ui.allocate_painter((32.0, 32.0).into(), Sense::drag()); + let (resp, painter) = ui.allocate_painter((11.0, 25.0).into(), Sense::drag()); painter.image( self.textures.get_for_state(*self.state), - Rect::from_min_size(painter.clip_rect().left_top(), vec2(32.0, 32.0)), + Rect::from_min_size(painter.clip_rect().left_top(), vec2(11.0, 25.0)), NULL_UV, NULL_TINT, ); if resp.drag_started() { let interact_pos = resp.interact_pointer_pos().unwrap(); - let sw_center = painter.clip_rect().left_top() + vec2(15.0, 16.0); - if Rect::from_center_size(interact_pos, (10.0, 24.0).into()).contains(sw_center) { - if interact_pos.y > sw_center.y { - *self.state = SwitchState::Down; - } else { - *self.state = SwitchState::Up; - }; - } + let sw_center = painter.clip_rect().left_top() + vec2(5.0, 12.0); + if interact_pos.y > sw_center.y { + *self.state = SwitchState::Down; + } else { + *self.state = SwitchState::Up; + }; } else if resp.drag_released() { *self.state = SwitchState::Neut; } @@ -101,19 +99,15 @@ impl<'a> ToggleSwitch<'a> { impl Widget for ToggleSwitch<'_> { fn ui(self, ui: &mut eframe::egui::Ui) -> eframe::egui::Response { - let (resp, painter) = ui.allocate_painter((32.0, 32.0).into(), Sense::drag()); + let (resp, painter) = ui.allocate_painter((11.0, 25.0).into(), Sense::drag()); painter.image( self.textures.get_for_bool(*self.state), - Rect::from_min_size(painter.clip_rect().left_top(), vec2(32.0, 32.0)), + Rect::from_min_size(painter.clip_rect().left_top(), vec2(11.0, 25.0)), NULL_UV, NULL_TINT, ); if resp.drag_started() { - let interact_pos = resp.interact_pointer_pos().unwrap(); - let sw_center = painter.clip_rect().left_top() + vec2(15.0, 16.0); - if Rect::from_center_size(interact_pos, (10.0, 24.0).into()).contains(sw_center) { - *self.state = !*self.state; - } + *self.state = !*self.state; } resp }