From 2745a1be8b9454f2730b60d0d7dddf6c17ff6bee Mon Sep 17 00:00:00 2001 From: William Casarin Date: Mon, 18 Dec 2023 07:57:35 -0800 Subject: [PATCH] ui: move note ui to its own function it's a bit cleaner --- src/main.rs | 37 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/src/main.rs b/src/main.rs index e064a18..bebb116 100644 --- a/src/main.rs +++ b/src/main.rs @@ -44,30 +44,29 @@ fn nip19_target(nip19: &Nip19) -> Option { } } -fn render_note<'a>(_app_ctx: &Context, content: &'a str) -> Vec { +fn note_ui(ctx: &egui::Context, content: &str) { use egui::{FontId, RichText}; + + egui::CentralPanel::default().show(&ctx, |ui| { + ui.horizontal(|ui| { + ui.label(RichText::new("✏").font(FontId::proportional(120.0))); + ui.vertical(|ui| { + ui.label(RichText::new(content).font(FontId::proportional(40.0))); + }); + }) + }); +} + +fn render_note(_app_ctx: &Context, content: &str) -> Vec { use egui_skia::{rasterize, RasterizeOptions}; use skia_safe::EncodedImageFormat; - let mut surface = rasterize( - (1200, 630), - |ctx| { - //setup_fonts(&app_ctx.font_data, ctx); + let options = RasterizeOptions { + pixels_per_point: 1.0, + frames_before_screenshot: 1, + }; - egui::CentralPanel::default().show(&ctx, |ui| { - ui.horizontal(|ui| { - ui.label(RichText::new("✏").font(FontId::proportional(120.0))); - ui.vertical(|ui| { - ui.label(RichText::new(content).font(FontId::proportional(40.0))); - }); - }) - }); - }, - Some(RasterizeOptions { - pixels_per_point: 1.0, - frames_before_screenshot: 1, - }), - ); + let mut surface = rasterize((1200, 630), |ctx| note_ui(ctx, content), Some(options)); surface .image_snapshot()