Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions res/icons/pan-down-symbolic.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 7 additions & 1 deletion src/widget/dropdown/widget.rs
Original file line number Diff line number Diff line change
Expand Up @@ -373,8 +373,14 @@ pub struct State {
impl State {
/// Creates a new [`State`] for a [`Dropdown`].
pub fn new() -> Self {
#[cfg(target_os = "linux")]
let icon = icon::from_name("pan-down-symbolic").size(16).handle();
#[cfg(not(target_os = "linux"))]
let icon = icon::from_svg_bytes(include_bytes!("../../../res/icons/pan-down-symbolic.svg"))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be a static global variable, and shared between other widgets that are also using this icon. The multi dropdown and table widgets also use this icon.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So something like this? A function is used to clone it for convenience, since references to an icon::Handle aren't useful. 31fa09a...48ffffd

Or would it be preferable to wrap the icon in a struct that passes through function calls to the inner icon::Named on Linux, but those functions do nothing on Windows since they're not relevant for from_svg_bytes icons? That way the caller doesn't need to care about whether or not the icon is bundled. 31fa09a...8944f59

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have some ideas. I'll look into this soon

.symbolic(true);

Self {
icon: match icon::from_name("pan-down-symbolic").size(16).handle().data {
icon: match icon.data {
icon::Data::Name(named) => named
.path()
.filter(|path| path.extension().is_some_and(|ext| ext == OsStr::new("svg")))
Expand Down