notedeck

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

commit 49ef85aef60ac93bcc147c354d769e85cfd4cfb1
parent 29f59459d2dba675a44417c6dcfd8c23db2b76c4
Author: kernelkind <kernelkind@gmail.com>
Date:   Wed, 13 Aug 2025 19:09:41 -0400

copy toolbar rendering to `notedeck_ui`

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

Diffstat:
Mcrates/notedeck_columns/src/ui/mod.rs | 1+
Acrates/notedeck_columns/src/ui/toolbar.rs | 66++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 67 insertions(+), 0 deletions(-)

diff --git a/crates/notedeck_columns/src/ui/mod.rs b/crates/notedeck_columns/src/ui/mod.rs @@ -17,6 +17,7 @@ pub mod side_panel; pub mod support; pub mod thread; pub mod timeline; +pub mod toolbar; pub mod wallet; pub mod widgets; diff --git a/crates/notedeck_columns/src/ui/toolbar.rs b/crates/notedeck_columns/src/ui/toolbar.rs @@ -0,0 +1,66 @@ +use egui::{Color32, Layout}; +use notedeck_ui::icons::{home_button, notifications_button}; + +use crate::{toolbar::ToolbarAction, ui::side_panel::search_button_impl, Damus}; + +pub fn toolbar(ui: &mut egui::Ui, unseen_notification: bool) -> Option<ToolbarAction> { + use egui_tabs::{TabColor, Tabs}; + + let rect = ui.available_rect_before_wrap(); + ui.painter().hline( + rect.x_range(), + rect.top(), + ui.visuals().widgets.noninteractive.bg_stroke, + ); + + if !ui.visuals().dark_mode { + ui.painter().rect( + rect, + 0, + notedeck_ui::colors::ALMOST_WHITE, + egui::Stroke::new(0.0, Color32::TRANSPARENT), + egui::StrokeKind::Inside, + ); + } + + let rs = Tabs::new(3) + .selected(Damus::initially_selected_toolbar_index()) + .hover_bg(TabColor::none()) + .selected_fg(TabColor::none()) + .selected_bg(TabColor::none()) + .height(Damus::toolbar_height()) + .layout(Layout::centered_and_justified(egui::Direction::TopDown)) + .show(ui, |ui, state| { + let index = state.index(); + + let mut action: Option<ToolbarAction> = None; + + let btn_size: f32 = 20.0; + if index == 0 { + if home_button(ui, btn_size).clicked() { + action = Some(ToolbarAction::Home); + } + } else if index == 1 + && ui + .add(search_button_impl(ui.visuals().text_color(), 2.0)) + .clicked() + { + action = Some(ToolbarAction::Search) + } else if index == 2 + && notifications_button(ui, btn_size, unseen_notification).clicked() + { + action = Some(ToolbarAction::Notifications); + } + + action + }) + .inner(); + + for maybe_r in rs { + if maybe_r.inner.is_some() { + return maybe_r.inner; + } + } + + None +}