Skip to content

Commit

Permalink
more updates
Browse files Browse the repository at this point in the history
  • Loading branch information
yeastplume committed Mar 20, 2024
1 parent 414fda1 commit 21f6ed5
Show file tree
Hide file tree
Showing 9 changed files with 458 additions and 1,128 deletions.
1,463 changes: 395 additions & 1,068 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ iced_renderer = { version = "0.12" }
iced_core = { version = "0.12" }
iced_aw = { version = "0.8", default-features = false, features = ["card", "modal"]}

plotters-iced = "0.9.0"
plotters-iced = "0.10.0"
plotters="0.3"
plotters-backend = "0.3"
rand = "0.8.3"
Expand Down
5 changes: 3 additions & 2 deletions crates/core/src/theme/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,11 @@ pub type Text<'a> = iced::widget::Text<'a, Theme, Renderer>;
pub type TextInput<'a, Message> = iced::widget::TextInput<'a, Message, Theme, Renderer>;
pub type Button<'a, Message> = iced::widget::Button<'a, Message, Theme, Renderer>;
pub type Scrollable<'a, Message> = iced::widget::Scrollable<'a, Message, Theme, Renderer>;
pub type PickList<'a, T, Message> = iced::widget::PickList<'a, T, Message, Theme, Renderer>;
pub type PickList<'a, T, L, V, Message> =
iced::widget::PickList<'a, T, L, V, Message, Theme, Renderer>;
pub type Radio<Message> = iced::widget::Radio<Message, Theme, Renderer>;
pub type Card<'a, Message> = iced_aw::native::Card<'a, Message, Theme, Renderer>;
pub type Modal<'a, Content, Message> = iced_aw::modal::Modal<'a, Content, Message>;
pub type Modal<'a, Message, Theme, Renderer> = iced_aw::modal::Modal<'a, Message, Theme, Renderer>;
pub type Header<'a, Message> = crate::widget::header::Header<'a, Message, Theme, Renderer>;
pub type TableRow<'a, Message> = crate::widget::table_row::TableRow<'a, Message, Theme, Renderer>;

Expand Down
28 changes: 11 additions & 17 deletions src/gui/element/settings/general.rs
Original file line number Diff line number Diff line change
Expand Up @@ -458,14 +458,11 @@ pub fn data_container<'a>(state: &'a StateContainer, config: &Config) -> Contain

#[cfg(target_os = "windows")]
let close_to_tray_column = {
let checkbox = Checkbox::new(
localized_string("close-to-tray"),
config.close_to_tray,
Interaction::ToggleCloseToTray,
)
.style(grin_gui_core::theme::CheckboxStyle::Normal)
.text_size(DEFAULT_FONT_SIZE)
.spacing(5);
let checkbox = Checkbox::new(localized_string("close-to-tray"), config.close_to_tray)
.style(grin_gui_core::theme::CheckboxStyle::Normal)
.text_size(DEFAULT_FONT_SIZE)
.on_toggle(Interaction::ToggleCloseToTray)
.spacing(5);

let checkbox: Element<Interaction> = checkbox.into();

Expand All @@ -476,14 +473,11 @@ pub fn data_container<'a>(state: &'a StateContainer, config: &Config) -> Contain

#[cfg(target_os = "windows")]
let toggle_autostart_column = {
let checkbox = Checkbox::new(
localized_string("toggle-autostart"),
config.autostart,
Interaction::ToggleAutoStart,
)
.style(grin_gui_core::theme::CheckboxStyle::Normal)
.text_size(DEFAULT_FONT_SIZE)
.spacing(5);
let checkbox = Checkbox::new(localized_string("toggle-autostart"), config.autostart)
.style(grin_gui_core::theme::CheckboxStyle::Normal)
.text_size(DEFAULT_FONT_SIZE)
.on_toggle(Interaction::ToggleAutoStart)
.spacing(5);

let checkbox: Element<Interaction> = checkbox.into();

Expand All @@ -497,10 +491,10 @@ pub fn data_container<'a>(state: &'a StateContainer, config: &Config) -> Contain
let checkbox = Checkbox::new(
localized_string("start-closed-to-tray"),
config.start_closed_to_tray,
Interaction::ToggleStartClosedToTray,
)
.style(grin_gui_core::theme::CheckboxStyle::Normal)
.text_size(DEFAULT_FONT_SIZE)
.on_toggle(Interaction::ToggleStartClosedToTray)
.spacing(5);

