make icon for overlay toggle button
This commit is contained in:
parent
16e9049ceb
commit
ff69b967dd
3 changed files with 10 additions and 33 deletions
BIN
assets/marble_overlay.png
Normal file
BIN
assets/marble_overlay.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 400 B |
|
@ -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");
|
||||
|
|
32
src/ui.rs
32
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<T>(
|
||||
d: &mut RaylibDrawHandle,
|
||||
x: i32,
|
||||
|
|
Loading…
Reference in a new issue