Skip to content

Commit

Permalink
update header crates for iced-rs 0.12.1
Browse files Browse the repository at this point in the history
  • Loading branch information
yeastplume committed Mar 13, 2024
1 parent 32857d2 commit b079297
Show file tree
Hide file tree
Showing 27 changed files with 1,244 additions and 1,273 deletions.
13 changes: 0 additions & 13 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ debug = ["iced/debug"]

[dependencies]
grin-gui-core = { version = "0.1.0-alpha.6", path = "crates/core", features = ["wgpu"]}
grin-gui-widgets = { version = "0.1.0-alpha.6", path = "crates/widgets" }

iced = { version = "0.10", features = ["canvas", "tokio"] }
iced_futures = { version = "0.7", features = ["async-std"] }
Expand Down
4 changes: 0 additions & 4 deletions crates/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ grin_servers = { git = "https://github.com/mimblewimble/grin", branch = "master"
grin_keychain = { git = "https://github.com/mimblewimble/grin", branch = "master"}
grin_chain = { git = "https://github.com/mimblewimble/grin", branch = "master"}



### Wallet
grin_wallet = { git = "https://github.com/mimblewimble/grin-wallet", branch = "contracts" }
grin_wallet_config = { git = "https://github.com/mimblewimble/grin-wallet", branch = "contracts" }
Expand All @@ -46,7 +44,6 @@ grin_wallet_api = { git = "https://github.com/mimblewimble/grin-wallet", branch
grin_wallet_impls = { git = "https://github.com/mimblewimble/grin-wallet", branch = "contracts" }
grin_wallet_libwallet = { git = "https://github.com/mimblewimble/grin-wallet", branch = "contracts" }


############ Local testing ################
### Node
# grin_config = { path = "../../../grin/config" }
Expand All @@ -65,7 +62,6 @@ grin_wallet_libwallet = { git = "https://github.com/mimblewimble/grin-wallet", b
#grin_wallet_impls = { path = "../../../grin-wallet/impls"}
#grin_wallet_libwallet = { path = "../../../grin-wallet/libwallet"}

grin-gui-widgets = { path = "../widgets" }
regex = "1.4.3"
fancy-regex = "0.5.0" # Regex with backtracking
async-std = { version = "1.9.0", features = ["unstable"] }
Expand Down
12 changes: 7 additions & 5 deletions crates/core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,17 @@

pub mod backup;
pub mod config;
pub mod wallet;
pub mod logger;
pub mod node;
pub mod error;
pub mod fs;
pub mod theme;
pub mod logger;
pub mod network;
pub mod node;
pub mod style;
pub mod theme;
#[cfg(feature = "wgpu")]
pub mod utility;
pub mod wallet;
pub mod widget;

#[macro_use]
extern crate lazy_static;
Expand All @@ -21,5 +23,5 @@ extern crate lazy_static;
extern crate log;

// Re-exports
pub use grin_util::logger::{LoggingConfig, LogEntry};
pub use grin_core::consensus::GRIN_BASE;
pub use grin_util::logger::{LogEntry, LoggingConfig};
58 changes: 58 additions & 0 deletions crates/core/src/style/header.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
use iced::Theme;
use iced_core::{Background, Color};

/// The appearance of a header.
#[derive(Debug, Clone, Copy)]
pub struct Appearance {
pub text_color: Option<Color>,
pub background: Option<Background>,
pub border_radius: f32,
pub border_width: f32,
pub border_color: Color,
pub offset_left: f32,
pub offset_right: f32,
}

/// A set of rules that dictate the style of a header.
pub trait StyleSheet {
type Style: std::default::Default + Copy;

/// Produces the style of a header.
fn appearance(&self, style: &Self::Style) -> Appearance;

/// Produces the a hovered appearance for header.
fn hovered(&self, style: &Self::Style) -> Appearance;
}

#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub enum HeaderStyle {
#[default]
Default,
}

impl StyleSheet for Theme {
type Style = HeaderStyle;

fn appearance(&self, style: &Self::Style) -> Appearance {
match style {
HeaderStyle::Default => Appearance {
//text_color: Some(self.palette.bright.surface),
text_color: None,
background: Some(Background::Color(self.palette().primary)),
border_radius: 0.0,
border_width: 0.0,
border_color: Color::TRANSPARENT,
offset_right: 0.0,
offset_left: 0.0,
},
}
}

fn hovered(&self, style: &Self::Style) -> Appearance {
let appearance = self.appearance(style);
Appearance {
background: None,
..appearance
}
}
}
File renamed without changes.
134 changes: 134 additions & 0 deletions crates/core/src/style/table_row.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
use iced::Theme;
use iced::{Background, Color};

/// The appearance of a table row.
#[derive(Debug, Clone, Copy, Default)]
pub struct Appearance {
pub text_color: Option<Color>,
pub background: Option<Background>,
pub border_radius: f32,
pub border_width: f32,
pub border_color: Color,
pub offset_left: f32,
pub offset_right: f32,
}

/// A set of rules that dictate the style of a table row.
pub trait StyleSheet {
type Style: std::default::Default + Copy;

/// Produces the default appearance of a table row.
fn appearance(&self, style: &Self::Style) -> Appearance;

/// Produces the hovered appearance table row.
fn hovered(&self, style: &Self::Style) -> Appearance;
}

#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub enum TableRowStyle {
#[default]
Default,
TableRowAlternate,
TableRowHighlife,
TableRowLowlife,
TableRowSelected,
}

impl StyleSheet for Theme {
type Style = TableRowStyle;

fn appearance(&self, style: &Self::Style) -> Appearance {
match style {
TableRowStyle::Default => Appearance {
text_color: Some(self.palette().primary),
background: Some(Background::Color(self.palette().primary)),
border_radius: 0.0,
border_width: 0.0,
border_color: Color::TRANSPARENT,
// offset_left: 10.0,
// offset_right: 25.0,
offset_left: 0.0,
offset_right: 0.0,
},
TableRowStyle::TableRowAlternate => Appearance {
background: Some(Background::Color(Color {
a: 0.50,
..self.palette().primary
})),
..Appearance::default()
},
TableRowStyle::TableRowHighlife => Appearance {
text_color: Some(self.palette().primary),
background: Some(Background::Color(Color {
a: 0.30,
..self.palette().primary
})),
border_radius: 0.0,
border_width: 0.0,
border_color: Color::TRANSPARENT,
offset_left: 0.0,
offset_right: 0.0,
},
TableRowStyle::TableRowLowlife => Appearance {
text_color: Some(self.palette().primary),
background: Some(Background::Color(Color::TRANSPARENT)),
border_radius: 0.0,
border_width: 0.0,
border_color: Color::TRANSPARENT,
offset_left: 0.0,
offset_right: 0.0,
},
TableRowStyle::TableRowSelected => Appearance {
text_color: Some(self.palette().primary),
background: Some(Background::Color(self.palette().primary)),
border_radius: 0.0,
border_width: 0.0,
border_color: Color::TRANSPARENT,
offset_left: 0.0,
offset_right: 0.0,
},
}
}

fn hovered(&self, style: &Self::Style) -> Appearance {
let appearance = self.appearance(style);

match style {
TableRowStyle::Default => Appearance {
background: Some(Background::Color(Color {
a: 0.60,
..self.palette().primary
})),
..appearance
},
TableRowStyle::TableRowAlternate => Appearance {
background: Some(Background::Color(Color {
a: 0.25,
..self.palette().primary
})),
..appearance
},
TableRowStyle::TableRowHighlife => Appearance {
background: Some(Background::Color(Color {
a: 0.60,
..self.palette().primary
})),
..appearance
},
TableRowStyle::TableRowLowlife => Appearance {
background: Some(Background::Color(Color {
a: 0.60,
..self.palette().primary
})),
..appearance
},
TableRowStyle::TableRowSelected => Appearance {
background: Some(Background::Color(Color {
a: 0.60,
..self.palette().primary
})),
..appearance
},
}
}
}
Loading

0 comments on commit b079297

Please sign in to comment.