refactor: use theme corner radii everywhere
not all values matched a default value but I picked the next closest in that case
This commit is contained in:
parent
56965ac2e5
commit
310064ca1d
14 changed files with 103 additions and 68 deletions
|
|
@ -4,6 +4,8 @@
|
|||
//! Change the apperance of a button.
|
||||
use iced_core::{Background, BorderRadius, Color, Vector};
|
||||
|
||||
use crate::theme::THEME;
|
||||
|
||||
/// The appearance of a button.
|
||||
#[must_use]
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
|
|
@ -39,10 +41,11 @@ pub struct Appearance {
|
|||
impl Appearance {
|
||||
// TODO: `BorderRadius` is not `const fn` compatible.
|
||||
pub fn new() -> Self {
|
||||
let rad_0 = THEME.with(|t| t.borrow().cosmic().corner_radii.radius_0);
|
||||
Self {
|
||||
shadow_offset: Vector::new(0.0, 0.0),
|
||||
background: None,
|
||||
border_radius: BorderRadius::from(0.0),
|
||||
border_radius: BorderRadius::from(rad_0),
|
||||
border_width: 0.0,
|
||||
border_color: Color::TRANSPARENT,
|
||||
outline_width: 0.0,
|
||||
|
|
|
|||
|
|
@ -23,6 +23,8 @@ use iced_core::{
|
|||
};
|
||||
use iced_renderer::core::widget::{operation, OperationOutputWrapper};
|
||||
|
||||
use crate::theme::THEME;
|
||||
|
||||
pub use super::style::{Appearance, StyleSheet};
|
||||
|
||||
/// Internally defines different button widget variants.
|
||||
|
|
@ -387,6 +389,8 @@ where
|
|||
{
|
||||
let selection_background = theme.selection_background();
|
||||
|
||||
let c_rad = THEME.with(|t| t.borrow().cosmic().corner_radii);
|
||||
|
||||
if self.selected {
|
||||
renderer.fill_quad(
|
||||
Quad {
|
||||
|
|
@ -396,7 +400,13 @@ where
|
|||
x: bounds.x + styling.border_width,
|
||||
y: bounds.y + (bounds.height - 20.0 - styling.border_width),
|
||||
},
|
||||
border_radius: [0.0, 8.0, 0.0, 8.0].into(),
|
||||
border_radius: [
|
||||
c_rad.radius_0[0],
|
||||
c_rad.radius_s[1],
|
||||
c_rad.radius_0[2],
|
||||
c_rad.radius_s[3],
|
||||
]
|
||||
.into(),
|
||||
border_width: 0.0,
|
||||
border_color: Color::TRANSPARENT,
|
||||
},
|
||||
|
|
@ -423,7 +433,7 @@ where
|
|||
renderer.fill_quad(
|
||||
renderer::Quad {
|
||||
bounds,
|
||||
border_radius: 20.0.into(),
|
||||
border_radius: c_rad.radius_m.into(),
|
||||
border_width: 0.0,
|
||||
border_color: Color::TRANSPARENT,
|
||||
},
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ impl<'a, Message: Clone + 'static> ContextDrawer<'a, Message> {
|
|||
icon_color: Some(Color::from(palette.primary.on)),
|
||||
text_color: Some(Color::from(palette.primary.on)),
|
||||
background: Some(iced::Background::Color(palette.primary.base.into())),
|
||||
border_radius: 8.0.into(),
|
||||
border_radius: palette.corner_radii.radius_s.into(),
|
||||
border_width: 0.0,
|
||||
border_color: Color::TRANSPARENT,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ pub fn style(theme: &crate::Theme) -> crate::widget::container::Appearance {
|
|||
icon_color: Some(container.on.into()),
|
||||
text_color: Some(container.on.into()),
|
||||
background: Some(Background::Color(container.base.into())),
|
||||
border_radius: 8.0.into(),
|
||||
border_radius: theme.cosmic().corner_radii.radius_s.into(),
|
||||
border_width: 0.0,
|
||||
border_color: Color::TRANSPARENT,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ pub fn nav_bar_style(theme: &Theme) -> iced_style::container::Appearance {
|
|||
icon_color: Some(cosmic.on_bg_color().into()),
|
||||
text_color: Some(cosmic.on_bg_color().into()),
|
||||
background: Some(Background::Color(cosmic.primary.base.into())),
|
||||
border_radius: 8.0.into(),
|
||||
border_radius: cosmic.corner_radii.radius_s.into(),
|
||||
border_width: 0.0,
|
||||
border_color: Color::TRANSPARENT,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ fn active_style(theme: &crate::Theme) -> container::Appearance {
|
|||
icon_color: Some(cosmic.palette.neutral_9.into()),
|
||||
text_color: Some(cosmic.palette.neutral_9.into()),
|
||||
background: Some(Background::Color(neutral_7.into())),
|
||||
border_radius: 24.0.into(),
|
||||
border_radius: cosmic.corner_radii.radius_m.into(),
|
||||
border_width: 2.0,
|
||||
border_color: cosmic.accent.focus.into(),
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use super::model::{Entity, Model, Selectable};
|
||||
use crate::theme::SegmentedButton as Style;
|
||||
use crate::theme::{SegmentedButton as Style, THEME};
|
||||
use crate::widget::{icon, Icon};
|
||||
use crate::{Element, Renderer};
|
||||
use derive_setters::Setters;
|
||||
|
|
@ -558,10 +558,11 @@ where
|
|||
bounds.y = bounds.y + bounds.height - width;
|
||||
bounds.height = width;
|
||||
|
||||
let rad_0 = THEME.with(|t| t.borrow().cosmic().corner_radii.radius_0);
|
||||
renderer.fill_quad(
|
||||
renderer::Quad {
|
||||
bounds,
|
||||
border_radius: BorderRadius::from(0.0),
|
||||
border_radius: rad_0.into(),
|
||||
border_width: 0.0,
|
||||
border_color: Color::TRANSPARENT,
|
||||
},
|
||||
|
|
|
|||
|
|
@ -1933,6 +1933,9 @@ pub fn draw<'a, Message>(
|
|||
let font = font.unwrap_or_else(|| renderer.default_font());
|
||||
let size = size.unwrap_or_else(|| renderer.default_size().0);
|
||||
|
||||
let radius_0 = THEME
|
||||
.with(|t| t.borrow().cosmic().corner_radii.radius_0)
|
||||
.into();
|
||||
let (cursor, offset) = if let Some(focus) = &state.is_focused {
|
||||
match state.cursor.state(value) {
|
||||
cursor::State::Index(position) => {
|
||||
|
|
@ -1956,7 +1959,7 @@ pub fn draw<'a, Message>(
|
|||
width: 1.0,
|
||||
height: text_bounds.height,
|
||||
},
|
||||
border_radius: 0.0.into(),
|
||||
border_radius: radius_0,
|
||||
border_width: 0.0,
|
||||
border_color: Color::TRANSPARENT,
|
||||
},
|
||||
|
|
@ -1994,7 +1997,7 @@ pub fn draw<'a, Message>(
|
|||
width,
|
||||
height: text_bounds.height,
|
||||
},
|
||||
border_radius: 0.0.into(),
|
||||
border_radius: radius_0,
|
||||
border_width: 0.0,
|
||||
border_color: Color::TRANSPARENT,
|
||||
},
|
||||
|
|
|
|||
|
|
@ -57,11 +57,12 @@ impl<'a, Message: 'static + Clone> From<Warning<'a, Message>> for Element<'a, Me
|
|||
|
||||
#[must_use]
|
||||
pub fn warning_container(theme: &Theme) -> widget::container::Appearance {
|
||||
let cosmic = theme.cosmic();
|
||||
widget::container::Appearance {
|
||||
icon_color: Some(theme.cosmic().warning.on.into()),
|
||||
text_color: Some(theme.cosmic().warning.on.into()),
|
||||
background: Some(Background::Color(theme.cosmic().warning_color().into())),
|
||||
border_radius: 0.0.into(),
|
||||
border_radius: cosmic.corner_radii.radius_0.into(),
|
||||
border_width: 0.0,
|
||||
border_color: Color::TRANSPARENT,
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue