Skip to content

Commit a0796f7

Browse files
committed
[*] refactor
1 parent 23937a2 commit a0796f7

File tree

12 files changed

+95
-58
lines changed

12 files changed

+95
-58
lines changed

todo.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
## 问题
22
- subtitle需要重新设计
33

4-
- 选中的font没有显示在字体列表中
5-
- fly in filter参数面板暂停时会恢复默认值
4+
- preview相关界面中,没有filter的也会进入编辑模式
65

76
## 待验证
8-
- font 列表显示有问题,条目变少了。刷新时有275条,但是显示时却只有254条
7+
- 选中的font没有显示在字体列表中
8+
- 选中segment边框颜色不能写,可以增加边框宽度
9+
- font列表刷新成功应该显示toast
910

1011
- 视频轨道分离字幕
1112

wayshot/src/logic/video_editor/font.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,12 @@ fn init_font_dialog(ui: &AppWindow) {
5757

5858
fn refresh_font_entries(ui: &AppWindow) {
5959
let ui_weak = ui.as_weak();
60+
6061
tokio::spawn(async move {
6162
refresh_font_entries_impl(ui_weak).await;
6263
});
64+
65+
crate::toast_success!(ui, "Refresh...");
6366
}
6467

6568
async fn refresh_font_entries_impl(ui_weak: Weak<AppWindow>) {

wayshot/ui/base/line-input.slint

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ export component LineInput inherits Rectangle {
3939
out property has-focus <=> text-input.has-focus;
4040
out property <color> default-border-color: text-input.has-focus ? Theme.thirdly-brand-color : Theme.base-border-color;
4141
in-out property <bool> show-icon-hover-background: true;
42+
in-out property <bool> is-show-color-block;
43+
in-out property <color> color-block-color;
4244

4345
in property <bool> is-show-icon;
4446
in property <image> icon;
@@ -93,15 +95,29 @@ export component LineInput inherits Rectangle {
9395
accept
9496
}
9597

96-
text-input := TextInput {
97-
single-line: true;
98-
vertical-alignment: TextVerticalAlignment.center;
99-
color: root.enabled ? Theme.primary-text-color : root.disabled-color;
100-
font-size: Theme.default-font-size;
98+
HorizontalLayout {
99+
spacing: Theme.spacing * 2;
101100

102-
accepted => {
103-
self.clear-focus();
104-
root.accepted();
101+
if is-show-color-block: VerticalLayout {
102+
alignment: center;
103+
104+
Rectangle {
105+
width: text-input.font-size * 0.8;
106+
height: self.width;
107+
background: color-block-color;
108+
}
109+
}
110+
111+
text-input := TextInput {
112+
single-line: true;
113+
vertical-alignment: TextVerticalAlignment.center;
114+
color: root.enabled ? Theme.primary-text-color : root.disabled-color;
115+
font-size: Theme.default-font-size;
116+
117+
accepted => {
118+
self.clear-focus();
119+
root.accepted();
120+
}
105121
}
106122
}
107123
}

wayshot/ui/panel/desktop/font-dialog.slint

Lines changed: 49 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -175,52 +175,59 @@ export component FontDialog inherits MovingDialog {
175175
Logic.init-font-dialog();
176176
}
177177

178-
VerticalLayout {
179-
padding: Theme.padding * 2;
180-
spacing: Theme.spacing * 2;
181-
alignment: start;
178+
Rectangle {
179+
TouchArea { }
182180

183-
HeadBar { }
181+
VerticalLayout {
182+
padding: Theme.padding * 2;
183+
spacing: Theme.spacing * 2;
184+
alignment: start;
184185

185-
if Store.font-entries.length == 0: CenterLayout {
186-
NoDataImg {
187-
width: root.header-width * Theme.golden-ratio;
188-
text: Logic.tr("No found system fonts");
189-
font-size: Theme.default-font-size;
186+
HeadBar { }
187+
188+
if Store.font-entries.length == 0: CenterLayout {
189+
NoDataImg {
190+
width: root.header-width * Theme.golden-ratio;
191+
text: Logic.tr("No found system fonts");
192+
font-size: Theme.default-font-size;
193+
}
190194
}
191-
}
192195

193-
if Store.font-entries.length > 0: Rectangle {
194-
height: font-item-height * 10;
195-
border-radius: Theme.border-radius;
196-
border-color: Theme.base-border-color;
197-
border-width: Theme.default-border-width;
198-
199-
private property <length> font-item-height: Theme.default-font-size + Theme.padding * 6;
200-
201-
ScrollView {
202-
x: parent.border-width;
203-
y: parent.border-width;
204-
width: parent.width - parent.border-width * 2;
205-
viewport-width: vbox.preferred-width;
206-
viewport-height: vbox.preferred-height;
207-
208-
vbox := VerticalLayout {
209-
alignment: start;
210-
211-
private property <length> font-item-max-family-width;
212-
private property <length> font-item-max-style-width;
213-
214-
for entry[index] in Store.font-entries: FontItem {
215-
index: index;
216-
entry: entry;
217-
height: font-item-height;
218-
family-width: parent.font-item-max-family-width;
219-
style-width: parent.font-item-max-style-width;
220-
221-
init => {
222-
parent.font-item-max-family-width = max(parent.font-item-max-family-width, self.family-preferred-width);
223-
parent.font-item-max-style-width = max(parent.font-item-max-style-width, self.style-preferred-width);
196+
if Store.font-entries.length > 0: Rectangle {
197+
height: font-item-height * 10;
198+
width: parent.width - parent.padding * 2;
199+
border-radius: Theme.border-radius;
200+
border-color: Theme.base-border-color;
201+
border-width: Theme.default-border-width;
202+
203+
private property <length> font-item-height: Theme.default-font-size + Theme.padding * 6;
204+
205+
ScrollView {
206+
x: parent.border-width;
207+
y: parent.border-width;
208+
width: parent.width - parent.border-width * 2;
209+
viewport-width: vbox.preferred-width;
210+
viewport-height: vbox.preferred-height;
211+
212+
vbox := VerticalLayout {
213+
alignment: start;
214+
width: parent.width;
215+
216+
private property <length> font-item-max-family-width;
217+
private property <length> font-item-max-style-width;
218+
219+
for entry[index] in Store.font-entries: FontItem {
220+
index: index;
221+
entry: entry;
222+
height: font-item-height;
223+
width: parent.width;
224+
family-width: parent.font-item-max-family-width;
225+
style-width: parent.font-item-max-style-width;
226+
227+
init => {
228+
parent.font-item-max-family-width = max(parent.font-item-max-family-width, self.family-preferred-width);
229+
parent.font-item-max-style-width = max(parent.font-item-max-style-width, self.style-preferred-width);
230+
}
224231
}
225232
}
226233
}

wayshot/ui/panel/desktop/video-editor/right-panel/filter/filter.slint

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -588,10 +588,10 @@ component FilterSelector inherits VerticalLayout {
588588
export component Filter inherits Rectangle {
589589
private property <bool> is-show-selector;
590590
private property <FilterType> filter-tab-type;
591-
private property <bool> is-subtitle-track: Logic.video-editor-is-subtitle-track(Store.video-editor-current-edited-track-index);
591+
// private property <bool> is-subtitle-track: Logic.video-editor-is-subtitle-track(Store.video-editor-current-edited-track-index);
592592
private property <bool> is-show-segment-filter: Store.video-editor-current-edited-track-index >= 0 && Store.video-editor-selected-segments-index.length > 0 && !is-subtitle-track;
593593

594-
// private property <bool> is-subtitle-track: true; // todo
594+
private property <bool> is-subtitle-track: true; // todo
595595
// private property <bool> is-show-segment-filter: true; // todo
596596

597597
if !is-show-segment-filter && !is-subtitle-track: NoDataImg {

wayshot/ui/panel/desktop/video-editor/right-panel/filter/subtitle/background-color.slint

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ export component BackgroundColor inherits Rectangle {
4343
icon: Icons.color-picker-light;
4444
is-show-icon: true;
4545
text: Util.color-picker-str(config.r, config.g, config.b, config.a);
46+
is-show-color-block: true;
47+
color-block-color: Util.color-picker-hex-color(self.text);
4648

4749
clicked => {
4850
Store.video-editor-color-picker-color = Util.color-picker-hex-color(self.text);

wayshot/ui/panel/desktop/video-editor/right-panel/filter/subtitle/font-path.slint

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ export component FontPath inherits Rectangle {
2323
private property <FontEntry> selected-font <=> Store.selected-font-entry;
2424

2525
changed selected-font => {
26-
font-li.text = Util.file-name(config.font-path);
26+
debug("xxxxxx");
27+
font-li.text = selected-font.family;
2728
config.font-path = selected-font.path;
2829
self.apply(config);
2930
}

wayshot/ui/panel/desktop/video-editor/right-panel/filter/subtitle/outline-color.slint

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ export component OutlineColor inherits Rectangle {
4343
icon: Icons.color-picker-light;
4444
is-show-icon: true;
4545
text: Util.color-picker-str(config.r, config.g, config.b, config.a);
46+
is-show-color-block: true;
47+
color-block-color: Util.color-picker-hex-color(self.text);
4648

4749
clicked => {
4850
Store.video-editor-color-picker-color = Util.color-picker-hex-color(self.text);

wayshot/ui/panel/desktop/video-editor/right-panel/filter/subtitle/primary-color.slint

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ export component PrimaryColor inherits Rectangle {
4141
icon: Icons.color-picker-light;
4242
is-show-icon: true;
4343
text: Util.color-picker-str(config.r, config.g, config.b, config.a);
44+
is-show-color-block: true;
45+
color-block-color: Util.color-picker-hex-color(self.text);
4446

4547
clicked => {
4648
Store.video-editor-color-picker-color = Util.color-picker-hex-color(self.text);
@@ -49,4 +51,3 @@ export component PrimaryColor inherits Rectangle {
4951
}
5052
}
5153
}
52-

wayshot/ui/panel/desktop/video-editor/right-panel/filter/video/border.slint

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ export component Border inherits Rectangle {
8787
is-show-icon: true;
8888
enabled: selected-filter.enabled;
8989
text: Util.color-picker-str(config.color-r, config.color-g, config.color-b, config.color-a);
90+
is-show-color-block: true;
91+
color-block-color: Util.color-picker-hex-color(self.text);
9092
icon: Icons.color-picker-light;
9193
border-color: Theme.is-dark ? Theme.base-border-color.brighter(20%) : Theme.base-border-color.darker(10%);
9294
border-width: 1px;

0 commit comments

Comments
 (0)