diff --git a/crates/dtmm/src/ui/widget/controller.rs b/crates/dtmm/src/ui/widget/controller.rs index a2bf429..f7f71ef 100644 --- a/crates/dtmm/src/ui/widget/controller.rs +++ b/crates/dtmm/src/ui/widget/controller.rs @@ -1,5 +1,5 @@ -use druid::widget::{Button, Controller}; -use druid::{Data, Env, Event, EventCtx, LifeCycle, LifeCycleCtx, UpdateCtx, Widget}; +use druid::widget::{Button, Controller, Scroll}; +use druid::{Data, Env, Event, EventCtx, LifeCycle, LifeCycleCtx, Rect, UpdateCtx, Widget}; pub struct DisabledButtonController; @@ -45,3 +45,23 @@ impl Controller> for DisabledButtonController { child.update(ctx, old_data, data, env) } } + +pub struct AutoScrollController; + +impl> Controller> for AutoScrollController { + fn update( + &mut self, + child: &mut Scroll, + ctx: &mut UpdateCtx, + old_data: &T, + data: &T, + env: &Env, + ) { + if !ctx.is_disabled() { + let size = child.child_size(); + let end_region = Rect::new(size.width - 1., size.height - 1., size.width, size.height); + child.scroll_to(ctx, end_region); + } + child.update(ctx, old_data, data, env) + } +} diff --git a/crates/dtmm/src/ui/window/main.rs b/crates/dtmm/src/ui/window/main.rs index f7897f0..fa66c1f 100644 --- a/crates/dtmm/src/ui/window/main.rs +++ b/crates/dtmm/src/ui/window/main.rs @@ -14,6 +14,7 @@ use crate::state::{ ACTION_START_DELETE_SELECTED_MOD, ACTION_START_DEPLOY, }; use crate::ui::theme; +use crate::ui::widget::controller::AutoScrollController; use crate::ui::widget::ExtraWidgetExt; const TITLE: &str = "Darktide Mod Manager"; @@ -267,7 +268,8 @@ fn build_log_view() -> impl Widget { .with_line_break_mode(LineBreaking::WordWrap) .lens(State::log) .scroll() - .vertical(); + .vertical() + .controller(AutoScrollController); SizedBox::new(label).expand_width().height(128.0) }