-
-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
257 changed files
with
12,114 additions
and
5,161 deletions.
There are no files selected for viewing
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* @marc2332 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,5 @@ target | |
Cargo.lock | ||
.idea | ||
snapshot_before.png | ||
snapshot_after.png | ||
snapshot_after.png | ||
documents_example |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, ancestor_node_id: NodeId) { | ||
self.removed.insert(node_id, ancestor_node_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) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
use std::ops::{ | ||
Deref, | ||
DerefMut, | ||
}; | ||
|
||
use freya_native_core::NodeId; | ||
use rustc_hash::FxHashSet; | ||
|
||
#[derive(Clone, Default, Debug)] | ||
pub struct CompositorDirtyNodes(FxHashSet<NodeId>); | ||
|
||
impl Deref for CompositorDirtyNodes { | ||
type Target = FxHashSet<NodeId>; | ||
|
||
fn deref(&self) -> &Self::Target { | ||
&self.0 | ||
} | ||
} | ||
|
||
impl DerefMut for CompositorDirtyNodes { | ||
fn deref_mut(&mut self) -> &mut Self::Target { | ||
&mut self.0 | ||
} | ||
} | ||
|
||
impl CompositorDirtyNodes { | ||
/// Mark a certain node as invalidated. | ||
pub fn invalidate(&mut self, node_id: NodeId) { | ||
self.0.insert(node_id); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,48 @@ | ||
use std::sync::{ | ||
Arc, | ||
Mutex, | ||
MutexGuard, | ||
use std::{ | ||
self, | ||
ops::{ | ||
Deref, | ||
DerefMut, | ||
}, | ||
}; | ||
|
||
use freya_native_core::NodeId; | ||
use rustc_hash::FxHashMap; | ||
|
||
#[derive(Default, Clone)] | ||
pub struct Layers { | ||
pub layers: Arc<Mutex<FxHashMap<i16, Vec<NodeId>>>>, | ||
} | ||
#[derive(Default, Clone, Debug, PartialEq)] | ||
pub struct Layers(FxHashMap<i16, Vec<NodeId>>); | ||
|
||
impl Layers { | ||
pub fn insert_node_in_layer(&self, node_id: NodeId, layer_n: i16) { | ||
let mut layers = self.layers.lock().unwrap(); | ||
let layer = layers.entry(layer_n).or_default(); | ||
/// Insert the given [NodeId] in the given layer. Will create an entry for the layer if missing. | ||
pub fn insert_node_in_layer(&mut self, node_id: NodeId, layer_n: i16) { | ||
let layer = self.0.entry(layer_n).or_default(); | ||
if layer.contains(&node_id) { | ||
return; | ||
} | ||
layer.push(node_id); | ||
} | ||
|
||
pub fn remove_node_from_layer(&self, node_id: NodeId, layer_n: i16) { | ||
let mut layers = self.layers.lock().unwrap(); | ||
let layer = layers.get_mut(&layer_n).unwrap(); | ||
/// Remove the [NodeId] from the given layer. Will remove the entry of the layer if it becomes empty. | ||
pub fn remove_node_from_layer(&mut self, node_id: NodeId, layer_n: i16) { | ||
let layer = self.0.get_mut(&layer_n).unwrap(); | ||
layer.retain(|id| *id != node_id); | ||
|
||
if layer.is_empty() { | ||
layers.remove(&layer_n); | ||
self.0.remove(&layer_n); | ||
} | ||
} | ||
} | ||
|
||
pub fn layers(&self) -> MutexGuard<FxHashMap<i16, Vec<NodeId>>> { | ||
self.layers.lock().unwrap() | ||
impl Deref for Layers { | ||
type Target = FxHashMap<i16, Vec<NodeId>>; | ||
|
||
fn deref(&self) -> &Self::Target { | ||
&self.0 | ||
} | ||
} | ||
|
||
pub fn len_layers(&self) -> usize { | ||
self.layers.lock().unwrap().len() | ||
impl DerefMut for Layers { | ||
fn deref_mut(&mut self) -> &mut Self::Target { | ||
&mut self.0 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
mod event_messages; | ||
mod accessibility; | ||
mod compositor_dirty_nodes; | ||
mod layers; | ||
mod layout; | ||
mod paragraphs; | ||
|
||
pub use event_messages::*; | ||
pub use accessibility::*; | ||
pub use compositor_dirty_nodes::*; | ||
pub use layers::*; | ||
pub use layout::*; | ||
pub use paragraphs::*; |
Oops, something went wrong.