add icon_button_with_handle
This commit is contained in:
parent
1575aa267c
commit
dc7d122954
1 changed files with 24 additions and 1 deletions
|
|
@ -12,7 +12,7 @@ use crate::{
|
|||
},
|
||||
iced_style, iced_widget,
|
||||
theme::{self, Button, THEME},
|
||||
widget, Application, Element, Renderer,
|
||||
widget::{self, icon::Handle}, Application, Element, Renderer,
|
||||
};
|
||||
pub use cosmic_panel_config;
|
||||
use cosmic_panel_config::{CosmicPanelBackground, PanelAnchor, PanelSize};
|
||||
|
|
@ -143,6 +143,29 @@ impl Context {
|
|||
.style(Button::AppletIcon)
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn icon_button_with_handle<'a, Message: 'static>(
|
||||
&self,
|
||||
handle: Handle,
|
||||
) -> crate::widget::Button<'a, Message, crate::Theme, Renderer> {
|
||||
let suggested = self.suggested_size();
|
||||
let applet_padding = self.suggested_padding();
|
||||
crate::widget::button(
|
||||
widget::icon(
|
||||
handle,
|
||||
)
|
||||
.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(applet_padding)
|
||||
.style(Button::AppletIcon)
|
||||
}
|
||||
|
||||
// TODO popup container which tracks the size of itself and requests the popup to resize to match
|
||||
pub fn popup_container<'a, Message: 'static>(
|
||||
&self,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue