fix: Ui overlapping for small screen

This commit is contained in:
Louis-Marie Baer 2024-03-21 12:27:52 +01:00
parent 4f13862136
commit 0f67fe7a08
7 changed files with 55 additions and 34 deletions

View file

@ -41,6 +41,7 @@
- [x] without hero option, to give minimum to be in most accessible round type - [x] without hero option, to give minimum to be in most accessible round type
- [x] sleep 10mn less time to spare then ask Xmrig to mine on XvB node - [x] sleep 10mn less time to spare then ask Xmrig to mine on XvB node
- [x] output log to console in XvB tab - [x] output log to console in XvB tab
- [x] fix some overlapping from upstream
- [ ] edit metadata of project - [ ] edit metadata of project
- [ ] adapt README for XvB - [ ] adapt README for XvB
- [ ] adapt doc for new code - [ ] adapt doc for new code

View file

@ -16,6 +16,8 @@ impl P2pool {
text_edit: f32, text_edit: f32,
node_vec: &mut Vec<(String, Node)>, node_vec: &mut Vec<(String, Node)>,
) { ) {
let height = size.y / 16.0;
let space_h = size.y / 128.0;
debug!("P2Pool Tab | Rendering [Node List] elements"); debug!("P2Pool Tab | Rendering [Node List] elements");
let mut incorrect_input = false; // This will disable [Add/Delete] on bad input let mut incorrect_input = false; // This will disable [Add/Delete] on bad input
// [Monero node IP/RPC/ZMQ] // [Monero node IP/RPC/ZMQ]
@ -228,16 +230,16 @@ impl P2pool {
}); });
}); });
}); });
ui.add_space(5.0); // ui.add_space(space_h);
debug!("P2Pool Tab | Rendering [Main/Mini/Peers/Log] elements"); debug!("P2Pool Tab | Rendering [Main/Mini/Peers/Log] elements");
// [Main/Mini] // [Main/Mini]
ui.horizontal(|ui| { ui.horizontal(|ui| {
let height = size.y / 4.0; let height = height / 4.0;
ui.group(|ui| { ui.group(|ui| {
ui.horizontal(|ui| { ui.horizontal(|ui| {
let width = (size.x / 4.0) - SPACE; let width = (size.x / 4.0) - SPACE;
let height = height + 6.0; let height = height + space_h;
if ui if ui
.add_sized( .add_sized(
[width, height], [width, height],
@ -292,7 +294,9 @@ impl P2pool {
debug!("P2Pool Tab | Rendering Backup host button"); debug!("P2Pool Tab | Rendering Backup host button");
ui.group(|ui| { ui.group(|ui| {
let width = size.x - SPACE; let width = size.x - SPACE;
let height = ui.available_height() / 3.0; let height = ui.available_height();
ui.style_mut().spacing.icon_width = height;
ui.style_mut().spacing.icon_width_inner = height * 0.9;
// [Backup host] // [Backup host]
ui.add_sized( ui.add_sized(
[width, height], [width, height],

View file

@ -48,7 +48,8 @@ impl P2pool {
debug!("P2Pool Tab | Rendering [Console]"); debug!("P2Pool Tab | Rendering [Console]");
ui.group(|ui| { ui.group(|ui| {
if self.simple { if self.simple {
let height = size.y / 2.8; // height of console = height - address - simple(dropmenu, select_bar, buttons, warning)
let height = (size.y * 0.38) - SPACE;
let width = size.x - SPACE; let width = size.x - SPACE;
egui::Frame::none().fill(DARK_GRAY).show(ui, |ui| { egui::Frame::none().fill(DARK_GRAY).show(ui, |ui| {
ui.style_mut().override_text_style = Some(Name("MonospaceSmall".into())); ui.style_mut().override_text_style = Some(Name("MonospaceSmall".into()));
@ -66,7 +67,12 @@ impl P2pool {
}); });
//---------------------------------------------------------------------------------------------------- [Advanced] Console //---------------------------------------------------------------------------------------------------- [Advanced] Console
} else { } else {
let height = height / 2.8; // fix for advanced submenu overlap on bottom when small window
let height = if size.y < 600.0 {
size.y * 0.22 - SPACE
} else {
size.y * 0.36 - SPACE
};
let width = width - SPACE; let width = width - SPACE;
egui::Frame::none().fill(DARK_GRAY).show(ui, |ui| { egui::Frame::none().fill(DARK_GRAY).show(ui, |ui| {
ui.style_mut().override_text_style = Some(Name("MonospaceSmall".into())); ui.style_mut().override_text_style = Some(Name("MonospaceSmall".into()));
@ -155,7 +161,7 @@ impl P2pool {
self.address.truncate(95); self.address.truncate(95);
}); });
let height = ui.available_height(); // let height = ui.available_height();
let size = vec2(width, height); let size = vec2(width, height);
if self.simple { if self.simple {
//---------------------------------------------------------------------------------------------------- Simple //---------------------------------------------------------------------------------------------------- Simple

View file

@ -21,8 +21,9 @@ use log::*;
impl P2pool { impl P2pool {
pub(super) fn simple(&mut self, ui: &mut Ui, size: Vec2, ping: &Arc<Mutex<Ping>>) { pub(super) fn simple(&mut self, ui: &mut Ui, size: Vec2, ping: &Arc<Mutex<Ping>>) {
// [Node] // [Node]
let height = size.y / 6.5; let height = size.y / 13.0;
ui.spacing_mut().slider_width = size.x - 8.0; let space_h = size.y / 96.0;
ui.spacing_mut().slider_width = size.x - 16.0;
ui.spacing_mut().icon_width = size.x / 25.0; ui.spacing_mut().icon_width = size.x / 25.0;
// [Auto-select] if we haven't already. // [Auto-select] if we haven't already.
@ -73,7 +74,7 @@ impl P2pool {
}); });
}); });
ui.add_space(5.0); ui.add_space(space_h);
debug!("P2Pool Tab | Rendering [Select fastest ... Ping] buttons"); debug!("P2Pool Tab | Rendering [Select fastest ... Ping] buttons");
ui.horizontal(|ui| { ui.horizontal(|ui| {
@ -142,16 +143,16 @@ impl P2pool {
let msg = RichText::new(format!("{} ... {}%", lock!(ping).msg, prog)); let msg = RichText::new(format!("{} ... {}%", lock!(ping).msg, prog));
let height = height / 1.25; let height = height / 1.25;
let size = vec2(size.x, height); let size = vec2(size.x, height);
ui.add_space(5.0); ui.add_space(space_h);
ui.add_sized(size, Label::new(msg)); ui.add_sized(size, Label::new(msg));
ui.add_space(5.0); ui.add_space(space_h);
if pinging { if pinging {
ui.add_sized(size, Spinner::new().size(height)); ui.add_sized(size, Spinner::new().size(height));
} else { } else {
ui.add_sized(size, Label::new("...")); ui.add_sized(size, Label::new("..."));
} }
ui.add_sized(size, ProgressBar::new(prog.round() / 100.0)); ui.add_sized(size, ProgressBar::new(prog.round() / 100.0));
ui.add_space(5.0); ui.add_space(space_h);
}); });
}); });

View file

@ -167,11 +167,14 @@ fn p2pool(
.on_hover_text(STATUS_P2POOL_SHARES); .on_hover_text(STATUS_P2POOL_SHARES);
ui.add_sized( ui.add_sized(
[width, height], [width, height],
Label::new((if let Some(s) = api.shares_found { Label::new(
(if let Some(s) = api.shares_found {
s.to_string() s.to_string()
} else { } else {
UNKNOWN_DATA.to_string() UNKNOWN_DATA.to_string()
}).to_string()), })
.to_string(),
),
); );
ui.add_sized( ui.add_sized(
[width, height], [width, height],

View file

@ -48,7 +48,7 @@ impl crate::disk::state::Xvb {
debug!("XvB Tab | Rendering [Console]"); debug!("XvB Tab | Rendering [Console]");
ui.group(|ui| { ui.group(|ui| {
let height = size.y / 2.8; let height = size.y / 2.8;
let width = size.x - space_h; let width = size.x - (space_h / 2.0);
egui::Frame::none().fill(DARK_GRAY).show(ui, |ui| { egui::Frame::none().fill(DARK_GRAY).show(ui, |ui| {
ui.style_mut().override_text_style = Some(Name("MonospaceSmall".into())); ui.style_mut().override_text_style = Some(Name("MonospaceSmall".into()));
egui::ScrollArea::vertical() egui::ScrollArea::vertical()
@ -199,7 +199,7 @@ impl crate::disk::state::Xvb {
// Rules link help // Rules link help
ui.horizontal_centered(|ui| { ui.horizontal_centered(|ui| {
// can't have horizontal and vertical centering work together so fix by this. // can't have horizontal and vertical centering work together so fix by this.
ui.add_space((width /2.0)-(ui.text_style_height( &TextStyle::Heading) * 1.5 )); ui.add_space((width / 2.0) - (ui.text_style_height(&TextStyle::Heading) * 1.5));
ui.style_mut().override_text_style = Some(TextStyle::Heading); ui.style_mut().override_text_style = Some(TextStyle::Heading);
ui.hyperlink_to("Rules", XVB_URL_RULES) ui.hyperlink_to("Rules", XVB_URL_RULES)
.on_hover_text("Click here to read the rules and understand how the raffle works."); .on_hover_text("Click here to read the rules and understand how the raffle works.");

View file

@ -1,22 +1,24 @@
use std::io::Write;
use crate::components::update::Update; use crate::components::update::Update;
use crate::helper::{Helper, ProcessSignal}; use crate::helper::{Helper, ProcessSignal};
use crate::utils::constants::{APP_MIN_WIDTH, APP_MIN_HEIGHT, APP_MAX_WIDTH, APP_MAX_HEIGHT, BYTES_ICON}; use crate::utils::constants::{
APP_MAX_HEIGHT, APP_MAX_WIDTH, APP_MIN_HEIGHT, APP_MIN_WIDTH, BYTES_ICON,
};
use crate::utils::regex::Regexes; use crate::utils::regex::Regexes;
use std::io::Write;
//---------------------------------------------------------------------------------------------------- Init functions //---------------------------------------------------------------------------------------------------- Init functions
use crate::{components::node::Ping, miscs::clamp_scale};
use crate::app::App; use crate::app::App;
use std::sync::Arc; use crate::{components::node::Ping, miscs::clamp_scale};
use std::time::Instant; use crate::{disk::state::*, utils::macros::lock};
use crate::{info, warn};
use eframe::NativeOptions; use eframe::NativeOptions;
use egui::TextStyle::Small;
use egui::TextStyle::{Body, Button, Heading, Monospace, Name};
use egui::*;
use env_logger::fmt::style::Style; use env_logger::fmt::style::Style;
use env_logger::{Builder, WriteStyle}; use env_logger::{Builder, WriteStyle};
use log::LevelFilter; use log::LevelFilter;
use egui::TextStyle::{Body, Button, Monospace, Heading, Name}; use std::sync::Arc;
use crate::{disk::state::*, utils::macros::lock}; use std::time::Instant;
use egui::TextStyle::Small;
use crate::{info, warn};
use egui::*;
#[cold] #[cold]
#[inline(never)] #[inline(never)]
@ -208,9 +210,13 @@ pub fn init_auto(app: &mut App) {
} }
// [Auto-XvB] // [Auto-XvB]
if app.state.gupax.auto_xvb { if app.state.gupax.auto_xvb {
Helper::start_xvb(&app.helper, &app.state.xvb, &app.state.p2pool, &app.state.xmrig); Helper::start_xvb(
&app.helper,
&app.state.xvb,
&app.state.p2pool,
&app.state.xmrig,
);
} else { } else {
info!("Skipping auto-xvb..."); info!("Skipping auto-xvb...");
} }
} }