notedeck

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

commit 443d356cc7ece87e17f04503490d6d5187ff1c9a
parent a714bef690d8bf6906646579e23f2e1dd1914721
Author: William Casarin <jb55@jb55.com>
Date:   Tue, 15 Jul 2025 08:26:53 -0700

ui/column: remove move/remove column buttons on narrow

It doesn't make sense to move columns in narrow mode

Fixes: https://github.com/damus-io/notedeck/issues/960
Signed-off-by: William Casarin <jb55@jb55.com>

Diffstat:
Mcrates/notedeck_columns/src/nav.rs | 7+++++++
Mcrates/notedeck_columns/src/ui/column/header.rs | 47+++++++++++++++++++++++++++++++++++++++++++++--
2 files changed, 52 insertions(+), 2 deletions(-)

diff --git a/crates/notedeck_columns/src/nav.rs b/crates/notedeck_columns/src/nav.rs @@ -788,6 +788,8 @@ pub fn render_nav( ctx: &mut AppContext<'_>, ui: &mut egui::Ui, ) -> RenderNavResponse { + let narrow = is_narrow(ui.ctx()); + if let Some(sheet_route) = app .columns(ctx.accounts) .column(col) @@ -822,6 +824,8 @@ pub fn render_nav( &[route.clone()], col, ) + .show_move_button(!narrow) + .show_delete_button(!narrow) .show(ui), NavUiType::Body => render_nav_body(ui, app, ctx, route, 1, col, inner_rect), }); @@ -858,7 +862,10 @@ pub fn render_nav( nav.routes(), col, ) + .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) diff --git a/crates/notedeck_columns/src/ui/column/header.rs b/crates/notedeck_columns/src/ui/column/header.rs @@ -25,9 +25,14 @@ pub struct NavTitle<'a> { columns: &'a Columns, routes: &'a [Route], col_id: usize, + options: u32, } impl<'a> NavTitle<'a> { + // options + const SHOW_MOVE: u32 = 1 << 0; + const SHOW_DELETE: u32 = 1 << 1; + pub fn new( ndb: &'a Ndb, img_cache: &'a mut Images, @@ -35,12 +40,14 @@ impl<'a> NavTitle<'a> { routes: &'a [Route], col_id: usize, ) -> Self { + let options = Self::SHOW_MOVE | Self::SHOW_DELETE; NavTitle { ndb, img_cache, columns, routes, col_id, + options, } } @@ -519,6 +526,34 @@ impl<'a> NavTitle<'a> { }; } + pub fn show_move_button(&mut self, enable: bool) -> &mut Self { + if enable { + self.options |= Self::SHOW_MOVE; + } else { + self.options &= !Self::SHOW_MOVE; + } + + self + } + + pub fn show_delete_button(&mut self, enable: bool) -> &mut Self { + if enable { + self.options |= Self::SHOW_DELETE; + } else { + self.options &= !Self::SHOW_DELETE; + } + + self + } + + fn should_show_move_button(&self) -> bool { + (self.options & Self::SHOW_MOVE) == Self::SHOW_MOVE + } + + fn should_show_delete_button(&self) -> bool { + (self.options & Self::SHOW_DELETE) == Self::SHOW_DELETE + } + fn title(&mut self, ui: &mut egui::Ui, top: &Route, navigating: bool) -> Option<TitleResponse> { let title_r = if !navigating { self.title_presentation(ui, top, 32.0) @@ -530,8 +565,16 @@ impl<'a> NavTitle<'a> { if navigating { self.title_presentation(ui, top, 32.0) } else { - let move_col = self.move_button_section(ui); - let remove_col = self.delete_button_section(ui); + let mut move_col: Option<usize> = None; + let mut remove_col = false; + + if self.should_show_move_button() { + move_col = self.move_button_section(ui); + } + if self.should_show_delete_button() { + remove_col = self.delete_button_section(ui); + } + if let Some(col) = move_col { Some(TitleResponse::MoveColumn(col)) } else if remove_col {