Skip to content

Commit

Permalink
Improve UX of bottom bar and timeline widget
Browse files Browse the repository at this point in the history
  • Loading branch information
valadaptive committed Oct 29, 2024
1 parent 19cc463 commit 62f1407
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
8 changes: 5 additions & 3 deletions crates/gui/src/app/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1651,7 +1651,8 @@ impl NtscApp {

ui.separator();

ui.label("🔎");
ui.add(egui::Label::new("🔎").selectable(false))
.on_hover_text("Zoom preview");
ui.add_enabled(
!self.video_zoom.fit,
egui::DragValue::new(&mut self.video_zoom.scale)
Expand Down Expand Up @@ -1684,7 +1685,7 @@ impl NtscApp {
self.handle_result(res);
}
}
ui.label("scanlines");
ui.label("lines");
});

ui.separator();
Expand Down Expand Up @@ -1764,7 +1765,8 @@ impl NtscApp {
ui.separator();

let mut update_effect_preview = false;
ui.label("✨").on_hover_text("Effect preview");
ui.add(egui::Label::new("✨").selectable(false))
.on_hover_text("Effect preview");
update_effect_preview |= ui
.selectable_value(
&mut self.effect_preview.mode,
Expand Down
11 changes: 8 additions & 3 deletions crates/gui/src/widgets/timeline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,9 +208,14 @@ impl<'a> Widget for Timeline<'a> {
let range_f64 = *self.range.start() as f64..=*self.range.end() as f64;

if ui.rect_contains_pointer(rect) {
let scroll_delta = ui.ctx().input(|input| input.raw_scroll_delta);
let zoom_delta = ui.ctx().input(|input| input.zoom_delta());
let scroll_delta = scroll_delta.x + scroll_delta.y;
// If we're zooming, it may be via ctrl-scroll. We never want to zoom and scroll at the same time.
let scroll_delta = if zoom_delta == 1.0 {
let scroll_delta = ui.ctx().input(|input| input.smooth_scroll_delta);
scroll_delta.x + scroll_delta.y
} else {
0.0
};

if zoom_delta != 1.0 {
let pointer_pos = ui.ctx().input(|i| i.pointer.hover_pos());
Expand Down Expand Up @@ -253,7 +258,7 @@ impl<'a> Widget for Timeline<'a> {
if scroll_delta != 0.0 {
let zoom_span = state.zoom_range[1] - state.zoom_range[0];
// we need to negate the scroll delta--scrolling down and right are both negative?
let delta = (-scroll_delta.signum() / rect.width()) as f64 * zoom_span;
let delta = (-scroll_delta / rect.width()) as f64 * zoom_span;
if delta > 0.0 {
state.zoom_range[1] = (state.zoom_range[1] + delta).min(1.0);
state.zoom_range[0] = state.zoom_range[1] - zoom_span;
Expand Down

0 comments on commit 62f1407

Please sign in to comment.