Skip to content

Commit 41f2223

Browse files
committed
[*] update normally
1 parent b789bf5 commit 41f2223

File tree

14 files changed

+501
-172
lines changed

14 files changed

+501
-172
lines changed

flake.nix

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,7 @@
5757

5858
# Set include paths
5959
C_INCLUDE_PATH = with pkgs;
60-
lib.concatStringsSep ":" [
61-
"${glibc.dev}/include"
62-
"${stdenv.cc.cc}/lib/gcc/x86_64-unknown-linux-gnu/${stdenv.cc.cc.version}/include"
63-
];
60+
lib.concatStringsSep ":" [ "${glibc.dev}/include" ];
6461

6562
CPLUS_INCLUDE_PATH = with pkgs;
6663
lib.concatStringsSep ":" [ "${glibc.dev}/include" ];

wayshot/src/logic.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,17 @@ macro_rules! logic_cb {
8989
}
9090
}}
9191
};
92+
($callback_name:ident, $ui:expr) => {
93+
{{
94+
let ui_weak = $ui.as_weak();
95+
paste::paste! {
96+
crate::global_logic!($ui)
97+
.[<on_ $callback_name>](move || {
98+
$callback_name(&ui_weak.unwrap())
99+
});
100+
}
101+
}}
102+
};
92103
}
93104

94105
/// Macro to implement serde Serialize and Deserialize for Slint enums

wayshot/src/logic/recorder.rs

Lines changed: 62 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,67 @@
1-
use crate::{logic_cb, slint_generatedAppWindow::AppWindow};
1+
use crate::{
2+
global_store, logic_cb,
3+
slint_generatedAppWindow::{AppWindow, Source as UISource},
4+
};
25
use slint::{ComponentHandle, Model, ModelRc, SharedString, VecModel};
36

7+
// static CACHE: Lazy<Mutex<Cache>> = Lazy::new(|| Mutex::new(Cache::default()));
8+
9+
#[macro_export]
10+
macro_rules! store_audio_sources {
11+
($ui:expr) => {
12+
crate::global_store!($ui)
13+
.get_audio_sources()
14+
.as_any()
15+
.downcast_ref::<VecModel<SharedString>>()
16+
.expect("We know we set a VecModel<SharedString> earlier")
17+
};
18+
}
19+
20+
#[macro_export]
21+
macro_rules! store_video_sources {
22+
($ui:expr) => {
23+
crate::global_store!($ui)
24+
.get_video_sources()
25+
.as_any()
26+
.downcast_ref::<VecModel<SharedString>>()
27+
.expect("We know we set a VecModel<SharedString> earlier")
28+
};
29+
}
30+
31+
#[macro_export]
32+
macro_rules! store_sources {
33+
($ui:expr) => {
34+
crate::global_store!($ui)
35+
.get_sources()
36+
.as_any()
37+
.downcast_ref::<VecModel<UISource>>()
38+
.expect("We know we set a VecModel<UISource> earlier")
39+
};
40+
}
41+
442
pub fn init(ui: &AppWindow) {
5-
// logic_cb!(generate_search_values, ui, entries);
6-
// logic_cb!(get_sidebar_key_from_search_values, ui, entries, text);
43+
inner_init(&ui);
44+
45+
logic_cb!(screen_changed, ui, name);
46+
logic_cb!(input_audio_changed, ui, name);
47+
logic_cb!(start_recording, ui);
48+
logic_cb!(stop_recording, ui);
49+
logic_cb!(stop_merge_tracks, ui);
50+
}
51+
52+
fn inner_init(ui: &AppWindow) {
53+
store_sources!(ui).set_vec(vec![]);
54+
store_audio_sources!(ui).set_vec(vec![]);
55+
store_video_sources!(ui).set_vec(vec![]);
56+
global_store!(ui).set_preview_image(Default::default());
757
}
858

9-
// fn generate_search_values(
10-
// _ui: &AppWindow,
11-
// entries: ModelRc<UISideBarEntry>,
12-
// ) -> ModelRc<SharedString> {
13-
// }
14-
//
15-
// fn get_sidebar_key_from_search_values(
16-
// _ui: &AppWindow,
17-
// entries: ModelRc<UISideBarEntry>,
18-
// text: SharedString,
19-
// ) -> SharedString {
20-
// }
59+
fn screen_changed(ui: &AppWindow, name: SharedString) {}
60+
61+
fn input_audio_changed(ui: &AppWindow, name: SharedString) {}
62+
63+
fn start_recording(ui: &AppWindow) {}
64+
65+
fn stop_recording(ui: &AppWindow) {}
66+
67+
fn stop_merge_tracks(ui: &AppWindow) {}

