fix: add missing vertical scrollbar

adjust width grow of sliders
This commit is contained in:
Cyrix126 2024-12-11 22:46:55 +01:00
parent a920c53d56
commit 4ebd48f3b5
6 changed files with 239 additions and 220 deletions

View file

@ -1,4 +1,4 @@
use egui::{Button, ComboBox, RichText, SelectableLabel, Ui}; use egui::{Button, ComboBox, RichText, SelectableLabel, TextStyle, Ui};
use log::{debug, info}; use log::{debug, info};
use crate::{ use crate::{
@ -54,18 +54,6 @@ impl PoolNode {
PoolNode::Pool(p) => p.rig = new_custom, 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 /// compatible for P2Pool and Xmrig/Proxy
/// current is (name, ip, port, zmq/rig) /// current is (name, ip, port, zmq/rig)
@ -78,8 +66,9 @@ pub fn list_poolnode(
) { ) {
ui.vertical(|ui| { ui.vertical(|ui| {
ui.spacing_mut().item_spacing.y = 0.0; ui.spacing_mut().item_spacing.y = 0.0;
// ui.spacing_mut().button_padding.x = ui.available_width() / 2.0; let width = ui
let width = ui.available_width(); .available_width()
.max(ui.text_style_height(&TextStyle::Button) * 28.0);
// [Manual node selection] // [Manual node selection]
// [Ping List] // [Ping List]
debug!("P2Pool Tab | Rendering [Node List]"); debug!("P2Pool Tab | Rendering [Node List]");

View file

@ -28,7 +28,7 @@ pub fn slider_state_field(
ui.style_mut().spacing.slider_width = (ui.available_width() ui.style_mut().spacing.slider_width = (ui.available_width()
- ui.spacing().item_spacing.x * 4.0 - ui.spacing().item_spacing.x * 4.0
- ui.spacing().scroll.bar_width - ui.spacing().scroll.bar_width
- SPACE * 2.0 - SPACE * 1.0
+ 2.0) + 2.0)
.max(80.0); .max(80.0);
ui.add_sized( ui.add_sized(

View file

@ -14,9 +14,11 @@ impl P2pool {
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]
egui::ScrollArea::horizontal()
.id_salt("p2pool_horizontal")
.show(ui, |ui| {
ui.horizontal(|ui| { ui.horizontal(|ui| {
ui.group(|ui| { ui.group(|ui| {
// let width = size.x/10.0;
ui.vertical(|ui| { ui.vertical(|ui| {
if !self.name_field(ui) { if !self.name_field(ui) {
incorrect_input = false; incorrect_input = false;
@ -40,7 +42,6 @@ impl P2pool {
); );
}); });
}); });
// 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]
@ -48,12 +49,11 @@ impl P2pool {
// let height = height / 4.0; // let height = height / 4.0;
ui.group(|ui| { ui.group(|ui| {
ui.vertical(|ui| { ui.vertical(|ui| {
let height = height_txt_before_button(ui, &egui::TextStyle::Button) * 1.9; let height =
height_txt_before_button(ui, &egui::TextStyle::Button) * 1.9;
ui.horizontal(|ui| { ui.horizontal(|ui| {
let width = (ui.available_width() / 4.0) - SPACE; let width = ((ui.available_width() / 4.0) - SPACE).max(80.0);
if ui if ui
// if ui.add_sized(, )
// .selectable_label(!self.mini, "P2Pool Main")
.add_sized( .add_sized(
[width, height], [width, height],
SelectableLabel::new(!self.mini, "P2Pool Main"), SelectableLabel::new(!self.mini, "P2Pool Main"),
@ -64,8 +64,6 @@ impl P2pool {
self.mini = false; self.mini = false;
} }
if ui if ui
// .selectable_label(!self.mini, "P2Pool Mini")
// if ui
.add_sized( .add_sized(
[width, height], [width, height],
SelectableLabel::new(self.mini, "P2Pool Mini"), SelectableLabel::new(self.mini, "P2Pool Mini"),
@ -83,7 +81,6 @@ impl P2pool {
[(ui.available_width() / 2.0) - (SPACE * 2.0), height], [(ui.available_width() / 2.0) - (SPACE * 2.0), height],
Checkbox::new(&mut self.backup_host, "Backup host"), Checkbox::new(&mut self.backup_host, "Backup host"),
) )
// ui.checkbox(&mut self.backup_host, "Backup host")
.on_hover_text(P2POOL_BACKUP_HOST_ADVANCED); .on_hover_text(P2POOL_BACKUP_HOST_ADVANCED);
}); });
}); });
@ -118,6 +115,7 @@ impl P2pool {
}) })
}); });
}); });
});
} }
fn name_field(&mut self, ui: &mut Ui) -> bool { fn name_field(&mut self, ui: &mut Ui) -> bool {
StateTextEdit::new(ui) StateTextEdit::new(ui)

View file

@ -100,6 +100,9 @@ impl Xmrig {
); );
}); });
if !self.simple { if !self.simple {
egui::ScrollArea::horizontal()
.id_salt("xmrig_horizontal")
.show(ui, |ui| {
debug!("XMRig Tab | Rendering [Pool List] elements"); debug!("XMRig Tab | Rendering [Pool 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
ui.horizontal(|ui| { ui.horizontal(|ui| {
@ -121,7 +124,12 @@ impl Xmrig {
ui.vertical(|ui| { ui.vertical(|ui| {
list_poolnode( list_poolnode(
ui, ui,
&mut (&mut self.name, &mut self.ip, &mut self.port, &mut self.rig), &mut (
&mut self.name,
&mut self.ip,
&mut self.port,
&mut self.rig,
),
&mut self.selected_pool, &mut self.selected_pool,
pool_vec, pool_vec,
incorrect_input, incorrect_input,
@ -145,17 +153,25 @@ impl Xmrig {
ui.horizontal(|ui| { ui.horizontal(|ui| {
let width = (ui.available_width() / 2.0) - 11.0; let width = (ui.available_width() / 2.0) - 11.0;
let height = let height =
height_txt_before_button(ui, &egui::TextStyle::Button) * 2.0; height_txt_before_button(ui, &egui::TextStyle::Button)
* 2.0;
let size = vec2(width, height); let size = vec2(width, height);
ui.add_sized(size, Checkbox::new(&mut self.tls, "TLS Connection")) ui.add_sized(
size,
Checkbox::new(&mut self.tls, "TLS Connection"),
)
.on_hover_text(XMRIG_TLS); .on_hover_text(XMRIG_TLS);
ui.separator(); ui.separator();
ui.add_sized(size, Checkbox::new(&mut self.keepalive, "Keepalive")) ui.add_sized(
size,
Checkbox::new(&mut self.keepalive, "Keepalive"),
)
.on_hover_text(XMRIG_KEEPALIVE); .on_hover_text(XMRIG_KEEPALIVE);
}); });
}); });
}); });
}); });
});
} }
}); });
} }

View file

@ -89,6 +89,9 @@ impl XmrigProxy {
// let width = ui.available_width() - 10.0; // let width = ui.available_width() - 10.0;
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
// [Pool IP/Port] // [Pool IP/Port]
egui::ScrollArea::horizontal()
.id_salt("proxy_horizontal")
.show(ui, |ui| {
ui.horizontal(|ui| { ui.horizontal(|ui| {
ui.group(|ui| { ui.group(|ui| {
// let width = width / 10.0; // let width = width / 10.0;
@ -110,7 +113,12 @@ impl XmrigProxy {
ui.vertical(|ui| { ui.vertical(|ui| {
list_poolnode( list_poolnode(
ui, ui,
&mut (&mut self.name, &mut self.ip, &mut self.port, &mut self.rig), &mut (
&mut self.name,
&mut self.ip,
&mut self.port,
&mut self.rig,
),
&mut self.selected_pool, &mut self.selected_pool,
pool_vec, pool_vec,
incorrect_input, incorrect_input,
@ -137,17 +145,25 @@ impl XmrigProxy {
// TLS/Keepalive // TLS/Keepalive
ui.horizontal(|ui| { ui.horizontal(|ui| {
let width = (ui.available_width() / 2.0) - 11.0; let width = (ui.available_width() / 2.0) - 11.0;
let height = height_txt_before_button(ui, &TextStyle::Button) * 2.0; let height =
height_txt_before_button(ui, &TextStyle::Button) * 2.0;
let size = vec2(width, height); let size = vec2(width, height);
ui.add_sized(size, Checkbox::new(&mut self.tls, "TLS Connection")) ui.add_sized(
size,
Checkbox::new(&mut self.tls, "TLS Connection"),
)
.on_hover_text(XMRIG_TLS); .on_hover_text(XMRIG_TLS);
ui.separator(); ui.separator();
ui.add_sized(size, Checkbox::new(&mut self.keepalive, "Keepalive")) ui.add_sized(
size,
Checkbox::new(&mut self.keepalive, "Keepalive"),
)
.on_hover_text(XMRIG_KEEPALIVE); .on_hover_text(XMRIG_KEEPALIVE);
}); });
}); });
}); });
}); });
});
} }
}); });
} }

