notedeck

One damus client to rule them all
git clone git://jb55.com/notedeck
Log | Files | Refs | README | LICENSE

commit 2bd139ef9e2c3bc067cbcd0f5dd893c95d354766
parent cda0a68854d8a3d8c284d7814aafd0da6e22dc3d
Author: kernelkind <kernelkind@gmail.com>
Date:   Thu, 24 Jul 2025 09:48:49 -0600

use `DragSwitch` to allow dragging anywhere in navigation

instead of just the top header when there is a vertical scroll

Signed-off-by: kernelkind <kernelkind@gmail.com>

Diffstat:
Mcrates/notedeck_columns/src/nav.rs | 118++++++++++++++++++++++++++++++++++++++++++++++++++++++-------------------------
1 file changed, 81 insertions(+), 37 deletions(-)

diff --git a/crates/notedeck_columns/src/nav.rs b/crates/notedeck_columns/src/nav.rs @@ -4,6 +4,7 @@ use crate::{ column::ColumnsAction, deck_state::DeckState, decks::{Deck, DecksAction, DecksCache}, + drag::{get_drag_id, get_drag_id_through_frame}, options::AppOptions, profile::{ProfileAction, SaveProfileChanges}, route::{Route, Router, SingletonRouter}, @@ -954,47 +955,90 @@ pub fn render_nav( } }; - let nav_response = Nav::new( - &app.columns(ctx.accounts) - .column(col) - .router() - .routes() - .clone(), - ) - .navigating( - app.columns_mut(ctx.i18n, ctx.accounts) - .column_mut(col) - .router_mut() - .navigating, - ) - .returning( - app.columns_mut(ctx.i18n, ctx.accounts) - .column_mut(col) - .router_mut() - .returning, - ) - .id_source(egui::Id::new(("nav", col))) - .show_mut(ui, |ui, render_type, nav| match render_type { - NavUiType::Title => NavTitle::new( - ctx.ndb, - ctx.img_cache, - get_active_columns_mut(ctx.i18n, ctx.accounts, &mut app.decks_cache), - nav.routes(), + let routes = app + .columns(ctx.accounts) + .column(col) + .router() + .routes() + .clone(); + let nav = Nav::new(&routes).id_source(egui::Id::new(("nav", col))); + + let drag_ids = 's: { + let Some(top_route) = &routes.last().cloned() else { + break 's None; + }; + + let Some(scroll_id) = get_scroll_id( + top_route, + app.columns(ctx.accounts) + .column(col) + .router() + .routes() + .len(), + &app.timeline_cache, col, - ctx.i18n, + ) else { + break 's None; + }; + + let vertical_drag_id = if route_uses_frame(top_route) { + get_drag_id_through_frame(ui, scroll_id) + } else { + get_drag_id(ui, scroll_id) + }; + + let horizontal_drag_id = nav.drag_id(ui); + + let drag = &mut get_active_columns_mut(ctx.i18n, ctx.accounts, &mut app.decks_cache) + .column_mut(col) + .drag; + + drag.update(horizontal_drag_id, vertical_drag_id, ui.ctx()); + + Some((horizontal_drag_id, vertical_drag_id)) + }; + + let nav_response = nav + .navigating( + app.columns_mut(ctx.i18n, ctx.accounts) + .column_mut(col) + .router_mut() + .navigating, + ) + .returning( + app.columns_mut(ctx.i18n, ctx.accounts) + .column_mut(col) + .router_mut() + .returning, ) - .show_move_button(!narrow) - .show_delete_button(!narrow) - .show(ui), + .show_mut(ui, |ui, render_type, nav| match render_type { + NavUiType::Title => NavTitle::new( + ctx.ndb, + ctx.img_cache, + get_active_columns_mut(ctx.i18n, ctx.accounts, &mut app.decks_cache), + nav.routes(), + col, + ctx.i18n, + ) + .show_move_button(!narrow) + .show_delete_button(!narrow) + .show(ui), - NavUiType::Body => { - if let Some(top) = nav.routes().last() { - render_nav_body(ui, app, ctx, top, nav.routes().len(), col, inner_rect) - } else { - None + NavUiType::Body => { + if let Some(top) = nav.routes().last() { + render_nav_body(ui, app, ctx, top, nav.routes().len(), col, inner_rect) + } else { + None + } } - } - }); + }); + + if let Some((horizontal_drag_id, vertical_drag_id)) = drag_ids { + let drag = &mut get_active_columns_mut(ctx.i18n, ctx.accounts, &mut app.decks_cache) + .column_mut(col) + .drag; + drag.check_for_drag_start(ui.ctx(), horizontal_drag_id, vertical_drag_id); + } RenderNavResponse::new(col, NotedeckNavResponse::Nav(Box::new(nav_response))) }