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

env setup is confusing #1181

Closed
cmyr opened this issue Sep 4, 2020 · 2 comments · Fixed by #1237
Closed

env setup is confusing #1181

cmyr opened this issue Sep 4, 2020 · 2 comments · Fixed by #1237
Labels
good first issue requires little knowledge of druid's internals help wanted has no one working on it yet

Comments

@cmyr
Copy link
Member

cmyr commented Sep 4, 2020

We have Env::default but the actual way to create the default env is theme::init. I think it probably should be Env::default, but maybe there's a method in theme that adds the theme items, and Env::default should just call this?

@cmyr cmyr added help wanted has no one working on it yet good first issue requires little knowledge of druid's internals labels Sep 4, 2020
@totsteps
Copy link
Collaborator

totsteps commented Sep 12, 2020

Will give this a shot. I tried this:

// file env.rs
impl Default for Env {
    fn default() -> Self {
        ...
       let env = Env(Arc::new(inner))
            .adding(Env::DEBUG_PAINT, false)
            .adding(Env::DEBUG_WIDGET_ID, false)
            .adding(Env::DEBUG_WIDGET, false);

       crate::theme::init(env)
    }
}

// file theme.rs
pub fn init(env: Env) -> Env {
    env.adding(WINDOW_BACKGROUND_COLOR, Color::rgb8(0x29, 0x29, 0x29))
     ...
    .adding(
        UI_FONT,
        FontDescriptor::new(FontFamily::SYSTEM_UI).with_size(15.0),
    )
}

@cmyr
Copy link
Member Author

cmyr commented Sep 12, 2020

I think this is a good solution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue requires little knowledge of druid's internals help wanted has no one working on it yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants