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 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]");

View file

@ -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(

View file

@ -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)

View file

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

View file

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

View file

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