Skip to content

Commit f55b738

Browse files
committed
Merge branch 'main' of https://github.com/marc2332/freya into feat/image-viewer-optimizations
2 parents bacae80 + 5a852b5 commit f55b738

72 files changed

Lines changed: 1125 additions & 401 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/publish.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,6 @@ jobs:
2424
run: sudo apt update && sudo apt install build-essential libssl-dev pkg-config libglib2.0-dev libgtk-3-dev libudev-dev libxdo-dev libwebkit2gtk-4.1-dev
2525
- name: Install Rust toolchain
2626
uses: actions-rust-lang/setup-rust-toolchain@46268bd060767258de96ed93c1251119784f2ab6 # v1
27-
- run: cargo publish --features skia-engine --workspace --exclude "examples" --exclude "android" --exclude "freya-devtools-app"
27+
- run: cargo publish --workspace --exclude "examples" --exclude "android" --exclude "freya-devtools-app"
2828
env:
2929
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}

.github/workflows/rust_sync.yml

Lines changed: 0 additions & 28 deletions
This file was deleted.

CONTRIBUTING.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ Freya is split in various crates, each with it's own meaning and purpose, here i
8282
- `ragnarok`: UI events measurer (e.g what event to figure when the user clicks in a coordinate).
8383
- `pathgraph`: Map to store nested data structures based on the assumption that you always know its location.
8484
- `freya-components`: Collection of components ready to be used out of the box with in Freya apps (Button, Switch, Slider, Table, ScrollView, etc)
85-
- `freya-engine`: Simple re-export and mock of all Skia APIs used in freya so Freya docs can be built on docs.rs.
85+
- `freya-engine`: Simple re-export of all Skia APIs used in freya.
8686
- `freya-devtools`: Devtools server and plugin for Freya.
8787
- `freya-devtools-app`: Standalone Freya app to debug or inspect your Freya apps, its powered by `freya-devtools`.
8888
- `freya-radio`: Global reactive state management based on Topics.
@@ -101,6 +101,7 @@ Freya is split in various crates, each with it's own meaning and purpose, here i
101101
- `freya-material-design`: Material Design Components for Freya apps.
102102
- `freya-plotters-backend`: Freya's skia-safe backend for plotters.
103103
- `freya-code-editor`: Set of APIs to create text Code Editors in Freya.
104+
- `freya-camera`: Camera capture support for Freya.
104105

105106
## Examples
106107
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.

Cargo.toml

Lines changed: 31 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -44,46 +44,48 @@ members = [
4444
"./crates/freya-webview",
4545
"./crates/freya-terminal",
4646
"./crates/freya-code-editor",
47+
"./crates/freya-camera",
4748
"./crates/freya-android",
4849
"./examples/ai-chat",
4950
"./examples/state_query_sqlite",
5051
"./examples/android",
5152
]
5253

