From d9eaea7f5008c2e986d03589d8d2da5fb610e81b Mon Sep 17 00:00:00 2001 From: Mark Friedenbach Date: Wed, 10 Jul 2024 00:21:08 -0700 Subject: [PATCH] Convert examples/* to proper cargo-manifest structure. --- Cargo.toml | 22 ++++++++++++- .../{animations/src/main.rs => animations.rs} | 33 +++++++++++++++++++ examples/animations/Cargo.toml | 8 ----- examples/animations/README.md | 31 ----------------- examples/{context/src/main.rs => context.rs} | 0 examples/context/Cargo.toml | 8 ----- .../src/main.rs => counter-simple.rs} | 0 examples/counter-simple/Cargo.toml | 8 ----- examples/{counter/src/main.rs => counter.rs} | 0 examples/counter/Cargo.toml | 8 ----- .../{draggable/src/main.rs => draggable.rs} | 0 examples/draggable/Cargo.toml | 8 ----- .../src/main.rs => dyn-container.rs} | 0 examples/dyn-container/Cargo.toml | 8 ----- examples/{editor/src/main.rs => editor.rs} | 0 examples/editor/Cargo.toml | 8 ----- examples/{files/src/main.rs => files.rs} | 0 examples/files/Cargo.toml | 8 ----- .../src/main.rs => flight-booker.rs} | 19 +++++++++++ examples/flight_booker/Cargo.toml | 11 ------- examples/flight_booker/README.md | 22 ------------- .../src/main.rs => keyboard-handler.rs} | 0 examples/keyboard_handler/Cargo.toml | 10 ------ examples/layout/Cargo.toml | 8 ----- .../layout/{src => }/draggable_sidebar.rs | 0 examples/layout/{src => }/holy_grail.rs | 0 examples/layout/{src => }/left_sidebar.rs | 0 examples/layout/{src => }/main.rs | 0 examples/layout/{src => }/right_sidebar.rs | 0 examples/layout/{src => }/tab_navigation.rs | 0 .../{responsive/src/main.rs => responsive.rs} | 0 examples/responsive/Cargo.toml | 8 ----- examples/stacks/Cargo.toml | 8 ----- examples/stacks/README.md | 2 -- examples/stacks/{src => }/dyn_stack.rs | 0 examples/stacks/{src => }/main.rs | 2 ++ examples/stacks/{src => }/stack.rs | 0 examples/stacks/{src => }/stack_from_iter.rs | 0 examples/stacks/{src => }/virtual_stack.rs | 0 .../src/main.rs => syntax-editor.rs} | 0 examples/syntax-editor/Cargo.toml | 10 ------ examples/{themes/src/main.rs => themes.rs} | 0 examples/themes/Cargo.toml | 7 ---- examples/{timer/src/main.rs => timer.rs} | 13 ++++++++ examples/timer/Cargo.toml | 10 ------ examples/timer/README.md | 18 ---------- .../src/main.rs => virtual-list.rs} | 8 +++++ examples/virtual_list/Cargo.toml | 8 ----- examples/virtual_list/README.md | 5 --- examples/widget-gallery/Cargo.toml | 9 ----- examples/widget-gallery/{src => }/buttons.rs | 0 examples/widget-gallery/{src => }/checkbox.rs | 0 .../widget-gallery/{src => }/clipboard.rs | 0 .../widget-gallery/{src => }/context_menu.rs | 0 examples/widget-gallery/{src => }/dropdown.rs | 0 examples/widget-gallery/{src => }/form.rs | 0 examples/widget-gallery/{src => }/images.rs | 6 ++-- examples/widget-gallery/{src => }/inputs.rs | 0 examples/widget-gallery/{src => }/labels.rs | 0 examples/widget-gallery/{src => }/lists.rs | 0 examples/widget-gallery/{src => }/main.rs | 0 .../widget-gallery/{src => }/radio_buttons.rs | 0 .../widget-gallery/{src => }/rich_text.rs | 0 examples/widget-gallery/{src => }/slider.rs | 0 examples/window-icon/Cargo.toml | 10 ------ examples/window-icon/{src => }/main.rs | 7 ++-- .../src/main.rs => window-scale.rs} | 0 examples/window-scale/Cargo.toml | 8 ----- .../src/main.rs => window-size.rs} | 0 examples/window-size/Cargo.toml | 8 ----- 70 files changed, 104 insertions(+), 263 deletions(-) rename examples/{animations/src/main.rs => animations.rs} (82%) delete mode 100644 examples/animations/Cargo.toml delete mode 100644 examples/animations/README.md rename examples/{context/src/main.rs => context.rs} (100%) delete mode 100644 examples/context/Cargo.toml rename examples/{counter-simple/src/main.rs => counter-simple.rs} (100%) delete mode 100644 examples/counter-simple/Cargo.toml rename examples/{counter/src/main.rs => counter.rs} (100%) delete mode 100644 examples/counter/Cargo.toml rename examples/{draggable/src/main.rs => draggable.rs} (100%) delete mode 100644 examples/draggable/Cargo.toml rename examples/{dyn-container/src/main.rs => dyn-container.rs} (100%) delete mode 100644 examples/dyn-container/Cargo.toml rename examples/{editor/src/main.rs => editor.rs} (100%) delete mode 100644 examples/editor/Cargo.toml rename examples/{files/src/main.rs => files.rs} (100%) delete mode 100644 examples/files/Cargo.toml rename examples/{flight_booker/src/main.rs => flight-booker.rs} (75%) delete mode 100644 examples/flight_booker/Cargo.toml delete mode 100644 examples/flight_booker/README.md rename examples/{keyboard_handler/src/main.rs => keyboard-handler.rs} (100%) delete mode 100644 examples/keyboard_handler/Cargo.toml delete mode 100644 examples/layout/Cargo.toml rename examples/layout/{src => }/draggable_sidebar.rs (100%) rename examples/layout/{src => }/holy_grail.rs (100%) rename examples/layout/{src => }/left_sidebar.rs (100%) rename examples/layout/{src => }/main.rs (100%) rename examples/layout/{src => }/right_sidebar.rs (100%) rename examples/layout/{src => }/tab_navigation.rs (100%) rename examples/{responsive/src/main.rs => responsive.rs} (100%) delete mode 100644 examples/responsive/Cargo.toml delete mode 100644 examples/stacks/Cargo.toml delete mode 100644 examples/stacks/README.md rename examples/stacks/{src => }/dyn_stack.rs (100%) rename examples/stacks/{src => }/main.rs (94%) rename examples/stacks/{src => }/stack.rs (100%) rename examples/stacks/{src => }/stack_from_iter.rs (100%) rename examples/stacks/{src => }/virtual_stack.rs (100%) rename examples/{syntax-editor/src/main.rs => syntax-editor.rs} (100%) delete mode 100644 examples/syntax-editor/Cargo.toml rename examples/{themes/src/main.rs => themes.rs} (100%) delete mode 100644 examples/themes/Cargo.toml rename examples/{timer/src/main.rs => timer.rs} (76%) delete mode 100644 examples/timer/Cargo.toml delete mode 100644 examples/timer/README.md rename examples/{virtual_list/src/main.rs => virtual-list.rs} (69%) delete mode 100644 examples/virtual_list/Cargo.toml delete mode 100644 examples/virtual_list/README.md delete mode 100644 examples/widget-gallery/Cargo.toml rename examples/widget-gallery/{src => }/buttons.rs (100%) rename examples/widget-gallery/{src => }/checkbox.rs (100%) rename examples/widget-gallery/{src => }/clipboard.rs (100%) rename examples/widget-gallery/{src => }/context_menu.rs (100%) rename examples/widget-gallery/{src => }/dropdown.rs (100%) rename examples/widget-gallery/{src => }/form.rs (100%) rename examples/widget-gallery/{src => }/images.rs (92%) rename examples/widget-gallery/{src => }/inputs.rs (100%) rename examples/widget-gallery/{src => }/labels.rs (100%) rename examples/widget-gallery/{src => }/lists.rs (100%) rename examples/widget-gallery/{src => }/main.rs (100%) rename examples/widget-gallery/{src => }/radio_buttons.rs (100%) rename examples/widget-gallery/{src => }/rich_text.rs (100%) rename examples/widget-gallery/{src => }/slider.rs (100%) delete mode 100644 examples/window-icon/Cargo.toml rename examples/window-icon/{src => }/main.rs (93%) rename examples/{window-scale/src/main.rs => window-scale.rs} (100%) delete mode 100644 examples/window-scale/Cargo.toml rename examples/{window-size/src/main.rs => window-size.rs} (100%) delete mode 100644 examples/window-size/Cargo.toml diff --git a/Cargo.toml b/Cargo.toml index d4022d9e..d0cc996c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [workspace] resolver = "2" -members = ["renderer", "vger", "tiny_skia", "reactive", "editor-core", "examples/*"] +members = ["renderer", "vger", "tiny_skia", "reactive", "editor-core"] [workspace.package] license = "MIT" @@ -68,12 +68,20 @@ image = { workspace = true } im = { workspace = true } wgpu = { workspace = true } +[dev-dependencies] +lazy_static = "1.4.0" +nsvg = "0.5" +strum = { version = "0.25.0", features = ["derive"] } +syntect = "5.2.0" +time = { version = "0.3.31", features = ["parsing", "macros"] } + [features] default = ["editor", "default-image-formats"] # TODO: this is only winit and the editor serde, there are other dependencies that still depend on # serde serde = ["floem-winit/serde", "dep:serde"] editor = ["floem-editor-core", "dep:lapce-xi-rope", "dep:strum", "dep:strum_macros", "dep:downcast-rs"] +strum-derive = ["dep:strum", "strum/derive"] # Image support # From: https://github.com/image-rs/image/blob/main/Cargo.toml @@ -99,3 +107,15 @@ tokio = ["dep:tokio"] # rfd (file dialog) async runtime rfd-async-std = ["dep:rfd", "rfd/async-std"] rfd-tokio = ["dep:rfd", "rfd/tokio"] + +[[example]] +name = "files" +required-features = ["rfd-async-std"] + +[[example]] +name = "syntax-editor" +required-features = ["editor"] + +[[example]] +name = "widget-gallery" +required-features = ["strum-derive"] diff --git a/examples/animations/src/main.rs b/examples/animations.rs similarity index 82% rename from examples/animations/src/main.rs rename to examples/animations.rs index 27f7ec4b..df719de0 100644 --- a/examples/animations/src/main.rs +++ b/examples/animations.rs @@ -1,3 +1,36 @@ +//! > WARNING +//! > ======= +//! > **Work in progress, which is subject to frequent change.** If you plan to add changes, please make sure you reach +//! > out in our discord first. +//! +//! The end-goal is to support reactive animations, similar to Swift UI(including spring animations). The API we are +//! currently aiming for looks something like this: +//! ```rust +//! let (is_hovered, set_is_hovered) = create_signal(false); +//! let (scroll_offset_pct, set_scroll_offset_pct) = create_signal(0.); +//! +//! scroll({ +//! button() +//! .style(|s| { +//! s.width(move || {50.0}) +//! }) +//! .animation(|s| { +//! s.width(300) +//! // we get animation on scroll "for free", since everything is integrated with the reactive system +//! .opacity(move || scroll_offset_pct) +//! .scale(move || is_hovered.get() {1.2} else {1.0} ) +//! .easing_fn(EasingFn::Cubic) +//! .ease_in_out() +//! .duration(Duration::from_secs(1)) +//! }) +//! }.on_scroll(move |scroll| { +//! let offset_pct = ......snip........ +//! set_scroll_offset_pct.update(|value| *value = offset_pct); +//! true +//! }) +//! ) +//! ``` + use std::time::Duration; use floem::{ diff --git a/examples/animations/Cargo.toml b/examples/animations/Cargo.toml deleted file mode 100644 index 9992c3ad..00000000 --- a/examples/animations/Cargo.toml +++ /dev/null @@ -1,8 +0,0 @@ -[package] -name = "animations" -version = "0.1.0" -edition = "2021" - -[dependencies] -im.workspace = true -floem = { path = "../.." } diff --git a/examples/animations/README.md b/examples/animations/README.md deleted file mode 100644 index 59ef5ad6..00000000 --- a/examples/animations/README.md +++ /dev/null @@ -1,31 +0,0 @@ -> [!WARNING] -> **Work in progress, which is subject to frequent change.** - If you plan to add changes, please make sure you reach out in our discord first. - - The end-goal is to support reactive animations, similar to Swift UI(including spring animations). - The API we are currently aiming for looks something like this: - ```rust - let (is_hovered, set_is_hovered) = create_signal(false); - let (scroll_offset_pct, set_scroll_offset_pct) = create_signal(0.); - - scroll({ - button() - .style(|s| { - s.width(move || {50.0}) - }) - .animation(|s| { - s.width(300) - // we get animation on scroll "for free", since everything is integrated with the reactive system - .opacity(move || scroll_offset_pct) - .scale(move || is_hovered.get() {1.2} else {1.0} ) - .easing_fn(EasingFn::Cubic) - .ease_in_out() - .duration(Duration::from_secs(1)) - }) - }.on_scroll(move |scroll| { - let offset_pct = ......snip........ - set_scroll_offset_pct.update(|value| *value = offset_pct); - true - }) - ) - ``` diff --git a/examples/context/src/main.rs b/examples/context.rs similarity index 100% rename from examples/context/src/main.rs rename to examples/context.rs diff --git a/examples/context/Cargo.toml b/examples/context/Cargo.toml deleted file mode 100644 index 94d2802e..00000000 --- a/examples/context/Cargo.toml +++ /dev/null @@ -1,8 +0,0 @@ -[package] -name = "context" -version = "0.1.0" -edition = "2021" - -[dependencies] -im.workspace = true -floem = { path = "../.." } diff --git a/examples/counter-simple/src/main.rs b/examples/counter-simple.rs similarity index 100% rename from examples/counter-simple/src/main.rs rename to examples/counter-simple.rs diff --git a/examples/counter-simple/Cargo.toml b/examples/counter-simple/Cargo.toml deleted file mode 100644 index 395e20db..00000000 --- a/examples/counter-simple/Cargo.toml +++ /dev/null @@ -1,8 +0,0 @@ -[package] -name = "counter-simple" -version = "0.1.0" -edition = "2021" - -[dependencies] -im.workspace = true -floem = { path = "../.." } diff --git a/examples/counter/src/main.rs b/examples/counter.rs similarity index 100% rename from examples/counter/src/main.rs rename to examples/counter.rs diff --git a/examples/counter/Cargo.toml b/examples/counter/Cargo.toml deleted file mode 100644 index 73ff1c1d..00000000 --- a/examples/counter/Cargo.toml +++ /dev/null @@ -1,8 +0,0 @@ -[package] -name = "counter" -version = "0.1.0" -edition = "2021" - -[dependencies] -im.workspace = true -floem = { path = "../.." } diff --git a/examples/draggable/src/main.rs b/examples/draggable.rs similarity index 100% rename from examples/draggable/src/main.rs rename to examples/draggable.rs diff --git a/examples/draggable/Cargo.toml b/examples/draggable/Cargo.toml deleted file mode 100644 index 4cd7ca18..00000000 --- a/examples/draggable/Cargo.toml +++ /dev/null @@ -1,8 +0,0 @@ -[package] -name = "draggable" -version = "0.1.0" -edition = "2021" - -[dependencies] -im.workspace = true -floem = { path = "../.." } diff --git a/examples/dyn-container/src/main.rs b/examples/dyn-container.rs similarity index 100% rename from examples/dyn-container/src/main.rs rename to examples/dyn-container.rs diff --git a/examples/dyn-container/Cargo.toml b/examples/dyn-container/Cargo.toml deleted file mode 100644 index 459ebfa2..00000000 --- a/examples/dyn-container/Cargo.toml +++ /dev/null @@ -1,8 +0,0 @@ -[package] -name = "dyn-container" -version = "0.1.0" -edition = "2021" - -[dependencies] -im.workspace = true -floem = { path = "../.." } diff --git a/examples/editor/src/main.rs b/examples/editor.rs similarity index 100% rename from examples/editor/src/main.rs rename to examples/editor.rs diff --git a/examples/editor/Cargo.toml b/examples/editor/Cargo.toml deleted file mode 100644 index 7a2a7c94..00000000 --- a/examples/editor/Cargo.toml +++ /dev/null @@ -1,8 +0,0 @@ -[package] -name = "editor" -version = "0.1.0" -edition = "2021" - -[dependencies] -im.workspace = true -floem = { path = "../..", features = ["editor"] } diff --git a/examples/files/src/main.rs b/examples/files.rs similarity index 100% rename from examples/files/src/main.rs rename to examples/files.rs diff --git a/examples/files/Cargo.toml b/examples/files/Cargo.toml deleted file mode 100644 index df48a646..00000000 --- a/examples/files/Cargo.toml +++ /dev/null @@ -1,8 +0,0 @@ -[package] -name = "fils" -version = "0.1.0" -edition = "2021" - -[dependencies] -im.workspace = true -floem = { path = "../..", features = ["rfd-async-std"] } diff --git a/examples/flight_booker/src/main.rs b/examples/flight-booker.rs similarity index 75% rename from examples/flight_booker/src/main.rs rename to examples/flight-booker.rs index c185fa33..ae4b818f 100644 --- a/examples/flight_booker/src/main.rs +++ b/examples/flight-booker.rs @@ -1,3 +1,22 @@ +//! This is an example that emulates an application that books flights, as described in [task 3][task3] of [7gui +//! tasks][7gui]. +//! +//! > The focus of Flight Booker lies on modelling constraints between widgets on the one hand and modelling constraints +//! > within a widget on the other hand. Such constraints are very common in everyday interactions with GUI +//! > applications. A good solution for Flight Booker will make the constraints clear, succinct and explicit in the +//! > source code and not hidden behind a lot of scaffolding. +//! +//! | Initial state | Invalid date format | Return date before start date | +//! | ------- | ------- | ------- | +//! | ![valid] | ![invalid] | ![return-disabled] | +//! +//! [task3]: https://eugenkiss.github.io/7guis/tasks/#flight +//! [7gui]: https://eugenkiss.github.io/7guis/ +//! +//! [valid]: https://github.com/lapce/floem/assets/23398472/fe2758d3-7161-43a3-b059-8a4a1ce0c02e +//! [invalid]: https://github.com/lapce/floem/assets/23398472/aeb843aa-520b-48f3-a39d-6acb414dba57 +//! [return-disabled]: https://github.com/lapce/floem/assets/23398472/8f1268f9-efbd-4a4d-9a47-7a50425e3e39 + use floem::{ peniko::Color, reactive::{create_rw_signal, create_signal}, diff --git a/examples/flight_booker/Cargo.toml b/examples/flight_booker/Cargo.toml deleted file mode 100644 index d1354406..00000000 --- a/examples/flight_booker/Cargo.toml +++ /dev/null @@ -1,11 +0,0 @@ -[package] -name = "flight_booker" -edition = "2021" -license.workspace = true -version.workspace = true - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] -floem = { path = "../.." } -time = { version = "0.3.31", features = ["parsing", "macros"] } diff --git a/examples/flight_booker/README.md b/examples/flight_booker/README.md deleted file mode 100644 index c0dcbc6a..00000000 --- a/examples/flight_booker/README.md +++ /dev/null @@ -1,22 +0,0 @@ -# Flight Booker - -This is an example that emulates an application that books flights, as -described in [task 3][task3] of [7gui tasks][7gui]. - -> The focus of Flight Booker lies on modelling constraints between -> widgets on the one hand and modelling constraints within a widget -> on the other hand. Such constraints are very common in everyday -> interactions with GUI applications. A good solution for Flight Booker -> will make the constraints clear, succinct and explicit in the source -> code and not hidden behind a lot of scaffolding. - -| Initial state | Invalid date format | Return date before start date | -| ------- | ------- | ------- | -| ![valid] | ![invalid] | ![return-disabled] | - -[task3]: https://eugenkiss.github.io/7guis/tasks/#flight -[7gui]: https://eugenkiss.github.io/7guis/ - -[valid]: https://github.com/lapce/floem/assets/23398472/fe2758d3-7161-43a3-b059-8a4a1ce0c02e -[invalid]: https://github.com/lapce/floem/assets/23398472/aeb843aa-520b-48f3-a39d-6acb414dba57 -[return-disabled]: https://github.com/lapce/floem/assets/23398472/8f1268f9-efbd-4a4d-9a47-7a50425e3e39 \ No newline at end of file diff --git a/examples/keyboard_handler/src/main.rs b/examples/keyboard-handler.rs similarity index 100% rename from examples/keyboard_handler/src/main.rs rename to examples/keyboard-handler.rs diff --git a/examples/keyboard_handler/Cargo.toml b/examples/keyboard_handler/Cargo.toml deleted file mode 100644 index 17a7d963..00000000 --- a/examples/keyboard_handler/Cargo.toml +++ /dev/null @@ -1,10 +0,0 @@ -[package] -name = "keyboard_handler" -edition = "2021" -license.workspace = true -version.workspace = true - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] -floem = { path = "../.." } diff --git a/examples/layout/Cargo.toml b/examples/layout/Cargo.toml deleted file mode 100644 index dda3c04d..00000000 --- a/examples/layout/Cargo.toml +++ /dev/null @@ -1,8 +0,0 @@ -[package] -name = "layout" -version = "0.1.0" -edition = "2021" - -[dependencies] -im.workspace = true -floem = { path = "../.." } diff --git a/examples/layout/src/draggable_sidebar.rs b/examples/layout/draggable_sidebar.rs similarity index 100% rename from examples/layout/src/draggable_sidebar.rs rename to examples/layout/draggable_sidebar.rs diff --git a/examples/layout/src/holy_grail.rs b/examples/layout/holy_grail.rs similarity index 100% rename from examples/layout/src/holy_grail.rs rename to examples/layout/holy_grail.rs diff --git a/examples/layout/src/left_sidebar.rs b/examples/layout/left_sidebar.rs similarity index 100% rename from examples/layout/src/left_sidebar.rs rename to examples/layout/left_sidebar.rs diff --git a/examples/layout/src/main.rs b/examples/layout/main.rs similarity index 100% rename from examples/layout/src/main.rs rename to examples/layout/main.rs diff --git a/examples/layout/src/right_sidebar.rs b/examples/layout/right_sidebar.rs similarity index 100% rename from examples/layout/src/right_sidebar.rs rename to examples/layout/right_sidebar.rs diff --git a/examples/layout/src/tab_navigation.rs b/examples/layout/tab_navigation.rs similarity index 100% rename from examples/layout/src/tab_navigation.rs rename to examples/layout/tab_navigation.rs diff --git a/examples/responsive/src/main.rs b/examples/responsive.rs similarity index 100% rename from examples/responsive/src/main.rs rename to examples/responsive.rs diff --git a/examples/responsive/Cargo.toml b/examples/responsive/Cargo.toml deleted file mode 100644 index c2aee8cf..00000000 --- a/examples/responsive/Cargo.toml +++ /dev/null @@ -1,8 +0,0 @@ -[package] -name = "responsive" -version = "0.1.0" -edition = "2021" - -[dependencies] -im.workspace = true -floem = { path = "../.." } diff --git a/examples/stacks/Cargo.toml b/examples/stacks/Cargo.toml deleted file mode 100644 index 9fd6aa62..00000000 --- a/examples/stacks/Cargo.toml +++ /dev/null @@ -1,8 +0,0 @@ -[package] -name = "stacks" -version = "0.1.0" -edition = "2021" - -[dependencies] -im.workspace = true -floem = { path = "../.." } diff --git a/examples/stacks/README.md b/examples/stacks/README.md deleted file mode 100644 index 8a826934..00000000 --- a/examples/stacks/README.md +++ /dev/null @@ -1,2 +0,0 @@ -In this example you can see the four different types of stacks floem has and -their differences. diff --git a/examples/stacks/src/dyn_stack.rs b/examples/stacks/dyn_stack.rs similarity index 100% rename from examples/stacks/src/dyn_stack.rs rename to examples/stacks/dyn_stack.rs diff --git a/examples/stacks/src/main.rs b/examples/stacks/main.rs similarity index 94% rename from examples/stacks/src/main.rs rename to examples/stacks/main.rs index 25b38d50..4765ce76 100644 --- a/examples/stacks/src/main.rs +++ b/examples/stacks/main.rs @@ -1,3 +1,5 @@ +//! In this example you can see the four different types of stacks floem has and their differences. + use floem::{ keyboard::{Key, Modifiers, NamedKey}, views::Decorators, diff --git a/examples/stacks/src/stack.rs b/examples/stacks/stack.rs similarity index 100% rename from examples/stacks/src/stack.rs rename to examples/stacks/stack.rs diff --git a/examples/stacks/src/stack_from_iter.rs b/examples/stacks/stack_from_iter.rs similarity index 100% rename from examples/stacks/src/stack_from_iter.rs rename to examples/stacks/stack_from_iter.rs diff --git a/examples/stacks/src/virtual_stack.rs b/examples/stacks/virtual_stack.rs similarity index 100% rename from examples/stacks/src/virtual_stack.rs rename to examples/stacks/virtual_stack.rs diff --git a/examples/syntax-editor/src/main.rs b/examples/syntax-editor.rs similarity index 100% rename from examples/syntax-editor/src/main.rs rename to examples/syntax-editor.rs diff --git a/examples/syntax-editor/Cargo.toml b/examples/syntax-editor/Cargo.toml deleted file mode 100644 index dcea0715..00000000 --- a/examples/syntax-editor/Cargo.toml +++ /dev/null @@ -1,10 +0,0 @@ -[package] -name = "syntax-editor" -version = "0.1.0" -edition = "2021" - -[dependencies] -im.workspace = true -floem = { path = "../..", features = ["editor"] } -syntect = "5.2.0" -lazy_static = "1.4.0" \ No newline at end of file diff --git a/examples/themes/src/main.rs b/examples/themes.rs similarity index 100% rename from examples/themes/src/main.rs rename to examples/themes.rs diff --git a/examples/themes/Cargo.toml b/examples/themes/Cargo.toml deleted file mode 100644 index 5ce3f70f..00000000 --- a/examples/themes/Cargo.toml +++ /dev/null @@ -1,7 +0,0 @@ -[package] -name = "themes" -version = "0.1.0" -edition = "2021" - -[dependencies] -floem = { path = "../.." } diff --git a/examples/timer/src/main.rs b/examples/timer.rs similarity index 76% rename from examples/timer/src/main.rs rename to examples/timer.rs index 429822db..942ca16a 100644 --- a/examples/timer/src/main.rs +++ b/examples/timer.rs @@ -1,3 +1,16 @@ +//! This is an example timer app, as described in [task 4][task4] of [7gui tasks][7gui]. +//! +//! > Timer deals with concurrency in the sense that a timer process that updates the elapsed time runs concurrently to +//! > the user’s interactions with the GUI application. This also means that the solution to competing user and signal +//! > interactions is tested. The fact that slider adjustments must be reflected immediately moreover tests the +//! > responsiveness of the solution. A good solution will make it clear that the signal is a timer tick and, as always, +//! > has not much scaffolding. +//! +//! ![timer](https://github.com/lapce/floem/assets/23398472/b55dae4f-56fe-4e9f-a0ee-1898db048588) +//! +//! [task4]: https://eugenkiss.github.io/7guis/tasks/#timer +//! [7gui]: https://eugenkiss.github.io/7guis/ + use std::time::{Duration, Instant}; use floem::{ diff --git a/examples/timer/Cargo.toml b/examples/timer/Cargo.toml deleted file mode 100644 index 6cd3b0d1..00000000 --- a/examples/timer/Cargo.toml +++ /dev/null @@ -1,10 +0,0 @@ -[package] -name = "timer" -edition = "2021" -license.workspace = true -version.workspace = true - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] -floem = { path = "../.." } diff --git a/examples/timer/README.md b/examples/timer/README.md deleted file mode 100644 index 9c903a0b..00000000 --- a/examples/timer/README.md +++ /dev/null @@ -1,18 +0,0 @@ -# Timer - -This is an example timer app, as described in -[task 4][task4] of [7gui tasks][7gui]. - -> Timer deals with concurrency in the sense that a timer process -> that updates the elapsed time runs concurrently to the user’s -> interactions with the GUI application. This also means that the -> solution to competing user and signal interactions is tested. The -> fact that slider adjustments must be reflected immediately moreover -> tests the responsiveness of the solution. A good solution will make -> it clear that the signal is a timer tick and, as always, has not -> much scaffolding. - -![timer](https://github.com/lapce/floem/assets/23398472/b55dae4f-56fe-4e9f-a0ee-1898db048588) - -[task4]: https://eugenkiss.github.io/7guis/tasks/#timer -[7gui]: https://eugenkiss.github.io/7guis/ diff --git a/examples/virtual_list/src/main.rs b/examples/virtual-list.rs similarity index 69% rename from examples/virtual_list/src/main.rs rename to examples/virtual-list.rs index 1bf872ff..58b3f10b 100644 --- a/examples/virtual_list/src/main.rs +++ b/examples/virtual-list.rs @@ -1,3 +1,11 @@ +//! In this example, it shows the ability to have 1 million fixed height items in a list. +//! +//! What it does behind the scenes, is effectively only add the list item view on the screen to the view tree, and +//! remove them from the view tree when they are out of view. +//! +//! The ```VirtualList``` in Floem gives the user a way to deal with really long lists in a performant way without +//! manually doing the adding and removing. + use floem::{ reactive::create_signal, unit::UnitExt, diff --git a/examples/virtual_list/Cargo.toml b/examples/virtual_list/Cargo.toml deleted file mode 100644 index ee8e5814..00000000 --- a/examples/virtual_list/Cargo.toml +++ /dev/null @@ -1,8 +0,0 @@ -[package] -name = "virtual_list" -version = "0.1.0" -edition = "2021" - -[dependencies] -im.workspace = true -floem = { path = "../.." } diff --git a/examples/virtual_list/README.md b/examples/virtual_list/README.md deleted file mode 100644 index 4ae5aca6..00000000 --- a/examples/virtual_list/README.md +++ /dev/null @@ -1,5 +0,0 @@ -In this example, it shows the ability to have 1 million fixed height items in a list. - -What it does behind the scenes, is effectively only add the list item view on the screen to the view tree, and remove them from the view tree when they are out of view. - -The ```VirtualList``` in Floem gives the user a way to deal with really long lists in a performant way without manually doing the adding and removing. \ No newline at end of file diff --git a/examples/widget-gallery/Cargo.toml b/examples/widget-gallery/Cargo.toml deleted file mode 100644 index 8d1045e1..00000000 --- a/examples/widget-gallery/Cargo.toml +++ /dev/null @@ -1,9 +0,0 @@ -[package] -name = "widget-gallery" -version = "0.1.0" -edition = "2021" - -[dependencies] -im.workspace = true -floem = { path = "../.." } -strum = { version = "0.25.0", features = ["derive"] } diff --git a/examples/widget-gallery/src/buttons.rs b/examples/widget-gallery/buttons.rs similarity index 100% rename from examples/widget-gallery/src/buttons.rs rename to examples/widget-gallery/buttons.rs diff --git a/examples/widget-gallery/src/checkbox.rs b/examples/widget-gallery/checkbox.rs similarity index 100% rename from examples/widget-gallery/src/checkbox.rs rename to examples/widget-gallery/checkbox.rs diff --git a/examples/widget-gallery/src/clipboard.rs b/examples/widget-gallery/clipboard.rs similarity index 100% rename from examples/widget-gallery/src/clipboard.rs rename to examples/widget-gallery/clipboard.rs diff --git a/examples/widget-gallery/src/context_menu.rs b/examples/widget-gallery/context_menu.rs similarity index 100% rename from examples/widget-gallery/src/context_menu.rs rename to examples/widget-gallery/context_menu.rs diff --git a/examples/widget-gallery/src/dropdown.rs b/examples/widget-gallery/dropdown.rs similarity index 100% rename from examples/widget-gallery/src/dropdown.rs rename to examples/widget-gallery/dropdown.rs diff --git a/examples/widget-gallery/src/form.rs b/examples/widget-gallery/form.rs similarity index 100% rename from examples/widget-gallery/src/form.rs rename to examples/widget-gallery/form.rs diff --git a/examples/widget-gallery/src/images.rs b/examples/widget-gallery/images.rs similarity index 92% rename from examples/widget-gallery/src/images.rs rename to examples/widget-gallery/images.rs index eca7ad01..157e8a56 100644 --- a/examples/widget-gallery/src/images.rs +++ b/examples/widget-gallery/images.rs @@ -7,12 +7,12 @@ use floem::{ use crate::form::{form, form_item}; pub fn img_view() -> impl IntoView { - let ferris_png = include_bytes!("./../assets/ferris.png"); - let ferris_svg = include_str!("./../assets/ferris.svg"); + let ferris_png = include_bytes!("assets/ferris.png"); + let ferris_svg = include_str!("assets/ferris.svg"); let svg_str = r##" "##; - let sunflower = include_bytes!("./../assets/sunflower.jpg"); + let sunflower = include_bytes!("assets/sunflower.jpg"); form({ ( diff --git a/examples/widget-gallery/src/inputs.rs b/examples/widget-gallery/inputs.rs similarity index 100% rename from examples/widget-gallery/src/inputs.rs rename to examples/widget-gallery/inputs.rs diff --git a/examples/widget-gallery/src/labels.rs b/examples/widget-gallery/labels.rs similarity index 100% rename from examples/widget-gallery/src/labels.rs rename to examples/widget-gallery/labels.rs diff --git a/examples/widget-gallery/src/lists.rs b/examples/widget-gallery/lists.rs similarity index 100% rename from examples/widget-gallery/src/lists.rs rename to examples/widget-gallery/lists.rs diff --git a/examples/widget-gallery/src/main.rs b/examples/widget-gallery/main.rs similarity index 100% rename from examples/widget-gallery/src/main.rs rename to examples/widget-gallery/main.rs diff --git a/examples/widget-gallery/src/radio_buttons.rs b/examples/widget-gallery/radio_buttons.rs similarity index 100% rename from examples/widget-gallery/src/radio_buttons.rs rename to examples/widget-gallery/radio_buttons.rs diff --git a/examples/widget-gallery/src/rich_text.rs b/examples/widget-gallery/rich_text.rs similarity index 100% rename from examples/widget-gallery/src/rich_text.rs rename to examples/widget-gallery/rich_text.rs diff --git a/examples/widget-gallery/src/slider.rs b/examples/widget-gallery/slider.rs similarity index 100% rename from examples/widget-gallery/src/slider.rs rename to examples/widget-gallery/slider.rs diff --git a/examples/window-icon/Cargo.toml b/examples/window-icon/Cargo.toml deleted file mode 100644 index 0e5f316d..00000000 --- a/examples/window-icon/Cargo.toml +++ /dev/null @@ -1,10 +0,0 @@ -[package] -name = "window-icon" -version = "0.1.0" -edition = "2021" - -[dependencies] -im.workspace = true -floem = { path = "../.." } -image = "0.25" -nsvg = "0.5" \ No newline at end of file diff --git a/examples/window-icon/src/main.rs b/examples/window-icon/main.rs similarity index 93% rename from examples/window-icon/src/main.rs rename to examples/window-icon/main.rs index f0d30137..86bf7c4b 100644 --- a/examples/window-icon/src/main.rs +++ b/examples/window-icon/main.rs @@ -33,7 +33,7 @@ fn app_view() -> impl IntoView { label(move || String::from("This window has an icon from a PNG file")) .style(|s| s.font_size(30.0)), button(|| "Open another window").on_click_stop(|_| { - let svg_icon = load_svg_icon(include_str!("../assets/ferris.svg")); + let svg_icon = load_svg_icon(include_str!("assets/ferris.svg")); new_window( sub_window_view, Some( @@ -65,7 +65,10 @@ fn app_view() -> impl IntoView { } fn main() { - let png_icon_path = concat!(env!("CARGO_MANIFEST_DIR"), "/assets/ferris.png"); + let png_icon_path = concat!( + env!("CARGO_MANIFEST_DIR"), + "/examples/window-icon/assets/ferris.png" + ); let png_icon = load_png_icon(Path::new(png_icon_path)); Application::new() diff --git a/examples/window-scale/src/main.rs b/examples/window-scale.rs similarity index 100% rename from examples/window-scale/src/main.rs rename to examples/window-scale.rs diff --git a/examples/window-scale/Cargo.toml b/examples/window-scale/Cargo.toml deleted file mode 100644 index bd495405..00000000 --- a/examples/window-scale/Cargo.toml +++ /dev/null @@ -1,8 +0,0 @@ -[package] -name = "window-scale" -version = "0.1.0" -edition = "2021" - -[dependencies] -im.workspace = true -floem = { path = "../.." } diff --git a/examples/window-size/src/main.rs b/examples/window-size.rs similarity index 100% rename from examples/window-size/src/main.rs rename to examples/window-size.rs diff --git a/examples/window-size/Cargo.toml b/examples/window-size/Cargo.toml deleted file mode 100644 index fd8dd206..00000000 --- a/examples/window-size/Cargo.toml +++ /dev/null @@ -1,8 +0,0 @@ -[package] -name = "window-size" -version = "0.1.0" -edition = "2021" - -[dependencies] -im.workspace = true -floem = { path = "../.." }