mirror of
https://github.com/Cyrix126/gupaxx.git
synced 2025-01-06 22:19:22 +00:00
feat: resizable consoles (#65)
Some checks failed
Lockbud / lockbud (push) Has been cancelled
Rust / fmt (push) Has been cancelled
Rust / test (push) Has been cancelled
Rust / clippy (macos-latest) (push) Has been cancelled
Rust / clippy (ubuntu-latest) (push) Has been cancelled
Rust / check (macos-latest) (push) Has been cancelled
Rust / check (ubuntu-latest) (push) Has been cancelled
Rust / doc (push) Has been cancelled
Typo / typo (push) Has been cancelled
Some checks failed
Lockbud / lockbud (push) Has been cancelled
Rust / fmt (push) Has been cancelled
Rust / test (push) Has been cancelled
Rust / clippy (macos-latest) (push) Has been cancelled
Rust / clippy (ubuntu-latest) (push) Has been cancelled
Rust / check (macos-latest) (push) Has been cancelled
Rust / check (ubuntu-latest) (push) Has been cancelled
Rust / doc (push) Has been cancelled
Typo / typo (push) Has been cancelled
This commit is contained in:
parent
550daa3681
commit
109c9a28b7
9 changed files with 64 additions and 33 deletions
|
@ -19,33 +19,47 @@ use std::sync::{Arc, Mutex};
|
||||||
|
|
||||||
use egui::{Label, TextEdit, TextStyle, TextWrapMode, Ui};
|
use egui::{Label, TextEdit, TextStyle, TextWrapMode, Ui};
|
||||||
|
|
||||||
use crate::{DARK_GRAY, helper::Process, miscs::height_txt_before_button, regex::num_lines};
|
use crate::{
|
||||||
|
DARK_GRAY,
|
||||||
|
helper::{Process, ProcessName},
|
||||||
|
miscs::height_txt_before_button,
|
||||||
|
regex::num_lines,
|
||||||
|
};
|
||||||
|
|
||||||
pub fn console(ui: &mut Ui, text: &str) {
|
pub fn console(ui: &mut Ui, text: &str, console_height: &mut u32, process_name: ProcessName) {
|
||||||
let nb_lines = num_lines(text);
|
let nb_lines = num_lines(text);
|
||||||
let height = ui.available_height() / 2.8;
|
*console_height = egui::Resize::default()
|
||||||
egui::Frame::none().fill(DARK_GRAY).show(ui, |ui| {
|
.id_salt(process_name.to_string())
|
||||||
ui.style_mut().wrap_mode = Some(TextWrapMode::Wrap);
|
.default_height(*console_height as f32)
|
||||||
ui.style_mut().override_text_style = Some(TextStyle::Small);
|
.min_width(ui.available_width())
|
||||||
egui::ScrollArea::vertical()
|
.max_width(ui.available_width())
|
||||||
.stick_to_bottom(true)
|
.show(ui, |ui| {
|
||||||
.max_width(ui.available_width())
|
egui::Frame::none().fill(DARK_GRAY).show(ui, |ui| {
|
||||||
.max_height(height)
|
ui.style_mut().wrap_mode = Some(TextWrapMode::Wrap);
|
||||||
.auto_shrink([false; 2])
|
ui.style_mut().override_text_style = Some(TextStyle::Small);
|
||||||
// .show_viewport(ui, |ui, _| {
|
egui::ScrollArea::vertical()
|
||||||
.show_rows(
|
.stick_to_bottom(true)
|
||||||
ui,
|
.max_width(ui.available_width())
|
||||||
ui.text_style_height(&TextStyle::Small),
|
.max_height(ui.available_height())
|
||||||
nb_lines,
|
.auto_shrink([false; 2])
|
||||||
|ui, row_range| {
|
// .show_viewport(ui, |ui, _| {
|
||||||
for i in row_range {
|
.show_rows(
|
||||||
if let Some(line) = text.lines().nth(i) {
|
ui,
|
||||||
ui.label(line);
|
ui.text_style_height(&TextStyle::Small),
|
||||||
}
|
nb_lines,
|
||||||
}
|
|ui, row_range| {
|
||||||
},
|
for i in row_range {
|
||||||
);
|
if let Some(line) = text.lines().nth(i) {
|
||||||
});
|
ui.label(line);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
);
|
||||||
|
})
|
||||||
|
})
|
||||||
|
.response
|
||||||
|
.rect
|
||||||
|
.height() as u32;
|
||||||
}
|
}
|
||||||
|
|
||||||
// input args
|
// input args
|
||||||
|
|
|
@ -29,8 +29,8 @@ use log::debug;
|
||||||
|
|
||||||
use crate::components::gupax::FileWindow;
|
use crate::components::gupax::FileWindow;
|
||||||
use crate::disk::state::Node;
|
use crate::disk::state::Node;
|
||||||
use crate::helper::Process;
|
|
||||||
use crate::helper::node::PubNodeApi;
|
use crate::helper::node::PubNodeApi;
|
||||||
|
use crate::helper::{Process, ProcessName};
|
||||||
use crate::{P2POOL_IN, P2POOL_LOG, P2POOL_OUT, SPACE};
|
use crate::{P2POOL_IN, P2POOL_LOG, P2POOL_OUT, SPACE};
|
||||||
|
|
||||||
impl Node {
|
impl Node {
|
||||||
|
@ -56,7 +56,7 @@ impl Node {
|
||||||
egui::ScrollArea::vertical().show(ui, |ui| {
|
egui::ScrollArea::vertical().show(ui, |ui| {
|
||||||
let text = &api.lock().unwrap().output;
|
let text = &api.lock().unwrap().output;
|
||||||
ui.group(|ui| {
|
ui.group(|ui| {
|
||||||
console(ui, text);
|
console(ui, text, &mut self.console_height, ProcessName::Node);
|
||||||
if !self.simple {
|
if !self.simple {
|
||||||
ui.separator();
|
ui.separator();
|
||||||
input_args_field(
|
input_args_field(
|
||||||
|
|
|
@ -56,7 +56,7 @@ impl P2pool {
|
||||||
egui::ScrollArea::vertical().show(ui, |ui| {
|
egui::ScrollArea::vertical().show(ui, |ui| {
|
||||||
let text = &api_lock.output;
|
let text = &api_lock.output;
|
||||||
ui.group(|ui| {
|
ui.group(|ui| {
|
||||||
console(ui, text);
|
console(ui, text, &mut self.console_height, ProcessName::P2pool);
|
||||||
if !self.simple {
|
if !self.simple {
|
||||||
ui.separator();
|
ui.separator();
|
||||||
input_args_field(
|
input_args_field(
|
||||||
|
|
|
@ -23,8 +23,8 @@ use crate::app::panels::middle::common::state_edit_field::{
|
||||||
};
|
};
|
||||||
use crate::constants::*;
|
use crate::constants::*;
|
||||||
use crate::disk::state::Xmrig;
|
use crate::disk::state::Xmrig;
|
||||||
use crate::helper::Process;
|
|
||||||
use crate::helper::xrig::xmrig::PubXmrigApi;
|
use crate::helper::xrig::xmrig::PubXmrigApi;
|
||||||
|
use crate::helper::{Process, ProcessName};
|
||||||
use crate::miscs::height_txt_before_button;
|
use crate::miscs::height_txt_before_button;
|
||||||
use crate::regex::REGEXES;
|
use crate::regex::REGEXES;
|
||||||
use egui::{Checkbox, Ui, vec2};
|
use egui::{Checkbox, Ui, vec2};
|
||||||
|
@ -58,7 +58,7 @@ impl Xmrig {
|
||||||
egui::ScrollArea::vertical().show(ui, |ui| {
|
egui::ScrollArea::vertical().show(ui, |ui| {
|
||||||
ui.group(|ui| {
|
ui.group(|ui| {
|
||||||
let text = &api.lock().unwrap().output;
|
let text = &api.lock().unwrap().output;
|
||||||
console(ui, text);
|
console(ui, text, &mut self.console_height, ProcessName::Xmrig);
|
||||||
if !self.simple {
|
if !self.simple {
|
||||||
ui.separator();
|
ui.separator();
|
||||||
input_args_field(
|
input_args_field(
|
||||||
|
|
|
@ -24,8 +24,8 @@ use crate::app::panels::middle::common::console::{console, input_args_field, sta
|
||||||
use crate::app::panels::middle::common::header_tab::header_tab;
|
use crate::app::panels::middle::common::header_tab::header_tab;
|
||||||
use crate::app::panels::middle::common::list_poolnode::list_poolnode;
|
use crate::app::panels::middle::common::list_poolnode::list_poolnode;
|
||||||
use crate::disk::state::XmrigProxy;
|
use crate::disk::state::XmrigProxy;
|
||||||
use crate::helper::Process;
|
|
||||||
use crate::helper::xrig::xmrig_proxy::PubXmrigProxyApi;
|
use crate::helper::xrig::xmrig_proxy::PubXmrigProxyApi;
|
||||||
|
use crate::helper::{Process, ProcessName};
|
||||||
use crate::miscs::height_txt_before_button;
|
use crate::miscs::height_txt_before_button;
|
||||||
use crate::regex::REGEXES;
|
use crate::regex::REGEXES;
|
||||||
use crate::{
|
use crate::{
|
||||||
|
@ -59,7 +59,7 @@ impl XmrigProxy {
|
||||||
egui::ScrollArea::vertical().show(ui, |ui| {
|
egui::ScrollArea::vertical().show(ui, |ui| {
|
||||||
ui.group(|ui| {
|
ui.group(|ui| {
|
||||||
let text = &api.lock().unwrap().output;
|
let text = &api.lock().unwrap().output;
|
||||||
console(ui, text);
|
console(ui, text, &mut self.console_height, ProcessName::XmrigProxy);
|
||||||
//---------------------------------------------------------------------------------------------------- [Advanced] Console
|
//---------------------------------------------------------------------------------------------------- [Advanced] Console
|
||||||
if !self.simple {
|
if !self.simple {
|
||||||
ui.separator();
|
ui.separator();
|
||||||
|
|
|
@ -27,6 +27,7 @@ use crate::app::panels::middle::common::console::console;
|
||||||
use crate::app::panels::middle::common::header_tab::header_tab;
|
use crate::app::panels::middle::common::header_tab::header_tab;
|
||||||
use crate::app::panels::middle::common::state_edit_field::StateTextEdit;
|
use crate::app::panels::middle::common::state_edit_field::StateTextEdit;
|
||||||
use crate::disk::state::{ManualDonationLevel, ManualDonationMetric, XvbMode};
|
use crate::disk::state::{ManualDonationLevel, ManualDonationMetric, XvbMode};
|
||||||
|
use crate::helper::ProcessName;
|
||||||
use crate::helper::xrig::xmrig::PubXmrigApi;
|
use crate::helper::xrig::xmrig::PubXmrigApi;
|
||||||
use crate::helper::xrig::xmrig_proxy::PubXmrigProxyApi;
|
use crate::helper::xrig::xmrig_proxy::PubXmrigProxyApi;
|
||||||
use crate::helper::xvb::PubXvbApi;
|
use crate::helper::xvb::PubXvbApi;
|
||||||
|
@ -83,7 +84,7 @@ impl crate::disk::state::Xvb {
|
||||||
debug!("XvB Tab | Rendering [Console]");
|
debug!("XvB Tab | Rendering [Console]");
|
||||||
ui.group(|ui| {
|
ui.group(|ui| {
|
||||||
let text = &api.lock().unwrap().output;
|
let text = &api.lock().unwrap().output;
|
||||||
console(ui, text);
|
console(ui, text, &mut self.console_height, ProcessName::Xvb);
|
||||||
});
|
});
|
||||||
// input token
|
// input token
|
||||||
ui.add_space(SPACE);
|
ui.add_space(SPACE);
|
||||||
|
|
|
@ -301,6 +301,7 @@ pub struct P2pool {
|
||||||
pub zmq: String,
|
pub zmq: String,
|
||||||
pub selected_node: SelectedPoolNode,
|
pub selected_node: SelectedPoolNode,
|
||||||
pub prefer_local_node: bool,
|
pub prefer_local_node: bool,
|
||||||
|
pub console_height: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
// compatible for P2Pool and Xmrig/Proxy
|
// compatible for P2Pool and Xmrig/Proxy
|
||||||
|
@ -328,6 +329,7 @@ pub struct Node {
|
||||||
pub dns_blocklist: bool,
|
pub dns_blocklist: bool,
|
||||||
pub disable_dns_checkpoint: bool,
|
pub disable_dns_checkpoint: bool,
|
||||||
pub path_db: String,
|
pub path_db: String,
|
||||||
|
pub console_height: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for Node {
|
impl Default for Node {
|
||||||
|
@ -346,6 +348,7 @@ impl Default for Node {
|
||||||
dns_blocklist: true,
|
dns_blocklist: true,
|
||||||
disable_dns_checkpoint: true,
|
disable_dns_checkpoint: true,
|
||||||
path_db: String::new(),
|
path_db: String::new(),
|
||||||
|
console_height: APP_DEFAULT_CONSOLE_HEIGHT,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -369,6 +372,7 @@ pub struct Xmrig {
|
||||||
pub port: String,
|
pub port: String,
|
||||||
pub selected_pool: SelectedPoolNode,
|
pub selected_pool: SelectedPoolNode,
|
||||||
pub token: String,
|
pub token: String,
|
||||||
|
pub console_height: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
// present for future.
|
// present for future.
|
||||||
|
@ -391,6 +395,7 @@ pub struct XmrigProxy {
|
||||||
pub selected_pool: SelectedPoolNode,
|
pub selected_pool: SelectedPoolNode,
|
||||||
pub token: String,
|
pub token: String,
|
||||||
pub redirect_local_xmrig: bool,
|
pub redirect_local_xmrig: bool,
|
||||||
|
pub console_height: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Gupax {
|
impl Gupax {
|
||||||
|
@ -453,6 +458,7 @@ impl Default for XmrigProxy {
|
||||||
api_port: "18089".to_string(),
|
api_port: "18089".to_string(),
|
||||||
tls: false,
|
tls: false,
|
||||||
keepalive: false,
|
keepalive: false,
|
||||||
|
console_height: APP_DEFAULT_CONSOLE_HEIGHT,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -469,6 +475,7 @@ pub struct Xvb {
|
||||||
pub manual_donation_metric: ManualDonationMetric,
|
pub manual_donation_metric: ManualDonationMetric,
|
||||||
pub p2pool_buffer: i8,
|
pub p2pool_buffer: i8,
|
||||||
pub use_p2pool_sidechain_hr: bool,
|
pub use_p2pool_sidechain_hr: bool,
|
||||||
|
pub console_height: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Eq, PartialEq, Debug, Deserialize, Serialize, Default, EnumCount, EnumIter)]
|
#[derive(Clone, Eq, PartialEq, Debug, Deserialize, Serialize, Default, EnumCount, EnumIter)]
|
||||||
|
@ -621,6 +628,7 @@ impl Default for P2pool {
|
||||||
zmq_rig: "18083".to_string(),
|
zmq_rig: "18083".to_string(),
|
||||||
},
|
},
|
||||||
prefer_local_node: true,
|
prefer_local_node: true,
|
||||||
|
console_height: APP_DEFAULT_CONSOLE_HEIGHT,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -665,6 +673,7 @@ impl Default for Xmrig {
|
||||||
.take(16)
|
.take(16)
|
||||||
.map(char::from)
|
.map(char::from)
|
||||||
.collect(),
|
.collect(),
|
||||||
|
console_height: APP_DEFAULT_CONSOLE_HEIGHT,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -682,6 +691,7 @@ impl Default for Xvb {
|
||||||
manual_donation_metric: Default::default(),
|
manual_donation_metric: Default::default(),
|
||||||
p2pool_buffer: 25,
|
p2pool_buffer: 25,
|
||||||
use_p2pool_sidechain_hr: false,
|
use_p2pool_sidechain_hr: false,
|
||||||
|
console_height: APP_DEFAULT_CONSOLE_HEIGHT,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -84,6 +84,7 @@ mod test {
|
||||||
rpc = "18089"
|
rpc = "18089"
|
||||||
zmq = "18083"
|
zmq = "18083"
|
||||||
prefer_local_node = true
|
prefer_local_node = true
|
||||||
|
console_height = 360
|
||||||
|
|
||||||
[p2pool.selected_node]
|
[p2pool.selected_node]
|
||||||
index = 0
|
index = 0
|
||||||
|
@ -109,6 +110,7 @@ mod test {
|
||||||
ip = "192.168.1.122"
|
ip = "192.168.1.122"
|
||||||
port = "3333"
|
port = "3333"
|
||||||
token = "testtoken"
|
token = "testtoken"
|
||||||
|
console_height = 360
|
||||||
|
|
||||||
|
|
||||||
[xmrig.selected_pool]
|
[xmrig.selected_pool]
|
||||||
|
@ -136,6 +138,7 @@ mod test {
|
||||||
p2pool_port = "18088"
|
p2pool_port = "18088"
|
||||||
token = "testtoken"
|
token = "testtoken"
|
||||||
redirect_local_xmrig = true
|
redirect_local_xmrig = true
|
||||||
|
console_height = 360
|
||||||
|
|
||||||
[xmrig_proxy.selected_pool]
|
[xmrig_proxy.selected_pool]
|
||||||
index = 0
|
index = 0
|
||||||
|
@ -157,6 +160,7 @@ mod test {
|
||||||
node = "Europe"
|
node = "Europe"
|
||||||
p2pool_buffer = 5
|
p2pool_buffer = 5
|
||||||
use_p2pool_sidechain_hr = false
|
use_p2pool_sidechain_hr = false
|
||||||
|
console_height = 360
|
||||||
|
|
||||||
[node]
|
[node]
|
||||||
simple = false
|
simple = false
|
||||||
|
@ -172,6 +176,7 @@ mod test {
|
||||||
dns_blocklist = true
|
dns_blocklist = true
|
||||||
disable_dns_checkpoint = true
|
disable_dns_checkpoint = true
|
||||||
path_db = ""
|
path_db = ""
|
||||||
|
console_height = 360
|
||||||
|
|
||||||
[version]
|
[version]
|
||||||
gupax = "v1.3.0"
|
gupax = "v1.3.0"
|
||||||
|
|
|
@ -40,6 +40,7 @@ pub const APP_MAX_HEIGHT: f32 = 2160.0;
|
||||||
// Default, 1280x960
|
// Default, 1280x960
|
||||||
pub const APP_DEFAULT_WIDTH: f32 = 1280.0;
|
pub const APP_DEFAULT_WIDTH: f32 = 1280.0;
|
||||||
pub const APP_DEFAULT_HEIGHT: f32 = 960.0;
|
pub const APP_DEFAULT_HEIGHT: f32 = 960.0;
|
||||||
|
pub const APP_DEFAULT_CONSOLE_HEIGHT: u32 = 360;
|
||||||
// App resolution scaling
|
// App resolution scaling
|
||||||
pub const APP_MIN_SCALE: f32 = 0.1;
|
pub const APP_MIN_SCALE: f32 = 0.1;
|
||||||
pub const APP_MAX_SCALE: f32 = 2.0;
|
pub const APP_MAX_SCALE: f32 = 2.0;
|
||||||
|
|
Loading…
Reference in a new issue