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,110 +14,108 @@ 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]
ui.horizontal(|ui| { egui::ScrollArea::horizontal()
ui.group(|ui| { .id_salt("p2pool_horizontal")
// let width = size.x/10.0; .show(ui, |ui| {
ui.vertical(|ui| { ui.horizontal(|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");
ui.group(|ui| { ui.group(|ui| {
// [Backup host] ui.vertical(|ui| {
ui.add_sized( if !self.name_field(ui) {
[(ui.available_width() / 2.0) - (SPACE * 2.0), height], incorrect_input = false;
Checkbox::new(&mut self.backup_host, "Backup host"), }
) if !self.ip_field(ui) {
// ui.checkbox(&mut self.backup_host, "Backup host") incorrect_input = false;
.on_hover_text(P2POOL_BACKUP_HOST_ADVANCED); }
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 { fn name_field(&mut self, ui: &mut Ui) -> bool {
StateTextEdit::new(ui) StateTextEdit::new(ui)

View file

@ -100,62 +100,78 @@ impl Xmrig {
); );
}); });
if !self.simple { if !self.simple {
debug!("XMRig Tab | Rendering [Pool List] elements"); egui::ScrollArea::horizontal()
let mut incorrect_input = false; // This will disable [Add/Delete] on bad input .id_salt("xmrig_horizontal")
ui.horizontal(|ui| { .show(ui, |ui| {
ui.group(|ui| { debug!("XMRig Tab | Rendering [Pool List] elements");
ui.vertical(|ui| { let mut incorrect_input = false; // This will disable [Add/Delete] on bad input
if !self.name_field(ui) { ui.horizontal(|ui| {
incorrect_input = false; ui.group(|ui| {
} ui.vertical(|ui| {
if !self.ip_field(ui) { if !self.name_field(ui) {
incorrect_input = false; incorrect_input = false;
} }
if !self.rpc_port_field(ui) { if !self.ip_field(ui) {
incorrect_input = false; incorrect_input = false;
} }
if !self.rig_field(ui) { if !self.rpc_port_field(ui) {
incorrect_input = false; 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| { ui.add_space(5.0);
list_poolnode( debug!("XMRig Tab | Rendering [API] TextEdits");
ui, // [HTTP API IP/Port]
&mut (&mut self.name, &mut self.ip, &mut self.port, &mut self.rig), ui.group(|ui| {
&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.horizontal(|ui| { ui.horizontal(|ui| {
let width = (ui.available_width() / 2.0) - 11.0; ui.vertical(|ui| {
let height = self.api_ip_field(ui);
height_txt_before_button(ui, &egui::TextStyle::Button) * 2.0; self.api_port_field(ui);
let size = vec2(width, height); });
ui.add_sized(size, Checkbox::new(&mut self.tls, "TLS Connection"))
.on_hover_text(XMRIG_TLS);
ui.separator(); ui.separator();
ui.add_sized(size, Checkbox::new(&mut self.keepalive, "Keepalive")) debug!("XMRig Tab | Rendering [TLS/Keepalive] buttons");
.on_hover_text(XMRIG_KEEPALIVE); 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);
});
});
}); });
}); });
}); });
});
} }
}); });
} }

View file

@ -89,65 +89,81 @@ 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]
ui.horizontal(|ui| { egui::ScrollArea::horizontal()
ui.group(|ui| { .id_salt("proxy_horizontal")
// let width = width / 10.0; .show(ui, |ui| {
ui.vertical(|ui| { ui.horizontal(|ui| {
if !self.name_field(ui) { ui.group(|ui| {
incorrect_input = false; // let width = width / 10.0;
} ui.vertical(|ui| {
if !self.ip_field(ui) { if !self.name_field(ui) {
incorrect_input = false; incorrect_input = false;
} }
if !self.rpc_port_field(ui) { if !self.ip_field(ui) {
incorrect_input = false; incorrect_input = false;
} }
if !self.rig_field(ui) { if !self.rpc_port_field(ui) {
incorrect_input = false; 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| { debug!("XMRig-Proxy Tab | Rendering [API] TextEdits");
list_poolnode( // [HTTP API IP/Port]
ui, ui.group(|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
ui.horizontal(|ui| { ui.horizontal(|ui| {
let width = (ui.available_width() / 2.0) - 11.0; ui.vertical(|ui| {
let height = height_txt_before_button(ui, &TextStyle::Button) * 2.0; // HTTP API
let size = vec2(width, height); self.api_ip_field(ui);
ui.add_sized(size, Checkbox::new(&mut self.tls, "TLS Connection")) self.api_port_field(ui);
.on_hover_text(XMRIG_TLS); });
ui.separator(); 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);
});
});
}); });
}); });
}); });
});
} }
}); });
} }

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
}); });
} }