-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rework of table to include new iced_aw style widget
- Loading branch information
1 parent
8fb807a
commit 5b39461
Showing
2 changed files
with
257 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
use iced::{Background, Color}; | ||
use iced_aw::style::table_header::Appearance; | ||
use iced_aw::table; | ||
|
||
use super::Theme; | ||
|
||
#[derive(Debug, Clone, Copy, Default)] | ||
pub enum TableHeaderStyle { | ||
#[default] | ||
Default, | ||
} | ||
|
||
impl table::TableHeaderStyleSheet for Theme { | ||
type Style = TableHeaderStyle; | ||
|
||
fn appearance(&self, style: &Self::Style) -> Appearance { | ||
let palette = self.palette; | ||
|
||
match style { | ||
TableHeaderStyle::Default => Appearance { | ||
//text_color: Some(self.palette.bright.surface), | ||
text_color: palette.base.foreground, | ||
background: Some(Background::Color(palette.base.background)), | ||
border_radius: 0.0.into(), | ||
border_width: 0.0, | ||
border_color: Color::TRANSPARENT, | ||
offset_right: 0.0, | ||
offset_left: 0.0, | ||
}, | ||
} | ||
} | ||
|
||
fn hovered(&self, style: &Self::Style) -> Appearance { | ||
let palette = self.palette; | ||
match style { | ||
TableHeaderStyle::Default => Appearance { | ||
background: None, | ||
..Appearance::default() | ||
}, | ||
} | ||
} | ||
} |
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,215 @@ | ||
use iced::{Background, Color}; | ||
use iced_aw::style::table_row::{Appearance, RowOrCellAppearance}; | ||
use iced_aw::table; | ||
|
||
use super::Theme; | ||
|
||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)] | ||
pub enum TableRowStyle { | ||
#[default] | ||
Default, | ||
TableRowAlternate, | ||
TableRowHighlight, | ||
TableRowLowlight, | ||
TableRowSelected, | ||
} | ||
|
||
impl table::TableRowStyleSheet for Theme { | ||
type Style = TableRowStyle; | ||
fn appearance(&self, style: &Self::Style, row_id: u16) -> Appearance { | ||
let palette = self.palette; | ||
|
||
match style { | ||
TableRowStyle::Default => Appearance { | ||
row: RowOrCellAppearance { | ||
text_color: palette.normal.primary, | ||
background: Some(Background::Color(palette.base.foreground)), | ||
border_radius: 0.0.into(), | ||
border_width: 0.0, | ||
border_color: Color::TRANSPARENT, | ||
offset_left: 0.0, | ||
offset_right: 0.0, | ||
}, | ||
cell: RowOrCellAppearance { | ||
text_color: palette.normal.primary, | ||
background: Some(Background::Color(palette.base.foreground)), | ||
border_radius: 0.0.into(), | ||
border_width: 1.0, | ||
border_color: Color::BLACK, | ||
offset_left: 0.0, | ||
offset_right: 0.0, | ||
}, | ||
}, | ||
TableRowStyle::TableRowAlternate => Appearance { | ||
row: RowOrCellAppearance { | ||
text_color: palette.normal.primary, | ||
background: Some(Background::Color(Color { | ||
a: 0.50, | ||
..palette.base.foreground | ||
})), | ||
..RowOrCellAppearance::default() | ||
}, | ||
cell: RowOrCellAppearance { | ||
text_color: palette.normal.primary, | ||
background: Some(Background::Color(Color { | ||
a: 0.50, | ||
..palette.normal.primary | ||
})), | ||
..RowOrCellAppearance::default() | ||
}, | ||
}, | ||
TableRowStyle::TableRowHighlight => Appearance { | ||
row: RowOrCellAppearance { | ||
text_color: palette.normal.primary, | ||
background: Some(Background::Color(Color { | ||
a: 0.30, | ||
..palette.base.foreground | ||
})), | ||
border_radius: 0.0.into(), | ||
border_width: 0.0, | ||
border_color: Color::TRANSPARENT, | ||
offset_left: 0.0, | ||
offset_right: 0.0, | ||
}, | ||
cell: RowOrCellAppearance { | ||
text_color: palette.normal.primary, | ||
background: Some(Background::Color(Color { | ||
a: 0.30, | ||
..palette.base.foreground | ||
})), | ||
border_radius: 0.0.into(), | ||
border_width: 0.0, | ||
border_color: Color::TRANSPARENT, | ||
offset_left: 0.0, | ||
offset_right: 0.0, | ||
}, | ||
}, | ||
TableRowStyle::TableRowLowlight => Appearance { | ||
row: RowOrCellAppearance { | ||
text_color: palette.normal.primary, | ||
background: Some(Background::Color(Color::TRANSPARENT)), | ||
border_radius: 0.0.into(), | ||
border_width: 0.0, | ||
border_color: Color::TRANSPARENT, | ||
offset_left: 0.0, | ||
offset_right: 0.0, | ||
}, | ||
cell: RowOrCellAppearance { | ||
text_color: palette.normal.primary, | ||
background: Some(Background::Color(Color::TRANSPARENT)), | ||
border_radius: 0.0.into(), | ||
border_width: 0.0, | ||
border_color: Color::TRANSPARENT, | ||
offset_left: 0.0, | ||
offset_right: 0.0, | ||
}, | ||
}, | ||
TableRowStyle::TableRowSelected => Appearance { | ||
row: RowOrCellAppearance { | ||
text_color: palette.normal.primary, | ||
background: Some(Background::Color(palette.normal.primary)), | ||
border_radius: 0.0.into(), | ||
border_width: 0.0, | ||
border_color: Color::TRANSPARENT, | ||
offset_left: 0.0, | ||
offset_right: 0.0, | ||
}, | ||
cell: RowOrCellAppearance { | ||
text_color: palette.normal.primary, | ||
background: Some(Background::Color(palette.normal.primary)), | ||
border_radius: 0.0.into(), | ||
border_width: 0.0, | ||
border_color: Color::TRANSPARENT, | ||
offset_left: 0.0, | ||
offset_right: 0.0, | ||
}, | ||
}, | ||
} | ||
} | ||
|
||
fn hovered(&self, style: &Self::Style, row_id: u16) -> Appearance { | ||
let palette = self.palette; | ||
match style { | ||
TableRowStyle::Default => Appearance { | ||
row: RowOrCellAppearance { | ||
background: Some(Background::Color(Color { | ||
a: 0.60, | ||
..palette.normal.primary | ||
})), | ||
..self.appearance(style, row_id).row | ||
}, | ||
cell: RowOrCellAppearance { | ||
background: Some(Background::Color(Color { | ||
a: 0.60, | ||
..palette.normal.primary | ||
})), | ||
..self.appearance(style, row_id).cell | ||
}, | ||
}, | ||
TableRowStyle::TableRowAlternate => Appearance { | ||
row: RowOrCellAppearance { | ||
background: Some(Background::Color(Color { | ||
a: 0.25, | ||
..palette.normal.primary | ||
})), | ||
..self.appearance(style, row_id).row | ||
}, | ||
cell: RowOrCellAppearance { | ||
background: Some(Background::Color(Color { | ||
a: 0.25, | ||
..palette.normal.primary | ||
})), | ||
..self.appearance(style, row_id).cell | ||
}, | ||
}, | ||
TableRowStyle::TableRowHighlight => Appearance { | ||
row: RowOrCellAppearance { | ||
background: Some(Background::Color(Color { | ||
a: 0.60, | ||
..palette.normal.primary | ||
})), | ||
..self.appearance(style, row_id).row | ||
}, | ||
cell: RowOrCellAppearance { | ||
background: Some(Background::Color(Color { | ||
a: 0.60, | ||
..palette.normal.primary | ||
})), | ||
..self.appearance(style, row_id).cell | ||
}, | ||
}, | ||
TableRowStyle::TableRowLowlight => Appearance { | ||
row: RowOrCellAppearance { | ||
background: Some(Background::Color(Color { | ||
a: 0.60, | ||
..palette.normal.primary | ||
})), | ||
..self.appearance(style, row_id).row | ||
}, | ||
cell: RowOrCellAppearance { | ||
background: Some(Background::Color(Color { | ||
a: 0.60, | ||
..palette.normal.primary | ||
})), | ||
..self.appearance(style, row_id).cell | ||
}, | ||
}, | ||
TableRowStyle::TableRowSelected => Appearance { | ||
row: RowOrCellAppearance { | ||
background: Some(Background::Color(Color { | ||
a: 0.60, | ||
..palette.normal.primary | ||
})), | ||
..self.appearance(style, row_id).row | ||
}, | ||
cell: RowOrCellAppearance { | ||
background: Some(Background::Color(Color { | ||
a: 0.60, | ||
..palette.normal.primary | ||
})), | ||
..self.appearance(style, row_id).cell | ||
}, | ||
}, | ||
} | ||
} | ||
} |