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

Add fixed_pos to Window #16

Merged
merged 2 commits into from
Aug 9, 2020
Merged

Add fixed_pos to Window #16

merged 2 commits into from
Aug 9, 2020

Conversation

tomassedovic
Copy link
Contributor

This allows changing the position of a window by opening the window
with a different value.

This allows changing the position of a window by opening the window
with a different value.
@tomassedovic
Copy link
Contributor Author

In my game, I want to have more control over how the windows work, e.g. control their size and position (e.g. cover the whole screen minus some padding), or disable collapsing (#15).

I'm not sure you want to go with the direction of extending the Window widget. I guess the alternative would be to write a custom widget, but since everything else would be the same, here's a couple PRs to see what you think.

@emilk
Copy link
Owner

emilk commented Aug 5, 2020

Thanks for describing your use case!

I think it makes sense to add helpers like these to disable parts of the Window features. You won't be the only one to want to fix the position and size of windows.

If you don't even want the title bar you could consider just combining Frame and Area directly. Something like this:

Area::new("my_area").fixed_pos([32.0, 16.0]).show(ctx, |ui| {
    Frame::window(ui.style()).show(|ui| {
        ui.label("Hello world!");
    });
});

Copy link
Owner

@emilk emilk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a docstring (even though I have been lazy and not done so for the other functions)

@tomassedovic
Copy link
Contributor Author

Thanks for showing the example of Area+Frame! In this particular usecase, I really want the UI, but I did have another one where I basically wanted a statically-positioned borderless window and wasn't sure how to do it nicely (ended up with a child Ui and a bunch of extra code).

@tomassedovic tomassedovic requested a review from emilk August 7, 2020 15:50
Copy link
Owner

@emilk emilk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for making the changes!

@emilk emilk merged commit 40af177 into emilk:master Aug 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants