mirror of
https://github.com/Cyrix126/gupaxx.git
synced 2025-01-03 12:39:35 +00:00
fix: simplify args of some functions
fix: Use Vec2 instead of two args height and width for p2pool tab simple and advanced
This commit is contained in:
parent
6797bdd173
commit
340ee45f47
3 changed files with 38 additions and 42 deletions
|
@ -1,8 +1,8 @@
|
||||||
use crate::disk::node::Node;
|
use crate::disk::node::Node;
|
||||||
use crate::{disk::state::P2pool, utils::regex::REGEXES};
|
use crate::{disk::state::P2pool, utils::regex::REGEXES};
|
||||||
use egui::Button;
|
|
||||||
use egui::Checkbox;
|
use egui::Checkbox;
|
||||||
use egui::Slider;
|
use egui::Slider;
|
||||||
|
use egui::{Button, Vec2};
|
||||||
|
|
||||||
use crate::constants::*;
|
use crate::constants::*;
|
||||||
use egui::{Color32, ComboBox, Label, RichText, SelectableLabel, TextStyle::*, Ui};
|
use egui::{Color32, ComboBox, Label, RichText, SelectableLabel, TextStyle::*, Ui};
|
||||||
|
@ -12,8 +12,7 @@ impl P2pool {
|
||||||
pub(super) fn advanced(
|
pub(super) fn advanced(
|
||||||
&mut self,
|
&mut self,
|
||||||
ui: &mut Ui,
|
ui: &mut Ui,
|
||||||
width: f32,
|
size: Vec2,
|
||||||
height: f32,
|
|
||||||
text_edit: f32,
|
text_edit: f32,
|
||||||
node_vec: &mut Vec<(String, Node)>,
|
node_vec: &mut Vec<(String, Node)>,
|
||||||
) {
|
) {
|
||||||
|
@ -22,7 +21,7 @@ impl P2pool {
|
||||||
// [Monero node IP/RPC/ZMQ]
|
// [Monero node IP/RPC/ZMQ]
|
||||||
ui.horizontal(|ui| {
|
ui.horizontal(|ui| {
|
||||||
ui.group(|ui| {
|
ui.group(|ui| {
|
||||||
let width = width/10.0;
|
let width = size.x/10.0;
|
||||||
ui.vertical(|ui| {
|
ui.vertical(|ui| {
|
||||||
ui.spacing_mut().text_edit_width = width*3.32;
|
ui.spacing_mut().text_edit_width = width*3.32;
|
||||||
ui.horizontal(|ui| {
|
ui.horizontal(|ui| {
|
||||||
|
@ -234,10 +233,10 @@ impl P2pool {
|
||||||
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 = height / 4.0;
|
let height = size.y / 4.0;
|
||||||
ui.group(|ui| {
|
ui.group(|ui| {
|
||||||
ui.horizontal(|ui| {
|
ui.horizontal(|ui| {
|
||||||
let width = (width / 4.0) - SPACE;
|
let width = (size.x / 4.0) - SPACE;
|
||||||
let height = height + 6.0;
|
let height = height + 6.0;
|
||||||
if ui
|
if ui
|
||||||
.add_sized(
|
.add_sized(
|
||||||
|
@ -292,7 +291,7 @@ impl P2pool {
|
||||||
|
|
||||||
debug!("P2Pool Tab | Rendering Backup host button");
|
debug!("P2Pool Tab | Rendering Backup host button");
|
||||||
ui.group(|ui| {
|
ui.group(|ui| {
|
||||||
let width = width - SPACE;
|
let width = size.x - SPACE;
|
||||||
let height = ui.available_height() / 3.0;
|
let height = ui.available_height() / 3.0;
|
||||||
// [Backup host]
|
// [Backup host]
|
||||||
ui.add_sized(
|
ui.add_sized(
|
||||||
|
|
|
@ -18,7 +18,7 @@ use crate::helper::p2pool::PubP2poolApi;
|
||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
use crate::{components::node::*, constants::*, helper::*, macros::*, utils::regex::Regexes};
|
use crate::{components::node::*, constants::*, helper::*, macros::*, utils::regex::Regexes};
|
||||||
use egui::{Color32, Label, RichText, TextEdit, TextStyle::*, Vec2};
|
use egui::{vec2, Color32, Label, RichText, TextEdit, TextStyle::*, Vec2};
|
||||||
use log::*;
|
use log::*;
|
||||||
|
|
||||||
use std::sync::{Arc, Mutex};
|
use std::sync::{Arc, Mutex};
|
||||||
|
@ -156,12 +156,13 @@ impl P2pool {
|
||||||
});
|
});
|
||||||
|
|
||||||
let height = ui.available_height();
|
let height = ui.available_height();
|
||||||
|
let size = vec2(width, height);
|
||||||
if self.simple {
|
if self.simple {
|
||||||
//---------------------------------------------------------------------------------------------------- Simple
|
//---------------------------------------------------------------------------------------------------- Simple
|
||||||
self.simple(ui, width, height, ping);
|
self.simple(ui, size, ping);
|
||||||
//---------------------------------------------------------------------------------------------------- Advanced
|
//---------------------------------------------------------------------------------------------------- Advanced
|
||||||
} else {
|
} else {
|
||||||
self.advanced(ui, width, height, text_edit, node_vec);
|
self.advanced(ui, size, text_edit, node_vec);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,18 +10,20 @@ use crate::components::node::Ping;
|
||||||
use crate::components::node::RemoteNode;
|
use crate::components::node::RemoteNode;
|
||||||
use crate::disk::state::P2pool;
|
use crate::disk::state::P2pool;
|
||||||
use crate::utils::macros::lock;
|
use crate::utils::macros::lock;
|
||||||
|
use egui::vec2;
|
||||||
use egui::Button;
|
use egui::Button;
|
||||||
use egui::Checkbox;
|
use egui::Checkbox;
|
||||||
|
use egui::Vec2;
|
||||||
|
|
||||||
use crate::constants::*;
|
use crate::constants::*;
|
||||||
use egui::{Color32, ComboBox, Label, RichText, Ui};
|
use egui::{Color32, ComboBox, Label, RichText, Ui};
|
||||||
use log::*;
|
use log::*;
|
||||||
impl P2pool {
|
impl P2pool {
|
||||||
pub(super) fn simple(&mut self, ui: &mut Ui, width: f32, height: f32, ping: &Arc<Mutex<Ping>>) {
|
pub(super) fn simple(&mut self, ui: &mut Ui, size: Vec2, ping: &Arc<Mutex<Ping>>) {
|
||||||
// [Node]
|
// [Node]
|
||||||
let height = height / 6.5;
|
let height = size.y / 6.5;
|
||||||
ui.spacing_mut().slider_width = width - 8.0;
|
ui.spacing_mut().slider_width = size.x - 8.0;
|
||||||
ui.spacing_mut().icon_width = width / 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.
|
||||||
// Using [Arc<Mutex<Ping>>] as an intermediary here
|
// Using [Arc<Mutex<Ping>>] as an intermediary here
|
||||||
|
@ -59,7 +61,7 @@ impl P2pool {
|
||||||
let text = RichText::new(format!(" ⏺ {}ms | {}", ms, ip_location)).color(color);
|
let text = RichText::new(format!(" ⏺ {}ms | {}", ms, ip_location)).color(color);
|
||||||
ComboBox::from_id_source("remote_nodes")
|
ComboBox::from_id_source("remote_nodes")
|
||||||
.selected_text(text)
|
.selected_text(text)
|
||||||
.width(width)
|
.width(size.x)
|
||||||
.show_ui(ui, |ui| {
|
.show_ui(ui, |ui| {
|
||||||
for data in lock!(ping).nodes.iter() {
|
for data in lock!(ping).nodes.iter() {
|
||||||
let ms = format_ms(data.ms);
|
let ms = format_ms(data.ms);
|
||||||
|
@ -75,10 +77,11 @@ impl P2pool {
|
||||||
|
|
||||||
debug!("P2Pool Tab | Rendering [Select fastest ... Ping] buttons");
|
debug!("P2Pool Tab | Rendering [Select fastest ... Ping] buttons");
|
||||||
ui.horizontal(|ui| {
|
ui.horizontal(|ui| {
|
||||||
let width = (width / 5.0) - 6.0;
|
let width = (size.x / 5.0) - 6.0;
|
||||||
|
let size = vec2(width, height);
|
||||||
// [Select random node]
|
// [Select random node]
|
||||||
if ui
|
if ui
|
||||||
.add_sized([width, height], Button::new("Select random node"))
|
.add_sized(size, Button::new("Select random node"))
|
||||||
.on_hover_text(P2POOL_SELECT_RANDOM)
|
.on_hover_text(P2POOL_SELECT_RANDOM)
|
||||||
.clicked()
|
.clicked()
|
||||||
{
|
{
|
||||||
|
@ -86,7 +89,7 @@ impl P2pool {
|
||||||
}
|
}
|
||||||
// [Select fastest node]
|
// [Select fastest node]
|
||||||
if ui
|
if ui
|
||||||
.add_sized([width, height], Button::new("Select fastest node"))
|
.add_sized(size, Button::new("Select fastest node"))
|
||||||
.on_hover_text(P2POOL_SELECT_FASTEST)
|
.on_hover_text(P2POOL_SELECT_FASTEST)
|
||||||
.clicked()
|
.clicked()
|
||||||
&& lock!(ping).pinged
|
&& lock!(ping).pinged
|
||||||
|
@ -96,7 +99,7 @@ impl P2pool {
|
||||||
// [Ping Button]
|
// [Ping Button]
|
||||||
ui.add_enabled_ui(!lock!(ping).pinging, |ui| {
|
ui.add_enabled_ui(!lock!(ping).pinging, |ui| {
|
||||||
if ui
|
if ui
|
||||||
.add_sized([width, height], Button::new("Ping remote nodes"))
|
.add_sized(size, Button::new("Ping remote nodes"))
|
||||||
.on_hover_text(P2POOL_PING)
|
.on_hover_text(P2POOL_PING)
|
||||||
.clicked()
|
.clicked()
|
||||||
{
|
{
|
||||||
|
@ -105,7 +108,7 @@ impl P2pool {
|
||||||
});
|
});
|
||||||
// [Last <-]
|
// [Last <-]
|
||||||
if ui
|
if ui
|
||||||
.add_sized([width, height], Button::new("⬅ Last"))
|
.add_sized(size, Button::new("⬅ Last"))
|
||||||
.on_hover_text(P2POOL_SELECT_LAST)
|
.on_hover_text(P2POOL_SELECT_LAST)
|
||||||
.clicked()
|
.clicked()
|
||||||
{
|
{
|
||||||
|
@ -118,7 +121,7 @@ impl P2pool {
|
||||||
}
|
}
|
||||||
// [Next ->]
|
// [Next ->]
|
||||||
if ui
|
if ui
|
||||||
.add_sized([width, height], Button::new("Next ➡"))
|
.add_sized(size, Button::new("Next ➡"))
|
||||||
.on_hover_text(P2POOL_SELECT_NEXT)
|
.on_hover_text(P2POOL_SELECT_NEXT)
|
||||||
.clicked()
|
.clicked()
|
||||||
{
|
{
|
||||||
|
@ -138,15 +141,16 @@ impl P2pool {
|
||||||
let prog = lock!(ping).prog.round();
|
let prog = lock!(ping).prog.round();
|
||||||
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);
|
||||||
ui.add_space(5.0);
|
ui.add_space(5.0);
|
||||||
ui.add_sized([width, height], Label::new(msg));
|
ui.add_sized(size, Label::new(msg));
|
||||||
ui.add_space(5.0);
|
ui.add_space(5.0);
|
||||||
if pinging {
|
if pinging {
|
||||||
ui.add_sized([width, height], Spinner::new().size(height));
|
ui.add_sized(size, Spinner::new().size(height));
|
||||||
} else {
|
} else {
|
||||||
ui.add_sized([width, height], Label::new("..."));
|
ui.add_sized(size, Label::new("..."));
|
||||||
}
|
}
|
||||||
ui.add_sized([width, height], ProgressBar::new(prog.round() / 100.0));
|
ui.add_sized(size, ProgressBar::new(prog.round() / 100.0));
|
||||||
ui.add_space(5.0);
|
ui.add_space(5.0);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -154,33 +158,25 @@ impl P2pool {
|
||||||
debug!("P2Pool Tab | Rendering [Auto-*] buttons");
|
debug!("P2Pool Tab | Rendering [Auto-*] buttons");
|
||||||
ui.group(|ui| {
|
ui.group(|ui| {
|
||||||
ui.horizontal(|ui| {
|
ui.horizontal(|ui| {
|
||||||
let width = (width / 3.0) - (SPACE * 1.75);
|
let width = (size.x / 3.0) - (SPACE * 1.75);
|
||||||
|
let size = vec2(width, height);
|
||||||
// [Auto-node]
|
// [Auto-node]
|
||||||
ui.add_sized(
|
ui.add_sized(size, Checkbox::new(&mut self.auto_select, "Auto-select"))
|
||||||
[width, height],
|
.on_hover_text(P2POOL_AUTO_SELECT);
|
||||||
Checkbox::new(&mut self.auto_select, "Auto-select"),
|
|
||||||
)
|
|
||||||
.on_hover_text(P2POOL_AUTO_SELECT);
|
|
||||||
ui.separator();
|
ui.separator();
|
||||||
// [Auto-node]
|
// [Auto-node]
|
||||||
ui.add_sized(
|
ui.add_sized(size, Checkbox::new(&mut self.auto_ping, "Auto-ping"))
|
||||||
[width, height],
|
.on_hover_text(P2POOL_AUTO_NODE);
|
||||||
Checkbox::new(&mut self.auto_ping, "Auto-ping"),
|
|
||||||
)
|
|
||||||
.on_hover_text(P2POOL_AUTO_NODE);
|
|
||||||
ui.separator();
|
ui.separator();
|
||||||
// [Backup host]
|
// [Backup host]
|
||||||
ui.add_sized(
|
ui.add_sized(size, Checkbox::new(&mut self.backup_host, "Backup host"))
|
||||||
[width, height],
|
.on_hover_text(P2POOL_BACKUP_HOST_SIMPLE);
|
||||||
Checkbox::new(&mut self.backup_host, "Backup host"),
|
|
||||||
)
|
|
||||||
.on_hover_text(P2POOL_BACKUP_HOST_SIMPLE);
|
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
debug!("P2Pool Tab | Rendering warning text");
|
debug!("P2Pool Tab | Rendering warning text");
|
||||||
ui.add_sized(
|
ui.add_sized(
|
||||||
[width, height / 2.0],
|
[size.x, height / 2.0],
|
||||||
Hyperlink::from_label_and_url(
|
Hyperlink::from_label_and_url(
|
||||||
"WARNING: It is recommended to run/use your own Monero Node (hover for details)",
|
"WARNING: It is recommended to run/use your own Monero Node (hover for details)",
|
||||||
"https://github.com/hinto-janai/gupax#running-a-local-monero-node",
|
"https://github.com/hinto-janai/gupax#running-a-local-monero-node",
|
||||||
|
|
Loading…
Reference in a new issue