5354
[workspace.dependencies]
54-
freya = { path = "./crates/freya", version = "0.4.0-rc.19" }
55-
freya-core = { path = "./crates/freya-core", version = "0.4.0-rc.19" }
56-
torin = { path = "./crates/torin", version = "0.4.0-rc.19" }
57-
ragnarok = { path = "./crates/ragnarok", version = "0.4.0-rc.19" }
58-
freya-clipboard = { path = "./crates/freya-clipboard", version = "0.4.0-rc.19" }
59-
freya-edit = { path = "./crates/freya-edit", version = "0.4.0-rc.19" }
60-
freya-winit = { path = "./crates/freya-winit", version = "0.4.0-rc.19" }
61-
freya-components = { path = "./crates/freya-components", version = "0.4.0-rc.19" }
62-
pathgraph = { path = "./crates/pathgraph/", version = "0.4.0-rc.19" }
63-
freya-animation = { path = "./crates/freya-animation", version = "0.4.0-rc.19" }
64-
freya-router = { path = "./crates/freya-router", version = "0.4.0-rc.19" }
65-
freya-router-macro = { path = "./crates/freya-router-macro", version = "0.4.0-rc.19" }
66-
freya-testing = { path = "./crates/freya-testing", version = "0.4.0-rc.19" }
67-
freya-i18n = { path = "./crates/freya-i18n", version = "0.4.0-rc.19" }
68-
freya-performance-plugin = { path = "./crates/freya-performance-plugin", version = "0.4.0-rc.19" }
69-
freya-radio = { path = "./crates/freya-radio", version = "0.4.0-rc.19" }
70-
freya-engine = { path = "./crates/freya-engine", version = "0.4.0-rc.19" }
71-
freya-devtools = { path = "./crates/freya-devtools", version = "0.4.0-rc.19" }
55+
freya = { path = "./crates/freya", version = "0.4.0-rc.21" }
56+
freya-core = { path = "./crates/freya-core", version = "0.4.0-rc.21" }
57+
torin = { path = "./crates/torin", version = "0.4.0-rc.21" }
58+
ragnarok = { path = "./crates/ragnarok", version = "0.4.0-rc.21" }
59+
freya-clipboard = { path = "./crates/freya-clipboard", version = "0.4.0-rc.21" }
60+
freya-edit = { path = "./crates/freya-edit", version = "0.4.0-rc.21" }
61+
freya-winit = { path = "./crates/freya-winit", version = "0.4.0-rc.21" }
62+
freya-components = { path = "./crates/freya-components", version = "0.4.0-rc.21" }
63+
pathgraph = { path = "./crates/pathgraph/", version = "0.4.0-rc.21" }
64+
freya-animation = { path = "./crates/freya-animation", version = "0.4.0-rc.21" }
65+
freya-router = { path = "./crates/freya-router", version = "0.4.0-rc.21" }
66+
freya-router-macro = { path = "./crates/freya-router-macro", version = "0.4.0-rc.21" }
67+
freya-testing = { path = "./crates/freya-testing", version = "0.4.0-rc.21" }
68+
freya-i18n = { path = "./crates/freya-i18n", version = "0.4.0-rc.21" }
69+
freya-performance-plugin = { path = "./crates/freya-performance-plugin", version = "0.4.0-rc.21" }
70+
freya-radio = { path = "./crates/freya-radio", version = "0.4.0-rc.21" }
71+
freya-engine = { path = "./crates/freya-engine", version = "0.4.0-rc.21" }
72+
freya-devtools = { path = "./crates/freya-devtools", version = "0.4.0-rc.21" }
7273
freya-icons = { path = "./crates/freya-icons", features = [
7374
"all",
74-
], version = "0.4.0-rc.19" }
75+
], version = "0.4.0-rc.21" }
7576
freya-sdk = { path = "./crates/freya-sdk", features = [
7677
"all",
77-
], version = "0.4.0-rc.19" }
78-
freya-material-design = { path = "./crates/freya-material-design", version = "0.4.0-rc.19" }
79-
freya-plotters-backend = { path = "./crates/freya-plotters-backend", version = "0.4.0-rc.19" }
80-
freya-query = { path = "./crates/freya-query", version = "0.4.0-rc.19" }
81-
freya-webview = { path = "./crates/freya-webview", version = "0.4.0-rc.19" }
82-
freya-terminal = { path = "./crates/freya-terminal", version = "0.4.0-rc.19" }
83-
freya-code-editor = { path = "./crates/freya-code-editor", version = "0.4.0-rc.19", features = [
78+
], version = "0.4.0-rc.21" }
79+
freya-material-design = { path = "./crates/freya-material-design", version = "0.4.0-rc.21" }
80+
freya-plotters-backend = { path = "./crates/freya-plotters-backend", version = "0.4.0-rc.21" }
81+
freya-query = { path = "./crates/freya-query", version = "0.4.0-rc.21" }
82+
freya-webview = { path = "./crates/freya-webview", version = "0.4.0-rc.21" }
83+
freya-terminal = { path = "./crates/freya-terminal", version = "0.4.0-rc.21" }
84+
freya-code-editor = { path = "./crates/freya-code-editor", version = "0.4.0-rc.21", features = [
8485
"rust",
8586
] }
86-
freya-android = { path = "./crates/freya-android", version = "0.4.0-rc.19" }
87+
freya-camera = { path = "./crates/freya-camera", version = "0.4.0-rc.21" }
88+
freya-android = { path = "./crates/freya-android", version = "0.4.0-rc.21" }
8789
mundy = { version = "0.2.3", default-features = false, features = [
8890
"async-io",
8991
"callback",
@@ -100,6 +102,7 @@ futures-util = "0.3.31"
100102
futures-channel = "0.3.31"
101103
futures-lite = "2.6.1"
102104
async-io = "2.5.0"
105+
async-channel = "2.5.0"
103106
blocking = "1.6.2"
104107
ureq = "3.1.4"
105108
serde = { version = "1", features = ["derive"] }
@@ -124,7 +127,7 @@ euclid = "0.22.9"
124127
itertools = "0.14.0"
125128

126129
# Rendering
127-
freya-skia-safe = { version = "0.96.1", features = [
130+
freya-skia-safe = { version = "0.97.5", features = [
128131
"textlayout",
129132
"svg",
130133
"webp",

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -749,7 +749,7 @@ freya = { git = "https://github.com/marc2332/freya", branch = "main" }
749749
Release candidates:
750750

751751
```toml
752-
freya = "0.4.0-rc.19"
752+
freya = "0.4.0-rc.21"
753753
```
754754

755755
### Contributing 🧙‍♂️
@@ -764,7 +764,7 @@ If you are interested in supporting the development of this project feel free to
764764

765765
Thanks to my sponsors for supporting this project! 😄
766766

767-
<!-- sponsors --><a href="https://github.com/piny4man"><img src="https:&#x2F;&#x2F;github.com&#x2F;piny4man.png" width="60px" alt="User avatar: " /></a><a href="https://github.com/gqf2008"><img src="https:&#x2F;&#x2F;github.com&#x2F;gqf2008.png" width="60px" alt="User avatar: 高庆丰" /></a><a href="https://github.com/lino-levan"><img src="https:&#x2F;&#x2F;github.com&#x2F;lino-levan.png" width="60px" alt="User avatar: Lino Le Van" /></a><a href="https://github.com/d3rpp"><img src="https:&#x2F;&#x2F;github.com&#x2F;d3rpp.png" width="60px" alt="User avatar: Huddy Buddy" /></a><a href="https://github.com/DrigsterI"><img src="https:&#x2F;&#x2F;github.com&#x2F;DrigsterI.png" width="60px" alt="User avatar: Gabriel Jõe" /></a><a href="https://github.com/markalexander"><img src="https:&#x2F;&#x2F;github.com&#x2F;markalexander.png" width="60px" alt="User avatar: Mark" /></a><a href="https://github.com/Natane0808"><img src="https:&#x2F;&#x2F;github.com&#x2F;Natane0808.png" width="60px" alt="User avatar: Natane" /></a><!-- sponsors -->
767+
<!-- sponsors --><a href="https://github.com/piny4man"><img src="https:&#x2F;&#x2F;github.com&#x2F;piny4man.png" width="60px" alt="User avatar: " /></a><a href="https://github.com/gqf2008"><img src="https:&#x2F;&#x2F;github.com&#x2F;gqf2008.png" width="60px" alt="User avatar: 高庆丰" /></a><a href="https://github.com/lino-levan"><img src="https:&#x2F;&#x2F;github.com&#x2F;lino-levan.png" width="60px" alt="User avatar: Lino Le Van" /></a><a href="https://github.com/d3rpp"><img src="https:&#x2F;&#x2F;github.com&#x2F;d3rpp.png" width="60px" alt="User avatar: Huddy Buddy" /></a><a href="https://github.com/DrigsterI"><img src="https:&#x2F;&#x2F;github.com&#x2F;DrigsterI.png" width="60px" alt="User avatar: Gabriel Jõe" /></a><a href="https://github.com/markalexander"><img src="https:&#x2F;&#x2F;github.com&#x2F;markalexander.png" width="60px" alt="User avatar: Mark" /></a><!-- sponsors -->
768768

769769
### Special thanks 💪
770770

crates/freya-android/Cargo.toml

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "freya-android"
3-
version = "0.4.0-rc.19"
3+
version = "0.4.0-rc.21"
44
description = "Android integration for Freya"
55
edition = "2024"
66
license = "MIT"
@@ -13,12 +13,6 @@ categories = ["gui"]
1313
[lints]
1414
workspace = true
1515

16-
[package.metadata.docs.rs]
17-
features = ["freya-core/mocked-engine"]
18-
19-
[features]
20-
skia-engine = ["freya-core/skia-engine"]
21-
2216
[dependencies]
2317
freya-core = { workspace = true }
2418
freya-components = { workspace = true }

crates/freya-animation/Cargo.toml

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "freya-animation"
3-
version = "0.4.0-rc.19"
3+
version = "0.4.0-rc.21"
44
description = "Animation APIs for Freya"
55
edition = "2024"
66
readme = "../../README.md"
@@ -14,12 +14,6 @@ categories = ["gui"]
1414
[lints]
1515
workspace = true
1616

17-
[package.metadata.docs.rs]
18-
features = ["freya-core/mocked-engine"]
19-
20-
[features]
21-
skia-engine = ["freya-core/skia-engine"]
22-
2317
[dependencies]
2418
freya-core = { workspace = true }
2519
easer = { workspace = true }

crates/freya-camera/Cargo.toml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
[package]
2+
name = "freya-camera"
3+
version = "0.4.0-rc.21"
4+
description = "Camera capture support for Freya."
5+
edition = "2024"
6+
license = "MIT"
7+
authors = ["Marc Espín <mespinsanz@gmail.com>"]
8+
readme = "../../README.md"
9+
homepage = "https://freyaui.dev/"
10+
repository = "https://github.com/marc2332/freya"
11+
keywords = ["freya", "camera", "webcam", "video"]
12+
categories = ["gui", "multimedia::video"]
13+
14+
[lints]
15+
workspace = true
16+
17+
[dependencies]
18+
freya-core = { workspace = true }
19+
freya-engine = { workspace = true }
20+
nokhwa = { version = "0.10", features = ["input-native"] }
21+
blocking = { workspace = true }
22+
bytes = { workspace = true }
23+
tracing = { workspace = true }
24+
25+
[dev-dependencies]
26+
freya = { path = "../freya" }

crates/freya-camera/src/camera.rs

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
//! Camera configuration types.
2+
3+
pub use nokhwa::{
4+
NokhwaError as CameraError,
5+
utils::{
6+
CameraIndex,
7+
CameraInfo,
8+
},
9+
};
10+
use nokhwa::{
11+
query as nokhwa_query,
12+
utils::ApiBackend,
13+
};
14+
15+
/// Requested capture format. The negotiated values are reported via [`StreamInfo`].
16+
#[derive(Clone, Debug, PartialEq, Eq, Hash, Default)]
17+
pub enum CameraFormat {
18+
/// Highest framerate available, any resolution.
19+
#[default]
20+
HighestFrameRate,
21+
/// Highest resolution available, any framerate.
22+
HighestResolution,
23+
/// Highest framerate at the given resolution.
24+
Resolution { width: u32, height: u32 },
25+
/// Closest match to the given resolution and framerate.
26+
Exact {
27+
width: u32,
28+
height: u32,
29+
frame_rate: u32,
30+
},
31+
}
32+
33+
/// Configuration used to open a camera.
34+
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
35+
pub struct CameraConfig {
36+
pub device: CameraIndex,
37+
pub format: CameraFormat,
38+
}
39+
40+
impl Default for CameraConfig {
41+
fn default() -> Self {
42+
Self {
43+
device: CameraIndex::Index(0),
44+
format: CameraFormat::default(),
45+
}
46+
}
47+
}
48+
49+
impl CameraConfig {
50+
pub fn new() -> Self {
51+
Self::default()
52+
}
53+
54+
pub fn device(mut self, device: CameraIndex) -> Self {
55+
self.device = device;
56+
self
57+
}
58+
59+
pub fn format(mut self, format: CameraFormat) -> Self {
60+
self.format = format;
61+
self
62+
}
63+
}
64+
65+
/// Negotiated information about a running camera.
66+
#[derive(Clone, Debug, PartialEq, Eq)]
67+
pub struct StreamInfo {
68+
pub width: u32,
69+
pub height: u32,
70+
pub frame_rate: u32,
71+
}
72+
73+
/// Enumerate the cameras available on the system.
74+
///
75+
/// # Example
76+
///
77+
/// ```rust, no_run
78+
/// use freya::camera::*;
79+
///
80+
/// for device in query().unwrap_or_default() {
81+
/// println!("{}: {}", device.human_name(), device.description());
82+
/// }
83+
/// ```
84+
pub fn query() -> Result<Vec<CameraInfo>, CameraError> {
85+
nokhwa_query(ApiBackend::Auto)
86+
}

0 commit comments

Comments
 (0)