diff --git a/assets/marble_overlay.png b/assets/marble_overlay.png new file mode 100644 index 0000000..ecdb128 Binary files /dev/null and b/assets/marble_overlay.png differ diff --git a/src/editor.rs b/src/editor.rs index 73c8ca5..165b2fa 100644 --- a/src/editor.rs +++ b/src/editor.rs @@ -718,8 +718,17 @@ impl Editor { }; draw_scaled_texture(d, textures.get(redo_icon), 186, 4, 2.); } - simple_toggle_button(d, &mut self.draw_overlay, 223, 4, 32, 32, 4); + self.tooltip.add(223, 4, 32, 32, "Toggle overlay"); + if simple_button(d, 223, 4, 32, 32) { + self.draw_overlay = !self.draw_overlay; + } + let overlay_btn_icon = if self.draw_overlay { + "marble_overlay" + } else { + "marble" + }; + draw_scaled_texture(d, textures.get(overlay_btn_icon), 223, 4, 2.); if self.sim_state == SimState::Running { self.tooltip.add(260, 4, 32, 32, "Pause"); diff --git a/src/ui.rs b/src/ui.rs index 4186304..c4de24b 100644 --- a/src/ui.rs +++ b/src/ui.rs @@ -167,38 +167,6 @@ pub fn simple_button(d: &mut RaylibDrawHandle, x: i32, y: i32, width: i32, heigh pressed } -pub fn simple_toggle_button( - d: &mut RaylibDrawHandle, - state: &mut bool, - x: i32, - y: i32, - width: i32, - height: i32, - margin: i32, -) { - let mouse_pos = d.get_mouse_position(); - let bounds = Rectangle { - x: x as f32, - y: y as f32, - width: width as f32, - height: height as f32, - }; - let hover = bounds.check_collision_point_rec(mouse_pos); - d.draw_rectangle(x, y, width, height, widget_bg(hover)); - if *state { - d.draw_rectangle( - x + margin, - y + margin, - width - margin * 2, - height - margin * 2, - FG_TOGGLE_ENABLED, - ); - } - if hover && d.is_mouse_button_pressed(MouseButton::MOUSE_BUTTON_LEFT) { - *state = !*state; - } -} - pub fn simple_option_button( d: &mut RaylibDrawHandle, x: i32,