commit 029896627cf83c0ea1dec1d618500c4ddebbe8f8
parent bc5ff4858fdf3f333c87547b9bb4a2981a100a2f
Author: William Casarin <jb55@jb55.com>
Date: Wed, 15 May 2024 15:26:19 -0700
ui: add feathering-resistant hline separator fn
"pixel-aligned" Separators get feathered into a blurry mess. This seems
to help.
Signed-off-by: William Casarin <jb55@jb55.com>
Diffstat:
2 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/src/timeline.rs b/src/timeline.rs
@@ -99,7 +99,8 @@ pub fn timeline_view(ui: &mut egui::Ui, app: &mut Damus, timeline: usize) {
let textmode = app.textmode;
let note_ui = ui::Note::new(app, ¬e).note_previews(!textmode);
ui.add(note_ui);
- ui.add(egui::Separator::default().spacing(0.0));
+ ui::hline(ui);
+ //ui.add(egui::Separator::default().spacing(0.0));
1
});
diff --git a/src/ui/mod.rs b/src/ui/mod.rs
@@ -39,6 +39,14 @@ pub fn padding<R>(
.show(ui, add_contents)
}
+pub fn hline(ui: &egui::Ui) {
+ // pixel perfect horizontal line
+ let rect = ui.available_rect_before_wrap();
+ let resize_y = ui.painter().round_to_pixel(rect.top()) - 0.5;
+ let stroke = ui.style().visuals.widgets.noninteractive.bg_stroke;
+ ui.painter().hline(rect.x_range(), resize_y, stroke);
+}
+
#[inline]
#[allow(unreachable_code)]
pub fn is_mobile(_ctx: &egui::Context) -> bool {