forked from mimblewimble/grin-gui
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Table row styles should be in the same module as the theme.
- Loading branch information
Showing
7 changed files
with
137 additions
and
148 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
use super::Theme; | ||
use crate::widgets::table_row::Appearance; | ||
use crate::widgets::style::table_row::StyleSheetAssociated; | ||
use iced_native::{Background, Color}; | ||
|
||
|
||
#[derive(Debug, Clone, Copy, Default)] | ||
pub enum TableRowStyle { | ||
#[default] | ||
Default, | ||
TableRowAlternate, | ||
TableRowHighlife, | ||
TableRowLowlife, | ||
TableRowSelected, | ||
} | ||
|
||
impl StyleSheetAssociated for Theme { | ||
type Style = TableRowStyle; | ||
|
||
fn appearance(&self, style: Self::Style) -> Appearance { | ||
match style { | ||
TableRowStyle::Default => Appearance { | ||
text_color: Some(self.palette.normal.primary), | ||
background: Some(Background::Color(self.palette.base.foreground)), | ||
border_radius: 0.0, | ||
border_width: 0.0, | ||
border_color: Color::TRANSPARENT, | ||
offset_left: 10.0, | ||
offset_right: 25.0, | ||
}, | ||
TableRowStyle::TableRowAlternate => Appearance { | ||
background: Some(Background::Color(Color { | ||
a: 0.50, | ||
..self.palette.base.foreground | ||
})), | ||
..Appearance::default() | ||
}, | ||
TableRowStyle::TableRowHighlife => Appearance { | ||
text_color: Some(self.palette.normal.primary), | ||
background: Some(Background::Color(Color { | ||
a: 0.30, | ||
..self.palette.base.foreground | ||
})), | ||
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.normal.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.normal.primary), | ||
background: Some(Background::Color(self.palette.normal.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.normal.primary | ||
})), | ||
..appearance | ||
}, | ||
TableRowStyle::TableRowAlternate => Appearance { | ||
background: Some(Background::Color(Color { | ||
a: 0.25, | ||
..self.palette.normal.primary | ||
})), | ||
..appearance | ||
}, | ||
TableRowStyle::TableRowHighlife => Appearance { | ||
background: Some(Background::Color(Color { | ||
a: 0.60, | ||
..self.palette.normal.primary | ||
})), | ||
..appearance | ||
}, | ||
TableRowStyle::TableRowLowlife => Appearance { | ||
background: Some(Background::Color(Color { | ||
a: 0.60, | ||
..self.palette.normal.primary | ||
})), | ||
..appearance | ||
}, | ||
TableRowStyle::TableRowSelected => Appearance { | ||
background: Some(Background::Color(Color { | ||
a: 0.60, | ||
..self.palette.normal.primary | ||
})), | ||
..appearance | ||
}, | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.