element/stack: Style fixes
This commit is contained in:
parent
04b5c18a03
commit
61f11d1363
5 changed files with 27 additions and 15 deletions
|
|
@ -34,8 +34,8 @@ pub(super) fn primary_container_color(theme: &cosmic::cosmic_theme::Theme) -> Co
|
|||
|
||||
/// The background color for the selected stack tab.
|
||||
pub(super) fn selected_state_color(theme: &cosmic::cosmic_theme::Theme) -> Color {
|
||||
const SELECTED_STATE_DARK: Color = Color::from_rgba(0.302, 0.302, 0.302, 0.3);
|
||||
const SELECTED_STATE_LIGHT: Color = Color::from_rgba(0.596, 0.596, 0.596, 0.2);
|
||||
const SELECTED_STATE_DARK: Color = Color::from_rgba(0.195, 0.195, 0.195, 1.0);
|
||||
const SELECTED_STATE_LIGHT: Color = Color::from_rgba(0.8344, 0.8344, 0.8344, 1.0);
|
||||
|
||||
if theme.is_dark {
|
||||
SELECTED_STATE_DARK
|
||||
|
|
@ -231,7 +231,7 @@ impl<Message: TabMessage + 'static> Tab<Message> {
|
|||
.padding([2, 4])
|
||||
.center_y()
|
||||
.into(),
|
||||
tab_text(self.title)
|
||||
tab_text(self.title, self.active)
|
||||
.font(self.font)
|
||||
.font_size(14.0)
|
||||
.height(Length::Fill)
|
||||
|
|
|
|||
|
|
@ -14,8 +14,8 @@ use cosmic::{
|
|||
};
|
||||
|
||||
/// Text in a stack tab with an overflow gradient.
|
||||
pub fn tab_text(text: String) -> TabText {
|
||||
TabText::new(text)
|
||||
pub fn tab_text(text: String, selected: bool) -> TabText {
|
||||
TabText::new(text, selected)
|
||||
}
|
||||
|
||||
struct LocalState {
|
||||
|
|
@ -29,17 +29,19 @@ pub struct TabText {
|
|||
text: String,
|
||||
font: cosmic::font::Font,
|
||||
font_size: f32,
|
||||
selected: bool,
|
||||
height: Length,
|
||||
width: Length,
|
||||
}
|
||||
|
||||
impl TabText {
|
||||
pub fn new(text: String) -> Self {
|
||||
pub fn new(text: String, selected: bool) -> Self {
|
||||
TabText {
|
||||
width: Length::Shrink,
|
||||
height: Length::Shrink,
|
||||
font: cosmic::font::DEFAULT,
|
||||
font_size: 14.0,
|
||||
selected,
|
||||
text,
|
||||
}
|
||||
}
|
||||
|
|
@ -146,7 +148,11 @@ impl<Message> Widget<Message, cosmic::Theme, cosmic::Renderer> for TabText {
|
|||
});
|
||||
|
||||
if state.overflowed {
|
||||
let background = super::tab::primary_container_color(theme.cosmic());
|
||||
let background = if self.selected {
|
||||
super::tab::selected_state_color(theme.cosmic())
|
||||
} else {
|
||||
super::tab::primary_container_color(theme.cosmic())
|
||||
};
|
||||
let transparent = Color {
|
||||
a: 0.0,
|
||||
..background
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue