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

Configuration options for color picker layout/style #5153

Open
philpax opened this issue Sep 24, 2024 · 1 comment
Open

Configuration options for color picker layout/style #5153

philpax opened this issue Sep 24, 2024 · 1 comment
Labels
egui feature New feature or request

Comments

@philpax
Copy link

philpax commented Sep 24, 2024

Is your feature request related to a problem? Please describe.
Using egui::widgets::color_picker::color_picker_hsva_2d (or similar) by itself results in a color slider that's much smaller than the row with the drag values:
image

This is because the color area draws its size from style.spacing.slider_with (which is slightly unintuitive if you haven't looked at the code / know that the area is a slider). This can be scaled up in a child UI

ui.scope(|ui| {
    ui.spacing_mut().slider_width = 220.0;
    egui::widgets::color_picker::color_picker_hsva_2d(
        ui,
        &mut egui_color,
        egui::color_picker::Alpha::Opaque,
    );
});

to get reasonable results:
image

However, I don't actually need the ability to change the color format or to copy the color, and would prefer to keep the color slider small.

Describe the solution you'd like
I would like the ability to configure the style and layout of the color picker widget, so that you can specify:

  • the size of the color slider in a more explicit fashion
  • whether or not the color format is shown
  • whether or not the copy button is shown
  • whether or not the raw values of the color are shown

I suspect the best way to do this would be to convert it into a formal Widget so that it can be configured and placed as the user requires.

In addition to this, breaking apart the widget into its constituent components and exposing them would help users pick and choose what they want. For example, making color_slider_2d (or its Widget equivalent) public would be perfect for what I need.

Describe alternatives you've considered
The only solution I can see that would work externally would be to copy the code from egui or to fork it, neither of which is ideal. A short-term fix would be to make all of the relevant constituent functions public, so that they can be used without using the full color_picker.

Additional context
I believe the disparity in size between the color picker and the value row was exacerbated by #2734.

@lucasmerlin lucasmerlin added feature New feature or request egui labels Sep 24, 2024
@lucasmerlin
Copy link
Collaborator

A proper configurable ColorPicker widget would be neat, that would also be useful in my app.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
egui feature New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants