Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ You can find its changes [documented below](#070---2021-01-01).
### Changed

- Warn on unhandled Commands ([#1533] by [@Maan2003])
- `WindowDesc::new` takes the root widget directly instead of a closure ([#1559] by [@lassipulkkinen])

### Deprecated

Expand Down Expand Up @@ -411,6 +412,7 @@ Last release without a changelog :(
[@Maan2003]: https://github.com/Maan2003
[@derekdreery]: https://github.com/derekdreery
[@MaximilianKoestler]: https://github.com/MaximilianKoestler
[@lassipulkkinen]: https://github.com/lassipulkkinen

[#599]: https://github.com/linebender/druid/pull/599
[#611]: https://github.com/linebender/druid/pull/611
Expand Down Expand Up @@ -608,6 +610,7 @@ Last release without a changelog :(
[#1533]: https://github.com/linebender/druid/pull/1533
[#1534]: https://github.com/linebender/druid/pull/1534
[#1254]: https://github.com/linebender/druid/pull/1254
[#1559]: https://github.com/linebender/druid/pull/1559

[Unreleased]: https://github.com/linebender/druid/compare/v0.6.0...master
[0.6.0]: https://github.com/linebender/druid/compare/v0.5.0...v0.6.0
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ use druid::widget::{Button, Flex, Label};
use druid::{AppLauncher, LocalizedString, PlatformError, Widget, WidgetExt, WindowDesc};

fn main() -> Result<(), PlatformError> {
let main_window = WindowDesc::new(ui_builder);
let main_window = WindowDesc::new(ui_builder());
let data = 0_u32;
AppLauncher::with_window(main_window)
.use_simple_logger()
Expand Down
2 changes: 1 addition & 1 deletion druid/examples/anim.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ impl Widget<()> for AnimWidget {
}

pub fn main() {
let window = WindowDesc::new(|| AnimWidget { t: 0.0 }).title(
let window = WindowDesc::new(AnimWidget { t: 0.0 }).title(
LocalizedString::new("anim-demo-window-title")
.with_placeholder("You spin me right round..."),
);
Expand Down
2 changes: 1 addition & 1 deletion druid/examples/async_event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ use druid::{AppLauncher, Color, Selector, Target, WidgetExt, WindowDesc};
const SET_COLOR: Selector<Color> = Selector::new("event-example.set-color");

pub fn main() {
let window = WindowDesc::new(make_ui).title("External Event Demo");
let window = WindowDesc::new(make_ui()).title("External Event Demo");

let launcher = AppLauncher::with_window(window);

Expand Down
3 changes: 2 additions & 1 deletion druid/examples/blocking_function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ impl AppDelegate<AppState> for Delegate {
}

fn main() {
let main_window = WindowDesc::new(ui_builder).title(LocalizedString::new("Blocking functions"));
let main_window =
WindowDesc::new(ui_builder()).title(LocalizedString::new("Blocking functions"));
AppLauncher::with_window(main_window)
.delegate(Delegate {})
.launch(AppState::default())
Expand Down
2 changes: 1 addition & 1 deletion druid/examples/calc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ fn build_calc() -> impl Widget<CalcState> {
}

pub fn main() {
let window = WindowDesc::new(build_calc)
let window = WindowDesc::new(build_calc())
.window_size((223., 300.))
.resizable(false)
.title(
Expand Down
3 changes: 2 additions & 1 deletion druid/examples/cursor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ impl AppState {
}

pub fn main() {
let main_window = WindowDesc::new(ui_builder).title(LocalizedString::new("Blocking functions"));
let main_window =
WindowDesc::new(ui_builder()).title(LocalizedString::new("Blocking functions"));
let cursor_image = ImageBuf::from_data(include_bytes!("./assets/PicWithAlpha.png")).unwrap();
// The (0,0) refers to where the "hotspot" is located, so where the mouse actually points.
// (0,0) is the top left, and (cursor_image.width(), cursor_image.width()) the bottom right.
Expand Down
2 changes: 1 addition & 1 deletion druid/examples/custom_widget.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ impl Widget<String> for CustomWidget {
}

pub fn main() {
let window = WindowDesc::new(|| CustomWidget {}).title(LocalizedString::new("Fancy Colors"));
let window = WindowDesc::new(CustomWidget {}).title(LocalizedString::new("Fancy Colors"));
AppLauncher::with_window(window)
.use_simple_logger()
.launch("Druid + Piet".to_string())
Expand Down
2 changes: 1 addition & 1 deletion druid/examples/either.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ fn ui_builder() -> impl Widget<AppState> {
}

pub fn main() {
let main_window = WindowDesc::new(ui_builder).title("Switcheroo");
let main_window = WindowDesc::new(ui_builder()).title("Switcheroo");
AppLauncher::with_window(main_window)
.use_simple_logger()
.launch(AppState::default())
Expand Down
2 changes: 1 addition & 1 deletion druid/examples/event_viewer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ fn make_list_item() -> impl Widget<LoggedEvent> {

pub fn main() {
//describe the main window
let main_window = WindowDesc::new(build_root_widget)
let main_window = WindowDesc::new(build_root_widget())
.title("Event Viewer")
.window_size((760.0, 680.0));

Expand Down
2 changes: 1 addition & 1 deletion druid/examples/flex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ fn make_ui() -> impl Widget<AppState> {
}

pub fn main() {
let main_window = WindowDesc::new(make_ui)
let main_window = WindowDesc::new(make_ui())
.window_size((720., 600.))
.with_min_size((620., 300.))
.title("Flex Container Options");
Expand Down
2 changes: 1 addition & 1 deletion druid/examples/game_of_life.rs
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ fn make_widget() -> impl Widget<AppData> {
}

pub fn main() {
let window = WindowDesc::new(make_widget)
let window = WindowDesc::new(make_widget())
.window_size(Size {
width: 800.0,
height: 800.0,
Expand Down
2 changes: 1 addition & 1 deletion druid/examples/hello.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ struct HelloState {

pub fn main() {
// describe the main window
let main_window = WindowDesc::new(build_root_widget)
let main_window = WindowDesc::new(build_root_widget())
.title("Hello World!")
.window_size((400.0, 400.0));

Expand Down
2 changes: 1 addition & 1 deletion druid/examples/hello_web/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ pub fn main() {
//
// Window title is set in index.html and window size is ignored on the web,
// so can we leave those off.
let main_window = WindowDesc::new(build_root_widget);
let main_window = WindowDesc::new(build_root_widget());

// create the initial app state
let initial_state = HelloState {
Expand Down
2 changes: 1 addition & 1 deletion druid/examples/identity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ struct OurData {
}

pub fn main() {
let window = WindowDesc::new(make_ui).title("identity example");
let window = WindowDesc::new(make_ui()).title("identity example");
let data = OurData {
counter_one: 0,
counter_two: 0,
Expand Down
2 changes: 1 addition & 1 deletion druid/examples/image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ fn make_ui() -> impl Widget<AppState> {
}

pub fn main() {
let main_window = WindowDesc::new(make_ui)
let main_window = WindowDesc::new(make_ui())
.window_size((650., 450.))
.title("Flex Container Options");

Expand Down
2 changes: 1 addition & 1 deletion druid/examples/invalidation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use druid::{AppLauncher, Color, Data, Lens, LocalizedString, Point, WidgetExt, W
use instant::Instant;

pub fn main() {
let window = WindowDesc::new(build_widget).title(
let window = WindowDesc::new(build_widget()).title(
LocalizedString::new("invalidate-demo-window-title").with_placeholder("Invalidate demo"),
);
let state = AppState {
Expand Down
2 changes: 1 addition & 1 deletion druid/examples/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ fn build_app() -> impl Widget<u32> {
}

pub fn main() {
let window = WindowDesc::new(build_app).title("Very flexible");
let window = WindowDesc::new(build_app()).title("Very flexible");

AppLauncher::with_window(window)
.use_simple_logger()
Expand Down
2 changes: 1 addition & 1 deletion druid/examples/lens.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use druid::widget::{CrossAxisAlignment, Flex, Label, TextBox};
use druid::{AppLauncher, Data, Env, Lens, LocalizedString, Widget, WidgetExt, WindowDesc};

pub fn main() {
let main_window = WindowDesc::new(ui_builder)
let main_window = WindowDesc::new(ui_builder())
.title(LocalizedString::new("lens-demo-window-title").with_placeholder("Lens Demo"));
let data = MyComplexState {
term: "hello".into(),
Expand Down
2 changes: 1 addition & 1 deletion druid/examples/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ struct AppData {
}

pub fn main() {
let main_window = WindowDesc::new(ui_builder)
let main_window = WindowDesc::new(ui_builder())
.title(LocalizedString::new("list-demo-window-title").with_placeholder("List Demo"));
// Set our initial data
let left = vector![1, 2];
Expand Down
2 changes: 1 addition & 1 deletion druid/examples/markdown_preview.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ impl<W: Widget<AppState>> Controller<AppState, W> for RichTextRebuilder {

pub fn main() {
// describe the main window
let main_window = WindowDesc::new(build_root_widget)
let main_window = WindowDesc::new(build_root_widget())
.title(WINDOW_TITLE)
.menu(make_menu())
.window_size((700.0, 600.0));
Expand Down
4 changes: 2 additions & 2 deletions druid/examples/multiwin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ struct State {
}

pub fn main() {
let main_window = WindowDesc::new(ui_builder)
let main_window = WindowDesc::new(ui_builder())
.menu(make_menu(&State::default()))
.title(
LocalizedString::new("multiwin-demo-window-title").with_placeholder("Many windows!"),
Expand Down Expand Up @@ -157,7 +157,7 @@ impl AppDelegate<State> for Delegate {
) -> Handled {
match cmd {
_ if cmd.is(sys_cmds::NEW_FILE) => {
let new_win = WindowDesc::new(ui_builder)
let new_win = WindowDesc::new(ui_builder())
.menu(make_menu(data))
.window_size((data.selected as f64 * 100.0 + 300.0, 500.0));
ctx.new_window(new_win);
Expand Down
2 changes: 1 addition & 1 deletion druid/examples/open_save.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use druid::{
struct Delegate;

pub fn main() {
let main_window = WindowDesc::new(ui_builder)
let main_window = WindowDesc::new(ui_builder())
.title(LocalizedString::new("open-save-demo").with_placeholder("Opening/Saving Demo"));
let data = "Type here.".to_owned();
AppLauncher::with_window(main_window)
Expand Down
2 changes: 1 addition & 1 deletion druid/examples/panels.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ fn build_app() -> impl Widget<()> {
}

pub fn main() -> Result<(), PlatformError> {
let main_window = WindowDesc::new(build_app)
let main_window = WindowDesc::new(build_app())
.title(LocalizedString::new("panels-demo-window-title").with_placeholder("Fancy Boxes!"));
AppLauncher::with_window(main_window)
.use_simple_logger()
Expand Down
2 changes: 1 addition & 1 deletion druid/examples/scroll.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use druid::widget::{Flex, Padding, Scroll};
use druid::{AppLauncher, Data, Insets, LocalizedString, Rect, WindowDesc};

pub fn main() {
let window = WindowDesc::new(build_widget)
let window = WindowDesc::new(build_widget())
.title(LocalizedString::new("scroll-demo-window-title").with_placeholder("Scroll demo"));
AppLauncher::with_window(window)
.use_simple_logger()
Expand Down
2 changes: 1 addition & 1 deletion druid/examples/scroll_colors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ fn build_app() -> impl Widget<u32> {
}

pub fn main() {
let main_window = WindowDesc::new(build_app).title(
let main_window = WindowDesc::new(build_app()).title(
LocalizedString::new("scroll-colors-demo-window-title").with_placeholder("Rainbows!"),
);
let data = 0_u32;
Expand Down
2 changes: 1 addition & 1 deletion druid/examples/split_demo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ fn build_app() -> impl Widget<u32> {
}

pub fn main() {
let window = WindowDesc::new(build_app)
let window = WindowDesc::new(build_app())
.title(LocalizedString::new("split-demo-window-title").with_placeholder("Split Demo"));
AppLauncher::with_window(window)
.use_simple_logger()
Expand Down
2 changes: 1 addition & 1 deletion druid/examples/styled_text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ impl Display for AppData {
}

pub fn main() -> Result<(), PlatformError> {
let main_window = WindowDesc::new(ui_builder).title(
let main_window = WindowDesc::new(ui_builder()).title(
LocalizedString::new("styled-text-demo-window-title").with_placeholder("Type Styler"),
);
let data = AppData {
Expand Down
2 changes: 1 addition & 1 deletion druid/examples/sub_window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ struct HelloState {

pub fn main() {
// describe the main window
let main_window = WindowDesc::new(build_root_widget)
let main_window = WindowDesc::new(build_root_widget())
.title(WINDOW_TITLE)
.window_size((400.0, 400.0));

Expand Down
2 changes: 1 addition & 1 deletion druid/examples/svg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use druid::{
};

pub fn main() {
let main_window = WindowDesc::new(ui_builder)
let main_window = WindowDesc::new(ui_builder())
.title(LocalizedString::new("svg-demo-window-title").with_placeholder("Rawr!"));
let data = 0_u32;
AppLauncher::with_window(main_window)
Expand Down
2 changes: 1 addition & 1 deletion druid/examples/switches.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ fn build_widget() -> impl Widget<DemoState> {
}

pub fn main() {
let window = WindowDesc::new(build_widget)
let window = WindowDesc::new(build_widget())
.title(LocalizedString::new("switch-demo-window-title").with_placeholder("Switch Demo"));
AppLauncher::with_window(window)
.use_simple_logger()
Expand Down
2 changes: 1 addition & 1 deletion druid/examples/tabs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ struct AppState {

pub fn main() {
// describe the main window
let main_window = WindowDesc::new(build_root_widget)
let main_window = WindowDesc::new(build_root_widget())
.title("Tabs")
.window_size((700.0, 400.0));

Expand Down
2 changes: 1 addition & 1 deletion druid/examples/text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ impl Controller<AppState, RawLabel<AppState>> for LabelController {

pub fn main() {
// describe the main window
let main_window = WindowDesc::new(build_root_widget)
let main_window = WindowDesc::new(build_root_widget())
.title(WINDOW_TITLE)
.window_size((400.0, 600.0));

Expand Down
2 changes: 1 addition & 1 deletion druid/examples/timer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ impl Widget<u32> for SimpleBox {
}

pub fn main() {
let window = WindowDesc::new(|| TimerWidget {
let window = WindowDesc::new(TimerWidget {
timer_id: TimerToken::INVALID,
simple_box: WidgetPod::new(SimpleBox),
pos: Point::ZERO,
Expand Down
2 changes: 1 addition & 1 deletion druid/examples/value_formatting/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ pub struct AppData {
}

pub fn main() {
let main_window = WindowDesc::new(ui_builder).title("Formatting and Validation");
let main_window = WindowDesc::new(ui_builder()).title("Formatting and Validation");

let data = AppData {
dollars: 12.2,
Expand Down
2 changes: 1 addition & 1 deletion druid/examples/view_switcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ struct AppState {
}

pub fn main() {
let main_window = WindowDesc::new(make_ui).title(LocalizedString::new("View Switcher"));
let main_window = WindowDesc::new(make_ui()).title(LocalizedString::new("View Switcher"));
let data = AppState {
current_view: 0,
current_text: "Edit me!".to_string(),
Expand Down
2 changes: 1 addition & 1 deletion druid/examples/widget_gallery.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ enum MyRadio {
}

pub fn main() {
let main_window = WindowDesc::new(ui_builder).title("Widget Gallery");
let main_window = WindowDesc::new(ui_builder()).title("Widget Gallery");
// Set our initial data
let data = AppData {
label_data: "test".into(),
Expand Down
13 changes: 4 additions & 9 deletions druid/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,13 @@ pub struct PendingWindow<T> {

impl<T: Data> PendingWindow<T> {
/// Create a pending window from any widget.
pub fn new<W, F>(root: F) -> PendingWindow<T>
pub fn new<W>(root: W) -> PendingWindow<T>
where
W: Widget<T> + 'static,
F: FnOnce() -> W + 'static,
{
// This just makes our API slightly cleaner; callers don't need to explicitly box.
PendingWindow {
root: Box::new(root()),
root: Box::new(root),
title: LocalizedString::new("app-name").into(),
menu: MenuDesc::platform_default(),
size_policy: WindowSizePolicy::User,
Expand Down Expand Up @@ -381,16 +380,12 @@ impl WindowConfig {
}

impl<T: Data> WindowDesc<T> {
/// Create a new `WindowDesc`, taking a function that will generate the root
/// [`Widget`] for this window.
///
/// It is possible that a `WindowDesc` can be reused to launch multiple windows.
/// Create a new `WindowDesc`, taking the root [`Widget`] for this window.
///
/// [`Widget`]: trait.Widget.html
pub fn new<W, F>(root: F) -> WindowDesc<T>
pub fn new<W>(root: W) -> WindowDesc<T>
where
W: Widget<T> + 'static,
F: FnOnce() -> W + 'static,
{
WindowDesc {
pending: PendingWindow::new(root),
Expand Down
Loading