From 7ab64da9ee9967853a0bb73987dc61d5cc39ae4e Mon Sep 17 00:00:00 2001 From: ardocrat Date: Fri, 21 Jun 2024 16:37:27 +0300 Subject: [PATCH] ui: window stroke for title panel, bottom padding and corners --- src/gui/app.rs | 31 ++++++++++++++++++++++--------- src/gui/views/network/content.rs | 2 ++ src/gui/views/root.rs | 2 ++ 3 files changed, 26 insertions(+), 9 deletions(-) diff --git a/src/gui/app.rs b/src/gui/app.rs index 5220615..d727a4a 100644 --- a/src/gui/app.rs +++ b/src/gui/app.rs @@ -83,6 +83,7 @@ impl App { } else { egui::CentralPanel::default() .frame(egui::Frame { + stroke: Stroke::NONE, ..Default::default() }) .show(ctx, |ui| { @@ -110,11 +111,9 @@ fn custom_window_frame(ctx: &Context, add_contents: impl FnOnce(&mut egui::Ui)) rounding: Rounding { nw: 8.0, ne: 8.0, - sw: 0.0, - se: 0.0, + sw: 8.0, + se: 8.0, }, - // stroke: ctx.style().visuals.widgets.noninteractive.fg_stroke, - // outer_margin: 0.5.into(), // so the stroke is within the bounds ..Default::default() }; @@ -130,7 +129,12 @@ fn custom_window_frame(ctx: &Context, add_contents: impl FnOnce(&mut egui::Ui)) let window_title_bg = RectShape { rect: window_title_rect, - rounding: panel_frame.rounding, + rounding: Rounding { + nw: 8.0, + ne: 8.0, + sw: 0.0, + se: 0.0, + }, fill: Colors::yellow_dark(), stroke: Stroke::NONE, fill_texture_id: Default::default(), @@ -157,6 +161,15 @@ fn custom_window_frame(ctx: &Context, add_contents: impl FnOnce(&mut egui::Ui)) }; let bg_idx = ui.painter().add(title_bar_bg); + // Draw line to support title panel. + ui.painter().line_segment( + [ + title_bar_rect.left_bottom() + egui::vec2(0.0, 0.5), + title_bar_rect.right_bottom() + egui::vec2(0.0, 0.5), + ], + View::item_stroke(), + ); + // Draw main content. let mut content_rect = { let mut rect = app_rect; @@ -164,17 +177,17 @@ fn custom_window_frame(ctx: &Context, add_contents: impl FnOnce(&mut egui::Ui)) rect }; content_rect.min += egui::emath::vec2(4.0, 0.0); - content_rect.max -= egui::emath::vec2(4.0, 4.0); + content_rect.max -= egui::emath::vec2(4.0, 2.0); let mut content_ui = ui.child_ui(content_rect, *ui.layout()); add_contents(&mut content_ui); - // Setup title bar background. + // Setup title panel background. ui.painter().set(bg_idx, title_bar_bg); }); } /// Draw custom window title content. -fn window_title_ui(ui: &mut egui::Ui, title_bar_rect: egui::epaint::Rect) { +fn window_title_ui(ui: &mut egui::Ui, title_bar_rect: Rect) { let painter = ui.painter(); let title_bar_response = ui.interact( @@ -192,7 +205,7 @@ fn window_title_ui(ui: &mut egui::Ui, title_bar_rect: egui::epaint::Rect) { egui::Color32::from_gray(60), ); - // Interact with the title bar (drag to move window): + // Interact with the window title (drag to move window): if title_bar_response.double_clicked() { let is_maximized = ui.input(|i| i.viewport().maximized.unwrap_or(false)); ui.ctx() diff --git a/src/gui/views/network/content.rs b/src/gui/views/network/content.rs index 446d9a4..d0bb517 100644 --- a/src/gui/views/network/content.rs +++ b/src/gui/views/network/content.rs @@ -55,6 +55,7 @@ impl NetworkContent { egui::TopBottomPanel::bottom("node_tabs_panel") .resizable(false) .frame(egui::Frame { + stroke: Stroke::NONE, fill: Colors::fill(), inner_margin: Margin { left: View::get_left_inset() + 4.0, @@ -82,6 +83,7 @@ impl NetworkContent { .resizable(false) .exact_width(ui.available_width()) .frame(egui::Frame { + stroke: Stroke::NONE, ..Default::default() }) .show_animated_inside(ui, !show_connections, |ui| { diff --git a/src/gui/views/root.rs b/src/gui/views/root.rs index 87c1233..8b65454 100644 --- a/src/gui/views/root.rs +++ b/src/gui/views/root.rs @@ -109,6 +109,7 @@ impl Root { .resizable(false) .exact_width(panel_width) .frame(egui::Frame { + stroke: egui::Stroke::NONE, fill: Colors::white_or_black(false), ..Default::default() }) @@ -119,6 +120,7 @@ impl Root { // Show wallets content. egui::CentralPanel::default() .frame(egui::Frame { + stroke: egui::Stroke::NONE, fill: Colors::fill_deep(), ..Default::default() })