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

View file

@ -79,19 +79,11 @@ impl NetworkContent {
.resizable(false)
.exact_width(ui.available_width())
.frame(egui::Frame {
outer_margin: if !show_connections {
Margin {
left: -0.5,
right: if !dual_panel {
-0.5
} else {
0.0
},
top: 0.0,
bottom: 0.0,
}
} else {
Margin::ZERO
outer_margin: Margin {
left: -0.5,
right: -0.5,
top: 0.0,
bottom: 0.0,
},
..Default::default()
})
@ -116,59 +108,61 @@ impl NetworkContent {
// Show connections content.
egui::CentralPanel::default()
.frame(egui::Frame {
stroke: View::item_stroke(),
outer_margin: if show_connections {
Margin {
left: -0.5,
right: if !dual_panel {
-0.5
} else {
0.0
},
right: -0.5,
top: 0.0,
bottom: -0.5,
}
} else {
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()
})
.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
egui::CentralPanel::default()
.frame(egui::Frame {
stroke: View::item_stroke(),
inner_margin: Margin {
left: if show_connections {
View::get_left_inset() + 4.0
} else {
ui.available_width()
};
View::max_width_ui(ui, max_width, |ui| {
self.connections.ui(ui, cb);
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::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);
// Show network content.
if is_panel_open {
egui::SidePanel::left("network_panel")
.resizable(false)
.exact_width(panel_width)
.frame(egui::Frame {
fill: Colors::fill(),
..Default::default()
})
.show_inside(ui, |ui| {
self.network.ui(ui, cb);
});
}
egui::SidePanel::left("network_panel")
.resizable(false)
.exact_width(panel_width)
.frame(egui::Frame {
..Default::default()
})
.show_animated_inside(ui, is_panel_open, |ui| {
self.network.ui(ui, cb);
});
// Show wallets content.
egui::CentralPanel::default()
.frame(egui::Frame {
fill: Colors::fill(),
..Default::default()
})
.show_inside(ui, |ui| {

View file

@ -206,20 +206,6 @@ impl WalletsContent {
egui::Frame::default()
} else {
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(),
fill: Colors::fill_deep(),
inner_margin: Margin {
@ -228,6 +214,16 @@ impl WalletsContent {
top: 3.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()
}
})

View file

@ -79,20 +79,6 @@ impl WalletCreation {
top: 4.0,
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()
})
.show_inside(ui, |ui| {

View file

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

View file

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