Skip to content

Commit 87648aa

Browse files
authored
Merge pull request #1955 from mintlayer/node_gui_visual_improvements2
More node gui visual improvements; fix wallet recovery in node-gui
2 parents ad7da96 + 984beeb commit 87648aa

7 files changed

Lines changed: 60 additions & 18 deletions

File tree

node-gui/backend/src/backend_impl.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,9 @@ use super::{
6363
wallet_events::GuiWalletEvents,
6464
};
6565

66-
const TRANSACTION_LIST_PAGE_COUNT: usize = 10;
66+
/// This number of transactions will fit into the corresponding widget when the main window
67+
/// has the initial height (both when the status bar is visible and when it's not).
68+
const TRANSACTION_LIST_PAGE_COUNT: usize = 16;
6769
/// In which top N MB should we aim for our transactions to be in the mempool
6870
/// e.g. for 5, we aim to be in the top 5 MB of transactions based on paid fees
6971
/// This is to avoid getting trimmed off the lower end if the mempool runs out of memory

node-gui/src/main.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ use iced::{
2626
advanced::graphics::core::window,
2727
executor, font,
2828
widget::{column, row, text, tooltip, Text},
29-
Element, Length, Settings, Subscription, Task, Theme,
29+
Element, Length, Settings, Size, Subscription, Task, Theme,
3030
};
3131
use iced_aw::widgets::spinner::Spinner;
3232
use tokio::sync::mpsc::UnboundedReceiver;
@@ -46,6 +46,10 @@ const HOT_WALLET_TOOLTIP_TEXT: &str = "Start the wallet in Hot mode and connect
4646
const MAIN_NETWORK_TOOLTIP: &str = "The 'Mainnet' is the main network that has coins with value.";
4747
const TEST_NETWORK_TOOLTIP: &str = "The 'Testnet' is the network with coins that have no value, but is used for testing various applications before deploying them on Mainnet.";
4848

