Skip to content

Commit

Permalink
resolve conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
marc2332 committed Apr 6, 2024
2 parents 84c0e65 + 0e05a3e commit 078f7d2
Show file tree
Hide file tree
Showing 243 changed files with 13,922 additions and 4,446 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/deploy_docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- name: Set up cargo cache
uses: Swatinem/rust-cache@v2
with:
prefix-key: "2"
prefix-key: "3"

- name: cargo doc
run: cargo doc --no-deps --workspace
Expand All @@ -30,4 +30,4 @@ jobs:
with:
project: freya-docs
entrypoint: https://deno.land/std/http/file_server.ts
root: target/doc
root: target/doc
2 changes: 1 addition & 1 deletion .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
- name: Set up cargo cache
uses: Swatinem/rust-cache@v2
with:
prefix-key: "6"
prefix-key: "8"
- name: Install linux dependencies
if: runner.os == 'Linux'
run: |
Expand Down
47 changes: 28 additions & 19 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,23 @@ version = "0.0.0"
edition = "2021"

[workspace]
members = ["crates/renderer", "crates/state", "crates/freya", "crates/elements", "crates/components", "crates/hooks", "crates/common", "crates/core", "crates/testing", "crates/devtools", "crates/dom", "crates/torin", "crates/engine", "./examples/installer"]
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"]
devtools = ["freya/devtools"]
use_camera = ["freya/use_camera"]
hot-reload = ["freya/hot-reload"]

[patch.crates-io]
dioxus = { git = "https://github.com/DioxusLabs/dioxus", rev = "46b0eeb12cf2b388d29a9061b74e9470a8487679" }
dioxus-rsx = { git = "https://github.com/DioxusLabs/dioxus", rev = "46b0eeb12cf2b388d29a9061b74e9470a8487679" }
dioxus-core-macro = { git = "https://github.com/DioxusLabs/dioxus", rev = "46b0eeb12cf2b388d29a9061b74e9470a8487679" }
dioxus-hooks = { git = "https://github.com/DioxusLabs/dioxus", rev = "46b0eeb12cf2b388d29a9061b74e9470a8487679" }
dioxus-signals = { git = "https://github.com/DioxusLabs/dioxus", rev = "46b0eeb12cf2b388d29a9061b74e9470a8487679" }
dioxus-core = { git = "https://github.com/DioxusLabs/dioxus", rev = "46b0eeb12cf2b388d29a9061b74e9470a8487679" }
dioxus-hot-reload = { git = "https://github.com/DioxusLabs/dioxus", rev = "46b0eeb12cf2b388d29a9061b74e9470a8487679" }
dioxus-router = { git = "https://github.com/DioxusLabs/dioxus", rev = "46b0eeb12cf2b388d29a9061b74e9470a8487679" }

