Skip to content

Commit

Permalink
Merge branch 'main' into feat/enhanced-alignments
Browse files Browse the repository at this point in the history
  • Loading branch information
marc2332 authored Oct 24, 2023
2 parents 44079af + 13d83b9 commit a2ad34a
Show file tree
Hide file tree
Showing 35 changed files with 288 additions and 207 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,6 @@ jobs:
if: runner.os == 'Linux'
with:
token: ${{ secrets.CODECOV_TOKEN }}
- name: Make sure the mocked Skia bindings are on sync
if: runner.os == 'Linux'
run: cargo build --package freya --features mocked-engine-development --no-default-features
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"rust-analyzer.cargo.features": [
"devtools",
"log"
"log",
"use_camera"
]
}
22 changes: 11 additions & 11 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,21 @@ dioxus-core = { version = "0.4" }
dioxus-hot-reload = { version = "0.4", features = ["file_watcher"] }
dioxus-router = { version = "0.4", default-features = false }

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

gl = "0.14.0"
glutin = "0.30.6"
glutin = "0.30.10"
glutin-winit = "0.3.0"
raw-window-handle = "0.5.1"
winit = "0.28.2"
tokio = { version = "1.23.0", features = ["sync", "rt-multi-thread", "time", "macros"] }
winit = "0.28.7"
tokio = { version = "1.33.0", features = ["sync", "rt-multi-thread", "time", "macros"] }
accesskit = { version = "0.11.0", features = ["serde"]}
accesskit_winit = "0.14.1"
zbus = "3.13.1"
zbus = "3.14.1"

euclid = "0.22.7"
uuid = { version = "1.2.2", features = ["v4"]}
futures = "0.3.25"
euclid = "0.22.9"
uuid = { version = "1.4.1", features = ["v4"]}
futures = "0.3.28"
anymap = "0.12.1"
tracing = "0.1"
tracing-subscriber = "0.3.17"
Expand All @@ -64,9 +64,9 @@ tokio = { workspace = true }
dioxus = { workspace = true }
freya = { workspace = true }
freya-node-state = { workspace = true }
reqwest = { version = "0.11.13", features = ["json"] }
serde = "1.0.152"
tracing-subscriber = "0.2.25"
reqwest = { version = "0.11.22", features = ["json"] }
serde = "1.0.189"
tracing-subscriber = "0.3.17"
dioxus-std = { version = "0.4", features = ["utils", "i18n"] }
rand = "0.8.5"
dioxus-router = { workspace = true }
Expand Down
2 changes: 1 addition & 1 deletion crates/components/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ tokio = { workspace = true }
tracing = { workspace = true }

open = "5"
reqwest = { version = "0.11.13", features = ["json"] }
reqwest = { version = "0.11.22", features = ["json"] }

[dev-dependencies]
freya = { path = "../freya" }
Expand Down
15 changes: 6 additions & 9 deletions crates/components/src/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,12 @@ pub fn Input<'a>(cx: Scope<'a, InputProps<'a>>) -> Element {
let theme = use_get_theme(cx);
let focus_manager = use_focus(cx);

if &cx.props.value != editable.editor().current().rope() {
editable.editor().with_mut(|editor| {
editor.set(&cx.props.value);
});
}

