notedeck

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

commit 51d2b4414b7b6c243dcb4a5b8b91b76abdccbb94
parent c0c2120f746e9d620536b00828d4d48e9d37452d
Author: William Casarin <jb55@jb55.com>
Date:   Thu, 17 Jul 2025 09:36:46 -0700

ui/note: refactor reply line into a function

this is a bit neater

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

Diffstat:
Mcrates/notedeck_columns/src/ui/note/reply.rs | 90++++++++++++++++++++++++++++++++++++++++++++++---------------------------------
1 file changed, 52 insertions(+), 38 deletions(-)

diff --git a/crates/notedeck_columns/src/ui/note/reply.rs b/crates/notedeck_columns/src/ui/note/reply.rs @@ -4,6 +4,7 @@ use crate::ui::{ note::{PostAction, PostResponse, PostType}, }; +use egui::{Rect, Response, Ui}; use enostr::{FilledKeypair, NoteId}; use notedeck::NoteContext; use notedeck_ui::jobs::JobsCache; @@ -102,44 +103,12 @@ impl<'a, 'd> PostReplyView<'a, 'd> { .action .or(quoted_note.action.map(PostAction::QuotedNoteAction)); - // - // reply line - // - - // Position and draw the reply line - let mut rect = ui.min_rect(); - - // Position the line right above the poster's profile pic in - // the post box. Use the PostView's margin values to - // determine this offset. - rect.min.x = avail_rect.min.x + pfp_offset as f32; - - // honestly don't know what the fuck I'm doing here. just trying - // to get the line under the profile picture - rect.min.y = avail_rect.min.y - + (ProfilePic::medium_size() as f32 / 2.0 - + ProfilePic::medium_size() as f32 - + NoteView::expand_size() as f32 * 2.0) - + 1.0; - - // For some reason we need to nudge the reply line's height a - // few more pixels? - let nudge = if post_response.edit_response.has_focus() { - // we nudge by one less pixel if focused, otherwise it - // overlaps the focused PostView purple border color - 2.0 - } else { - // we have to nudge by one more pixel when not focused - // otherwise it looks like there's a gap(?) - 3.0 - }; - - rect.max.y = rect_before_post.max.y + ui::PostView::outer_margin() as f32 + nudge; - - ui.painter().vline( - rect.left(), - rect.y_range(), - ui.visuals().widgets.noninteractive.bg_stroke, + reply_line_ui( + &rect_before_post, + &post_response.edit_response, + pfp_offset as f32, + &avail_rect, + ui, ); post_response @@ -147,3 +116,48 @@ impl<'a, 'd> PostReplyView<'a, 'd> { .inner } } + +/// The vertical line in the reply view +fn reply_line_ui( + rect_before_post: &Rect, + edit_response: &Response, + pfp_offset: f32, + avail_rect: &Rect, + ui: &mut Ui, +) { + // Position and draw the reply line + let mut rect = ui.min_rect(); + + // Position the line right above the poster's profile pic in + // the post box. Use the PostView's margin values to + // determine this offset. + rect.min.x = avail_rect.min.x + pfp_offset; + + // honestly don't know what the fuck I'm doing here. just trying + // to get the line under the profile picture + rect.min.y = avail_rect.min.y + + (ProfilePic::medium_size() as f32 / 2.0 + + ProfilePic::medium_size() as f32 + + NoteView::expand_size() as f32 * 2.0) + + 1.0; + + // For some reason we need to nudge the reply line's height a + // few more pixels? + let nudge = if edit_response.has_focus() { + // we nudge by one less pixel if focused, otherwise it + // overlaps the focused PostView purple border color + 2.0 + } else { + // we have to nudge by one more pixel when not focused + // otherwise it looks like there's a gap(?) + 3.0 + }; + + rect.max.y = rect_before_post.max.y + ui::PostView::outer_margin() as f32 + nudge; + + ui.painter().vline( + rect.left(), + rect.y_range(), + ui.visuals().widgets.noninteractive.bg_stroke, + ); +}