fix: check for window size data availability

This commit is contained in:
ardocrat 2024-05-22 13:23:05 +03:00
parent 2e23bfb396
commit 3263d594a7
2 changed files with 13 additions and 7 deletions

View file

@ -23,6 +23,7 @@ use egui::epaint::text::TextWrapping;
use egui::os::OperatingSystem;
use egui::text::{LayoutJob, TextFormat};
use egui::text_edit::TextEditState;
use crate::AppConfig;
use crate::gui::Colors;
use crate::gui::icons::{CHECK_SQUARE, CLIPBOARD_TEXT, COPY, EYE, EYE_SLASH, SCAN, SQUARE};
@ -63,8 +64,11 @@ impl View {
ui.ctx().input(|i| {
return match i.viewport().inner_rect {
None => {
let size = i.viewport().monitor_size.unwrap();
if let Some(size) = i.viewport().monitor_size {
(size.x, size.y)
} else {
(AppConfig::DEFAULT_WIDTH, AppConfig::DEFAULT_HEIGHT)
}
}
Some(rect) => {
(rect.width(), rect.height())

View file

@ -47,9 +47,6 @@ pub struct AppConfig {
lang: Option<String>
}
const DEFAULT_WIDTH: f32 = 1280.0;
const DEFAULT_HEIGHT: f32 = 745.0;
impl Default for AppConfig {
fn default() -> Self {
Self {
@ -58,8 +55,8 @@ impl Default for AppConfig {
android_integrated_node_warning: None,
show_wallets_at_dual_panel: false,
show_connections_network_panel: false,
width: DEFAULT_WIDTH,
height: DEFAULT_HEIGHT,
width: Self::DEFAULT_WIDTH,
height: Self::DEFAULT_HEIGHT,
x: None,
y: None,
lang: None,
@ -68,6 +65,11 @@ impl Default for AppConfig {
}
impl AppConfig {
/// Default window width.
pub const DEFAULT_WIDTH: f32 = 1280.0;
/// Default window height.
pub const DEFAULT_HEIGHT: f32 = 745.0;
/// Application configuration file name.
pub const FILE_NAME: &'static str = "app.toml";