notedeck

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

commit 83100d7f5078af61a461ead1a7a1e33c047413c2
parent 6fc5eb27fc0f0fa1072206a902f87d1bc099d4d3
Author: William Casarin <jb55@jb55.com>
Date:   Thu, 23 May 2024 15:50:06 -0700

tabs: select notes & replies by default

Signed-off-by: William Casarin <jb55@jb55.com>

Diffstat:
MCargo.lock | 2+-
MCargo.toml | 2+-
Msrc/timeline.rs | 49+++++++++++++++++++++++++++----------------------
3 files changed, 29 insertions(+), 24 deletions(-)

diff --git a/Cargo.lock b/Cargo.lock @@ -1023,7 +1023,7 @@ dependencies = [ [[package]] name = "egui-tabs" version = "0.1.0" -source = "git+https://github.com/damus-io/egui-tabs?rev=ed97a57fc66b3781bc10ab644f9e1ed125d7377a#ed97a57fc66b3781bc10ab644f9e1ed125d7377a" +source = "git+https://github.com/damus-io/egui-tabs?rev=75f47141aebcf876986fad00dd83a69a7bb04840#75f47141aebcf876986fad00dd83a69a7bb04840" dependencies = [ "egui", "egui_extras", diff --git a/Cargo.toml b/Cargo.toml @@ -19,7 +19,7 @@ eframe = { version = "0.27.2", default-features = false, features = [ "glow", "w #eframe = "0.22.0" egui_extras = { version = "0.27.2", features = ["all_loaders"] } ehttp = "0.2.0" -egui-tabs = { git = "https://github.com/damus-io/egui-tabs", rev = "ed97a57fc66b3781bc10ab644f9e1ed125d7377a" } +egui-tabs = { git = "https://github.com/damus-io/egui-tabs", rev = "75f47141aebcf876986fad00dd83a69a7bb04840" } reqwest = { version = "0.12.4", default-features = false, features = [ "rustls-tls-native-roots" ] } image = { version = "0.24", features = ["jpeg", "png", "webp"] } poll-promise = { version = "0.3.0", features = ["tokio"] } diff --git a/src/timeline.rs b/src/timeline.rs @@ -179,6 +179,7 @@ fn tabs_ui(timeline: &mut Timeline, ui: &mut egui::Ui) { ui.spacing_mut().item_spacing.y = 0.0; let tab_res = egui_tabs::Tabs::new(2) + .selected(1) .hover_bg(TabColor::none()) .selected_fg(TabColor::none()) .selected_bg(TabColor::none()) @@ -210,37 +211,41 @@ fn tabs_ui(timeline: &mut Timeline, ui: &mut egui::Ui) { //ui.add_space(0.5); ui::hline(ui); + let sel = if let Some(sel) = tab_res.selected() { + sel + } else { + 0 + }; + // fun animation - if let Some(sel) = tab_res.selected() { - timeline.selected_view = sel; + timeline.selected_view = sel; - let (underline, underline_y) = tab_res.inner()[sel as usize].inner; - let underline_width = underline.span(); + let (underline, underline_y) = tab_res.inner()[sel as usize].inner; + let underline_width = underline.span(); - let tab_anim_id = ui.id().with("tab_anim"); - let tab_anim_size = tab_anim_id.with("size"); + let tab_anim_id = ui.id().with("tab_anim"); + let tab_anim_size = tab_anim_id.with("size"); - let stroke = egui::Stroke { - color: ui.visuals().hyperlink_color, - width: 3.0, - }; + let stroke = egui::Stroke { + color: ui.visuals().hyperlink_color, + width: 3.0, + }; - let speed = 0.1f32; + let speed = 0.1f32; - // animate underline position - let x = ui - .ctx() - .animate_value_with_time(tab_anim_id, underline.min, speed); + // animate underline position + let x = ui + .ctx() + .animate_value_with_time(tab_anim_id, underline.min, speed); - // animate underline width - let w = ui - .ctx() - .animate_value_with_time(tab_anim_size, underline_width, speed); + // animate underline width + let w = ui + .ctx() + .animate_value_with_time(tab_anim_size, underline_width, speed); - let underline = egui::Rangef::new(x, x + w); + let underline = egui::Rangef::new(x, x + w); - ui.painter().hline(underline, underline_y, stroke); - } + ui.painter().hline(underline, underline_y, stroke); } pub fn timeline_view(ui: &mut egui::Ui, app: &mut Damus, timeline: usize) {