Skip to content

Commit 3a1b872

Browse files
committed
better coordinates + fix settings
1 parent 87edc63 commit 3a1b872

File tree

9 files changed

+270
-184
lines changed

9 files changed

+270
-184
lines changed

apps/desktop/src-tauri/src/web_api.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,6 @@ pub fn make_url(pathname: impl AsRef<str>) -> String {
99
format!("{server_url_base}{}", pathname.as_ref())
1010
}
1111

12-
pub async fn do_request(
13-
build: impl FnOnce(reqwest::Client) -> reqwest::RequestBuilder,
14-
) -> Result<reqwest::Response, reqwest::Error> {
15-
let client = reqwest::Client::new();
16-
build(client).send().await
17-
}
18-
1912
async fn do_authed_request(
2013
auth: &AuthStore,
2114
build: impl FnOnce(reqwest::Client) -> reqwest::RequestBuilder,

apps/desktop/src/routes/(window-chrome)/settings/general.tsx

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,21 +45,15 @@ export default function GeneralSettings() {
4545
const [store] = createResource(() => generalSettingsStore.get());
4646

4747
return (
48-
<Show
49-
when={(() => {
50-
const s = store();
51-
if (s === undefined) return;
52-
return [s];
53-
})()}
54-
>
55-
{(store) => <Inner store={store()[0]} />}
48+
<Show when={store.state === "ready" && ([store()] as const)}>
49+
{(store) => <Inner initialStore={store()[0] ?? null} />}
5650
</Show>
5751
);
5852
}
5953

60-
function Inner(props: { store: GeneralSettingsStore | null }) {
54+
function Inner(props: { initialStore: GeneralSettingsStore | null }) {
6155
const [settings, setSettings] = createStore<GeneralSettingsStore>(
62-
props.store ?? {
56+
props.initialStore ?? {
6357
upload_individual_files: false,
6458
open_editor_after_recording: false,
6559
hide_dock_icon: false,

apps/desktop/src/routes/(window-chrome)/settings/hotkeys.tsx

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,22 +31,16 @@ export default function () {
3131
const [store] = createResource(() => hotkeysStore.get());
3232

3333
return (
34-
<Show
35-
when={(() => {
36-
const s = store();
37-
if (s === undefined) return;
38-
return [s];
39-
})()}
40-
>
41-
{(store) => <Inner store={store()[0]} />}
34+
<Show when={store.state === "ready" && ([store()] as const)}>
35+
{(store) => <Inner initialStore={store()[0] ?? null} />}
4236
</Show>
4337
);
4438
}
4539

46-
function Inner(props: { store: HotkeysStore | null }) {
40+
function Inner(props: { initialStore: HotkeysStore | null }) {
4741
const [hotkeys, setHotkeys] = createStore<{
4842
[K in HotkeyAction]?: Hotkey;
49-
}>(props.store?.hotkeys ?? {});
43+
}>(props.initialStore?.hotkeys ?? {});
5044

5145
createEffect(() => {
5246
// biome-ignore lint/suspicious/noExplicitAny: specta#283

crates/media/src/encoders/h264.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use ffmpeg::{
22
codec::{codec::Codec, context, encoder},
3-
format::{self, pixel::Pixel},
3+
format::{self},
44
threading::Config,
55
Dictionary,
66
};

crates/media/src/feeds/camera.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ use ffmpeg::software::scaling;
22
use flume::{Receiver, Sender, TryRecvError};
33
use nokhwa::{pixel_format::*, utils::*, Camera};
44
use std::{
5-
io::Write,
65
thread::{self, JoinHandle},
76
time::Instant,
87
};

crates/media/src/filters/video.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use ffmpeg::{filter, format::pixel::Pixel};
1+
use ffmpeg::filter;
22

33
use crate::{
44
data::{FFVideo, VideoInfo},

crates/project/src/configuration.rs

Lines changed: 85 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
use std::ops::{Add, Div, Mul, Sub};
2+
13
use serde::{Deserialize, Serialize};
24
use specta::Type;
35

@@ -46,14 +48,93 @@ impl Default for BackgroundSource {
4648
}
4749
}
4850

49-
#[derive(Type, Serialize, Deserialize, Clone, Debug, Default)]
51+
#[derive(Type, Serialize, Deserialize, Clone, Copy, Debug, Default)]
5052
#[serde(rename_all = "camelCase")]
5153
pub struct XY<T> {
5254
pub x: T,
5355
pub y: T,
5456
}
5557

56-
#[derive(Type, Serialize, Deserialize, Clone, Debug, Default)]
58+
impl<T> XY<T> {
59+
pub fn new(x: T, y: T) -> Self {
60+
Self { x, y }
61+
}
62+
63+
pub fn map<U, F: Fn(T) -> U>(self, f: F) -> XY<U> {
64+
XY {
65+
x: f(self.x),
66+
y: f(self.y),
67+
}
68+
}
69+
}
70+
71+
impl<T: Add<Output = T>> Add for XY<T> {
72+
type Output = Self;
73+
74+
fn add(self, other: Self) -> Self {
75+
Self {
76+
x: self.x + other.x,
77+
y: self.y + other.y,
78+
}
79+
}
80+
}
81+
82+
impl<T: Sub<Output = T>> Sub for XY<T> {
83+
type Output = Self;
84+
85+
fn sub(self, other: Self) -> Self {
86+
Self {
87+
x: self.x - other.x,
88+
y: self.y - other.y,
89+
}
90+
}
91+
}
92+
93+
impl<T: Sub<Output = T> + Copy> Sub<T> for XY<T> {
94+
type Output = Self;
95+
96+
fn sub(self, other: T) -> Self {
97+
Self {
98+
x: self.x - other,
99+
y: self.y - other,
100+
}
101+
}
102+
}
103+
104+
impl<T: Mul<Output = T> + Copy> Mul<T> for XY<T> {
105+
type Output = Self;
106+
107+
fn mul(self, other: T) -> Self {
108+
Self {
109+
x: self.x * other,
110+
y: self.y * other,
111+
}
112+
}
113+
}
114+
115+
impl<T: Mul<Output = T> + Copy> Mul<XY<T>> for XY<T> {
116+
type Output = Self;
117+
118+
fn mul(self, other: Self) -> Self {
119+
Self {
120+
x: self.x * other.x,
121+
y: self.y * other.y,
122+
}
123+
}
124+
}
125+
126+
impl<T: Div<Output = T> + Copy> Div<T> for XY<T> {
127+
type Output = Self;
128+
129+
fn div(self, other: T) -> Self {
130+
Self {
131+
x: self.x / other,
132+
y: self.y / other,
133+
}
134+
}
135+
}
136+
137+
#[derive(Type, Serialize, Deserialize, Clone, Copy, Debug, Default)]
57138
#[serde(rename_all = "camelCase")]
58139
pub struct Crop {
59140
pub position: XY<u32>,
@@ -71,8 +152,8 @@ impl Crop {
71152
pub struct BackgroundConfiguration {
72153
pub source: BackgroundSource,
73154
pub blur: u32,
74-
pub padding: f32,
75-
pub rounding: f32,
155+
pub padding: f64,
156+
pub rounding: f64,
76157
pub inset: u32,
77158
pub crop: Option<Crop>,
78159
}

0 commit comments

Comments
 (0)