wayshot/ui/base/audio-level.slint

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import { Theme } from "theme.slint";
2+
import { Label } from "label.slint";
3+
4+
export component AudioLevel inherits Rectangle {
5+
height: Theme.icon-size * 2 / 3;
6+
width: 300px;
7+
8+
in-out property <bool> enable: true;
9+
in-out property <int> db: -60;
10+
private property <int> real-db: clamp(root.db, -60, 0);
11+
12+
HorizontalLayout {
13+
x: 0;
14+
y: 0;
15+
16+
Rectangle {
17+
height: 100%;
18+
width: 66%;
19+
background: Theme.is-dark ? Theme.hover-background.brighter(20%) : Theme.thirdly-background.darker(10%);
20+
}
21+
22+
Rectangle {
23+
height: 100%;
24+
width: 17%;
25+
background: Theme.is-dark ? Theme.hover-background.darker(10%) : Theme.thirdly-background;
26+
}
27+
28+
Rectangle {
29+
height: 100%;
30+
width: 17%;
31+
background: Theme.is-dark ? Theme.hover-background.brighter(40%) : Theme.thirdly-background.darker(20%);
32+
}
33+
}
34+
35+
Rectangle {
36+
x: 0;
37+
y: 0;
38+
width: parent.width * (1 - real-db / -60);
39+
background: root.enable ? (real-db < -20 ? Theme.success-color : (real-db < -10 ? Theme.warning-color : Theme.danger-color)) : Theme.disabled-color;
40+
}
41+
}

wayshot/ui/base/icon.slint

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,8 @@ export global Icons {
231231
out property <image> zoom-out-light: @image-url("../images/icons/zoom-out-light.svg");
232232
out property <image> merge-above-light: @image-url("../images/icons/merge-above-light.svg");
233233
out property <image> split-down-light: @image-url("../images/icons/split-down-light.svg");
234+
out property <image> audio-fill: @image-url("../images/icons/audio-fill.svg");
235+
out property <image> screen-fill: @image-url("../images/icons/screen-fill.svg");
234236

235237
out property <image> landing-account: @image-url("../images/landing/landing-account.svg");
236238
out property <image> landing-language-switch: @image-url("../images/landing/landing-language-switch.svg");

wayshot/ui/base/select.slint

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export component Select inherits Rectangle {
2222
in-out property <[string]> values;
2323

2424
in-out property <length> popup-max-height: 300px;
25-
in-out property <ComponentPosition> popup-position: ComponentPosition.Bottom;
25+
in-out property <ComponentPosition> popup-position: ComponentPosition.Bottom;
2626

2727
in-out property <length> font-size: Theme.default-font-size;
2828
in-out property <length> hpadding: Theme.padding * 3;

wayshot/ui/base/widgets.slint

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ import { DashLine } from "dash-line.slint";
8888
import { RenameDialog } from "rename-dialog.slint";
8989
import { ReplaceDialog } from "replace-dialog.slint";
9090
import { GroupBox } from "group-box.slint";
91+
import { AudioLevel } from "audio-level.slint";
9192

9293
export {
9394
AppPosType,
@@ -227,4 +228,5 @@ export {
227228
RenameDialog,
228229
ReplaceDialog,
229230
GroupBox,
231+
AudioLevel,
230232
}
Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 1 addition & 0 deletions
Loading

wayshot/ui/logic.slint

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,11 @@ export global Logic {
7474
callback get-setting-ai-model() -> SettingAiModel;
7575
callback set-setting-ai-model(setting: SettingAiModel);
7676

77-
callback source-changed(value: string);
78-
callback set-control-setting(setting: ControlSetting);
77+
callback get-setting-control(setting: ControlSetting);
78+
callback set-setting-control(setting: ControlSetting);
79+
80+
callback screen-changed(value: string);
81+
callback input-audio-changed(value: string);
7982
callback start-recording();
8083
callback stop-recording();
8184
callback stop-merge-tracks();

0 commit comments

Comments
 (0)