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

Window.fixed_size() et al. do not work #498

Open
parasyte opened this issue Jun 19, 2021 · 5 comments
Open

Window.fixed_size() et al. do not work #498

parasyte opened this issue Jun 19, 2021 · 5 comments
Labels
bug Something is broken

Comments

@parasyte
Copy link
Contributor

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:

let size = if self.with_stroke || self.resizable {
// We show how large we are,
// so we must follow the contents:
state.desired_size = state.desired_size.max(state.last_content_size);
// We are as large as we look
state.desired_size
} else {
// Probably a window.
state.last_content_size
};

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.

@CodingMentalModels
Copy link

Is there a workaround or fix for this? Thanks.

@CodingMentalModels
Copy link

This workaround worked for me.

@CodingMentalModels
Copy link

CodingMentalModels commented Oct 11, 2023

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.

@Resonanz
Copy link

Any action on this one ?

@barries
Copy link

barries commented Oct 15, 2024

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

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

5 participants