-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(widget): add dropdown widget as pick_list replacement
The Dropdown widget is based on the PickList widget from iced.
- Loading branch information
Showing
9 changed files
with
1,118 additions
and
15 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,28 @@ | ||
// Copyright 2023 System76 <[email protected]> | ||
// SPDX-License-Identifier: MPL-2.0 | ||
|
||
use crate::widget::dropdown; | ||
use crate::Theme; | ||
use iced::{Background, Color}; | ||
|
||
impl dropdown::menu::StyleSheet for Theme { | ||
type Style = (); | ||
|
||
fn appearance(&self, _style: &Self::Style) -> dropdown::menu::Appearance { | ||
let cosmic = self.cosmic(); | ||
|
||
dropdown::menu::Appearance { | ||
text_color: cosmic.on_bg_color().into(), | ||
background: Background::Color(cosmic.background.component.base.into()), | ||
border_width: 0.0, | ||
border_radius: 16.0.into(), | ||
border_color: Color::TRANSPARENT, | ||
|
||
hovered_text_color: cosmic.on_bg_color().into(), | ||
hovered_background: Background::Color(cosmic.primary.component.hover.into()), | ||
|
||
selected_text_color: cosmic.accent.base.into(), | ||
selected_background: Background::Color(cosmic.primary.component.hover.into()), | ||
} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// Copyright 2023 System76 <[email protected]> | ||
// Copyright 2019 Héctor Ramón, Iced contributors | ||
// SPDX-License-Identifier: MPL-2.0 AND MIT | ||
|
||
//! Change the appearance of menus. | ||
use iced_core::{Background, BorderRadius, Color}; | ||
|
||
/// The appearance of a menu. | ||
#[derive(Debug, Clone, Copy)] | ||
pub struct Appearance { | ||
/// Menu text color | ||
pub text_color: Color, | ||
/// Menu background | ||
pub background: Background, | ||
/// Menu border width | ||
pub border_width: f32, | ||
/// Menu border radius | ||
pub border_radius: BorderRadius, | ||
/// Menu border color | ||
pub border_color: Color, | ||
/// Text color when hovered | ||
pub hovered_text_color: Color, | ||
/// Background when hovered | ||
pub hovered_background: Background, | ||
/// Text color when selected | ||
pub selected_text_color: Color, | ||
/// Background when selected | ||
pub selected_background: Background, | ||
} | ||
|
||
/// The style sheet of a menu. | ||
pub trait StyleSheet { | ||
/// The supported style of the [`StyleSheet`]. | ||
type Style: Default + Clone; | ||
|
||
/// Produces the [`Appearance`] of a menu. | ||
fn appearance(&self, style: &Self::Style) -> Appearance; | ||
} |
Oops, something went wrong.