[workspace.dependencies]
freya = { path = "crates/freya", version = "0.2" }
Expand All @@ -21,24 +32,24 @@ freya-common = { path = "crates/common", version = "0.2" }
freya-hooks = { path = "crates/hooks", version = "0.2" }
freya-core = { path = "crates/core", version = "0.2" }
freya-components = { path = "crates/components", version = "0.2" }
freya-dom = { path = "crates/dom", 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 = { git = "https://github.com/DioxusLabs/dioxus", rev = "ef101dd876ee8ecdd702a7e22addfd47f2ebd892", default-features = false, features = ["macro", "signals", "hooks", "hot-reload", "html"]}
dioxus-native-core-macro = { git = "https://github.com/DioxusLabs/dioxus", rev = "ef101dd876ee8ecdd702a7e22addfd47f2ebd892" }
dioxus-rsx = { git = "https://github.com/DioxusLabs/dioxus", rev = "ef101dd876ee8ecdd702a7e22addfd47f2ebd892", features = ["hot_reload"] }
dioxus-native-core = { git = "https://github.com/DioxusLabs/dioxus", rev = "ef101dd876ee8ecdd702a7e22addfd47f2ebd892", features = ["dioxus"] }
dioxus-core-macro = { git = "https://github.com/DioxusLabs/dioxus", rev = "ef101dd876ee8ecdd702a7e22addfd47f2ebd892" }
dioxus-hooks = { git = "https://github.com/DioxusLabs/dioxus", rev = "ef101dd876ee8ecdd702a7e22addfd47f2ebd892" }
dioxus-signals = { git = "https://github.com/DioxusLabs/dioxus", rev = "ef101dd876ee8ecdd702a7e22addfd47f2ebd892" }
dioxus-core = { git = "https://github.com/DioxusLabs/dioxus", rev = "ef101dd876ee8ecdd702a7e22addfd47f2ebd892" }
dioxus-hot-reload = { git = "https://github.com/DioxusLabs/dioxus", rev = "ef101dd876ee8ecdd702a7e22addfd47f2ebd892", features = ["file_watcher"], default-features = false }
dioxus-router = { git = "https://github.com/DioxusLabs/dioxus", rev = "ef101dd876ee8ecdd702a7e22addfd47f2ebd892", default-features = false }
dioxus-std = { git = "https://github.com/DioxusLabs/dioxus-std", rev = "791a21f67657b43a66baac241b6431eab6c5fd2f", features = ["clipboard"] }
dioxus-native-core-macro = { path = "crates/native-core-macro", version = "0.2" }
dioxus-native-core = { path = "crates/native-core", version = "0.2" }

dioxus = { version = "0.5.0-alpha.0", default-features = false, features = ["macro", "signals", "hooks"]}
dioxus-rsx = { version = "0.5.0-alpha.0", features = ["hot_reload"] }
dioxus-core-macro = { version = "0.5.0-alpha.0" }
dioxus-hooks = { version = "0.5.0-alpha.0" }
dioxus-signals = { version = "0.5.0-alpha.0" }
dioxus-core = { version = "0.5.0-alpha.0" }
dioxus-hot-reload = { version = "0.5.0-alpha.0", features = ["file_watcher"], default-features = false }
dioxus-router = { version = "0.5.0-alpha.0", default-features = false }
dioxus-std = { git = "https://github.com/marc2332/dioxus-std", rev = "4d8ae33b94537d54471cd924c32f03c1d949430f", features = ["clipboard"]}

skia-safe = { version = "0.67.0", features = ["gl", "textlayout", "svg"] }
skia-safe = { version = "0.72.0", features = ["gl", "textlayout", "svg"] }

gl = "0.14.0"
glutin = "0.31.2"
Expand All @@ -48,6 +59,8 @@ winit = "0.29.9"
tokio = { version = "1.33.0", features = ["sync", "rt-multi-thread", "time", "macros"] }
accesskit = { version = "0.12.2", features = ["serde"]}
accesskit_winit = "0.18.0"
shipyard = { version = "0.6.2", features = ["proc", "std", "parallel"], default-features = false }
smallvec = "1.13.1"

euclid = "0.22.9"
uuid = { version = "1.4.1", features = ["v4"]}
Expand All @@ -59,17 +72,13 @@ rustc-hash = "1.1.0"

[dev-dependencies]
skia-safe = { workspace = true }
winit = { workspace = true }
tokio = { workspace = true }
dioxus = { workspace = true }
dioxus-core = { workspace = true }
freya = { workspace = true }
freya-node-state = { workspace = true }
freya-core = { workspace = true }
reqwest = { version = "0.11.22", features = ["json"] }
serde = "1.0.189"
tracing-subscriber = "0.3.17"
dioxus-std = { git = "https://github.com/DioxusLabs/dioxus-std", rev = "137b4149dc86a648119eef8f331e3a682c2c6b62", features = ["i18n"] }
dioxus-std = { git = "https://github.com/marc2332/dioxus-std", rev = "4d8ae33b94537d54471cd924c32f03c1d949430f", features = ["i18n"] }
rand = "0.8.5"
dioxus-router = { workspace = true }
itertools = "0.11.0"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ fn app() -> Element {

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 Mendez" /></a><a href="https://github.com/andar1an"><img src="https://github.com/andar1an.png" width="60px" alt="Andar1an" /></a><!-- sponsors -->
<!-- sponsors --><a href="https://github.com/piny4man"><img src="https://github.com/piny4man.png" width="60px" alt="Alberto Mendez" /></a><a href="https://github.com/andar1an"><img src="https://github.com/andar1an.png" width="60px" alt="andar1an" /></a><!-- sponsors -->

### Want to try it? 🤔

Expand Down
19 changes: 16 additions & 3 deletions book/src/guides/font_style.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,6 @@ Compatible elements: [`label`](/guides/elements.html#label), [`paragraph`](/guid

With the `font_family` you can specify what font do you want to use for the inner text.

Limitation: Only fonts installed in the system are supported for now.

Example:

```rust, no_run
Expand All @@ -76,6 +74,21 @@ fn app() -> Element {
}
```

You can also specify multiple fonts in order of priority, if one is not found it will fallback to the next one.

Example:

```rust, no_run
fn app(cx: Scope) -> Element {
render!(
label {
font_family: "DoesntExist Font, Impact",
"Hello, World!"
}
)
}
```

Compatible elements: [`label`](/guides/elements.html#label), [`paragraph`](/guides/elements.html#paragraph-and-text),

### font_size
Expand Down Expand Up @@ -243,7 +256,7 @@ fn app() -> Element {
"Hello, World! \n Hello, World! \n Hello, world!" // Will show all three lines
}
label {
lines_height: "2",
max_lines: "2",
"Hello, World! \n Hello, World! \n Hello, world!" // Will only show two lines
}
)
Expand Down
14 changes: 9 additions & 5 deletions crates/common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,22 @@ repository = "https://github.com/marc2332/freya"
keywords = ["gui", "ui", "desktop", "skia", "dioxus"]
categories = ["gui", "asynchronous"]

[package.metadata.docs.rs]
features = ["freya-engine/mocked-engine"]

[features]
skia-engine = ["freya-engine/skia-engine"]

[dependencies]
torin = { workspace = true }

dioxus-rsx = { workspace = true }
dioxus-native-core = { workspace = true }
dioxus-core-macro = { workspace = true }
dioxus-hooks = { workspace = true }
dioxus-core = { workspace = true }

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

euclid = { workspace = true }
uuid = { workspace = true }
4 changes: 0 additions & 4 deletions crates/common/src/event_messages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,8 @@ pub enum EventMessage {
UpdateTemplate(Template),
/// Pull the VirtualDOM
PollVDOM,
/// Request a layout recalculation
RequestRelayout,
/// Request a rerender
RequestRerender,
/// Request a redraw
RequestRedraw,
/// Remeasure a text elements group
RemeasureTextGroup(Uuid),
/// Change the cursor icon
Expand Down
34 changes: 34 additions & 0 deletions crates/common/src/layers.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
use dioxus_native_core::NodeId;
use rustc_hash::FxHashMap;
use std::sync::{Arc, Mutex, MutexGuard};

#[derive(Default, Clone)]
pub struct Layers {
pub layers: Arc<Mutex<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();
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();
layer.retain(|id| *id != node_id);

if layer.is_empty() {
layers.remove(&layer_n);
}
}

pub fn layers(&self) -> MutexGuard<FxHashMap<i16, Vec<NodeId>>> {
self.layers.lock().unwrap()
}

pub fn len_layers(&self) -> usize {
self.layers.lock().unwrap().len()
}
}
11 changes: 11 additions & 0 deletions crates/common/src/layout.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use freya_engine::prelude::Paragraph;
use std::ops::Div;
use torin::geometry::{Area, Size2D};

Expand All @@ -21,3 +22,13 @@ pub enum CursorLayoutResponse {
CursorPosition { position: usize, id: usize },
TextSelection { from: usize, to: usize, id: usize },
}

pub struct CachedParagraph(pub Paragraph);

/// # Safety
/// Skia `Paragraph` are neither Sync or Send, but in order to store them in the Associated
/// data of the Nodes in Torin (which will be used across threads when making the attributes diffing),
/// we must manually mark the Paragraph as Send and Sync, this is fine because `Paragraph`s will only be accessed and modified
/// In the main thread when measuring the layout and painting.
unsafe impl Send for CachedParagraph {}
unsafe impl Sync for CachedParagraph {}
4 changes: 4 additions & 0 deletions crates/common/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
mod event_messages;
mod layers;
mod layout;
mod paragraphs;

pub use event_messages::*;
pub use layers::*;
pub use layout::*;
pub use paragraphs::*;
39 changes: 39 additions & 0 deletions crates/common/src/paragraphs.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
use dioxus_native_core::NodeId;
use rustc_hash::FxHashMap;
use std::sync::{Arc, Mutex, MutexGuard};
use uuid::Uuid;

#[derive(Default, Clone)]
pub struct ParagraphElements {
pub paragraphs: Arc<Mutex<FxHashMap<Uuid, Vec<NodeId>>>>,
}

impl ParagraphElements {
pub fn insert_paragraph(&self, node_id: NodeId, text_id: Uuid) {
let mut paragraphs = self.paragraphs.lock().unwrap();
let text_group = paragraphs.entry(text_id).or_default();

text_group.push(node_id);
}

pub fn paragraphs(&self) -> MutexGuard<FxHashMap<Uuid, Vec<NodeId>>> {
self.paragraphs.lock().unwrap()
}

pub fn remove_paragraph(&self, node_id: NodeId, text_id: &Uuid) {
let mut paragraphs = self.paragraphs.lock().unwrap();
let text_group = paragraphs.get_mut(text_id);

if let Some(text_group) = text_group {
text_group.retain(|id| *id != node_id);

if text_group.is_empty() {
paragraphs.remove(text_id);
}
}
}

pub fn len_paragraphs(&self) -> usize {
self.paragraphs.lock().unwrap().len()
}
}
8 changes: 4 additions & 4 deletions crates/components/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ freya-elements = { workspace = true }
freya-node-state = { workspace = true }
freya-hooks = { workspace = true }
freya-common = { workspace = true }
freya-core = { path = "../core", version = "0.2" }
freya-engine = { path = "../engine", version = "0.2" }
freya-core = { workspace = true }
freya-engine = { workspace = true }
torin = { workspace = true }

dioxus = { workspace = true }
dioxus-router = { workspace = true }
dioxus = { workspace = true }
futures-util = { workspace = true }

winit = { workspace = true }
Expand All @@ -39,4 +39,4 @@ reqwest = { version = "0.11.22", features = ["json"] }

[dev-dependencies]
freya = { path = "../freya" }
freya-testing = { path = "../testing" }
freya-testing = { path = "../testing" }
Loading

0 comments on commit 078f7d2

Please sign in to comment.