let checkbox: Element<Interaction> = checkbox.into();
Expand Down
15 changes: 6 additions & 9 deletions src/gui/element/wallet/operation/create_tx_contracts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -374,18 +374,15 @@ pub fn data_container<'a>(config: &'a Config, state: &'a StateContainer) -> Cont
.style(grin_gui_core::theme::ContainerStyle::NormalBackground);*/

let checkbox_column = {
let checkbox = Checkbox::new(
localized_string("wallet-self-send"),
state.is_self_send,
|v| {
let checkbox = Checkbox::new(localized_string("wallet-self-send"), state.is_self_send)
.on_toggle(|v| {
Interaction::WalletOperationCreateTxContractsViewInteraction(
LocalViewInteraction::SelfSendSelected(v),
)
},
)
.style(grin_gui_core::theme::CheckboxStyle::Normal)
.text_size(DEFAULT_FONT_SIZE)
.spacing(5);
})
.style(grin_gui_core::theme::CheckboxStyle::Normal)
.text_size(DEFAULT_FONT_SIZE)
.spacing(5);

let checkbox: Element<Interaction> = checkbox.into();

Expand Down
2 changes: 1 addition & 1 deletion src/gui/element/wallet/operation/open.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ pub fn data_container<'a>(state: &'a StateContainer, config: &Config) -> Contain
.size(DEFAULT_FONT_SIZE)
.padding(6)
.style(grin_gui_core::theme::TextInputStyle::AddonsQuery)
.password();
.secure(true);

let password_input: Element<Interaction> = password_input.into();

Expand Down
5 changes: 3 additions & 2 deletions src/gui/element/wallet/operation/tx_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use {
crate::Result,
grin_gui_core::theme::{
Button, Column, Container, Element, Header, PickList, Row, Scrollable, TableRow, Text,
TextInput,
TextInput, Theme,
},
grin_gui_core::widget::header,
grin_gui_core::{
Expand Down Expand Up @@ -895,7 +895,7 @@ pub fn titles_row_header<'a>(
column_state: &'a [ColumnState],
previous_column_key: Option<ColumnKey>,
previous_sort_direction: Option<SortDirection>,
) -> Container<'a, Message> {
) -> Header<'a, Message> {
// A row containing titles above the addon rows.
let mut row_titles = vec![];

