ui: wgpu renderer for macos, desktop content background fix, do not show left line for camera content at dual panel mode
This commit is contained in:
parent
f9426287d5
commit
dcaf9945c8
4 changed files with 36 additions and 42 deletions
|
@ -14,7 +14,7 @@
|
||||||
|
|
||||||
use std::sync::atomic::{AtomicBool, Ordering};
|
use std::sync::atomic::{AtomicBool, Ordering};
|
||||||
use lazy_static::lazy_static;
|
use lazy_static::lazy_static;
|
||||||
use egui::{Align, Context, CursorIcon, Layout, Modifiers, Rect, ResizeDirection, Rounding, Stroke, UiBuilder, ViewportCommand};
|
use egui::{Align, Context, CursorIcon, Layout, Modifiers, ResizeDirection, Rounding, UiBuilder, ViewportCommand};
|
||||||
use egui::epaint::{RectShape};
|
use egui::epaint::{RectShape};
|
||||||
use egui::os::OperatingSystem;
|
use egui::os::OperatingSystem;
|
||||||
|
|
||||||
|
@ -138,35 +138,29 @@ impl<Platform: PlatformCallbacks> App<Platform> {
|
||||||
|
|
||||||
/// Draw mobile platform window content.
|
/// Draw mobile platform window content.
|
||||||
fn mobile_window_ui(&mut self, ui: &mut egui::Ui) {
|
fn mobile_window_ui(&mut self, ui: &mut egui::Ui) {
|
||||||
Self::title_panel_bg(ui, false);
|
Self::title_panel_bg(ui, true);
|
||||||
self.content.ui(ui, &self.platform);
|
self.content.ui(ui, &self.platform);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Draw desktop platform window content.
|
/// Draw desktop platform window content.
|
||||||
fn desktop_window_ui(&mut self, ui: &mut egui::Ui, is_fullscreen: bool) {
|
fn desktop_window_ui(&mut self, ui: &mut egui::Ui, is_fullscreen: bool) {
|
||||||
Self::title_panel_bg(ui, is_fullscreen);
|
Self::title_panel_bg(ui, is_fullscreen);
|
||||||
|
let rect = ui.max_rect();
|
||||||
|
|
||||||
let content_bg_rect = {
|
let content_bg_rect = {
|
||||||
let mut rect = ui.max_rect();
|
let mut r = rect.clone();
|
||||||
if !is_fullscreen {
|
if !is_fullscreen {
|
||||||
rect = rect.shrink(Content::WINDOW_FRAME_MARGIN);
|
r = r.shrink(Content::WINDOW_FRAME_MARGIN);
|
||||||
}
|
}
|
||||||
let top = Content::WINDOW_TITLE_HEIGHT + TitlePanel::HEIGHT + 0.5;
|
let top = Content::WINDOW_TITLE_HEIGHT + TitlePanel::HEIGHT + if !is_fullscreen {
|
||||||
rect.min += egui::vec2(0.0, top);
|
Content::WINDOW_FRAME_MARGIN
|
||||||
rect
|
} else {
|
||||||
};
|
0.0
|
||||||
let content_bg = RectShape {
|
};
|
||||||
rect: content_bg_rect,
|
r.min.y = top;
|
||||||
rounding: Rounding::ZERO,
|
r
|
||||||
fill: Colors::fill_lite(),
|
|
||||||
stroke: Stroke {
|
|
||||||
width: 1.0,
|
|
||||||
color: Colors::stroke()
|
|
||||||
},
|
|
||||||
blur_width: 0.0,
|
|
||||||
fill_texture_id: Default::default(),
|
|
||||||
uv: Rect::ZERO
|
|
||||||
};
|
};
|
||||||
|
let content_bg = RectShape::filled(content_bg_rect, Rounding::ZERO, Colors::fill_lite());
|
||||||
// Draw content background.
|
// Draw content background.
|
||||||
ui.painter().add(content_bg);
|
ui.painter().add(content_bg);
|
||||||
|
|
||||||
|
@ -184,10 +178,10 @@ impl<Platform: PlatformCallbacks> App<Platform> {
|
||||||
rect.min.y += Content::WINDOW_TITLE_HEIGHT;
|
rect.min.y += Content::WINDOW_TITLE_HEIGHT;
|
||||||
rect
|
rect
|
||||||
};
|
};
|
||||||
// Draw main content.
|
|
||||||
let mut content_ui = ui.new_child(UiBuilder::new()
|
let mut content_ui = ui.new_child(UiBuilder::new()
|
||||||
.max_rect(content_rect)
|
.max_rect(content_rect)
|
||||||
.layout(*ui.layout()));
|
.layout(*ui.layout()));
|
||||||
|
// Draw main content.
|
||||||
self.content.ui(&mut content_ui, &self.platform);
|
self.content.ui(&mut content_ui, &self.platform);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -224,10 +218,8 @@ impl<Platform: PlatformCallbacks> App<Platform> {
|
||||||
|
|
||||||
/// Draw custom window title content.
|
/// Draw custom window title content.
|
||||||
fn window_title_ui(&self, ui: &mut egui::Ui, is_fullscreen: bool) {
|
fn window_title_ui(&self, ui: &mut egui::Ui, is_fullscreen: bool) {
|
||||||
let content_rect = ui.max_rect();
|
|
||||||
|
|
||||||
let title_rect = {
|
let title_rect = {
|
||||||
let mut rect = content_rect;
|
let mut rect = ui.max_rect();
|
||||||
rect.max.y = rect.min.y + Content::WINDOW_TITLE_HEIGHT;
|
rect.max.y = rect.min.y + Content::WINDOW_TITLE_HEIGHT;
|
||||||
rect
|
rect
|
||||||
};
|
};
|
||||||
|
@ -268,9 +260,8 @@ impl<Platform: PlatformCallbacks> App<Platform> {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Paint the title.
|
// Paint the title.
|
||||||
let dual_wallets_panel =
|
let dual_wallets_panel = ui.available_width() >= (Content::SIDE_PANEL_WIDTH * 3.0) +
|
||||||
ui.available_width() >= (Content::SIDE_PANEL_WIDTH * 3.0)
|
View::get_right_inset() + View::get_left_inset();
|
||||||
+ View::get_right_inset() + View::get_left_inset();
|
|
||||||
let wallet_panel_opened = self.content.wallets.showing_wallet();
|
let wallet_panel_opened = self.content.wallets.showing_wallet();
|
||||||
let show_app_name = if dual_wallets_panel {
|
let show_app_name = if dual_wallets_panel {
|
||||||
wallet_panel_opened && !AppConfig::show_wallets_at_dual_panel()
|
wallet_panel_opened && !AppConfig::show_wallets_at_dual_panel()
|
||||||
|
@ -411,7 +402,11 @@ impl<Platform: PlatformCallbacks> eframe::App for App<Platform> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn clear_color(&self, _visuals: &egui::Visuals) -> [f32; 4] {
|
fn clear_color(&self, _visuals: &egui::Visuals) -> [f32; 4] {
|
||||||
Colors::fill_lite().to_normalized_gamma_f32()
|
let is_mac = OperatingSystem::from_target_os() == OperatingSystem::Mac;
|
||||||
|
if !View::is_desktop() || is_mac {
|
||||||
|
return Colors::fill_lite().to_normalized_gamma_f32();
|
||||||
|
}
|
||||||
|
Colors::TRANSPARENT.to_normalized_gamma_f32()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -184,15 +184,14 @@ impl Modal {
|
||||||
i.viewport().fullscreen.unwrap_or(false)
|
i.viewport().fullscreen.unwrap_or(false)
|
||||||
});
|
});
|
||||||
|
|
||||||
// Setup content rect.
|
// Setup background rect.
|
||||||
let rect = if View::is_desktop() {
|
let bg_rect = if View::is_desktop() && !is_fullscreen {
|
||||||
if !is_fullscreen && OperatingSystem::from_target_os() != OperatingSystem::Mac {
|
let mut r = ctx.screen_rect();
|
||||||
ctx.screen_rect().shrink(Content::WINDOW_FRAME_MARGIN)
|
if OperatingSystem::Mac != OperatingSystem::from_target_os() {
|
||||||
} else {
|
r = r.shrink(Content::WINDOW_FRAME_MARGIN);
|
||||||
let mut r = ctx.screen_rect();
|
|
||||||
r.min.y += Content::WINDOW_TITLE_HEIGHT;
|
|
||||||
r
|
|
||||||
}
|
}
|
||||||
|
r.min.y += Content::WINDOW_TITLE_HEIGHT;
|
||||||
|
r
|
||||||
} else {
|
} else {
|
||||||
ctx.screen_rect()
|
ctx.screen_rect()
|
||||||
};
|
};
|
||||||
|
@ -202,18 +201,18 @@ impl Modal {
|
||||||
.title_bar(false)
|
.title_bar(false)
|
||||||
.resizable(false)
|
.resizable(false)
|
||||||
.collapsible(false)
|
.collapsible(false)
|
||||||
.fixed_rect(rect)
|
.fixed_rect(bg_rect)
|
||||||
.frame(egui::Frame {
|
.frame(egui::Frame {
|
||||||
fill: Colors::semi_transparent(),
|
fill: Colors::semi_transparent(),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
})
|
})
|
||||||
.show(ctx, |ui| {
|
.show(ctx, |ui| {
|
||||||
ui.set_min_size(rect.size());
|
ui.set_min_size(bg_rect.size());
|
||||||
});
|
});
|
||||||
|
|
||||||
// Setup width of modal content.
|
// Setup width of modal content.
|
||||||
let side_insets = View::get_left_inset() + View::get_right_inset();
|
let side_insets = View::get_left_inset() + View::get_right_inset();
|
||||||
let available_width = rect.width() - (side_insets + Self::DEFAULT_MARGIN);
|
let available_width = ctx.screen_rect().width() - (side_insets + Self::DEFAULT_MARGIN);
|
||||||
let width = f32::min(available_width, Self::DEFAULT_WIDTH);
|
let width = f32::min(available_width, Self::DEFAULT_WIDTH);
|
||||||
|
|
||||||
// Show main content window at given position.
|
// Show main content window at given position.
|
||||||
|
|
|
@ -159,7 +159,7 @@ impl WalletContent {
|
||||||
r
|
r
|
||||||
};
|
};
|
||||||
View::line(ui, LinePosition::BOTTOM, &r, Colors::item_stroke());
|
View::line(ui, LinePosition::BOTTOM, &r, Colors::item_stroke());
|
||||||
if dual_panel && show_wallets_dual {
|
if dual_panel && show_wallets_dual && !show_qr_scan {
|
||||||
View::line(ui, LinePosition::LEFT, &r, Colors::item_stroke());
|
View::line(ui, LinePosition::LEFT, &r, Colors::item_stroke());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -138,9 +138,9 @@ fn start_desktop_gui(platform: grim::gui::platform::Desktop) {
|
||||||
viewport,
|
viewport,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
// Use Glow renderer for Windows and Mac.
|
// Use Glow renderer for Windows.
|
||||||
let is_win = os == egui::os::OperatingSystem::Windows;
|
let is_win = os == egui::os::OperatingSystem::Windows;
|
||||||
options.renderer = if is_win || is_mac {
|
options.renderer = if is_win {
|
||||||
eframe::Renderer::Glow
|
eframe::Renderer::Glow
|
||||||
} else {
|
} else {
|
||||||
eframe::Renderer::Wgpu
|
eframe::Renderer::Wgpu
|
||||||
|
@ -151,7 +151,7 @@ fn start_desktop_gui(platform: grim::gui::platform::Desktop) {
|
||||||
match grim::start(options.clone(), grim::app_creator(app)) {
|
match grim::start(options.clone(), grim::app_creator(app)) {
|
||||||
Ok(_) => {}
|
Ok(_) => {}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
if is_win || is_mac {
|
if is_win {
|
||||||
panic!("{}", e);
|
panic!("{}", e);
|
||||||
}
|
}
|
||||||
// Start with another renderer on error.
|
// Start with another renderer on error.
|
||||||
|
|
Loading…
Reference in a new issue