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

Set sizes are fractions #313

Closed
OvermindDL1 opened this issue Apr 16, 2021 · 3 comments
Closed

Set sizes are fractions #313

OvermindDL1 opened this issue Apr 16, 2021 · 3 comments
Labels
design Some architectual design work needed feature New feature or request

Comments

@OvermindDL1
Copy link

Is your feature request related to a problem? Please describe.

Many areas take in something like impl Into<Vec2>, but this only allows setting a hard (logical) pixel size, which is limited because it can't work based on the viewable area, percentage, etc...

Describe the solution you'd like

It would be most convenient if the arguments that took a size took an enum instead, perhaps with a few useful heads like:

enum Size {
	LogicalPixel(float, float),     // Logical pixels...
	DevicePixel(float, float),      // Device pixels...
	ScreenPercentage(float, float), // 0.0 to 1.0 for the size of the overall screen dimensions
	ParentPercentage(float, float), // 0.0 to 1.0 for the available size the parent is offering it
	SelfPercantage(float, float),   // Multiplier of the 'preferred' size (so (2.0, 2.0) of a label
	                                // would double it's default size in each dimension)
}

Describe alternatives you've considered

Only real alternative that I see currently is calculating everything manually at every location you want to do something other than logical pixels, or reimplementing all the widgets and areas/panels.

@OvermindDL1 OvermindDL1 added the feature New feature or request label Apr 16, 2021
@emilk emilk changed the title More sized types Set sizes are fractions May 9, 2021
@emilk
Copy link
Owner

emilk commented May 9, 2021

I'm not convinced this is an improvement. The current system has the benefit of being simple: there is only one unit and one coordinate system. Going away from this will open up a can of complexity

  • DevicePixel - I see no reason to want to say "this button should be this many physical pixels wide so that it looks different on different on different displays". Seems like an invitation to portability problems
  • ScreenPercentage/ParentPercentage: Is Size::ScreenPercentage(0.2, 0.5) really better than vec2(0.2, 0.5) * screen_size ?
  • ParentPercentage: what parent? the immediate one? and what size? it's current, or its maximum?

I think I need some concrete user stories to be convinced of this.

PS: You are also confusing percentages (0%-100%) with fractions (0-1)

@emilk emilk added the design Some architectual design work needed label Sep 30, 2021
@emilk
Copy link
Owner

emilk commented Sep 30, 2021

Note that for Grid we do want some way to set a row/column size as a fraction of parent (see for instance #176 (comment))

@emilk
Copy link
Owner

emilk commented Apr 16, 2022

Most of this can now be accomplished with egui_extras::Strip (#963), so I'm gonna close this.

@emilk emilk closed this as completed Apr 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
design Some architectual design work needed feature New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants