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

New drag widget with 3 values, akin to DragFloat3 in ImGui #176

Open
MindSwipe opened this issue Feb 12, 2021 · 6 comments
Open

New drag widget with 3 values, akin to DragFloat3 in ImGui #176

MindSwipe opened this issue Feb 12, 2021 · 6 comments
Labels
feature New feature or request

Comments

@MindSwipe
Copy link

Is your feature request related to a problem? Please describe.
I want to list the translation of a transform in one single row and have it be editable, right now I have to add 3 separate DragValues to a horizontal which results in non uniformly sized boxes to drag, see this screenshot for a visual aid

Describe the solution you'd like
A new widget called DragValue3 which creates 3 equally sized DragValues in one row. Something like this

Describe alternatives you've considered
Adding 3 DragValue s to a horizontal row. This does work, but the boxes to change the values aren't always the same size

@MindSwipe MindSwipe added the feature New feature or request label Feb 12, 2021
@jakobhellermann
Copy link

I used

ui.label("Transform");
ui.columns(3, |ui| {
    ui[0].add(DragValue::f32(&mut x));
    ui[1].add(DragValue::f32(&mut y));
    ui[2].add(DragValue::f32(&mut z));
});

which looks like this:

image

@emilk
Copy link
Owner

emilk commented Feb 18, 2021

Yeah, I agree this is something egui should have. I think the implementation should be just a horizontal layout of three DragValues, but with some fixed width of the dragvalues (would require an addiiton of DragValue::width(...) in the builder).

@emilk emilk added the good first issue Good for newcomers label Feb 28, 2021
@emilk
Copy link
Owner

emilk commented Mar 31, 2021

One problem with DragValue3 is that people will want to use it for both x,y,z and r,g,b and will want to use it with their own Vec3 types, so it needs a lot of customization (e.g. units) and also will be hard to make ergonomic (e.g. passing &mut [f32; 3] will not work for glam::Vec3).

@emilk
Copy link
Owner

emilk commented Mar 31, 2021

By the way, in the next release of egui you can control the size of a DragValue (and other widgets) with:

ui.add_sized(vec2(48.0, 20.0), DragValue::new(&mut self.angle));

I will make all DragValues have the size of Spacing::interact_size which will make them a bit wider by default.

@emilk emilk removed the good first issue Good for newcomers label Apr 5, 2021
@DrOptix
Copy link
Contributor

DrOptix commented Sep 26, 2021

For a horizontal layout is there a way to have some widgets with the minimum required width and others to extent to as much as possible?

I'm trying to shape egui widgets and layouts into somethings like this:

        // +------------------------------------------------------------------+
        // | Transform       X: 12345.67890   Y: 12345.67890   Z: 12345.67890 |
        // | Rotation        X: 12345.67890   Y: 12345.67890   Z: 12345.67890 |
        // | Scale           X: 12345.67890   Y: 12345.67890   Z: 12345.67890 |
        // +------------------------------------------------------------------+

Something like Unity or Unreal transform component editor.

@emilk
Copy link
Owner

emilk commented Sep 30, 2021

For a horizontal layout is there a way to have some widgets with the minimum required width and others to extent to as much as possible?

A horizontal layout has no memory, and so only the last element can be set to "use as much as is available" (the earlier widgets can't know how much later widgets will use).

Grid could theoretically support this (since it remembers the sizes of the columns from previous frame), but currently it does not.

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

No branches or pull requests

4 participants