Expand Down Expand Up @@ -954,6 +954,7 @@ pub fn titles_row_header<'a>(
)
.spacing(1)
.height(Length::Fixed(25.0))
.into()
/* .on_resize(3, |event| {
//TODO
//Message::Interaction(Interaction::ResizeColumn(Mode::Catalog, event))
Expand Down
30 changes: 19 additions & 11 deletions src/gui/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@ use grin_gui_core::{
subscriber::{self, UIMessage},
ChainTypes, NodeInterface,
},
theme::{Button, ColorPalette, Column, Container, PickList, Row, Scrollable, Text, Theme},
theme::{
Button, ColorPalette, Column, Container, Modal, PickList, Row, Scrollable, Text, Theme,
},
wallet::{get_grin_wallet_default_path, global, HTTPNodeClient, WalletInterfaceHttpNodeClient},
};

use iced::widget::{button, pick_list, scrollable, text_input, Checkbox, Space, TextInput};
use iced::{
alignment, font, window, Alignment, Application, Command, Length, Settings, Subscription,
alignment, font, window, Alignment, Application, Command, Length, Settings, Size, Subscription,
};

use iced_aw::{modal, Card, Modal};

use iced_futures::futures::channel::mpsc;

use image::ImageFormat;
Expand Down Expand Up @@ -145,9 +145,9 @@ impl Application for GrinGui {
type Executor = iced::executor::Default;
type Message = Message;
type Flags = Config;
type Theme = iced::Theme;
type Theme = Theme;

fn theme(&self) -> iced::Theme {
fn theme(&self) -> Theme {
self.theme.clone()
}

Expand Down Expand Up @@ -293,7 +293,8 @@ impl Application for GrinGui {
}
};

Modal::new(self.show_modal, underlay, content)
// self.show_modal?
Modal::new(underlay, Some(content))
.on_esc(Message::Interaction(Interaction::CloseErrorModal))
.style(grin_gui_core::theme::ModalStyle::Normal)
.into()
Expand All @@ -310,25 +311,32 @@ pub fn run(opts: Opts, config: Config) {
log::debug!("config loaded:\n{:#?}", &config);

let mut settings = Settings::default();
settings.window.size = config.window_size.unwrap_or((900, 620));
let size = Size {
width: config.window_size.unwrap_or((900, 620)).0 as f32,
height: config.window_size.unwrap_or((900, 620)).1 as f32,
};
settings.window.size = size;

#[cfg(target_os = "macos")]
{
// false needed for Application shutdown
settings.exit_on_close_request = false;
settings.windows.exit_on_close_request = false;
}

#[cfg(target_os = "windows")]
{
settings.exit_on_close_request = false;
settings.window.exit_on_close_request = false;
}

#[cfg(not(target_os = "linux"))]
// TODO (casperstorm): Due to an upstream bug, min_size causes the window to become unresizable
// on Linux.
// @see: https://github.com/ajour/ajour/issues/427
{
settings.window.min_size = Some((600, 300));
settings.window.min_size = Some(Size {
width: 600.0,
height: 300.0,
});
}

#[cfg(feature = "wgpu")]
Expand Down
36 changes: 19 additions & 17 deletions src/gui/update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -271,10 +271,10 @@ pub fn handle_message(grin_gui: &mut GrinGui, message: Message) -> Result<Comman
}
grin_gui.error = err;
}
Message::RuntimeEvent(iced_core::Event::Window(iced_core::window::Event::Resized {
width,
height,
})) => {
Message::RuntimeEvent(iced_core::Event::Window(
iced_core::window::Id::MAIN,
iced_core::window::Event::Resized { width, height },
)) => {
let width = (width as f64 * grin_gui.general_settings_state.scale_state.scale) as u32;
let height = (height as f64 * grin_gui.general_settings_state.scale_state.scale) as u32;

Expand All @@ -297,6 +297,7 @@ pub fn handle_message(grin_gui: &mut GrinGui, message: Message) -> Result<Comman

#[cfg(target_os = "windows")]
Message::RuntimeEvent(iced_core::Event::Window(
iced_core::window::Id::MAIN,
iced_core::window::Event::CloseRequested,
)) => {
log::debug!("Message::RuntimeEvent(CloseRequested)");
Expand All @@ -305,13 +306,14 @@ pub fn handle_message(grin_gui: &mut GrinGui, message: Message) -> Result<Comman
if grin_gui.config.close_to_tray {
let _ = sender.try_send(TrayMessage::CloseToTray);
} else {
return Ok(window::close());
return Ok(window::close(iced_core::window::Id::MAIN));
}
}
}
Message::RuntimeEvent(iced_core::Event::Keyboard(
iced_core::keyboard::Event::KeyReleased {
key_code,
key,
location,
modifiers,
},
)) => {
Expand All @@ -323,21 +325,21 @@ pub fn handle_message(grin_gui: &mut GrinGui, message: Message) -> Result<Comman
return Ok(Command::none());
}

match key_code {
iced::keyboard::KeyCode::A => {}
iced::keyboard::KeyCode::C => {
match key {
iced::keyboard::Key::Character(A) => {}
iced::keyboard::Key::Character(C) => {
grin_gui.mode = Mode::Catalog;
}
iced::keyboard::KeyCode::R => {}
iced::keyboard::KeyCode::S => {
iced::keyboard::Key::Character(R) => {}
iced::keyboard::Key::Character(S) => {
grin_gui.mode = Mode::Settings;
}
iced::keyboard::KeyCode::U => {}
iced::keyboard::KeyCode::W => {}
iced::keyboard::KeyCode::I => {
iced::keyboard::Key::Character(U) => {}
iced::keyboard::Key::Character(W) => {}
iced::keyboard::Key::Character(I) => {
grin_gui.mode = Mode::Install;
}
iced::keyboard::KeyCode::Escape => match grin_gui.mode {
iced::keyboard::Key::Named(Escape) => match grin_gui.mode {
_ => (),
},
_ => (),
Expand Down Expand Up @@ -408,7 +410,7 @@ pub fn handle_message(grin_gui: &mut GrinGui, message: Message) -> Result<Comman
// Application shutdown
Message::Interaction(Interaction::Exit) => {
grin_gui.safe_exit();
return Ok(window::close());
return Ok(window::close(iced_core::window::Id::MAIN));
}
Message::Interaction(Interaction::ExitCancel) => {
grin_gui.show_exit(false);
Expand All @@ -420,7 +422,7 @@ pub fn handle_message(grin_gui: &mut GrinGui, message: Message) -> Result<Comman

#[cfg(target_os = "windows")]
if SHOULD_EXIT.load(Ordering::Relaxed) {
return Ok(window::close());
return Ok(window::close(iced_core::window::Id::MAIN));
}

Ok(Command::none())
Expand Down

0 comments on commit 21f6ed5

Please sign in to comment.