View file

@ -248,6 +248,7 @@ impl crate::disk::state::Xvb {
// private stats // private stats
ui.add_space(SPACE); ui.add_space(SPACE);
// ui.add_enabled_ui(is_alive, |ui| { // ui.add_enabled_ui(is_alive, |ui| {
ScrollArea::horizontal().id_salt("horizontal").show(ui, |ui| {
ui.add_enabled_ui(is_alive, |ui| { ui.add_enabled_ui(is_alive, |ui| {
let api = &api.lock().unwrap(); let api = &api.lock().unwrap();
let priv_stats = &api.stats_priv; 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 width_column = ui.text_style_height(&TextStyle::Body) * 16.0;
let height_column = 0.0; let height_column = 0.0;
ui.style_mut().wrap_mode = Some(egui::TextWrapMode::Extend); ui.style_mut().wrap_mode = Some(egui::TextWrapMode::Extend);
ScrollArea::horizontal().id_salt("horizontal").show(ui, |ui| {
ui.horizontal(|ui| { ui.horizontal(|ui| {
// Failures // Failures
stat_box(ui, XVB_FAILURE_FIELD, &priv_stats.fails.to_string(), width_column, height_column, style_height); 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" "You are not the winner"
} }
, width_column, height_column, style_height); , width_column, height_column, style_height);
});
}); });
ui.vertical(|ui| { ui.vertical(|ui| {
ui.group(|ui| { ui.group(|ui| {
@ -320,6 +319,7 @@ if priv_stats.win_current {
.on_disabled_hover_text("Algorithm is not running."); .on_disabled_hover_text("Algorithm is not running.");
// indicators // indicators
}) })
});
// currently mining on // currently mining on
}); });
} }