Skip to content

Commit

Permalink
feat: Use alpha 5
Browse files Browse the repository at this point in the history
  • Loading branch information
marc2332 committed Nov 24, 2024
2 parents 3230a55 + 8bd52cb commit 274bd3c
Show file tree
Hide file tree
Showing 275 changed files with 14,144 additions and 5,551 deletions.
Binary file added .github/overview.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions .github/workflows/deploy_book.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ jobs:

- name: Setup mdBook
uses: peaceiris/actions-mdbook@v2
with:
mdbook-version: '0.4.32'

- run: mdbook build
working-directory: book
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ jobs:
fetch-depth: 0
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: "1.80.1"
- name: Install linux dependencies
if: runner.os == 'Linux'
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
- name: Install linux dependencies
if: runner.os == 'Linux'
run: |
sudo apt update && sudo apt install build-essential libssl-dev pkg-config libglib2.0-dev libgtk-3-dev
sudo apt update && sudo apt install build-essential libssl-dev pkg-config libglib2.0-dev libgtk-3-dev libudev-dev
- name: Check examples
run: cargo check --examples
- name: Lint
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/sponsors.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
- cron: 30 15 * * 0-6
jobs:
deploy:
if: github.repository == 'marc2332/freya'
runs-on: ubuntu-latest
steps:
- name: Checkout 🛎️
Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@ target
Cargo.lock
.idea
snapshot_before.png
snapshot_after.png
snapshot_after.png
documents_example
bacon.toml
5 changes: 3 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"rust-analyzer.cargo.features": [
"devtools",
"log",
"use_camera"
"tracing-subscriber",
"use_camera",
"fade-cached-incremental-areas"
]
}
8 changes: 5 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ cargo +nightly fmt --all -- --error-on-unformatted --unstable-features
Freya is split in various crates, each with it's own meaning and purpose, here is the list sorted by their importance:

- `freya`: Entrypoint to the library used by end users, mainly reexports the other crates and contains the launch methods.
- `renderer`: GUI Renderer using Winit and a Skia Canvas to render the app.
- `core`: Core logic for events, DOM processing, accessibility integration and text layout measurement is located here.
- `native-core`: DOM tree-like data structure to hold all the nodes with their attribute values and registered event handlers.
- `renderer`: Provides a winit event loop based execution for the app.
- `core`: Core logic for events, DOM processing, accessibility integration, element rendering and text layout measurement is located here.
- `native-core`: DOM data structure to hold all the nodes with their attribute values and registered event handlers.
- `torin`: UI layout library specifically made for Freya, although it's agnostic.
- `hooks`: Various Dioxus hooks to be used in Freya apps (text editing, animation, theming, etc)
- `components`: Collection of built-in Dioxus components to be used out of the box with in Freya apps (Button, Switch, Slider, Table, ScrollView, etc)
Expand All @@ -38,6 +38,8 @@ Freya is split in various crates, each with it's own meaning and purpose, here i
- `native-core-macro`: Just some internal macros to be used in `states` so it can be integrated with `native-core`.
- `common`: Some simple utilities used across the different Freya crates.

![Overview](./.github/overview.png)

## Examples
All important examples are located in the `./examples` folder although you might also find some in the form of docs comments in the code itself.

Expand Down
57 changes: 33 additions & 24 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,24 @@ edition = "2021"
members = ["crates/renderer", "crates/state", "crates/freya", "crates/elements", "crates/components", "crates/hooks", "crates/common", "crates/core", "crates/testing", "crates/devtools", "crates/torin", "crates/engine", "./examples/installer", "crates/native-core", "crates/native-core-macro"]

[features]
log = ["freya/log"]
tracing-subscriber = ["freya/tracing-subscriber"]
devtools = ["freya/devtools"]
use_camera = ["freya/use_camera"]
hot-reload = ["freya/hot-reload"]
custom-tokio-rt = ["freya/custom-tokio-rt"]
performance-overlay = ["freya/performance-overlay"]
fade-cached-incremental-areas = ["freya/fade-cached-incremental-areas"]
disable-zoom-shortcuts = ["freya/disable-zoom-shortcuts"]

