supply inner_rect for PostView

Signed-off-by: kernelkind <kernelkind@gmail.com>
This commit is contained in:
kernelkind
2025-02-02 16:52:10 -05:00
parent 8c49e6e5f6
commit c1c4c1cc7a
5 changed files with 29 additions and 8 deletions

View File

@@ -500,7 +500,8 @@ fn render_damus_mobile(app: &mut Damus, app_ctx: &mut AppContext<'_>, ui: &mut e
//let routes = app.timelines[0].routes.clone(); //let routes = app.timelines[0].routes.clone();
if !app.columns(app_ctx.accounts).columns().is_empty() if !app.columns(app_ctx.accounts).columns().is_empty()
&& nav::render_nav(0, app, app_ctx, ui).process_render_nav_response(app, app_ctx) && nav::render_nav(0, ui.available_rect_before_wrap(), app, app_ctx, ui)
.process_render_nav_response(app, app_ctx)
&& !app.tmp_columns && !app.tmp_columns
{ {
storage::save_decks_cache(app_ctx.path, &app.decks_cache); storage::save_decks_cache(app_ctx.path, &app.decks_cache);
@@ -584,14 +585,17 @@ fn timelines_view(ui: &mut egui::Ui, sizes: Size, app: &mut Damus, ctx: &mut App
for col_index in 0..num_cols { for col_index in 0..num_cols {
strip.cell(|ui| { strip.cell(|ui| {
let rect = ui.available_rect_before_wrap(); let rect = ui.available_rect_before_wrap();
responses.push(nav::render_nav(col_index, app, ctx, ui)); let v_line_stroke = ui.visuals().widgets.noninteractive.bg_stroke;
let inner_rect = {
let mut inner = rect;
inner.set_right(rect.right() - v_line_stroke.width);
inner
};
responses.push(nav::render_nav(col_index, inner_rect, app, ctx, ui));
// vertical line // vertical line
ui.painter().vline( ui.painter()
rect.right(), .vline(rect.right(), rect.y_range(), v_line_stroke);
rect.y_range(),
ui.visuals().widgets.noninteractive.bg_stroke,
);
}); });
//strip.cell(|ui| timeline::timeline_view(ui, app, timeline_ind)); //strip.cell(|ui| timeline::timeline_view(ui, app, timeline_ind));

View File

@@ -241,6 +241,7 @@ fn render_nav_body(
top: &Route, top: &Route,
depth: usize, depth: usize,
col: usize, col: usize,
inner_rect: egui::Rect,
) -> Option<RenderNavAction> { ) -> Option<RenderNavAction> {
match top { match top {
Route::Timeline(kind) => render_timeline_route( Route::Timeline(kind) => render_timeline_route(
@@ -308,6 +309,7 @@ fn render_nav_body(
ctx.note_cache, ctx.note_cache,
ctx.img_cache, ctx.img_cache,
&note, &note,
inner_rect,
) )
.id_source(id) .id_source(id)
.show(ui) .show(ui)
@@ -342,6 +344,7 @@ fn render_nav_body(
ctx.img_cache, ctx.img_cache,
draft, draft,
&note, &note,
inner_rect,
) )
.id_source(id) .id_source(id)
.show(ui) .show(ui)
@@ -362,6 +365,7 @@ fn render_nav_body(
ctx.img_cache, ctx.img_cache,
ctx.note_cache, ctx.note_cache,
kp, kp,
inner_rect,
) )
.ui(&txn, ui); .ui(&txn, ui);
@@ -473,6 +477,7 @@ fn render_nav_body(
#[must_use = "RenderNavResponse must be handled by calling .process_render_nav_response(..)"] #[must_use = "RenderNavResponse must be handled by calling .process_render_nav_response(..)"]
pub fn render_nav( pub fn render_nav(
col: usize, col: usize,
inner_rect: egui::Rect,
app: &mut Damus, app: &mut Damus,
ctx: &mut AppContext<'_>, ctx: &mut AppContext<'_>,
ui: &mut egui::Ui, ui: &mut egui::Ui,
@@ -508,7 +513,7 @@ pub fn render_nav(
.show(ui), .show(ui),
NavUiType::Body => { NavUiType::Body => {
if let Some(top) = nav.routes().last() { if let Some(top) = nav.routes().last() {
render_nav_body(ui, app, ctx, top, nav.routes().len(), col) render_nav_body(ui, app, ctx, top, nav.routes().len(), col, inner_rect)
} else { } else {
None None
} }

View File

@@ -22,6 +22,7 @@ pub struct PostView<'a> {
note_cache: &'a mut NoteCache, note_cache: &'a mut NoteCache,
poster: FilledKeypair<'a>, poster: FilledKeypair<'a>,
id_source: Option<egui::Id>, id_source: Option<egui::Id>,
inner_rect: egui::Rect,
} }
#[derive(Clone)] #[derive(Clone)]
@@ -84,6 +85,7 @@ impl<'a> PostView<'a> {
img_cache: &'a mut ImageCache, img_cache: &'a mut ImageCache,
note_cache: &'a mut NoteCache, note_cache: &'a mut NoteCache,
poster: FilledKeypair<'a>, poster: FilledKeypair<'a>,
inner_rect: egui::Rect,
) -> Self { ) -> Self {
let id_source: Option<egui::Id> = None; let id_source: Option<egui::Id> = None;
PostView { PostView {
@@ -94,6 +96,7 @@ impl<'a> PostView<'a> {
poster, poster,
id_source, id_source,
post_type, post_type,
inner_rect,
} }
} }
@@ -535,6 +538,7 @@ mod preview {
app.img_cache, app.img_cache,
app.note_cache, app.note_cache,
self.poster.to_filled(), self.poster.to_filled(),
ui.available_rect_before_wrap(),
) )
.ui(&txn, ui); .ui(&txn, ui);
} }

View File

@@ -14,6 +14,7 @@ pub struct QuoteRepostView<'a> {
draft: &'a mut Draft, draft: &'a mut Draft,
quoting_note: &'a nostrdb::Note<'a>, quoting_note: &'a nostrdb::Note<'a>,
id_source: Option<egui::Id>, id_source: Option<egui::Id>,
inner_rect: egui::Rect,
} }
impl<'a> QuoteRepostView<'a> { impl<'a> QuoteRepostView<'a> {
@@ -24,6 +25,7 @@ impl<'a> QuoteRepostView<'a> {
img_cache: &'a mut ImageCache, img_cache: &'a mut ImageCache,
draft: &'a mut Draft, draft: &'a mut Draft,
quoting_note: &'a nostrdb::Note<'a>, quoting_note: &'a nostrdb::Note<'a>,
inner_rect: egui::Rect,
) -> Self { ) -> Self {
let id_source: Option<egui::Id> = None; let id_source: Option<egui::Id> = None;
QuoteRepostView { QuoteRepostView {
@@ -34,6 +36,7 @@ impl<'a> QuoteRepostView<'a> {
draft, draft,
quoting_note, quoting_note,
id_source, id_source,
inner_rect,
} }
} }
@@ -48,6 +51,7 @@ impl<'a> QuoteRepostView<'a> {
self.img_cache, self.img_cache,
self.note_cache, self.note_cache,
self.poster, self.poster,
self.inner_rect,
) )
.id_source(id) .id_source(id)
.ui(self.quoting_note.txn().unwrap(), ui) .ui(self.quoting_note.txn().unwrap(), ui)

View File

@@ -14,6 +14,7 @@ pub struct PostReplyView<'a> {
draft: &'a mut Draft, draft: &'a mut Draft,
note: &'a nostrdb::Note<'a>, note: &'a nostrdb::Note<'a>,
id_source: Option<egui::Id>, id_source: Option<egui::Id>,
inner_rect: egui::Rect,
} }
impl<'a> PostReplyView<'a> { impl<'a> PostReplyView<'a> {
@@ -24,6 +25,7 @@ impl<'a> PostReplyView<'a> {
note_cache: &'a mut NoteCache, note_cache: &'a mut NoteCache,
img_cache: &'a mut ImageCache, img_cache: &'a mut ImageCache,
note: &'a nostrdb::Note<'a>, note: &'a nostrdb::Note<'a>,
inner_rect: egui::Rect,
) -> Self { ) -> Self {
let id_source: Option<egui::Id> = None; let id_source: Option<egui::Id> = None;
PostReplyView { PostReplyView {
@@ -34,6 +36,7 @@ impl<'a> PostReplyView<'a> {
note_cache, note_cache,
img_cache, img_cache,
id_source, id_source,
inner_rect,
} }
} }
@@ -83,6 +86,7 @@ impl<'a> PostReplyView<'a> {
self.img_cache, self.img_cache,
self.note_cache, self.note_cache,
self.poster, self.poster,
self.inner_rect,
) )
.id_source(id) .id_source(id)
.ui(self.note.txn().unwrap(), ui) .ui(self.note.txn().unwrap(), ui)