Skip to content

Commit cd61b77

Browse files
committed
T
1 parent 0acf244 commit cd61b77

4 files changed

Lines changed: 21 additions & 108 deletions

File tree

cedinia/src/app.rs

Lines changed: 19 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -428,8 +428,6 @@ fn run_app_inner(
428428
wire_save_settings_now(&window, included_dirs.clone(), excluded_dirs.clone(), referenced_dirs.clone());
429429

430430
let gallery_momentum: Rc<std::cell::RefCell<f32>> = Rc::new(std::cell::RefCell::new(0.0));
431-
let list_momentum: Rc<std::cell::RefCell<f32>> = Rc::new(std::cell::RefCell::new(0.0));
432-
let list_max_scroll: Rc<std::cell::RefCell<f32>> = Rc::new(std::cell::RefCell::new(0.0));
433431

434432
{
435433
let weak_g = window.as_weak();
@@ -455,92 +453,33 @@ fn run_app_inner(
455453
});
456454
}
457455

458-
{
459-
let weak_l = window.as_weak();
460-
let mom_l = Rc::clone(&list_momentum);
461-
let max_l = Rc::clone(&list_max_scroll);
462-
window.global::<AppState>().on_list_swiped(move |total_delta, vel_px| {
463-
if let Some(win) = weak_l.upgrade() {
464-
let current = win.global::<AppState>().get_list_scroll_y();
465-
let max_scroll = win.global::<AppState>().get_list_max_scroll_f();
466-
467-
let new_y = (current + total_delta).clamp(-max_scroll, 0.0);
468-
win.global::<AppState>().set_list_scroll_y(new_y);
469-
470-
// Keep a local copy so the momentum timer doesn't need an extra
471-
// AppState round-trip every frame.
472-
*max_l.borrow_mut() = max_scroll;
473-
474-
const VEL_THRESHOLD: f32 = 4.0;
475-
*mom_l.borrow_mut() = if vel_px.abs() < VEL_THRESHOLD { 0.0 } else { vel_px * 1.5 };
476-
}
477-
});
478-
}
479-
480-
{
481-
let mom_l = Rc::clone(&list_momentum);
482-
window.global::<AppState>().on_list_stop_momentum(move || {
483-
*mom_l.borrow_mut() = 0.0;
484-
});
485-
}
486-
487456
let scroll_timer = Timer::default();
488457
{
489458
let weak_sc = window.as_weak();
490459
let mom_sc = Rc::clone(&gallery_momentum);
491-
let list_mom_sc = Rc::clone(&list_momentum);
492-
let list_max_sc = Rc::clone(&list_max_scroll);
493460
scroll_timer.start(TimerMode::Repeated, std::time::Duration::from_millis(16), move || {
494461
// ── Gallery fling ─────────────────────────────────────────────
495-
{
496-
let mut mom = mom_sc.borrow_mut();
497-
if mom.abs() > 0.3 {
498-
if let Some(win) = weak_sc.upgrade() {
499-
let current = win.global::<AppState>().get_gallery_scroll_y();
500-
let max_scroll = win.global::<AppState>().get_gallery_max_scroll_f();
501-
let new_y = (current + *mom).clamp(-max_scroll, 0.0);
502-
win.global::<AppState>().set_gallery_scroll_y(new_y);
503-
504-
*mom *= 0.95;
505-
506-
if new_y >= 0.0 || new_y <= -max_scroll {
507-
*mom = 0.0;
508-
}
509-
}
510-
} else if let Some(win) = weak_sc.upgrade() {
511-
let max_s = win.global::<AppState>().get_gallery_max_scroll_f();
512-
let cur = win.global::<AppState>().get_gallery_scroll_y();
513-
if max_s > 0.0 && cur < -max_s {
514-
win.global::<AppState>().set_gallery_scroll_y(-max_s);
515-
} else if cur > 0.0 {
516-
win.global::<AppState>().set_gallery_scroll_y(0.0);
462+
let mut mom = mom_sc.borrow_mut();
463+
if mom.abs() > 0.3 {
464+
if let Some(win) = weak_sc.upgrade() {
465+
let current = win.global::<AppState>().get_gallery_scroll_y();
466+
let max_scroll = win.global::<AppState>().get_gallery_max_scroll_f();
467+
let new_y = (current + *mom).clamp(-max_scroll, 0.0);
468+
win.global::<AppState>().set_gallery_scroll_y(new_y);
469+
470+
*mom *= 0.95;
471+
472+
if new_y >= 0.0 || new_y <= -max_scroll {
473+
*mom = 0.0;
517474
}
518475
}
519-
}
520-
// ── List fling ────────────────────────────────────────────────
521-
{
522-
let mut mom = list_mom_sc.borrow_mut();
523-
if mom.abs() > 0.3 {
524-
if let Some(win) = weak_sc.upgrade() {
525-
let current = win.global::<AppState>().get_list_scroll_y();
526-
let max_scroll = *list_max_sc.borrow();
527-
let new_y = (current + *mom).clamp(-max_scroll, 0.0);
528-
win.global::<AppState>().set_list_scroll_y(new_y);
529-
530-
*mom *= 0.95;
531-
532-
if new_y >= 0.0 || new_y <= -max_scroll {
533-
*mom = 0.0;
534-
}
535-
}
536-
} else if let Some(win) = weak_sc.upgrade() {
537-
let max_s = *list_max_sc.borrow();
538-
let cur = win.global::<AppState>().get_list_scroll_y();
539-
if max_s > 0.0 && cur < -max_s {
540-
win.global::<AppState>().set_list_scroll_y(-max_s);
541-
} else if cur > 0.0 {
542-
win.global::<AppState>().set_list_scroll_y(0.0);
543-
}
476+
} else if let Some(win) = weak_sc.upgrade() {
477+
let max_s = win.global::<AppState>().get_gallery_max_scroll_f();
478+
let cur = win.global::<AppState>().get_gallery_scroll_y();
479+
if max_s > 0.0 && cur < -max_s {
480+
win.global::<AppState>().set_gallery_scroll_y(-max_s);
481+
} else if cur > 0.0 {
482+
win.global::<AppState>().set_gallery_scroll_y(0.0);
544483
}
545484
}
546485
});

cedinia/ui/app_state.slint

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -199,12 +199,6 @@ export global AppState {
199199
callback gallery_swiped(float, float);
200200
callback gallery_stop_momentum();
201201

202-
// Scroll state for the regular (list) result views.
203-
in-out property <length> list_scroll_y: 0px;
204-
in-out property <float> list_max_scroll_f: 0.0;
205-
callback list_swiped(float, float);
206-
callback list_stop_momentum();
207-
208202

209203
in-out property <string> diag_thumbnails_size: "-";
210204
in-out property <string> diag_app_cache_size: "-";

cedinia/ui/components.slint

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -130,18 +130,6 @@ export component FileRow {
130130
// after a drag/scroll release.
131131
property <bool> _moved: false;
132132

133-
// Set by the parent MomentumScrollView via `scroll_swiping: scroll_view.is_swiping`.
134-
// When the scroll SGR claims the pointer gesture it stops forwarding pointer
135-
// events to child TouchAreas, so the only reliable way to cancel the
136-
// long-press timer during a scroll is to watch this flag directly.
137-
in property <bool> scroll_swiping: false;
138-
changed scroll_swiping => {
139-
if root.scroll_swiping {
140-
lp_timer.running = false;
141-
root._moved = true;
142-
}
143-
}
144-
145133
// Stored press coordinates for the dead-zone check.
146134
// On Android even a stationary finger generates tiny move events;
147135
// we only cancel the timer when the finger actually drifts > 8 px.

cedinia/ui/results_list.slint

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { ConfirmPopupAction, FileEntry, FileEntryIdx, ScanState } from "common.s
33
import { AppState } from "app_state.slint";
44
import { Translations } from "translations.slint";
55
import { FileRow, StatusChip, TouchButton } from "components.slint";
6-
import { MomentumScrollView } from "momentum_scroll.slint";
6+
import { ListView } from "std-widgets.slint";
77

88
export component ResultsList {
99
in property <[FileEntry]> entries: [];
@@ -106,14 +106,8 @@ export component ResultsList {
106106
}
107107

108108

109-
if entries.length > 0 : scroll_view := MomentumScrollView {
109+
if entries.length > 0 : ListView {
110110
vertical-stretch: 1.0;
111-
scroll_y <=> AppState.list_scroll_y;
112-
swiped(d, v, m) => {
113-
AppState.list_max_scroll_f = m;
114-
AppState.list_swiped(d, v);
115-
}
116-
stop_momentum => { AppState.list_stop_momentum(); }
117111

118112
for entry[idx] in entries : FileRow {
119113
name: entry.val_str[FileEntryIdx.name_idx];
@@ -125,8 +119,6 @@ export component ResultsList {
125119
is_reference: entry.is_reference;
126120
is_even: mod(idx, 2) == 0;
127121
extra_as_line2: root.extra_as_line2 && !entry.is_header;
128-
// Cancel long-press when the scroll SGR claims the gesture.
129-
scroll_swiping: scroll_view.is_swiping;
130122
toggle_checked => { AppState.toggle_file_checked(idx); }
131123
open_item => { AppState.open_path(entry.val_str[FileEntryIdx.path_idx] == "" ? entry.val_str[FileEntryIdx.name_idx] : entry.val_str[FileEntryIdx.path_idx] + "/" + entry.val_str[FileEntryIdx.name_idx]); }
132124
open_parent => { AppState.open_parent_folder(entry.val_str[FileEntryIdx.path_idx]); }

0 commit comments

Comments
 (0)