[patch.crates-io]
dioxus = { git = "https://github.com/DioxusLabs/dioxus", rev = "0bb81aba6eeb36df96b3e6943288fa3a2cc25cdd" }
dioxus-rsx = { git = "https://github.com/DioxusLabs/dioxus", rev = "0bb81aba6eeb36df96b3e6943288fa3a2cc25cdd" }
dioxus-core-macro = { git = "https://github.com/DioxusLabs/dioxus", rev = "0bb81aba6eeb36df96b3e6943288fa3a2cc25cdd" }
dioxus-hooks = { git = "https://github.com/DioxusLabs/dioxus", rev = "0bb81aba6eeb36df96b3e6943288fa3a2cc25cdd" }
dioxus-signals = { git = "https://github.com/DioxusLabs/dioxus", rev = "0bb81aba6eeb36df96b3e6943288fa3a2cc25cdd" }
dioxus-core = { git = "https://github.com/DioxusLabs/dioxus", rev = "0bb81aba6eeb36df96b3e6943288fa3a2cc25cdd" }
dioxus-hot-reload = { git = "https://github.com/DioxusLabs/dioxus", rev = "0bb81aba6eeb36df96b3e6943288fa3a2cc25cdd" }
dioxus-router = { git = "https://github.com/DioxusLabs/dioxus", rev = "0bb81aba6eeb36df96b3e6943288fa3a2cc25cdd" }
dioxus-lib = { git = "https://github.com/DioxusLabs/dioxus", rev = "0bb81aba6eeb36df96b3e6943288fa3a2cc25cdd" }
generational-box = { git = "https://github.com/DioxusLabs/dioxus", rev = "0bb81aba6eeb36df96b3e6943288fa3a2cc25cdd" }
dioxus-sdk = { git = "https://github.com/DioxusLabs/sdk", branch = "feat/dioxus-0.6" }
dioxus = { git = "https://github.com/DioxusLabs/dioxus", tag = "v0.6.0-alpha.5" }
dioxus-rsx = { git = "https://github.com/DioxusLabs/dioxus", tag = "v0.6.0-alpha.5" }
dioxus-core-macro = { git = "https://github.com/DioxusLabs/dioxus", tag = "v0.6.0-alpha.5" }
dioxus-hooks = { git = "https://github.com/DioxusLabs/dioxus", tag = "v0.6.0-alpha.5" }
dioxus-signals = { git = "https://github.com/DioxusLabs/dioxus", tag = "v0.6.0-alpha.5" }
dioxus-core = { git = "https://github.com/DioxusLabs/dioxus", tag = "v0.6.0-alpha.5" }
dioxus-router = { git = "https://github.com/DioxusLabs/dioxus", tag = "v0.6.0-alpha.5" }
dioxus-lib = { git = "https://github.com/DioxusLabs/dioxus", tag = "v0.6.0-alpha.5" }
generational-box = { git = "https://github.com/DioxusLabs/dioxus", tag = "v0.6.0-alpha.5" }

[workspace.dependencies]
freya = { path = "crates/freya", version = "0.2" }
Expand All @@ -39,21 +39,21 @@ freya-components = { path = "crates/components", version = "0.2" }
freya-testing = { path = "crates/testing", version = "0.2" }
freya-engine = { path = "crates/engine", version = "0.2" }
torin = { path = "crates/torin", version = "0.2" }
dioxus-clipboard = "0.2.0-alpha.1"

freya-native-core-macro = { path = "crates/native-core-macro", version = "0.2" }
freya-native-core = { path = "crates/native-core", version = "0.2" }

