cleanup
This commit is contained in:
parent
3906c76b13
commit
f35ca28c02
2 changed files with 10 additions and 15 deletions
|
@ -884,15 +884,11 @@ impl Editor {
|
||||||
self.tooltip.add(368, 4, 48, 32, "Speed");
|
self.tooltip.add(368, 4, 48, 32, "Speed");
|
||||||
draw_usize(d, textures, 1 << self.sim_speed, (368, 4), SPEED_DIGITS, 1);
|
draw_usize(d, textures, 1 << self.sim_speed, (368, 4), SPEED_DIGITS, 1);
|
||||||
slider(
|
slider(
|
||||||
d,
|
(d, &self.mouse),
|
||||||
&self.mouse,
|
rect(368, 24, 48, 12),
|
||||||
&mut self.sim_speed,
|
&mut self.sim_speed,
|
||||||
0,
|
0,
|
||||||
MAX_SPEED_POWER,
|
MAX_SPEED_POWER,
|
||||||
368,
|
|
||||||
24,
|
|
||||||
48,
|
|
||||||
12,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
self.tooltip.add(420, 4, 180, 32, "Steps");
|
self.tooltip.add(420, 4, 180, 32, "Steps");
|
||||||
|
|
17
src/ui.rs
17
src/ui.rs
|
@ -388,21 +388,20 @@ pub fn draw_usize_small(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn slider(
|
pub fn slider(
|
||||||
d: &mut RaylibDrawHandle,
|
(d, mouse): (&mut RaylibDrawHandle, &MouseInput),
|
||||||
mouse: &MouseInput,
|
bounds: Rectangle,
|
||||||
value: &mut u8,
|
value: &mut u8,
|
||||||
min: u8,
|
min: u8,
|
||||||
max: u8,
|
max: u8,
|
||||||
x: i32,
|
|
||||||
y: i32,
|
|
||||||
width: i32,
|
|
||||||
height: i32,
|
|
||||||
) -> bool {
|
) -> bool {
|
||||||
|
// draw state
|
||||||
// the +1 makes the lowest state look slightly filled and the max state fully filled
|
// the +1 makes the lowest state look slightly filled and the max state fully filled
|
||||||
let percent = (*value - min + 1) as f32 / (max - min + 1) as f32;
|
let percent = (*value - min + 1) as f32 / (max - min + 1) as f32;
|
||||||
d.draw_rectangle(x, y, width, height, BG_WIDGET);
|
d.draw_rectangle_rec(bounds, BG_WIDGET);
|
||||||
d.draw_rectangle(x, y, (width as f32 * percent) as i32, height, Color::CYAN);
|
let mut filled_bounds = bounds;
|
||||||
let bounds = Rectangle::new(x as f32, y as f32, width as f32, height as f32);
|
filled_bounds.width *= percent;
|
||||||
|
d.draw_rectangle_rec(filled_bounds, Color::CYAN);
|
||||||
|
// interaction
|
||||||
if mouse.is_over(bounds) {
|
if mouse.is_over(bounds) {
|
||||||
if mouse.left_hold() {
|
if mouse.left_hold() {
|
||||||
let percent = (mouse.pos().x - bounds.x) / bounds.width;
|
let percent = (mouse.pos().x - bounds.x) / bounds.width;
|
||||||
|
|
Loading…
Reference in a new issue