From 17a5e8bfebe25338b5dc490d42c5d8db86790432 Mon Sep 17 00:00:00 2001 From: Olivier FAURE Date: Thu, 5 Aug 2021 16:36:03 +0200 Subject: [PATCH 1/2] Add `windows_subsystem` attribute to examples. --- druid/examples/anim.rs | 3 +++ druid/examples/async_event.rs | 3 +++ druid/examples/blocking_function.rs | 3 +++ druid/examples/calc.rs | 3 +++ druid/examples/cursor.rs | 3 +++ druid/examples/custom_widget.rs | 3 +++ druid/examples/disabled.rs | 3 +++ druid/examples/either.rs | 3 +++ druid/examples/event_viewer.rs | 3 +++ druid/examples/flex.rs | 3 +++ druid/examples/game_of_life.rs | 3 +++ druid/examples/hello.rs | 3 +++ druid/examples/identity.rs | 3 +++ druid/examples/image.rs | 3 +++ druid/examples/invalidation.rs | 3 +++ druid/examples/layout.rs | 3 +++ druid/examples/lens.rs | 3 +++ druid/examples/list.rs | 3 +++ druid/examples/markdown_preview.rs | 5 ++++- druid/examples/multiwin.rs | 3 +++ druid/examples/open_save.rs | 3 +++ druid/examples/panels.rs | 3 +++ druid/examples/scroll.rs | 3 +++ druid/examples/scroll_colors.rs | 3 +++ druid/examples/split_demo.rs | 3 +++ druid/examples/styled_text.rs | 3 +++ druid/examples/sub_window.rs | 3 +++ druid/examples/svg.rs | 3 +++ druid/examples/switches.rs | 3 +++ druid/examples/tabs.rs | 3 +++ druid/examples/text.rs | 3 +++ druid/examples/textbox.rs | 3 +++ druid/examples/timer.rs | 3 +++ druid/examples/transparency.rs | 3 +++ druid/examples/value_formatting/src/main.rs | 3 +++ druid/examples/view_switcher.rs | 3 +++ druid/examples/widget_gallery.rs | 3 +++ 37 files changed, 112 insertions(+), 1 deletion(-) diff --git a/druid/examples/anim.rs b/druid/examples/anim.rs index 1355fbf76c..c3ceee9bf5 100644 --- a/druid/examples/anim.rs +++ b/druid/examples/anim.rs @@ -21,6 +21,9 @@ //! rest of the app. If this is something the rest of your widgets should know //! about, you could put it in the `data`. +// On Windows platform, don't show a console when opening the app. +#![windows_subsystem = "windows"] + use std::f64::consts::PI; use druid::kurbo::{Circle, Line}; diff --git a/druid/examples/async_event.rs b/druid/examples/async_event.rs index d585c2d5d6..534f364bc8 100644 --- a/druid/examples/async_event.rs +++ b/druid/examples/async_event.rs @@ -18,6 +18,9 @@ //! takes a long time but don't want to block the main thread //! (waiting on an http request, some cpu intensive work etc.) +// On Windows platform, don't show a console when opening the app. +#![windows_subsystem = "windows"] + use instant::Instant; use std::thread; use std::time::Duration; diff --git a/druid/examples/blocking_function.rs b/druid/examples/blocking_function.rs index ae4c5151ef..0ccfaa8d70 100644 --- a/druid/examples/blocking_function.rs +++ b/druid/examples/blocking_function.rs @@ -16,6 +16,9 @@ //! the other thread some data and then we also pass some data back //! to the main thread using commands. +// On Windows platform, don't show a console when opening the app. +#![windows_subsystem = "windows"] + use std::{thread, time}; use druid::widget::prelude::*; diff --git a/druid/examples/calc.rs b/druid/examples/calc.rs index 31adae5f31..42ae074c7b 100644 --- a/druid/examples/calc.rs +++ b/druid/examples/calc.rs @@ -14,6 +14,9 @@ //! Simple calculator. +// On Windows platform, don't show a console when opening the app. +#![windows_subsystem = "windows"] + use druid::{ theme, AppLauncher, Color, Data, Lens, LocalizedString, RenderContext, Widget, WidgetExt, WindowDesc, diff --git a/druid/examples/cursor.rs b/druid/examples/cursor.rs index e07da4938d..f79565b056 100644 --- a/druid/examples/cursor.rs +++ b/druid/examples/cursor.rs @@ -19,6 +19,9 @@ //! open so we have to work around that. When we receive the //! `WindowConnected` command we initiate the cursor. +// On Windows platform, don't show a console when opening the app. +#![windows_subsystem = "windows"] + use druid::{ AppLauncher, Color, Cursor, CursorDesc, Data, Env, ImageBuf, Lens, LocalizedString, WidgetExt, WindowDesc, diff --git a/druid/examples/custom_widget.rs b/druid/examples/custom_widget.rs index 376dd897a0..cd9f882d5b 100644 --- a/druid/examples/custom_widget.rs +++ b/druid/examples/custom_widget.rs @@ -15,6 +15,9 @@ //! An example of a custom drawing widget. //! We draw an image, some text, a shape, and a curve. +// On Windows platform, don't show a console when opening the app. +#![windows_subsystem = "windows"] + use druid::kurbo::BezPath; use druid::piet::{FontFamily, ImageFormat, InterpolationMode, Text, TextLayoutBuilder}; use druid::widget::prelude::*; diff --git a/druid/examples/disabled.rs b/druid/examples/disabled.rs index f6af92dc1a..ec0eec9c64 100644 --- a/druid/examples/disabled.rs +++ b/druid/examples/disabled.rs @@ -17,6 +17,9 @@ //! respond. Pressing Tab should only focus widgets not marked as disabled. If a widget //! is focused while getting disabled it should resign the focus. +// On Windows platform, don't show a console when opening the app. +#![windows_subsystem = "windows"] + use druid::widget::{ Button, Checkbox, CrossAxisAlignment, Flex, Label, Slider, Stepper, Switch, TextBox, }; diff --git a/druid/examples/either.rs b/druid/examples/either.rs index a9fb9ef7c0..7fdcd5a98a 100644 --- a/druid/examples/either.rs +++ b/druid/examples/either.rs @@ -16,6 +16,9 @@ //! This is a very simple example, it uses a bool to determine //! which widget gets shown. +// On Windows platform, don't show a console when opening the app. +#![windows_subsystem = "windows"] + use druid::widget::prelude::*; use druid::widget::{Checkbox, Either, Flex, Label, Slider}; use druid::{AppLauncher, Data, Lens, WidgetExt, WindowDesc}; diff --git a/druid/examples/event_viewer.rs b/druid/examples/event_viewer.rs index 1b4dd7958f..c56a78cc0e 100644 --- a/druid/examples/event_viewer.rs +++ b/druid/examples/event_viewer.rs @@ -15,6 +15,9 @@ //! An application that accepts keyboard and mouse input, and displays //! information about received events. +// On Windows platform, don't show a console when opening the app. +#![windows_subsystem = "windows"] + use druid::widget::prelude::*; use druid::widget::{Controller, CrossAxisAlignment, Flex, Label, List, Scroll, SizedBox, TextBox}; use druid::{ diff --git a/druid/examples/flex.rs b/druid/examples/flex.rs index 824e4d4b69..e00f1fb004 100644 --- a/druid/examples/flex.rs +++ b/druid/examples/flex.rs @@ -17,6 +17,9 @@ //! knobs to change all the parameters. 99% of the time you will want to //! hard-code these parameters, which will simplify your code considerably. +// On Windows platform, don't show a console when opening the app. +#![windows_subsystem = "windows"] + use druid::text::ParseFormatter; use druid::widget::prelude::*; use druid::widget::{ diff --git a/druid/examples/game_of_life.rs b/druid/examples/game_of_life.rs index 56080c56bb..21140f605e 100644 --- a/druid/examples/game_of_life.rs +++ b/druid/examples/game_of_life.rs @@ -15,6 +15,9 @@ //! This is an example of how you would implement the game of life with druid. //! This example doesnt showcase anything specific in druid. +// On Windows platform, don't show a console when opening the app. +#![windows_subsystem = "windows"] + use std::ops::{Index, IndexMut}; use std::time::{Duration, Instant}; diff --git a/druid/examples/hello.rs b/druid/examples/hello.rs index 7ee8448027..04687f27e6 100644 --- a/druid/examples/hello.rs +++ b/druid/examples/hello.rs @@ -15,6 +15,9 @@ //! This is a very small example of how to setup a druid application. //! It does the almost bare minimum while still being useful. +// On Windows platform, don't show a console when opening the app. +#![windows_subsystem = "windows"] + use druid::widget::prelude::*; use druid::widget::{Flex, Label, TextBox}; use druid::{AppLauncher, Data, Lens, UnitPoint, WidgetExt, WindowDesc}; diff --git a/druid/examples/identity.rs b/druid/examples/identity.rs index 6b80e9796a..7fcfd13949 100644 --- a/druid/examples/identity.rs +++ b/druid/examples/identity.rs @@ -27,6 +27,9 @@ //! other circumstances where widgets may need to communicate with specific //! other widgets, and identity is a useful mechanism in those cases. +// On Windows platform, don't show a console when opening the app. +#![windows_subsystem = "windows"] + use druid::widget::prelude::*; use druid::widget::{Button, Controller, Flex, Label, WidgetId}; use druid::{AppLauncher, Data, Lens, Selector, WidgetExt, WindowDesc}; diff --git a/druid/examples/image.rs b/druid/examples/image.rs index 84ba04e1d9..dc4ff9da05 100644 --- a/druid/examples/image.rs +++ b/druid/examples/image.rs @@ -16,6 +16,9 @@ //! propperties. You can change the parameters in the GUI to see how //! everything behaves. +// On Windows platform, don't show a console when opening the app. +#![windows_subsystem = "windows"] + use druid::piet::InterpolationMode; use druid::text::ParseFormatter; use druid::widget::{prelude::*, FillStrat, Image}; diff --git a/druid/examples/invalidation.rs b/druid/examples/invalidation.rs index 9ecadf5bba..877cd7cbab 100644 --- a/druid/examples/invalidation.rs +++ b/druid/examples/invalidation.rs @@ -15,6 +15,9 @@ //! Demonstrates how to debug invalidation regions, and also shows the //! invalidation behavior of several build-in widgets. +// On Windows platform, don't show a console when opening the app. +#![windows_subsystem = "windows"] + use druid::im::Vector; use druid::kurbo::{self, Shape}; use druid::widget::prelude::*; diff --git a/druid/examples/layout.rs b/druid/examples/layout.rs index e656ac49eb..28d3690e6f 100644 --- a/druid/examples/layout.rs +++ b/druid/examples/layout.rs @@ -15,6 +15,9 @@ //! This example shows how to construct a basic layout, //! using columns, rows, and loops, for repeated Widgets. +// On Windows platform, don't show a console when opening the app. +#![windows_subsystem = "windows"] + use druid::widget::{AspectRatioBox, Button, Flex, Label, LineBreaking}; use druid::{AppLauncher, Color, Widget, WidgetExt, WindowDesc}; diff --git a/druid/examples/lens.rs b/druid/examples/lens.rs index 0db1401259..71181f5482 100644 --- a/druid/examples/lens.rs +++ b/druid/examples/lens.rs @@ -14,6 +14,9 @@ //! This example shows basic usage of Lens +// On Windows platform, don't show a console when opening the app. +#![windows_subsystem = "windows"] + use druid::widget::Slider; use druid::widget::{CrossAxisAlignment, Flex, Label, TextBox}; use druid::{AppLauncher, Data, Env, Lens, LocalizedString, Widget, WidgetExt, WindowDesc}; diff --git a/druid/examples/list.rs b/druid/examples/list.rs index c76cfd29f8..7cf1eee81b 100644 --- a/druid/examples/list.rs +++ b/druid/examples/list.rs @@ -14,6 +14,9 @@ //! Demos basic list widget and list manipulations. +// On Windows platform, don't show a console when opening the app. +#![windows_subsystem = "windows"] + use druid::im::{vector, Vector}; use druid::lens::{self, LensExt}; use druid::widget::{Button, CrossAxisAlignment, Flex, Label, List, Scroll}; diff --git a/druid/examples/markdown_preview.rs b/druid/examples/markdown_preview.rs index 69c073f03e..43e6e0e77e 100644 --- a/druid/examples/markdown_preview.rs +++ b/druid/examples/markdown_preview.rs @@ -14,6 +14,9 @@ //! An example of live markdown preview +// On Windows platform, don't show a console when opening the app. +#![windows_subsystem = "windows"] + use pulldown_cmark::{Event as ParseEvent, Parser, Tag}; use druid::text::{AttributesAdder, RichText, RichTextBuilder}; @@ -34,7 +37,7 @@ const TEXT: &str = "*Hello* ***world***! This is a `TextBox` where you can \ If you're curious about Druid, a good place to ask questions \ and discuss development work is our [Zulip chat instance], \ in the #druid-help and #druid channels, respectively.\n\n\n\ - + [Zulip chat instance]: https://xi.zulipchat.com"; const SPACER_SIZE: f64 = 8.0; diff --git a/druid/examples/multiwin.rs b/druid/examples/multiwin.rs index b4e47b17d6..86a29471eb 100644 --- a/druid/examples/multiwin.rs +++ b/druid/examples/multiwin.rs @@ -14,6 +14,9 @@ //! Opening and closing windows and using window and context menus. +// On Windows platform, don't show a console when opening the app. +#![windows_subsystem = "windows"] + use druid::widget::prelude::*; use druid::widget::{ Align, BackgroundBrush, Button, Controller, ControllerHost, Flex, Label, Padding, diff --git a/druid/examples/open_save.rs b/druid/examples/open_save.rs index 2c23dcbd5c..bdd66b9b41 100644 --- a/druid/examples/open_save.rs +++ b/druid/examples/open_save.rs @@ -14,6 +14,9 @@ //! Usage of file open and saving. +// On Windows platform, don't show a console when opening the app. +#![windows_subsystem = "windows"] + use druid::widget::{Align, Button, Flex, TextBox}; use druid::{ commands, AppDelegate, AppLauncher, Command, DelegateCtx, Env, FileDialogOptions, FileSpec, diff --git a/druid/examples/panels.rs b/druid/examples/panels.rs index dd52898652..53c6feb111 100644 --- a/druid/examples/panels.rs +++ b/druid/examples/panels.rs @@ -14,6 +14,9 @@ //! This example shows how to construct a basic layout. +// On Windows platform, don't show a console when opening the app. +#![windows_subsystem = "windows"] + use druid::kurbo::Circle; use druid::widget::{Flex, Label, Painter}; use druid::{ diff --git a/druid/examples/scroll.rs b/druid/examples/scroll.rs index 8cc68a5ad4..9d9e0fff26 100644 --- a/druid/examples/scroll.rs +++ b/druid/examples/scroll.rs @@ -15,6 +15,9 @@ //! Shows a scroll widget, and also demonstrates how widgets that paint //! outside their bounds can specify their paint region. +// On Windows platform, don't show a console when opening the app. +#![windows_subsystem = "windows"] + use druid::kurbo::Circle; use druid::piet::RadialGradient; use druid::widget::prelude::*; diff --git a/druid/examples/scroll_colors.rs b/druid/examples/scroll_colors.rs index 09c8a0c2c0..d9239f6ea4 100644 --- a/druid/examples/scroll_colors.rs +++ b/druid/examples/scroll_colors.rs @@ -14,6 +14,9 @@ //! This example allows to play with scroll bars over different color tones. +// On Windows platform, don't show a console when opening the app. +#![windows_subsystem = "windows"] + use druid::widget::{Container, Flex, Scroll, SizedBox}; use druid::{AppLauncher, Color, LocalizedString, Widget, WindowDesc}; diff --git a/druid/examples/split_demo.rs b/druid/examples/split_demo.rs index d74cd20535..5c0389d4a3 100644 --- a/druid/examples/split_demo.rs +++ b/druid/examples/split_demo.rs @@ -14,6 +14,9 @@ //! This example demonstrates the `Split` widget +// On Windows platform, don't show a console when opening the app. +#![windows_subsystem = "windows"] + use druid::piet::Color; use druid::widget::{Align, Container, Label, Padding, Split}; use druid::{AppLauncher, LocalizedString, Widget, WindowDesc}; diff --git a/druid/examples/styled_text.rs b/druid/examples/styled_text.rs index 67f54dda05..c519024cf0 100644 --- a/druid/examples/styled_text.rs +++ b/druid/examples/styled_text.rs @@ -14,6 +14,9 @@ //! Example of dynamic text styling +// On Windows platform, don't show a console when opening the app. +#![windows_subsystem = "windows"] + use druid::widget::{ Checkbox, CrossAxisAlignment, Flex, Label, LensWrap, MainAxisAlignment, Painter, Parse, Scroll, Stepper, TextBox, diff --git a/druid/examples/sub_window.rs b/druid/examples/sub_window.rs index 65b005b44d..e7b1280f69 100644 --- a/druid/examples/sub_window.rs +++ b/druid/examples/sub_window.rs @@ -12,6 +12,9 @@ // See the License for the specific language governing permissions and // limitations under the License. +// On Windows platform, don't show a console when opening the app. +#![windows_subsystem = "windows"] + use druid::commands::CLOSE_WINDOW; use druid::lens::Unit; use druid::widget::{ diff --git a/druid/examples/svg.rs b/druid/examples/svg.rs index 65ff7ffbaf..83f7d5ddba 100644 --- a/druid/examples/svg.rs +++ b/druid/examples/svg.rs @@ -14,6 +14,9 @@ //! This example shows how to draw an SVG. +// On Windows platform, don't show a console when opening the app. +#![windows_subsystem = "windows"] + use tracing::error; use druid::{ diff --git a/druid/examples/switches.rs b/druid/examples/switches.rs index 14b736d6be..ed8d80298c 100644 --- a/druid/examples/switches.rs +++ b/druid/examples/switches.rs @@ -12,6 +12,9 @@ // See the License for the specific language governing permissions and // limitations under the License. +// On Windows platform, don't show a console when opening the app. +#![windows_subsystem = "windows"] + use druid::widget::{ Checkbox, Flex, Label, LensWrap, MainAxisAlignment, Padding, Parse, Stepper, Switch, TextBox, WidgetExt, diff --git a/druid/examples/tabs.rs b/druid/examples/tabs.rs index 18ffe96aa1..7ac782f5bf 100644 --- a/druid/examples/tabs.rs +++ b/druid/examples/tabs.rs @@ -12,6 +12,9 @@ // See the License for the specific language governing permissions and // limitations under the License. +// On Windows platform, don't show a console when opening the app. +#![windows_subsystem = "windows"] + use druid::im::Vector; use druid::widget::{ Axis, Button, CrossAxisAlignment, Flex, Label, MainAxisAlignment, RadioGroup, Split, TabInfo, diff --git a/druid/examples/text.rs b/druid/examples/text.rs index 65b886c19f..7d07415137 100644 --- a/druid/examples/text.rs +++ b/druid/examples/text.rs @@ -14,6 +14,9 @@ //! An example of various text layout features. +// On Windows platform, don't show a console when opening the app. +#![windows_subsystem = "windows"] + use druid::piet::{PietTextLayoutBuilder, TextStorage as PietTextStorage}; use druid::text::{Attribute, RichText, TextStorage}; use druid::widget::prelude::*; diff --git a/druid/examples/textbox.rs b/druid/examples/textbox.rs index 346328a2bf..4dd332516e 100644 --- a/druid/examples/textbox.rs +++ b/druid/examples/textbox.rs @@ -17,6 +17,9 @@ //! I would like to make this a bit fancier (like the flex demo) but for now //! lets keep it simple. +// On Windows platform, don't show a console when opening the app. +#![windows_subsystem = "windows"] + use std::sync::Arc; use druid::widget::{Flex, Label, TextBox}; diff --git a/druid/examples/timer.rs b/druid/examples/timer.rs index f21aa3b177..078314d967 100644 --- a/druid/examples/timer.rs +++ b/druid/examples/timer.rs @@ -14,6 +14,9 @@ //! An example of a timer. +// On Windows platform, don't show a console when opening the app. +#![windows_subsystem = "windows"] + use std::time::Duration; use druid::widget::prelude::*; diff --git a/druid/examples/transparency.rs b/druid/examples/transparency.rs index 7546af64ae..1047bd10fb 100644 --- a/druid/examples/transparency.rs +++ b/druid/examples/transparency.rs @@ -15,6 +15,9 @@ //! An example of a transparent window background. //! Useful for dropdowns, tooltips and other overlay windows. +// On Windows platform, don't show a console when opening the app. +#![windows_subsystem = "windows"] + use druid::kurbo::Circle; use druid::widget::prelude::*; use druid::widget::{Flex, Label, Painter, TextBox, WidgetExt}; diff --git a/druid/examples/value_formatting/src/main.rs b/druid/examples/value_formatting/src/main.rs index 5be6ed99a6..aecddba1fc 100644 --- a/druid/examples/value_formatting/src/main.rs +++ b/druid/examples/value_formatting/src/main.rs @@ -12,6 +12,9 @@ // See the License for the specific language governing permissions and // limitations under the License. +// On Windows platform, don't show a console when opening the app. +#![windows_subsystem = "windows"] + mod formatters; mod widgets; diff --git a/druid/examples/view_switcher.rs b/druid/examples/view_switcher.rs index dd3a657a2e..b643ab0885 100644 --- a/druid/examples/view_switcher.rs +++ b/druid/examples/view_switcher.rs @@ -14,6 +14,9 @@ //! This example demonstrates the `ViewSwitcher` widget +// On Windows platform, don't show a console when opening the app. +#![windows_subsystem = "windows"] + use druid::widget::{Button, Flex, Label, Split, TextBox, ViewSwitcher}; use druid::{AppLauncher, Data, Env, Lens, LocalizedString, Widget, WidgetExt, WindowDesc}; diff --git a/druid/examples/widget_gallery.rs b/druid/examples/widget_gallery.rs index f77e16f97e..d3d6ab6f1d 100644 --- a/druid/examples/widget_gallery.rs +++ b/druid/examples/widget_gallery.rs @@ -12,6 +12,9 @@ // See the License for the specific language governing permissions and // limitations under the License. +// On Windows platform, don't show a console when opening the app. +#![windows_subsystem = "windows"] + use druid::{ im, kurbo::{Affine, BezPath, Circle, Point}, From 5d54939091af769b204540294323457a26239f52 Mon Sep 17 00:00:00 2001 From: Olivier FAURE Date: Thu, 5 Aug 2021 16:39:36 +0200 Subject: [PATCH 2/2] Add a note for windows apps at the beginning of the doc. --- druid/src/lib.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/druid/src/lib.rs b/druid/src/lib.rs index 8839a8b6d9..181a58ca85 100644 --- a/druid/src/lib.rs +++ b/druid/src/lib.rs @@ -106,6 +106,12 @@ //! features = ["im", "svg", "image"] //! ``` //! +//! # Note for Windows apps +//! +//! By default, Windows will open a console with your application's window. If you don't want +//! the console to be shown, use `#![windows_subsystem = "windows"]` at the beginning of your +//! crate. +//! //! [`Widget`]: trait.Widget.html //! [`Data`]: trait.Data.html //! [`Lens`]: trait.Lens.html