dioxus = { version = "0.6.0-alpha.2" , default-features = false, features = ["macro", "signals", "hooks"] }
dioxus-rsx = { version = "0.6.0-alpha.2" }
dioxus-core-macro = { version = "0.6.0-alpha.2" }
dioxus-hooks = { version = "0.6.0-alpha.2" }
dioxus-signals = { version = "0.6.0-alpha.2" }
dioxus-core = { version = "0.6.0-alpha.2" }
dioxus-hot-reload = { version = "0.6.0-alpha.2" }
dioxus-router = { version = "0.6.0-alpha.2", default-features = false }
dioxus-sdk = { git = "https://github.com/DioxusLabs/sdk", branch = "feat/dioxus-0.6", features = ["clipboard"]}
dioxus = { version = "0.6.0-alpha.5", default-features = false, features = ["macro", "signals", "hooks"] }
dioxus-rsx = { version = "0.6.0-alpha.5" }
dioxus-core-macro = { version = "0.6.0-alpha.5" }
dioxus-hooks = { version = "0.6.0-alpha.5" }
dioxus-signals = { version = "0.6.0-alpha.5" }
dioxus-core = { version = "0.6.0-alpha.5" }
dioxus-router = { version = "0.6.0-alpha.5", default-features = false }
dioxus-sdk = { git = "https://github.com/DioxusLabs/sdk/", branch = "feat/dioxus-0.6" }

skia-safe = { version = "0.75.0", features = ["gl", "textlayout", "svg"] }
skia-safe = { version = "0.80.0", features = ["gl", "textlayout", "svg"] }

gl = "0.14.0"
glutin = "0.32.0"
Expand All @@ -79,16 +79,25 @@ skia-safe = { workspace = true }
tokio = { workspace = true, features = ["fs"]}
dioxus = { workspace = true }
freya = { workspace = true }
freya-hooks = { workspace = true }
freya-core = { workspace = true }
freya-testing = { workspace = true }
reqwest = { version = "0.12.0", features = ["json"] }
serde = "1.0.189"
dioxus-sdk = { git = "https://github.com/DioxusLabs/sdk", branch = "feat/dioxus-0.6", features = ["i18n"] }
dioxus-i18n = "0.2"
rand = "0.8.5"
dioxus-router = { workspace = true }
itertools = "0.13.0"
home = "0.5.9"
dioxus-query = "0.5.1"
gilrs = "0.10.8"
gl = { workspace = true }
tree-sitter-highlight = "0.23.0"
tree-sitter-rust = "0.23.0"
rfd = "0.14.1"
bytes = "1.5.0"
dioxus-clipboard = { workspace = true }
winit = { workspace = true }

[profile.release]
lto = true
Expand Down
43 changes: 28 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@

