Skip to content

Commit

Permalink
Create default env with Env::default()
Browse files Browse the repository at this point in the history
  • Loading branch information
totsteps committed Sep 15, 2020
1 parent 490d4e6 commit e0c3264
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 11 deletions.
6 changes: 2 additions & 4 deletions druid/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ use crate::shell::{Application, Error as PlatformError, WindowBuilder, WindowHan
use crate::widget::LabelText;
use crate::win_handler::{AppHandler, AppState};
use crate::window::WindowId;
use crate::{
theme, AppDelegate, Data, DruidHandler, Env, LocalizedString, MenuDesc, Widget, WidgetExt,
};
use crate::{AppDelegate, Data, DruidHandler, Env, LocalizedString, MenuDesc, Widget, WidgetExt};

use druid_shell::WindowState;

Expand Down Expand Up @@ -118,7 +116,7 @@ impl<T: Data> AppLauncher<T> {
pub fn launch(mut self, data: T) -> Result<(), PlatformError> {
let app = Application::new()?;

let mut env = theme::init();
let mut env = crate::Env::default();
if let Some(f) = self.env_setup.take() {
f(&mut env, &data);
}
Expand Down
2 changes: 1 addition & 1 deletion druid/src/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -995,7 +995,7 @@ mod tests {
state: &mut state,
};

let env = crate::theme::init();
let env = crate::Env::default();

widget.lifecycle(&mut ctx, &LifeCycle::WidgetAdded, &None, &env);
assert!(ctx.widget_state.children.may_contain(&ID_1));
Expand Down
6 changes: 4 additions & 2 deletions druid/src/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -470,10 +470,12 @@ impl Default for Env {
debug_colors,
};

Env(Arc::new(inner))
let env = Env(Arc::new(inner))
.adding(Env::DEBUG_PAINT, false)
.adding(Env::DEBUG_WIDGET_ID, false)
.adding(Env::DEBUG_WIDGET, false)
.adding(Env::DEBUG_WIDGET, false);

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

Expand Down
2 changes: 1 addition & 1 deletion druid/src/tests/harness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ impl<T: Data> Harness<'_, T> {

let inner = Inner {
data,
env: theme::init(),
env: Env::default(),
window,
cmds: Default::default(),
};
Expand Down
5 changes: 2 additions & 3 deletions druid/src/theme.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,8 @@ pub const SCROLLBAR_EDGE_WIDTH: Key<f64> =
Key::new("org.linebender.druid.theme.scrollbar_edge_width");

/// An initial theme.
pub fn init() -> Env {
Env::default()
.adding(WINDOW_BACKGROUND_COLOR, Color::rgb8(0x29, 0x29, 0x29))
pub fn init(env: Env) -> Env {
env.adding(WINDOW_BACKGROUND_COLOR, Color::rgb8(0x29, 0x29, 0x29))
.adding(LABEL_COLOR, Color::rgb8(0xf0, 0xf0, 0xea))
.adding(PLACEHOLDER_COLOR, Color::rgb8(0x80, 0x80, 0x80))
.adding(PRIMARY_LIGHT, Color::rgb8(0x5c, 0xc4, 0xff))
Expand Down

0 comments on commit e0c3264

Please sign in to comment.