ui: content paddings, background, glow renderer on windows to fix transparency

This commit is contained in:
ardocrat 2024-07-01 11:50:19 +03:00
parent 518b8e65d1
commit f2a23ec0e0
7 changed files with 88 additions and 110 deletions

View file

@ -105,7 +105,7 @@ impl<Platform: PlatformCallbacks> App<Platform> {
sw: 0.0, sw: 0.0,
se: 0.0, se: 0.0,
}, },
fill: Colors::TRANSPARENT, fill: Colors::yellow(),
stroke: Stroke { stroke: Stroke {
width: 1.0, width: 1.0,
color: egui::Color32::from_gray(200) color: egui::Color32::from_gray(200)
@ -126,7 +126,7 @@ impl<Platform: PlatformCallbacks> App<Platform> {
let content_stroke = RectShape { let content_stroke = RectShape {
rect: content_stroke_rect, rect: content_stroke_rect,
rounding: Rounding::ZERO, rounding: Rounding::ZERO,
fill: Colors::TRANSPARENT, fill: Colors::fill(),
stroke: Stroke { stroke: Stroke {
width: 1.0, width: 1.0,
color: Colors::stroke() color: Colors::stroke()

View file

@ -79,19 +79,11 @@ impl NetworkContent {
.resizable(false) .resizable(false)
.exact_width(ui.available_width()) .exact_width(ui.available_width())
.frame(egui::Frame { .frame(egui::Frame {
outer_margin: if !show_connections { outer_margin: Margin {
Margin { left: -0.5,
left: -0.5, right: -0.5,
right: if !dual_panel { top: 0.0,
-0.5 bottom: 0.0,
} else {
0.0
},
top: 0.0,
bottom: 0.0,
}
} else {
Margin::ZERO
}, },
..Default::default() ..Default::default()
}) })
@ -116,59 +108,61 @@ impl NetworkContent {
// Show connections content. // Show connections content.
egui::CentralPanel::default() egui::CentralPanel::default()
.frame(egui::Frame { .frame(egui::Frame {
stroke: View::item_stroke(),
outer_margin: if show_connections { outer_margin: if show_connections {
Margin { Margin {
left: -0.5, left: -0.5,
right: if !dual_panel { right: -0.5,
-0.5
} else {
0.0
},
top: 0.0, top: 0.0,
bottom: -0.5, bottom: -0.5,
} }
} else { } else {
Margin::ZERO Margin::ZERO
}, },
inner_margin: Margin {
left: if show_connections {
View::get_left_inset() + 4.0
} else {
0.0
},
right: if show_connections {
View::far_right_inset_margin(ui) + 4.0
} else {
0.0
},
top: 3.0,
bottom: if View::is_desktop() && show_connections {
6.0
} else {
4.0
},
},
fill: Colors::button(),
..Default::default() ..Default::default()
}) })
.show_inside(ui, |ui| { .show_inside(ui, |ui| {
ScrollArea::vertical() egui::CentralPanel::default()
.id_source("connections_content") .frame(egui::Frame {
.scroll_bar_visibility(ScrollBarVisibility::AlwaysHidden) stroke: View::item_stroke(),
.auto_shrink([false; 2]) inner_margin: Margin {
.show(ui, |ui| { left: if show_connections {
ui.add_space(1.0); View::get_left_inset() + 4.0
ui.vertical_centered(|ui| {
let max_width = if !dual_panel {
Root::SIDE_PANEL_WIDTH * 1.3
} else { } else {
ui.available_width() 0.0
}; },
View::max_width_ui(ui, max_width, |ui| { right: if show_connections {
self.connections.ui(ui, cb); View::far_right_inset_margin(ui) + 4.0
} else {
0.0
},
top: 3.0,
bottom: if View::is_desktop() && show_connections {
6.0
} else {
4.0
},
},
fill: Colors::fill(),
..Default::default()
})
.show_inside(ui, |ui| {
ScrollArea::vertical()
.id_source("connections_content")
.scroll_bar_visibility(ScrollBarVisibility::AlwaysHidden)
.auto_shrink([false; 2])
.show(ui, |ui| {
ui.add_space(1.0);
ui.vertical_centered(|ui| {
let max_width = if !dual_panel {
Root::SIDE_PANEL_WIDTH * 1.3
} else {
ui.available_width()
};
View::max_width_ui(ui, max_width, |ui| {
self.connections.ui(ui, cb);
});
});
}); });
});
}); });
}); });

View file

@ -111,23 +111,19 @@ impl Root {
let (is_panel_open, panel_width) = Self::network_panel_state_width(ui, dual_panel); let (is_panel_open, panel_width) = Self::network_panel_state_width(ui, dual_panel);
// Show network content. // Show network content.
if is_panel_open { egui::SidePanel::left("network_panel")
egui::SidePanel::left("network_panel") .resizable(false)
.resizable(false) .exact_width(panel_width)
.exact_width(panel_width) .frame(egui::Frame {
.frame(egui::Frame { ..Default::default()
fill: Colors::fill(), })
..Default::default() .show_animated_inside(ui, is_panel_open, |ui| {
}) self.network.ui(ui, cb);
.show_inside(ui, |ui| { });
self.network.ui(ui, cb);
});
}
// Show wallets content. // Show wallets content.
egui::CentralPanel::default() egui::CentralPanel::default()
.frame(egui::Frame { .frame(egui::Frame {
fill: Colors::fill(),
..Default::default() ..Default::default()
}) })
.show_inside(ui, |ui| { .show_inside(ui, |ui| {

View file

@ -206,20 +206,6 @@ impl WalletsContent {
egui::Frame::default() egui::Frame::default()
} else { } else {
egui::Frame { egui::Frame {
outer_margin: Margin {
left: if !root_dual_panel {
-0.5
} else {
0.0
},
right: if !wallet_panel_opened {
-0.5
} else {
0.0
},
top: 0.0,
bottom: 0.0,
},
stroke: View::item_stroke(), stroke: View::item_stroke(),
fill: Colors::fill_deep(), fill: Colors::fill_deep(),
inner_margin: Margin { inner_margin: Margin {
@ -228,6 +214,16 @@ impl WalletsContent {
top: 3.0, top: 3.0,
bottom: 4.0, bottom: 4.0,
}, },
outer_margin: Margin {
left: 0.0,
right: if !wallet_panel_opened {
-0.5
} else {
0.0
},
top: 0.0,
bottom: 0.0,
},
..Default::default() ..Default::default()
} }
}) })

View file

@ -79,20 +79,6 @@ impl WalletCreation {
top: 4.0, top: 4.0,
bottom: View::get_bottom_inset(), bottom: View::get_bottom_inset(),
}, },
outer_margin: if View::is_desktop() {
Margin {
left: if !Root::is_dual_panel_mode(ui) {
-0.5
} else {
0.0
},
right: -0.5,
top: 0.0,
bottom: -0.5,
}
} else {
Margin::ZERO
},
..Default::default() ..Default::default()
}) })
.show_inside(ui, |ui| { .show_inside(ui, |ui| {

View file

@ -103,11 +103,7 @@ impl WalletContent {
bottom: 0.0, bottom: 0.0,
}, },
outer_margin: Margin { outer_margin: Margin {
left: if !dual_panel { left: -0.5,
-0.5
} else {
0.0
},
right: -0.5, right: -0.5,
top: 0.0, top: 0.0,
bottom: if dual_panel { bottom: if dual_panel {
@ -156,11 +152,7 @@ impl WalletContent {
egui::CentralPanel::default() egui::CentralPanel::default()
.frame(egui::Frame { .frame(egui::Frame {
outer_margin: Margin { outer_margin: Margin {
left: if !dual_panel { left: -0.5,
-0.5
} else {
0.0
},
right: -0.5, right: -0.5,
top: 0.0, top: 0.0,
bottom: 0.0, bottom: 0.0,

View file

@ -12,6 +12,10 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
#![windows_subsystem = "windows"]
use egui::os::OperatingSystem;
pub fn main() { pub fn main() {
#[allow(dead_code)] #[allow(dead_code)]
#[cfg(not(target_os = "android"))] #[cfg(not(target_os = "android"))]
@ -74,17 +78,27 @@ fn real_main() {
viewport, viewport,
..Default::default() ..Default::default()
}; };
options.renderer = eframe::Renderer::Wgpu;
// Use Glow renderer for Windows.
let is_windows = OperatingSystem::from_target_os() == OperatingSystem::Windows;
options.renderer = if is_windows {
eframe::Renderer::Glow
} else {
eframe::Renderer::Wgpu
};
match grim::start(options.clone(), grim::app_creator(App::new(platform.clone()))) { match grim::start(options.clone(), grim::app_creator(App::new(platform.clone()))) {
Ok(_) => {} Ok(_) => {}
Err(_) => { Err(e) => {
// Start with Glow renderer on error. if is_windows {
panic!("{}", e);
}
// Start with another renderer on error.
options.renderer = eframe::Renderer::Glow; options.renderer = eframe::Renderer::Glow;
match grim::start(options, grim::app_creator(App::new(platform))) { match grim::start(options, grim::app_creator(App::new(platform))) {
Ok(_) => {} Ok(_) => {}
Err(_) => { Err(e) => {
panic!("Impossible to render"); panic!("{}", e);
} }
} }
} }