[Website](https://freyaui.dev) | [Nightly Docs](https://docs.freyaui.dev/freya) | [Stable Docs](https://docs.rs/freya/latest/freya) | [Book](https://book.freyaui.dev) | [Discord](https://discord.gg/sYejxCdewG)

**Freya** is a cross-paltform GUI library for Rust powered by 🧬 [Dioxus](https://dioxuslabs.com) and 🎨 [Skia](https://skia.org/).
**Freya** is a cross-platform GUI library for Rust powered by 🧬 [Dioxus](https://dioxuslabs.com) and 🎨 [Skia](https://skia.org/).

**It does not use any web tech**, check the [Differences with Dioxus](https://book.freyaui.dev/differences_with_dioxus.html).

⚠️ It's currently work in progress, but you can already play with it! You can join the [Discord](https://discord.gg/sYejxCdewG) server if you have any question or issue.

<br/>
<br/>

<table>
Expand All @@ -23,7 +24,7 @@
fn app() -> Element {
let mut count = use_signal(|| 0);

render!(
rsx!(
rect {
height: "50%",
width: "100%",
Expand Down Expand Up @@ -64,12 +65,6 @@ fn app() -> Element {
</td>
</table>

### Sponsors 🤗

Thanks to my sponsors for supporting this project! 😄

<!-- sponsors --><a href="https://github.com/piny4man"><img src="https://github.com/piny4man.png" width="60px" alt="Alberto" /></a><a href="https://github.com/albinekb"><img src="https://github.com/albinekb.png" width="60px" alt="Albin Ekblom" /></a><!-- sponsors -->

### Want to try it? 🤔

👋 Make sure to check the [Setup guide](https://book.freyaui.dev/setup.html) first.
Expand All @@ -91,19 +86,21 @@ Add Freya and Dioxus as dependencies:
freya = "0.2"
dioxus = { version = "0.5", features = ["macro", "hooks"], default-features = false }
```
### Contributing 🧙‍♂️

If you are interested in contributing please make sure to have read the [Contributing](CONTRIBUTING.md) guide first!

### Features ✨
- ⛏️ Built-in **components** (button, scroll views, switch and more)
- 🚇 Built-in **hooks** library (animations, text editing and more)
- 🔍 Built-in **devtools** panel
- 🚇 Built-in **hooks** (animations, text editing and more)
- 🔍 Built-in **developer tools** (tree inspection, fps overlay)
- 🧰 Built-in **headless runner** to test UI
- 🎨 **Theming** support (not extensible yet ⚠️)
- 🎨 **Theming** support
- 🛩️ **Cross-platform** (Windows, Linux, MacOS)
- 🖼️ SKSL **Shaders** support
- 🔄️ Dioxus **Hot-reload** support
- 📒 Multi-line **text editing**
- 🦾 Basic **Accessibility** Support (experimental ⚠️)
- 🧩Compatible with dioxus-sdk and other Dioxus renderer-agnostic libraries
- 🦾 **Accessibility** support
- 🧩 Compatible with dioxus-sdk and other Dioxus renderer-agnostic libraries

### Goals 😁
- Performant and low memory usage
Expand All @@ -113,6 +110,22 @@ dioxus = { version = "0.5", features = ["macro", "hooks"], default-features = fa
- Useful testing APIs
- Useful and extensible built-in components and hooks

### Support 🤗

If you are interested in supporting the development of this project feel free to donate to my [Github Sponsor](https://github.com/sponsors/marc2332/) page.

Thanks to my sponsors for supporting this project! 😄

<!-- sponsors --><a href="https://github.com/piny4man"><img src="https:&#x2F;&#x2F;avatars.githubusercontent.com&#x2F;u&#x2F;8446285?u&#x3D;fd37db4dd9b4ba94dabe0bccc3a95ef2a35376ab&amp;v&#x3D;4" width="60px" alt="" /></a><a href="https://github.com/gqf2008"><img src="https:&#x2F;&#x2F;avatars.githubusercontent.com&#x2F;u&#x2F;2295878?v&#x3D;4" width="60px" alt="高庆丰" /></a><a href="https://github.com/lino-levan"><img src="https:&#x2F;&#x2F;avatars.githubusercontent.com&#x2F;u&#x2F;11367844?v&#x3D;4" width="60px" alt="Lino Le Van" /></a><!-- sponsors -->

### Special thanks 💪

- [Jonathan Kelley](https://github.com/jkelleyrtp) and [Evan Almloff](https://github.com/ealmloff) for making [Dioxus](https://dioxuslabs.com/) and all their help, specially when I was still creating Freya.
- [Armin](https://github.com/pragmatrix) for making [rust-skia](https://github.com/rust-skia/rust-skia/) and all his help and making the favor of hosting prebuilt binaries of skia for the combo of features use by Freya.
- [geom3trik](https://github.com/geom3trik) for helping me figure out how to add incremental rendering.
- [Tropical](https://github.com/Tropix126) for this contributions to improving accessibility and rendering.
- And to the rest of contributors and anybody who gave me any kind of feedback!

### 🤠 Projects

[Valin](https://github.com/marc2332/valin) ⚒️ is a Work-In-Progress cross-platform code editor, made with Freya 🦀 and Rust, by me.
Expand Down
33 changes: 25 additions & 8 deletions book/src/differences_with_dioxus.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,32 @@
# Differences with Dioxus

**Freya** is built on top of the core crates from Dioxus, this means that you will effectively be creating Dioxus components, using RSX and hooks. But, you will **not** be using HTML, CSS, JS or any Web tech at all.
**Freya** is built on top of the **core** crates from Dioxus, this means that you will effectively be creating Dioxus components, using RSX and hooks.

Here you can find a list of the main differences between Freya and the official Dioxus renderers for Desktop (WebView and Blitz):
**But**, thanks to Dioxus being a renderer-agnostic library you will **NOT** be using JavaScript, HTML, OR CSS, or any other abstraction that ends up using one of those or anything close to web.

Freya does everything on its own when it comes to:
- Elements
- Styling
- Layout
- Events
- Rendering
- Testing
- Built-in components and hooks,
- Editing
- Animating

And more. Dioxus only is only used to run the app components (hooks, lifecycle, state, rsx), **everything else is managed by Freya**.

**Freya is not mean to be drop-in alternative to Dioxus renderers but as GUI library on its own.**

Here is the list of the main differences between Freya and the official Dioxus renderers for Desktop (WebView and Blitz):

| Category | Freya | Dioxus Renderers |
|--------------------------------------|------------------|---------------------------------|
| **Elements, attributes and events** | Custom | HTML |
| **Layout** | [`Torin`](https://github.com/marc2332/freya/tree/main/crates/torin) | CSS or [`Taffy`](https://github.com/DioxusLabs/taffy) |
| **Styling** | Custom | CSS |
| **Renderer** | Skia | WebView or WGPU |
| **Components library** | Custom | None, but can use HTML elements and CSS libraries |
| **Devtools** | Custom | Provided in Webview |
| **Headless testing runner** | Custom | None, but there is Playwright and similar |
| **Layout** | Custom ([`Torin`](https://github.com/marc2332/freya/tree/main/crates/torin)) | CSS or [`Taffy`](https://github.com/DioxusLabs/taffy) |
| **Styling** | Custom | CSS |
| **Renderer** | Skia | WebView or WGPU |
| **Components library** | Custom ([`freya-comonents`](https://github.com/marc2332/freya/tree/main/crates/components)) | None, but can use HTML elements and CSS libraries |
| **Devtools** | Custom ([`freya-devtools`](https://github.com/marc2332/freya/tree/main/crates/devtools)) | Provided in Webview |
| **Headless testing runner** | Custom ([`freya-testing`](https://github.com/marc2332/freya/tree/main/crates/testing)) | None, but there is Playwright and similar |
4 changes: 4 additions & 0 deletions book/src/setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ sudo dnf install openssl-devel pkgconf cmake gtk3-devel clang-devel -y
sudo dnf groupinstall "Development Tools" "C Development Tools and Libraries" -y
```

#### NixOS

Copy this [flake.nix](https://github.com/kuba375/freya-flake) into your project root. Then you can enter a dev shell by `nix develop`.

Don't hesitate to contribute so other distros can be added here.

### MacOS
Expand Down
9 changes: 8 additions & 1 deletion crates/common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,17 @@ torin = { workspace = true }
dioxus-core = { workspace = true }

accesskit = { workspace = true }
accesskit_winit = { workspace = true }
winit = { workspace = true }
freya-engine = { workspace = true }
freya-native-core = { workspace = true }
rustc-hash= { workspace = true }

itertools = "0.13.0"
uuid = { workspace = true }


[dev-dependencies]
dioxus = { workspace = true }
freya = { path = "../freya" }
freya-testing = { path = "../testing" }
tokio = { workspace = true }
55 changes: 55 additions & 0 deletions crates/common/src/accessibility.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
use std::sync::atomic::{
AtomicU64,
Ordering,
};

use freya_native_core::NodeId;
use rustc_hash::{
FxHashMap,
FxHashSet,
};

#[derive(Default)]
pub struct AccessibilityDirtyNodes {
pub requested_focus: Option<NodeId>,
pub added_or_updated: FxHashSet<NodeId>,
pub removed: FxHashMap<NodeId, NodeId>,
}

impl AccessibilityDirtyNodes {
pub fn request_focus(&mut self, node_id: NodeId) {
self.requested_focus = Some(node_id);
}

pub fn add_or_update(&mut self, node_id: NodeId) {
self.added_or_updated.insert(node_id);
}

pub fn remove(&mut self, node_id: NodeId, parent_id: NodeId) {
self.removed.insert(node_id, parent_id);
}

pub fn clear(&mut self) {
self.requested_focus.take();
self.added_or_updated.clear();
self.removed.clear();
}
}

pub struct AccessibilityGenerator {
counter: AtomicU64,
}

impl Default for AccessibilityGenerator {
fn default() -> Self {
Self {
counter: AtomicU64::new(1), // Must start at 1 because 0 is reserved for the Root
}
}
}

impl AccessibilityGenerator {
pub fn new_id(&self) -> u64 {
self.counter.fetch_add(1, Ordering::Relaxed)
}
}
Loading

0 comments on commit 274bd3c

Please sign in to comment.