let text = match cx.props.hidden {
InputMode::Hidden(ch) => ch.to_string().repeat(cx.props.value.len()),
InputMode::Shown => cx.props.value.clone(),
Expand All @@ -94,15 +100,6 @@ pub fn Input<'a>(cx: Scope<'a, InputProps<'a>>) -> Element {
let height = &cx.props.height;
let max_lines = &cx.props.max_lines;

use_memo(cx, &(cx.props.value.to_string(),), {
to_owned![editable];
move |(text,)| {
editable.editor().with_mut(|editor| {
editor.set(&text);
});
}
});

let onkeydown = {
to_owned![editable, focus_manager];
move |e: Event<KeyboardData>| {
Expand Down
2 changes: 1 addition & 1 deletion crates/elements/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ winit = { workspace = true }
tokio = { workspace = true }
accesskit = { workspace = true }

keyboard-types = "0.6.2"
keyboard-types = "0.7.0"
78 changes: 35 additions & 43 deletions crates/engine/src/mocked.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#![allow(non_upper_case_globals)]
#![allow(clippy::upper_case_acronyms)]
#![allow(non_camel_case_types)]
#![allow(unused_variables)]

use std::ops::*;

Expand Down Expand Up @@ -167,7 +168,7 @@ impl Matrix {
unimplemented!("This is mocked")
}

pub fn set_rotate(&self, _degrees: f32, _pivot: impl Into<Option<Point>>) -> &mut Self {
pub fn set_rotate(&mut self, _degrees: f32, _pivot: impl Into<Option<Point>>) -> &mut Self {
unimplemented!("This is mocked")
}
}
Expand Down Expand Up @@ -420,7 +421,7 @@ impl TextStyle {
unimplemented!("This is mocked")
}

pub fn decoration_mut(&mut self) -> &mut Decoration {
pub fn set_decoration(&mut self, decoration: &Decoration) {
unimplemented!("This is mocked")
}

Expand Down Expand Up @@ -708,7 +709,7 @@ impl Paragraph {
unimplemented!("This is mocked")
}

pub fn paint(&self, _canvas: &mut Canvas, _p: impl Into<Point>) {
pub fn paint(&self, _canvas: &Canvas, _p: impl Into<Point>) {
unimplemented!("This is mocked")
}

Expand Down Expand Up @@ -947,43 +948,43 @@ impl Canvas {
unimplemented!("This is mocked")
}

pub fn concat(&mut self, _matrix: &Matrix) {
pub fn concat(&self, _matrix: &Matrix) {
unimplemented!("This is mocked")
}

pub fn clip_rect(&mut self, _rect: Rect, _clip: ClipOp, _: bool) {
pub fn clip_rect(&self, _rect: Rect, _clip: ClipOp, _: bool) {
unimplemented!("This is mocked")
}

pub fn draw_image_nine(
&mut self,
&self,
_image: Image,
_center: IRect,
_dst: Rect,
_filter_mode: FilterMode,
_paint: Option<&Paint>,
) -> &mut Self {
) -> &Self {
unimplemented!("This is mocked")
}

pub fn draw_rect(&mut self, _rect: Rect, _paint: &Paint) -> &mut Self {
pub fn draw_rect(&self, _rect: Rect, _paint: &Paint) -> &Self {
unimplemented!("This is mocked")
}

pub fn draw_path(&mut self, _path: &Path, _paint: &Paint) -> &mut Self {
pub fn draw_path(&self, _path: &Path, _paint: &Paint) -> &Self {
unimplemented!("This is mocked")
}

pub fn clip_path(
&mut self,
&self,
_path: &Path,
_op: impl Into<Option<ClipOp>>,
_do_anti_alias: impl Into<Option<bool>>,
) -> &mut Self {
) -> &Self {
unimplemented!("This is mocked")
}

pub fn translate(&mut self, _d: impl Into<Point>) -> &mut Self {
pub fn translate(&self, _d: impl Into<Point>) -> &Self {
unimplemented!("This is mocked")
}

Expand All @@ -995,21 +996,11 @@ impl Canvas {
unimplemented!("This is mocked")
}

pub fn draw_line(
&mut self,
_p1: impl Into<Point>,
_p2: impl Into<Point>,
_paint: &Paint,
) -> &mut Self {
pub fn draw_line(&self, _p1: impl Into<Point>, _p2: impl Into<Point>, _paint: &Paint) -> &Self {
unimplemented!("This is mocked")
}

pub fn draw_circle(
&mut self,
_center: impl Into<Point>,
_radius: f32,
_paint: &Paint,
) -> &mut Self {
pub fn draw_circle(&self, _center: impl Into<Point>, _radius: f32, _paint: &Paint) -> &Self {
unimplemented!("This is mocked")
}
}
Expand Down Expand Up @@ -1132,7 +1123,7 @@ impl Image {
pub struct Data;

impl Data {
pub fn new_bytes(_bytes: &[u8]) -> Self {
pub unsafe fn new_bytes(_bytes: &[u8]) -> Self {
unimplemented!("This is mocked")
}
}
Expand Down Expand Up @@ -1328,7 +1319,7 @@ pub mod svg {
unimplemented!("This is mocked")
}

pub fn render(&self, _canvas: &mut Canvas) {
pub fn render(&self, _canvas: &Canvas) {
unimplemented!("This is mocked")
}
}
Expand All @@ -1353,7 +1344,7 @@ impl From<(i32, i32)> for Size {
pub struct Surface;

impl Surface {
pub fn canvas(&self) -> Canvas {
pub fn canvas(&mut self) -> Canvas {
unimplemented!("This is mocked")
}

Expand Down Expand Up @@ -1436,12 +1427,14 @@ impl DirectContext {
use std::ffi::c_void;

#[repr(u8)]
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub enum Protected {
No,
Yes,
}

#[derive(Clone, Copy)]
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
#[repr(C)]
pub struct FramebufferInfo {
pub fboid: i32,
pub format: Format,
Expand All @@ -1450,11 +1443,7 @@ pub struct FramebufferInfo {

impl Default for FramebufferInfo {
fn default() -> Self {
Self {
fboid: 0,
format: 0,
protected: Protected::No,
}
unimplemented!("This is mocked")
}
}

Expand All @@ -1466,16 +1455,7 @@ pub fn wrap_backend_render_target(
color_space: impl Into<Option<ColorSpace>>,
surface_props: Option<&SurfaceProps>,
) -> Option<Surface> {
Surface::from_ptr(unsafe {
sb::C_SkSurfaces_WrapBackendRenderTarget(
context.native_mut(),
backend_render_target.native(),
origin,
color_type.into_native(),
color_space.into().into_ptr_or_null(),
surface_props.native_ptr_or_null(),
)
})
unimplemented!("This is mocked")
}

pub struct Interface;
Expand Down Expand Up @@ -1534,3 +1514,15 @@ impl BackendRenderTarget {
unimplemented!("This is mocked")
}
}

pub mod backend_render_targets {
use crate::prelude::*;
pub fn make_gl(
(width, height): (i32, i32),
sample_count: impl Into<Option<usize>>,
stencil_bits: usize,
info: FramebufferInfo,
) -> BackendRenderTarget {
unimplemented!("This is mocked")
}
}
1 change: 1 addition & 0 deletions crates/engine/src/skia.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
pub use skia_safe::{
font_style::{Slant, Weight, Width},
gpu::{
backend_render_targets,
gl::{Format, FramebufferInfo, Interface},
surfaces::wrap_backend_render_target,
BackendRenderTarget, DirectContext, RecordingContext, SurfaceOrigin,
Expand Down
1 change: 1 addition & 0 deletions crates/freya/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ no-default-features = true
log = ["dep:tracing", "dep:tracing-subscriber"]
devtools = ["dep:freya-devtools", "freya-dom/shared"]
use_camera = ["freya-hooks/use_camera"]
mocked-engine-development = ["freya-engine/mocked-engine"] # This is just for the CI
default = ["freya-engine/skia-engine"]

[dependencies]
Expand Down
4 changes: 2 additions & 2 deletions crates/hooks/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ accesskit = { workspace = true }

euclid = { workspace = true }
uuid = { workspace = true }
tween = "2.0.0"
tween = "2.0.1"
ropey = "1.6.0"
nokhwa = { version = "0.10.4", features = ["input-native"], optional = true }
bytes = "1.3.0"
bytes = "1.5.0"

[dev-dependencies]
dioxus = { workspace = true }
Expand Down
7 changes: 7 additions & 0 deletions crates/hooks/src/rope_editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ impl RopeEditor {
mode,
}
}

pub fn rope(&self) -> &Rope {
&self.rope
}
}

impl TextEditor for RopeEditor {
Expand Down Expand Up @@ -157,6 +161,9 @@ impl TextEditor for RopeEditor {
fn set(&mut self, text: &str) {
self.rope.remove(0..);
self.rope.insert(0, text);
if self.cursor_pos() > text.len() {
self.set_cursor_pos(text.len());
}
}

fn unhighlight(&mut self) {
Expand Down
2 changes: 1 addition & 1 deletion crates/hooks/src/text_editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use freya_elements::events::keyboard::{Code, Key, Modifiers};
pub use ropey::Rope;

/// Holds the position of a cursor in a text
#[derive(Clone, Default)]
#[derive(Clone, Default, PartialEq, Debug)]
pub struct TextCursor {
col: usize,
row: usize,
Expand Down
2 changes: 1 addition & 1 deletion crates/hooks/src/use_accessibility.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ mod test {

let mut utils = launch_test_with_config(
use_focus_app,
TestingConfig::default().with_size((100.0, 100.0).into()),
*TestingConfig::default().with_size((100.0, 100.0).into()),
);

// Initial state
Expand Down
Loading

0 comments on commit a2ad34a

Please sign in to comment.