From 4ebd48f3b53da9849d23a473a0247789a55e33c9 Mon Sep 17 00:00:00 2001 From: Cyrix126 Date: Wed, 11 Dec 2024 22:46:55 +0100 Subject: [PATCH] fix: add missing vertical scrollbar adjust width grow of sliders --- src/app/panels/middle/common/list_poolnode.rs | 19 +- .../panels/middle/common/state_edit_field.rs | 2 +- src/app/panels/middle/p2pool/advanced.rs | 198 +++++++++--------- src/app/panels/middle/xmrig.rs | 116 +++++----- src/app/panels/middle/xmrig_proxy.rs | 120 ++++++----- src/app/panels/middle/xvb.rs | 4 +- 6 files changed, 239 insertions(+), 220 deletions(-) diff --git a/src/app/panels/middle/common/list_poolnode.rs b/src/app/panels/middle/common/list_poolnode.rs index 93cd16c..1f4b03c 100644 --- a/src/app/panels/middle/common/list_poolnode.rs +++ b/src/app/panels/middle/common/list_poolnode.rs @@ -1,4 +1,4 @@ -use egui::{Button, ComboBox, RichText, SelectableLabel, Ui}; +use egui::{Button, ComboBox, RichText, SelectableLabel, TextStyle, Ui}; use log::{debug, info}; use crate::{ @@ -54,18 +54,6 @@ impl PoolNode { PoolNode::Pool(p) => p.rig = new_custom, } } - // pub fn from_vec_node(vec_node: Vec<(String, Node)>) -> Vec<(String, Self)> { - // vec_node - // .into_iter() - // .map(|(name, node)| (name, PoolNode::Node(node))) - // .collect() - // } - // pub fn from_vec_pool(vec_node: Vec<(String, Pool)>) -> Vec<(String, Self)> { - // vec_node - // .into_iter() - // .map(|(name, pool)| (name, PoolNode::Pool(pool))) - // .collect() - // } } /// compatible for P2Pool and Xmrig/Proxy /// current is (name, ip, port, zmq/rig) @@ -78,8 +66,9 @@ pub fn list_poolnode( ) { ui.vertical(|ui| { ui.spacing_mut().item_spacing.y = 0.0; - // ui.spacing_mut().button_padding.x = ui.available_width() / 2.0; - let width = ui.available_width(); + let width = ui + .available_width() + .max(ui.text_style_height(&TextStyle::Button) * 28.0); // [Manual node selection] // [Ping List] debug!("P2Pool Tab | Rendering [Node List]"); diff --git a/src/app/panels/middle/common/state_edit_field.rs b/src/app/panels/middle/common/state_edit_field.rs index a5f0670..96f598a 100644 --- a/src/app/panels/middle/common/state_edit_field.rs +++ b/src/app/panels/middle/common/state_edit_field.rs @@ -28,7 +28,7 @@ pub fn slider_state_field( ui.style_mut().spacing.slider_width = (ui.available_width() - ui.spacing().item_spacing.x * 4.0 - ui.spacing().scroll.bar_width - - SPACE * 2.0 + - SPACE * 1.0 + 2.0) .max(80.0); ui.add_sized( diff --git a/src/app/panels/middle/p2pool/advanced.rs b/src/app/panels/middle/p2pool/advanced.rs index 33728cd..619dcc4 100644 --- a/src/app/panels/middle/p2pool/advanced.rs +++ b/src/app/panels/middle/p2pool/advanced.rs @@ -14,110 +14,108 @@ impl P2pool { debug!("P2Pool Tab | Rendering [Node List] elements"); let mut incorrect_input = false; // This will disable [Add/Delete] on bad input // [Monero node IP/RPC/ZMQ] - ui.horizontal(|ui| { - ui.group(|ui| { - // let width = size.x/10.0; - ui.vertical(|ui| { - if !self.name_field(ui) { - incorrect_input = false; - } - if !self.ip_field(ui) { - incorrect_input = false; - } - if !self.rpc_port_field(ui) { - incorrect_input = false; - } - if !self.zmq_port_field(ui) { - incorrect_input = false; - } - }); - list_poolnode( - ui, - &mut (&mut self.name, &mut self.ip, &mut self.rpc, &mut self.zmq), - &mut self.selected_node, - node_vec, - incorrect_input, - ); - }); - }); - // ui.add_space(space_h); - - debug!("P2Pool Tab | Rendering [Main/Mini/Peers/Log] elements"); - // [Main/Mini] - ui.horizontal(|ui| { - // let height = height / 4.0; - ui.group(|ui| { - ui.vertical(|ui| { - let height = height_txt_before_button(ui, &egui::TextStyle::Button) * 1.9; - ui.horizontal(|ui| { - let width = (ui.available_width() / 4.0) - SPACE; - if ui - // if ui.add_sized(, ) - // .selectable_label(!self.mini, "P2Pool Main") - .add_sized( - [width, height], - SelectableLabel::new(!self.mini, "P2Pool Main"), - ) - .on_hover_text(P2POOL_MAIN) - .clicked() - { - self.mini = false; - } - if ui - // .selectable_label(!self.mini, "P2Pool Mini") - // if ui - .add_sized( - [width, height], - SelectableLabel::new(self.mini, "P2Pool Mini"), - ) - .on_hover_text(P2POOL_MINI) - .clicked() - { - self.mini = true; - } - }); - debug!("P2Pool Tab | Rendering Backup host button"); + egui::ScrollArea::horizontal() + .id_salt("p2pool_horizontal") + .show(ui, |ui| { + ui.horizontal(|ui| { ui.group(|ui| { - // [Backup host] - ui.add_sized( - [(ui.available_width() / 2.0) - (SPACE * 2.0), height], - Checkbox::new(&mut self.backup_host, "Backup host"), - ) - // ui.checkbox(&mut self.backup_host, "Backup host") - .on_hover_text(P2POOL_BACKUP_HOST_ADVANCED); + ui.vertical(|ui| { + if !self.name_field(ui) { + incorrect_input = false; + } + if !self.ip_field(ui) { + incorrect_input = false; + } + if !self.rpc_port_field(ui) { + incorrect_input = false; + } + if !self.zmq_port_field(ui) { + incorrect_input = false; + } + }); + list_poolnode( + ui, + &mut (&mut self.name, &mut self.ip, &mut self.rpc, &mut self.zmq), + &mut self.selected_node, + node_vec, + incorrect_input, + ); + }); + }); + + debug!("P2Pool Tab | Rendering [Main/Mini/Peers/Log] elements"); + // [Main/Mini] + ui.horizontal(|ui| { + // let height = height / 4.0; + ui.group(|ui| { + ui.vertical(|ui| { + let height = + height_txt_before_button(ui, &egui::TextStyle::Button) * 1.9; + ui.horizontal(|ui| { + let width = ((ui.available_width() / 4.0) - SPACE).max(80.0); + if ui + .add_sized( + [width, height], + SelectableLabel::new(!self.mini, "P2Pool Main"), + ) + .on_hover_text(P2POOL_MAIN) + .clicked() + { + self.mini = false; + } + if ui + .add_sized( + [width, height], + SelectableLabel::new(self.mini, "P2Pool Mini"), + ) + .on_hover_text(P2POOL_MINI) + .clicked() + { + self.mini = true; + } + }); + debug!("P2Pool Tab | Rendering Backup host button"); + ui.group(|ui| { + // [Backup host] + ui.add_sized( + [(ui.available_width() / 2.0) - (SPACE * 2.0), height], + Checkbox::new(&mut self.backup_host, "Backup host"), + ) + .on_hover_text(P2POOL_BACKUP_HOST_ADVANCED); + }); + }); + }); + // [Out/In Peers] + [Log Level] + ui.group(|ui| { + ui.vertical(|ui| { + ui.add_space(SPACE); + slider_state_field( + ui, + "Out peers [2-450]:", + P2POOL_OUT, + &mut self.out_peers, + 2..=450, + ); + ui.add_space(SPACE); + slider_state_field( + ui, + "In peers [2-450]:", + P2POOL_IN, + &mut self.in_peers, + 2..=450, + ); + ui.add_space(SPACE); + slider_state_field( + ui, + "Log level [ 0-6 ]:", + P2POOL_LOG, + &mut self.log_level, + 0..=6, + ); + }) }); }); }); - // [Out/In Peers] + [Log Level] - ui.group(|ui| { - ui.vertical(|ui| { - ui.add_space(SPACE); - slider_state_field( - ui, - "Out peers [2-450]:", - P2POOL_OUT, - &mut self.out_peers, - 2..=450, - ); - ui.add_space(SPACE); - slider_state_field( - ui, - "In peers [2-450]:", - P2POOL_IN, - &mut self.in_peers, - 2..=450, - ); - ui.add_space(SPACE); - slider_state_field( - ui, - "Log level [ 0-6 ]:", - P2POOL_LOG, - &mut self.log_level, - 0..=6, - ); - }) - }); - }); } fn name_field(&mut self, ui: &mut Ui) -> bool { StateTextEdit::new(ui) diff --git a/src/app/panels/middle/xmrig.rs b/src/app/panels/middle/xmrig.rs index 1a00cb5..80266af 100644 --- a/src/app/panels/middle/xmrig.rs +++ b/src/app/panels/middle/xmrig.rs @@ -100,62 +100,78 @@ impl Xmrig { ); }); if !self.simple { - debug!("XMRig Tab | Rendering [Pool List] elements"); - let mut incorrect_input = false; // This will disable [Add/Delete] on bad input - ui.horizontal(|ui| { - ui.group(|ui| { - ui.vertical(|ui| { - if !self.name_field(ui) { - incorrect_input = false; - } - if !self.ip_field(ui) { - incorrect_input = false; - } - if !self.rpc_port_field(ui) { - incorrect_input = false; - } - if !self.rig_field(ui) { - incorrect_input = false; - } + egui::ScrollArea::horizontal() + .id_salt("xmrig_horizontal") + .show(ui, |ui| { + debug!("XMRig Tab | Rendering [Pool List] elements"); + let mut incorrect_input = false; // This will disable [Add/Delete] on bad input + ui.horizontal(|ui| { + ui.group(|ui| { + ui.vertical(|ui| { + if !self.name_field(ui) { + incorrect_input = false; + } + if !self.ip_field(ui) { + incorrect_input = false; + } + if !self.rpc_port_field(ui) { + incorrect_input = false; + } + if !self.rig_field(ui) { + incorrect_input = false; + } + }); + ui.vertical(|ui| { + list_poolnode( + ui, + &mut ( + &mut self.name, + &mut self.ip, + &mut self.port, + &mut self.rig, + ), + &mut self.selected_pool, + pool_vec, + incorrect_input, + ); + }); + }); }); - ui.vertical(|ui| { - list_poolnode( - ui, - &mut (&mut self.name, &mut self.ip, &mut self.port, &mut self.rig), - &mut self.selected_pool, - pool_vec, - incorrect_input, - ); - }); - }); - }); - ui.add_space(5.0); - debug!("XMRig Tab | Rendering [API] TextEdits"); - // [HTTP API IP/Port] - ui.group(|ui| { - ui.horizontal(|ui| { - ui.vertical(|ui| { - self.api_ip_field(ui); - self.api_port_field(ui); - }); - ui.separator(); - debug!("XMRig Tab | Rendering [TLS/Keepalive] buttons"); - ui.vertical(|ui| { - // TLS/Keepalive + ui.add_space(5.0); + debug!("XMRig Tab | Rendering [API] TextEdits"); + // [HTTP API IP/Port] + ui.group(|ui| { ui.horizontal(|ui| { - let width = (ui.available_width() / 2.0) - 11.0; - let height = - height_txt_before_button(ui, &egui::TextStyle::Button) * 2.0; - let size = vec2(width, height); - ui.add_sized(size, Checkbox::new(&mut self.tls, "TLS Connection")) - .on_hover_text(XMRIG_TLS); + ui.vertical(|ui| { + self.api_ip_field(ui); + self.api_port_field(ui); + }); ui.separator(); - ui.add_sized(size, Checkbox::new(&mut self.keepalive, "Keepalive")) - .on_hover_text(XMRIG_KEEPALIVE); + debug!("XMRig Tab | Rendering [TLS/Keepalive] buttons"); + ui.vertical(|ui| { + // TLS/Keepalive + ui.horizontal(|ui| { + let width = (ui.available_width() / 2.0) - 11.0; + let height = + height_txt_before_button(ui, &egui::TextStyle::Button) + * 2.0; + let size = vec2(width, height); + ui.add_sized( + size, + Checkbox::new(&mut self.tls, "TLS Connection"), + ) + .on_hover_text(XMRIG_TLS); + ui.separator(); + ui.add_sized( + size, + Checkbox::new(&mut self.keepalive, "Keepalive"), + ) + .on_hover_text(XMRIG_KEEPALIVE); + }); + }); }); }); }); - }); } }); } diff --git a/src/app/panels/middle/xmrig_proxy.rs b/src/app/panels/middle/xmrig_proxy.rs index aaa361c..1af1ef8 100644 --- a/src/app/panels/middle/xmrig_proxy.rs +++ b/src/app/panels/middle/xmrig_proxy.rs @@ -89,65 +89,81 @@ impl XmrigProxy { // let width = ui.available_width() - 10.0; let mut incorrect_input = false; // This will disable [Add/Delete] on bad input // [Pool IP/Port] - ui.horizontal(|ui| { - ui.group(|ui| { - // let width = width / 10.0; - ui.vertical(|ui| { - if !self.name_field(ui) { - incorrect_input = false; - } - if !self.ip_field(ui) { - incorrect_input = false; - } - if !self.rpc_port_field(ui) { - incorrect_input = false; - } - if !self.rig_field(ui) { - incorrect_input = false; - } + egui::ScrollArea::horizontal() + .id_salt("proxy_horizontal") + .show(ui, |ui| { + ui.horizontal(|ui| { + ui.group(|ui| { + // let width = width / 10.0; + ui.vertical(|ui| { + if !self.name_field(ui) { + incorrect_input = false; + } + if !self.ip_field(ui) { + incorrect_input = false; + } + if !self.rpc_port_field(ui) { + incorrect_input = false; + } + if !self.rig_field(ui) { + incorrect_input = false; + } + }); + + ui.vertical(|ui| { + list_poolnode( + ui, + &mut ( + &mut self.name, + &mut self.ip, + &mut self.port, + &mut self.rig, + ), + &mut self.selected_pool, + pool_vec, + incorrect_input, + ); + }); + }); }); + ui.add_space(5.0); - ui.vertical(|ui| { - list_poolnode( - ui, - &mut (&mut self.name, &mut self.ip, &mut self.port, &mut self.rig), - &mut self.selected_pool, - pool_vec, - incorrect_input, - ); - }); - }); - }); - ui.add_space(5.0); - - debug!("XMRig-Proxy Tab | Rendering [API] TextEdits"); - // [HTTP API IP/Port] - ui.group(|ui| { - ui.horizontal(|ui| { - ui.vertical(|ui| { - // HTTP API - self.api_ip_field(ui); - self.api_port_field(ui); - }); - - ui.separator(); - - debug!("XMRig-Proxy Tab | Rendering [TLS/Keepalive] buttons"); - ui.vertical(|ui| { - // TLS/Keepalive + debug!("XMRig-Proxy Tab | Rendering [API] TextEdits"); + // [HTTP API IP/Port] + ui.group(|ui| { ui.horizontal(|ui| { - let width = (ui.available_width() / 2.0) - 11.0; - let height = height_txt_before_button(ui, &TextStyle::Button) * 2.0; - let size = vec2(width, height); - ui.add_sized(size, Checkbox::new(&mut self.tls, "TLS Connection")) - .on_hover_text(XMRIG_TLS); + ui.vertical(|ui| { + // HTTP API + self.api_ip_field(ui); + self.api_port_field(ui); + }); + ui.separator(); - ui.add_sized(size, Checkbox::new(&mut self.keepalive, "Keepalive")) - .on_hover_text(XMRIG_KEEPALIVE); + + debug!("XMRig-Proxy Tab | Rendering [TLS/Keepalive] buttons"); + ui.vertical(|ui| { + // TLS/Keepalive + ui.horizontal(|ui| { + let width = (ui.available_width() / 2.0) - 11.0; + let height = + height_txt_before_button(ui, &TextStyle::Button) * 2.0; + let size = vec2(width, height); + ui.add_sized( + size, + Checkbox::new(&mut self.tls, "TLS Connection"), + ) + .on_hover_text(XMRIG_TLS); + ui.separator(); + ui.add_sized( + size, + Checkbox::new(&mut self.keepalive, "Keepalive"), + ) + .on_hover_text(XMRIG_KEEPALIVE); + }); + }); }); }); }); - }); } }); } diff --git a/src/app/panels/middle/xvb.rs b/src/app/panels/middle/xvb.rs index fb481c6..428127e 100644 --- a/src/app/panels/middle/xvb.rs +++ b/src/app/panels/middle/xvb.rs @@ -248,6 +248,7 @@ impl crate::disk::state::Xvb { // private stats ui.add_space(SPACE); // ui.add_enabled_ui(is_alive, |ui| { + ScrollArea::horizontal().id_salt("horizontal").show(ui, |ui| { ui.add_enabled_ui(is_alive, |ui| { let api = &api.lock().unwrap(); let priv_stats = &api.stats_priv; @@ -259,7 +260,6 @@ impl crate::disk::state::Xvb { let width_column = ui.text_style_height(&TextStyle::Body) * 16.0; let height_column = 0.0; ui.style_mut().wrap_mode = Some(egui::TextWrapMode::Extend); - ScrollArea::horizontal().id_salt("horizontal").show(ui, |ui| { ui.horizontal(|ui| { // Failures stat_box(ui, XVB_FAILURE_FIELD, &priv_stats.fails.to_string(), width_column, height_column, style_height); @@ -294,7 +294,6 @@ if priv_stats.win_current { "You are not the winner" } , width_column, height_column, style_height); - }); }); ui.vertical(|ui| { ui.group(|ui| { @@ -320,6 +319,7 @@ if priv_stats.win_current { .on_disabled_hover_text("Algorithm is not running."); // indicators }) + }); // currently mining on }); }