egui icon indicating copy to clipboard operation
egui copied to clipboard

Window.fixed_size() et al. do not work

Open parasyte opened this issue 4 years ago • 5 comments

Using the fixed_size() method on a window makes it non-resizable, but the size of the window always conforms to the contents. The size passed to the method is completely ignored.

I did some digging and discovered that the issue is in the following condition: https://github.com/emilk/egui/blob/60fd70921df538c5cfab9918ddac1a2df5a06c66/egui/src/containers/resize.rs#L266-L277

Because the window is not resizable, it will not be given the requested size.

Unconditionally using the first branch seems to fix it, but I do not know what else might break.

parasyte avatar Jun 19 '21 01:06 parasyte

Is there a workaround or fix for this? Thanks.

CodingMentalModels avatar Oct 11 '23 10:10 CodingMentalModels

This workaround worked for me.

CodingMentalModels avatar Oct 11 '23 20:10 CodingMentalModels

From looking at the file that @parasyte linked above, it seems like there's just a condition missing that checks whether the user has set fixed_size(). I'm happy to PR a fix if you'd like @emilk ?

From what I can tell, it looks like there are two options for fixing this that come down to how we want to express that fixed_size has been set:

  1. Check whether default_size == min_size == max_size (might have to add tolerances for those since I think they're implemented in terms of f32s). This is the current definition, more or less, of fixed_size based on the fixed_size() function.
  2. Add a property to the struct for fixed_size that gets set when it's called and then unset anytime that default_size, min_size, or max_size are changed.

In either case, we can just add the appropriate condition to the if statement mentioned above.

I'd opt for (1) as it's simpler and more consistent with the current code (and I can define a helper function is_fixed_size() that's consistent with this definition), but happy to do either. Just let me know if that works for you @emilk.

CodingMentalModels avatar Oct 11 '23 20:10 CodingMentalModels

Any action on this one ?

White-Rabbit-Scientific avatar Oct 14 '24 21:10 White-Rabbit-Scientific

@emilk, looks like the author can throw a PR together for this--do either of his approaches see acceptable?

barries avatar Oct 15 '24 18:10 barries

I added my thoughts here (https://github.com/emilk/egui/discussions/5660) but then found this thread.

White-Rabbit-Scientific avatar Jan 30 '25 23:01 White-Rabbit-Scientific

@barries Did you manage to do a PR for this?

White-Rabbit-Scientific avatar Jan 30 '25 23:01 White-Rabbit-Scientific