From c72094bfd35f4f49589370355a09e533bd28858e Mon Sep 17 00:00:00 2001 From: pjht Date: Sat, 27 Jan 2024 17:35:07 -0600 Subject: [PATCH] Trim switches down to interaction area only --- resources/Togdown.png | Bin 436 -> 4219 bytes resources/Togneut.png | Bin 397 -> 4210 bytes resources/Togup.png | Bin 423 -> 4205 bytes src/frontpanel.rs | 6 +++--- src/frontpanel/switch.rs | 28 +++++++++++----------------- 5 files changed, 14 insertions(+), 20 deletions(-) diff --git a/resources/Togdown.png b/resources/Togdown.png index 5529e0b525c8363e4852df8a7d3849ec1e7cbb78..9bbd16edc0214f76c127d48e219efe1facb4437e 100644 GIT binary patch literal 4219 zcmeHKe{2&~9B((2tvb{(gbmQ67#WP~U9Z<)M+?q%KME9T*T@JHz205Bb8YWvZ(9dC zaQs-%O_v}EKZX(@BQR0Ozz8I62{HpXh6xxD{6#_log(57Ae#BTYu9Z`VwT8%Yy0}X z@4e6ayzl$G@B6m5-o2nWLzAOXsZ<%x5{C!shoEGqje>92(Mfiw&TwT;ztcHGl?Dw! zsz<5RV97Xj!p;UeMV+cjg?b&7Ot58)TyoS8D0L&)6BG8^VCN<DXI*pTc8kN zXFtnFxSDNxJ0ZV4?uZx{7H$v$2xXxgL`8YvRxSk@+h~7-W$AAM`y?wwV znQ23$avHEq;R_1f&Vm9&j0k={$f;DZmTk=k<{oort?M|r!y|dJ&Q4ifS!}SDjjMN0 z>CzPKCiw%KK55>S^-ZVw^M>n4+U(Ws_3eF4W5)Pzc7FHDq|n_=KwXJm=_QK9{wm$+hyLJ+uZF%jv*o^(ZA3y!x z$&9?k9g}YtUmks6^6tem>oRY2@xk-GcX^_zj_fw(?d-jL>DP_3K57wPZ|H8GJ~ng4 zk-eL#Pc6NBj%2O5RGPWx>Bh5L`PR!t-nl2PxXDMaZ+Wm|-ZOO7>`_WXIP>BTc`?y{_R zN{>K*#CUI+ROXsbF+xa3vx1M)#X_R2rph)aCelnLCm}vAz=!SH8%H~|2+!KJi;OPZ zB^GcMe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lEQ!fwCtN3vkr+E8@c^1ElAit| ziQ+~YkGn6!IYmzJ)%=&Xe0dNH=tIbhg(&P_qfEtbR4KnEK8g4ArhK=jA8>VJNOc3F@DOVTl7{a?R*Ju?71V zCl*CvP>}(<_#6~3sD)Uv7$!Iae;?;35sSyU1%ixhGAw>a=o+DGSPTqHc_h0==o%IS z!%`l}uK$g$jDhDAAA zvbOlry|IP6QdeJVU9P=jx_r3x^2T$aj*DM0ohjRE+tap;cQnjecC9ggz30ulTT`EJ z+r6n-^&R!b^@c4a?z`ysr#{{FZ1=-;7ZKL@anqPP+wXr8>b*64ddcsz_rvBYM?s1G J!^NvN{0$_~mWTiV literal 423 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE0wix1Z>k4zl0AZa85pY67#JE_7#My5g&JNk zFq9fFFuY1&V6d9Oz#v{QXIG#NP=YDR+ueoXe|!I#{XiajiKnkC`*U_)epR9ACzFo? zg}Oam978;gzYTHZYf#{M-NXMl{lNJ@k+v%sc~`UXS1k}%@Sd%!%gp8@>d9d6S|p<4 zPE#p|$gXKKT-c{??u`^R{kp9=y+T(Z_J$kBCD!fCn`-Md9G<+^&c)%C;EfgE3uNqeGq`*Y-YvLNb { 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 }