From 9ddadd330f7c759e63f9d4c623d6081a5adf5a21 Mon Sep 17 00:00:00 2001 From: Ashley Wulber Date: Fri, 22 Sep 2023 18:03:40 -0400 Subject: [PATCH] fix: applet button styles --- examples/applet/src/window.rs | 4 +--- src/applet/mod.rs | 21 +++++++++++++++++---- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/examples/applet/src/window.rs b/examples/applet/src/window.rs index 9562412..7a67255 100644 --- a/examples/applet/src/window.rs +++ b/examples/applet/src/window.rs @@ -4,7 +4,6 @@ use cosmic::iced::window::Id; use cosmic::iced::{Command, Limits}; use cosmic::iced_runtime::core::window; use cosmic::iced_style::application; -use cosmic::theme::Button; use cosmic::widget::{list_column, settings, toggler}; use cosmic::{Element, Theme}; @@ -88,9 +87,8 @@ impl cosmic::Application for Window { fn view(&self) -> Element { self.core .applet - .icon_button(ID) + .icon_button("display-symbolic") .on_press(Message::TogglePopup) - .style(Button::Text) .into() } diff --git a/src/applet/mod.rs b/src/applet/mod.rs index ae07228..9f565cb 100644 --- a/src/applet/mod.rs +++ b/src/applet/mod.rs @@ -18,6 +18,7 @@ use iced_widget::runtime::command::platform_specific::wayland::popup::{ SctkPopupSettings, SctkPositioner, }; use sctk::reexports::protocols::xdg::shell::client::xdg_positioner::{Anchor, Gravity}; +use std::rc::Rc; use crate::app::cosmic; @@ -132,12 +133,24 @@ impl Context { &self, icon_name: &'a str, ) -> crate::widget::Button<'a, Message, Renderer> { + let suggested = self.suggested_size(); crate::widget::button( - widget::icon::from_name(icon_name) - .symbolic(true) - .size(self.suggested_size().0), + widget::icon( + widget::icon::from_name(icon_name) + .symbolic(true) + .size(self.suggested_size().0) + .into(), + ) + .style(theme::Svg::Custom(Rc::new(|theme| { + crate::iced_style::svg::Appearance { + color: Some(theme.cosmic().background.on.into()), + } + }))) + .width(Length::Fixed(suggested.0 as f32)) + .height(Length::Fixed(suggested.1 as f32)), ) - .padding(8) + .padding(APPLET_PADDING as u16) + .style(Button::Text) } // TODO popup container which tracks the size of itself and requests the popup to resize to match