Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Button::image(...)s in a grid or horizontal render with weird sizing #5419

Open
keriefie opened this issue Nov 30, 2024 · 1 comment
Open
Labels
bug Something is broken

Comments

@keriefie
Copy link

Trying to make a tool palette in a small window, but the icons render weirdly when placed next to each other, in a grid, as well as in a horizontal. I expect the icons should all be the same size.

The tool palette; the icons in the first column are smaller than the following icons, this also applies to a horizontal element in the context menu. (the icons are blurry consecutively as well which is strange)
image

fn add_image_button<'a>(ui: &mut Ui, icon_source: ImageSource<'a>, size: f32, rounding: f32) {
    ui.add(image_button(icon_source, size, rounding));
}

fn image_button<'a>(icon_source: ImageSource<'a>, size: f32, rounding: f32) -> Button<'a> {
    Button::image(icon_source).min_size(Vec2::splat(size)).rounding(rounding)
}
let tool_palette_open = enum_get!(self, Tab::CharacterDraw, tool_palette_open);
let window = Window::new("")
    .min_width(32.0)
    .open(tool_palette_open);
window.show(ctx, |ui| {
    let sized_icon_button = |ui: &mut Ui, icon_source: ImageSource| {
        add_image_button(ui, icon_source, 32.0, 2.0)
    };
    Grid::new("tool_palette_grid")
        .min_col_width(32.0)
        .spacing(Vec2::splat(5.0))
        .show(ui, |ui| {
            sized_icon_button(ui, include_image!("../assets/icons/zoom_large.svg"));
            sized_icon_button(ui, include_image!("../assets/icons/zoom_large.svg"));
            sized_icon_button(ui, include_image!("../assets/icons/zoom_large.svg"));
            sized_icon_button(ui, include_image!("../assets/icons/zoom_large.svg"));
            sized_icon_button(ui, include_image!("../assets/icons/zoom_large.svg"));
            sized_icon_button(ui, include_image!("../assets/icons/zoom_large.svg"));
            sized_icon_button(ui, include_image!("../assets/icons/zoom_large.svg"));
            ui.end_row();

            sized_icon_button(ui, include_image!("../assets/icons/select_large.svg"));
            sized_icon_button(ui, include_image!("../assets/icons/marquee_large.svg"));
            ui.end_row();

            sized_icon_button(ui, include_image!("../assets/icons/lasso_large.svg"));
            sized_icon_button(ui, include_image!("../assets/icons/move_large.svg"));
            ui.end_row();

            sized_icon_button(ui, include_image!("../assets/icons/expand_large.svg"));
            sized_icon_button(ui, include_image!("../assets/icons/rotate_large.svg"));
            ui.end_row();

            sized_icon_button(ui, include_image!("../assets/icons/eraser_large.svg"));
            sized_icon_button(ui, include_image!("../assets/icons/spline_large.svg"));
            ui.end_row();

            sized_icon_button(ui, include_image!("../assets/icons/pencil_line_large.svg"));
            sized_icon_button(ui, include_image!("../assets/icons/dot_large.svg"));
            ui.end_row();

            sized_icon_button(ui, include_image!("../assets/icons/cut_large.svg"));
            
            menu_custom_button(
                ui, 
                image_button(include_image!("../assets/icons/shapes_large.svg"), 32.0, 2.0),
                |ui| {
                    ui.horizontal(|ui| {
                        sized_icon_button(ui, include_image!("../assets/icons/square_large.svg"));
                        sized_icon_button(ui, include_image!("../assets/icons/circle_large.svg"));
                    });
                },
            );
        });

});
@keriefie keriefie added the bug Something is broken label Nov 30, 2024
@keriefie
Copy link
Author

Oh apparently they render in three different sizes too?
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something is broken
Projects
None yet
Development

No branches or pull requests

1 participant