fix: applet button styles

This commit is contained in:
Ashley Wulber 2023-09-22 18:03:40 -04:00 committed by Ashley Wulber
parent ebcaf242e9
commit 9ddadd330f
2 changed files with 18 additions and 7 deletions

View file

@ -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::Message> {
self.core
.applet
.icon_button(ID)
.icon_button("display-symbolic")
.on_press(Message::TogglePopup)
.style(Button::Text)
.into()
}

View file

@ -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