This commit is contained in:
Crispy 2024-12-24 23:32:25 +01:00
parent f35ca28c02
commit 74d142191c
2 changed files with 6 additions and 11 deletions

View file

@ -1024,8 +1024,7 @@ impl Editor {
|(row, col): (i32, i32), texture: &str, tooltip: &'static str, tool_option: Tool| { |(row, col): (i32, i32), texture: &str, tooltip: &'static str, tool_option: Tool| {
let border = 4.; let border = 4.;
let gap = 2.; let gap = 2.;
let tex_size = 32.; let button_size = 32. + border * 2.;
let button_size = tex_size + border * 2.;
let grid_size = button_size + gap * 2.; let grid_size = button_size + gap * 2.;
let pos = Vector2 { let pos = Vector2 {
x: 100. + col as f32 * grid_size - if col < 0 { 10. } else { 0. }, x: 100. + col as f32 * grid_size - if col < 0 { 10. } else { 0. },
@ -1036,13 +1035,11 @@ impl Editor {
tooltip, tooltip,
); );
scrollable_texture_option_button( scrollable_texture_option_button(
d, (d, &self.mouse),
&self.mouse,
pos, pos,
textures.get(texture), textures.get(texture),
tool_option, tool_option,
&mut self.active_tool, &mut self.active_tool,
tex_size,
border, border,
) )
}; };

View file

@ -299,13 +299,11 @@ pub fn text_input(
} }
pub fn scrollable_texture_option_button<T>( pub fn scrollable_texture_option_button<T>(
d: &mut RaylibDrawHandle, (d, mouse): (&mut RaylibDrawHandle, &MouseInput),
mouse: &MouseInput,
pos: Vector2, pos: Vector2,
texture: &Texture2D, texture: &Texture2D,
option: T, option: T,
current: &mut T, current: &mut T,
tex_size: f32,
border: f32, border: f32,
) -> Option<Scroll> ) -> Option<Scroll>
where where
@ -314,8 +312,8 @@ where
let bounds = Rectangle { let bounds = Rectangle {
x: pos.x, x: pos.x,
y: pos.y, y: pos.y,
width: tex_size + border * 2., width: 32. + border * 2.,
height: tex_size + border * 2., height: 32. + border * 2.,
}; };
d.draw_rectangle_rec( d.draw_rectangle_rec(
bounds, bounds,
@ -329,7 +327,7 @@ where
texture, texture,
pos + Vector2::new(border, border), pos + Vector2::new(border, border),
0., 0.,
tex_size / texture.width as f32, 32. / texture.width as f32,
Color::WHITE, Color::WHITE,
); );
if mouse.is_over(bounds) { if mouse.is_over(bounds) {