49+
// Note: these are the default values used by iced.
50+
const INITIAL_MAIN_WINDOW_WIDTH: f32 = 1024.0;
51+
const INITIAL_MAIN_WINDOW_HEIGHT: f32 = 768.0;
52+
4953
pub fn main() -> iced::Result {
5054
utils::rust_backtrace::enable();
5155

@@ -56,6 +60,7 @@ pub fn main() -> iced::Result {
5660
.subscription(subscription)
5761
.theme(theme)
5862
.window(window::Settings {
63+
size: Size::new(INITIAL_MAIN_WINDOW_WIDTH, INITIAL_MAIN_WINDOW_HEIGHT),
5964
exit_on_close_request: false,
6065
..Default::default()
6166
})

node-gui/src/main_window/main_widget/tabs/wallet/console.rs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ use iced::{
1818
Element, Length,
1919
};
2020

21+
use node_gui_backend::messages::WalletInfo;
22+
23+
use crate::main_window::main_widget::tabs::wallet::{
24+
status_bar::estimate_status_bar_height, STATUS_BAR_SEPARATOR_HEIGHT,
25+
};
26+
2127
use super::{ConsoleState, WalletMessage};
2228

2329
const SUBMIT_TOOLTIP_TEXT: &str = "Submit the provided command to be processed";
@@ -26,6 +32,7 @@ pub const CONSOLE_OUTPUT_ID: &str = "console_input_id";
2632
pub fn view_console(
2733
state: &ConsoleState,
2834
still_syncing: Option<WalletMessage>,
35+
wallet_info: &WalletInfo,
2936
) -> Element<'static, WalletMessage> {
3037
let s: Vec<String> = state
3138
.console_inputs
@@ -35,8 +42,20 @@ pub fn view_console(
3542
.collect();
3643

3744
let output = s.join("\n");
45+
// Note: it doesn't seem possible to make Scrollable fill the entire parent container,
46+
// e.g. passing Length::Fill for height will result in a panic:
47+
// "scrollable content must not fill its vertical scrolling axis".
48+
// So we have to use a fixed height. The value is chosen such that when the main window
49+
// has the initial height, the console widget fills the entire area of its parent.
50+
// But we also have to take the status bar into account.
51+
#[allow(clippy::float_arithmetic)]
52+
let height = {
53+
let status_bar_height =
54+
estimate_status_bar_height(&wallet_info.extra_info) + STATUS_BAR_SEPARATOR_HEIGHT;
55+
Length::Fixed(570.0 - status_bar_height)
56+
};
3857
let console_output = Scrollable::new(iced::widget::text(output.clone()))
39-
.height(Length::Fixed(350.0))
58+
.height(height)
4059
.width(Length::Fill)
4160
.id(Id::new(CONSOLE_OUTPUT_ID));
4261

node-gui/src/main_window/main_widget/tabs/wallet/mod.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ use crate::main_window::NodeState;
5252

5353
use super::{Tab, TabsMessage};
5454

55+
pub const STATUS_BAR_SEPARATOR_HEIGHT: f32 = 1.0;
56+
5557
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
5658
pub enum SelectedPanel {
5759
Transactions,
@@ -550,6 +552,7 @@ impl Tab for WalletTab {
550552
SelectedPanel::Console => console::view_console(
551553
&self.account_state.console_state,
552554
still_syncing.clone(),
555+
wallet_info,
553556
),
554557
};
555558

@@ -577,7 +580,7 @@ impl Tab for WalletTab {
577580
{
578581
Element::new(column![
579582
pane_grid,
580-
horizontal_rule(1),
583+
horizontal_rule(STATUS_BAR_SEPARATOR_HEIGHT),
581584
container(status_bar).width(Length::Fill)
582585
])
583586
} else {

node-gui/src/main_window/main_widget/tabs/wallet/status_bar.rs

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,27 @@ use wallet_controller::types::WalletExtraInfo;
2323

2424
use super::WalletMessage;
2525

26+
const TEXT_SIZE: f32 = 16.;
27+
const VERTICAL_PADDING: f32 = 5.;
28+
const HORIZONTAL_PADDING: f32 = 10.;
29+
30+
#[allow(clippy::float_arithmetic)]
31+
pub fn estimate_status_bar_height(wallet_info: &WalletExtraInfo) -> f32 {
32+
match wallet_info {
33+
WalletExtraInfo::SoftwareWallet => 0.,
34+
WalletExtraInfo::TrezorWallet { .. } => {
35+
TEXT_SIZE + 2. * VERTICAL_PADDING
36+
// For some reason, the status bar gets a bit of additional height.
37+
+ 4.
38+
}
39+
}
40+
}
41+
2642
pub fn view_status_bar(wallet_info: &WalletExtraInfo) -> Option<Element<'static, WalletMessage>> {
2743
let bold_font = Font {
2844
weight: font::Weight::Bold,
2945
..Font::default()
3046
};
31-
let text_size = 16;
3247

3348
let row = match wallet_info {
3449
WalletExtraInfo::SoftwareWallet => {
@@ -44,28 +59,25 @@ pub fn view_status_bar(wallet_info: &WalletExtraInfo) -> Option<Element<'static,
4459

4560
row![
4661
rich_text([span("Device name: ").font(bold_font), span(device_name.clone())])
47-
.size(text_size),
62+
.size(TEXT_SIZE),
4863
rich_text([
4964
span("Firmware version: ").font(bold_font),
5065
span(firmware_version.clone())
5166
])
52-
.size(text_size),
67+
.size(TEXT_SIZE),
5368
]
5469
}
5570
};
5671

57-
let vertical_padding = 5.;
58-
let horizontal_padding = 10.;
59-
6072
let status_bar = Container::new(
6173
row.width(Length::Fill)
6274
.padding(Padding {
63-
top: vertical_padding,
64-
right: horizontal_padding,
65-
bottom: vertical_padding,
66-
left: horizontal_padding,
75+
top: VERTICAL_PADDING,
76+
right: HORIZONTAL_PADDING,
77+
bottom: VERTICAL_PADDING,
78+
left: HORIZONTAL_PADDING,
6779
})
68-
.spacing(horizontal_padding)
80+
.spacing(HORIZONTAL_PADDING)
6981
.align_y(Alignment::Center),
7082
)
7183
.style(|theme: &Theme| {

node-gui/src/main_window/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -882,7 +882,7 @@ impl MainWindow {
882882
WalletType::Trezor => hw_wallet_create_dialog(
883883
Box::new(move || MainWindowMessage::ImportWalletMnemonic {
884884
args: WalletArgs::Trezor,
885-
import: ImportOrCreate::Create,
885+
import: ImportOrCreate::Import,
886886
}),
887887
Box::new(|| MainWindowMessage::CloseDialog),
888888
ImportOrCreate::Import,

wallet/src/account/transaction_list/mod.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,11 @@ pub struct TransactionInfo {
8282

8383
#[derive(Debug, Clone, Serialize)]
8484
pub struct TransactionList {
85-
/// How many transactions are in the single page (currently it's always 10)
85+
/// How many transactions are in a single page.
8686
pub count: usize,
8787

88-
/// How many transactions the user has seen and scrolled through (normally it can be 0, 10, 20, etc.)
88+
/// How many transactions the user has seen and scrolled through
89+
/// (normally it will be a multiple of `count`).
8990
pub skip: usize,
9091

9192
/// Total number of transactions

0 commit comments

Comments
 (0)