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

Convert examples/* to proper cargo-manifest structure. #508

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
22 changes: 21 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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
Expand All @@ -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"]
33 changes: 33 additions & 0 deletions examples/animations/src/main.rs → examples/animations.rs
Original file line number Diff line number Diff line change
@@ -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::{
Expand Down
8 changes: 0 additions & 8 deletions examples/animations/Cargo.toml

This file was deleted.

31 changes: 0 additions & 31 deletions examples/animations/README.md

This file was deleted.

File renamed without changes.
8 changes: 0 additions & 8 deletions examples/context/Cargo.toml

This file was deleted.

File renamed without changes.
8 changes: 0 additions & 8 deletions examples/counter-simple/Cargo.toml

This file was deleted.

File renamed without changes.
8 changes: 0 additions & 8 deletions examples/counter/Cargo.toml

This file was deleted.

File renamed without changes.
8 changes: 0 additions & 8 deletions examples/draggable/Cargo.toml

This file was deleted.

File renamed without changes.
8 changes: 0 additions & 8 deletions examples/dyn-container/Cargo.toml

This file was deleted.

File renamed without changes.
8 changes: 0 additions & 8 deletions examples/editor/Cargo.toml

This file was deleted.

File renamed without changes.
8 changes: 0 additions & 8 deletions examples/files/Cargo.toml

This file was deleted.

19 changes: 19 additions & 0 deletions examples/flight_booker/src/main.rs → examples/flight-booker.rs
Original file line number Diff line number Diff line change
@@ -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},
Expand Down
11 changes: 0 additions & 11 deletions examples/flight_booker/Cargo.toml

This file was deleted.

22 changes: 0 additions & 22 deletions examples/flight_booker/README.md

This file was deleted.

File renamed without changes.
10 changes: 0 additions & 10 deletions examples/keyboard_handler/Cargo.toml

This file was deleted.

8 changes: 0 additions & 8 deletions examples/layout/Cargo.toml

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
8 changes: 0 additions & 8 deletions examples/responsive/Cargo.toml

This file was deleted.

8 changes: 0 additions & 8 deletions examples/stacks/Cargo.toml

This file was deleted.

2 changes: 0 additions & 2 deletions examples/stacks/README.md

This file was deleted.

File renamed without changes.
2 changes: 2 additions & 0 deletions examples/stacks/src/main.rs → examples/stacks/main.rs
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
10 changes: 0 additions & 10 deletions examples/syntax-editor/Cargo.toml

This file was deleted.

File renamed without changes.
7 changes: 0 additions & 7 deletions examples/themes/Cargo.toml

This file was deleted.

13 changes: 13 additions & 0 deletions examples/timer/src/main.rs → examples/timer.rs
Original file line number Diff line number Diff line change
@@ -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::{
Expand Down
10 changes: 0 additions & 10 deletions examples/timer/Cargo.toml

This file was deleted.

18 changes: 0 additions & 18 deletions examples/timer/README.md

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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,
Expand Down
8 changes: 0 additions & 8 deletions examples/virtual_list/Cargo.toml

This file was deleted.

5 changes: 0 additions & 5 deletions examples/virtual_list/README.md

This file was deleted.

9 changes: 0 additions & 9 deletions examples/widget-gallery/Cargo.toml

This file was deleted.

File renamed without changes.
Loading