Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Allow setting windows size based on monitor size #3065

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

Open
acul009 wants to merge 2 commits into iced-rs:master
base: master
Choose a base branch
Loading
from acul009:master

Conversation

@acul009
Copy link

@acul009 acul009 commented Sep 27, 2025

This just adds the FromScreensize option to the window settings size.

I used the positioning option as a base.

I use this for my drowdown terminal, so the window size is automatically set.

Copy link
Contributor

pml68 commented Sep 27, 2025

I think you could use fn(Size) -> Size in the added variant to avoid the Arc, since Position::SpecificWith also just uses a function pointer (which is Send, Sync and Copy)

Copy link
Author

acul009 commented Sep 27, 2025

I think you could use fn(Size) -> Size in the added variant to avoid the Arc, since Position::SpecificWith also just uses a function pointer (which is Send, Sync and Copy)

I did in the original PR, but for the tester I need to support closures, since I need to make the window wider than it would otherwise be:

iced/tester/src/lib.rs

Lines 67 to 72 in 0a34496

fn window(&self) -> Option<window::Settings> {
self.program.window().map(|window| window::Settings {
size: window.size + Size::new(300.0, 80.0),
..window
})
}
impl Add<crate::Size> for Size {
type Output = Self;
fn add(self, other: crate::Size) -> Self {
match self {
Self::Fixed(size) => Self::Fixed(size + other),
Self::FromScreensize(func) => {
Self::from_screen_size(move |size| func(size) + other)
}
}
}
}

The only other solution I could think of, would be to ignore the variable window size when the tester is used.
Maybe you have a better idea?

Copy link
Contributor

pml68 commented Sep 27, 2025

Hmm

You could add an extra field to the variant which contains extra size, but that could make it a bit confusing to use, or just plain ugly.

@acul009 acul009 reopened this Oct 9, 2025
Copy link
Author

acul009 commented Oct 9, 2025
edited
Loading

Hmm

You could add an extra field to the variant which contains extra size, but that could make it a bit confusing to use, or just plain ugly.

The current API isn't really all user friendly either.
I added a helper function, but the enum variant is still there and requires a manual Arc.
It's not obvious you should use the helper.

@pml68 What do you think about creating a wrapper struct to hide the enum variants?
Then I'd just expose helper functions and nothing else.
That way I wouldn't expose any weird enum variants.

pub struct Size( pub(crate) SizeVariant)

Not sure these enum in struct types fir with the iced style.

Copy link
Contributor

pml68 commented Oct 10, 2025

@pml68 What do you think about creating a wrapper struct to hide the enum variants? Then I'd just expose helper functions and nothing else. That way I wouldn't expose any weird enum variants.

pub struct Size( pub(crate) SizeVariant)

Hmm not sure honestly. I can't really think of a better way, but I wonder what Héctor would think about the proposed solutions (user has to Arc / hidden enum / some other solution to the test recorder-size adding problem)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants

AltStyle によって変換されたページ (->オリジナル) /