refactor: update applet icon sizes
This commit is contained in:
parent
39f535c18b
commit
d54af65a2a
2 changed files with 24 additions and 19 deletions
19
Cargo.toml
19
Cargo.toml
|
|
@ -37,7 +37,13 @@ smol = ["iced/smol", "zbus?/async-io"]
|
|||
# Tokio async runtime
|
||||
tokio = ["dep:tokio", "ashpd?/tokio", "iced/tokio", "rfd?/tokio", "zbus?/tokio"]
|
||||
# Wayland window support
|
||||
wayland = ["ashpd?/wayland", "iced_runtime/wayland", "iced/wayland", "iced_sctk", "cctk"]
|
||||
wayland = [
|
||||
"ashpd?/wayland",
|
||||
"iced_runtime/wayland",
|
||||
"iced/wayland",
|
||||
"iced_sctk",
|
||||
"cctk",
|
||||
]
|
||||
# multi-window support
|
||||
multi-window = ["iced/multi-window"]
|
||||
# Render with wgpu
|
||||
|
|
@ -74,7 +80,7 @@ tokio = { version = "1.24.2", optional = true }
|
|||
tracing = "0.1"
|
||||
unicode-segmentation = "1.6"
|
||||
url = "2.4.0"
|
||||
zbus = {version = "3.14.1", default-features = false, optional = true}
|
||||
zbus = { version = "3.14.1", default-features = false, optional = true }
|
||||
|
||||
[target.'cfg(unix)'.dependencies]
|
||||
freedesktop-icons = "0.2.5"
|
||||
|
|
@ -143,10 +149,10 @@ features = ["grid"]
|
|||
|
||||
[workspace]
|
||||
members = [
|
||||
"cosmic-config",
|
||||
"cosmic-config-derive",
|
||||
"cosmic-theme",
|
||||
"examples/*",
|
||||
"cosmic-config",
|
||||
"cosmic-config-derive",
|
||||
"cosmic-theme",
|
||||
"examples/*",
|
||||
]
|
||||
exclude = ["examples/design-demo", "iced"]
|
||||
|
||||
|
|
@ -156,4 +162,3 @@ dirs = "5.0.1"
|
|||
|
||||
[patch."https://github.com/pop-os/libcosmic"]
|
||||
libcosmic = { path = "./" }
|
||||
|
||||
|
|
|
|||
|
|
@ -65,10 +65,10 @@ impl Default for Context {
|
|||
|
||||
impl Context {
|
||||
#[must_use]
|
||||
pub fn suggested_size(&self) -> (u16, u16) {
|
||||
pub fn suggested_size(&self, is_symbolic: bool) -> (u16, u16) {
|
||||
match &self.size {
|
||||
Size::PanelSize(ref size) => {
|
||||
let s = size.get_applet_icon_size() as u16;
|
||||
let s = size.get_applet_icon_size(is_symbolic) as u16;
|
||||
(s, s)
|
||||
}
|
||||
Size::Hardcoded((width, height)) => (*width, *height),
|
||||
|
|
@ -76,10 +76,10 @@ impl Context {
|
|||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn suggested_padding(&self) -> u16 {
|
||||
pub fn suggested_padding(&self, is_symbolic: bool) -> u16 {
|
||||
match &self.size {
|
||||
Size::PanelSize(ref size) => size.get_applet_padding(),
|
||||
Size::Hardcoded((width, height)) => 8,
|
||||
Size::PanelSize(ref size) => size.get_applet_padding(is_symbolic),
|
||||
Size::Hardcoded(_) => 8,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -91,10 +91,10 @@ impl Context {
|
|||
#[must_use]
|
||||
#[allow(clippy::cast_precision_loss)]
|
||||
pub fn window_settings(&self) -> crate::app::Settings {
|
||||
let (width, height) = self.suggested_size();
|
||||
let (width, height) = self.suggested_size(true);
|
||||
let width = f32::from(width);
|
||||
let height = f32::from(height);
|
||||
let applet_padding = self.suggested_padding();
|
||||
let applet_padding = self.suggested_padding(true);
|
||||
let mut settings = crate::app::Settings::default()
|
||||
.size(iced_core::Size::new(
|
||||
width + applet_padding as f32 * 2.,
|
||||
|
|
@ -122,8 +122,8 @@ impl Context {
|
|||
&self,
|
||||
icon: widget::icon::Handle,
|
||||
) -> crate::widget::Button<'a, Message, crate::Theme, Renderer> {
|
||||
let suggested = self.suggested_size();
|
||||
let applet_padding = self.suggested_padding();
|
||||
let suggested = self.suggested_size(icon.symbolic);
|
||||
let applet_padding = self.suggested_padding(icon.symbolic);
|
||||
crate::widget::button(
|
||||
widget::icon(icon)
|
||||
.style(theme::Svg::Custom(Rc::new(|theme| {
|
||||
|
|
@ -146,7 +146,7 @@ impl Context {
|
|||
self.icon_button_from_handle(
|
||||
widget::icon::from_name(icon_name)
|
||||
.symbolic(true)
|
||||
.size(self.suggested_size().0)
|
||||
.size(self.suggested_size(true).0)
|
||||
.into(),
|
||||
)
|
||||
}
|
||||
|
|
@ -198,8 +198,8 @@ impl Context {
|
|||
width_padding: Option<i32>,
|
||||
height_padding: Option<i32>,
|
||||
) -> SctkPopupSettings {
|
||||
let (width, height) = self.suggested_size();
|
||||
let applet_padding = self.suggested_padding();
|
||||
let (width, height) = self.suggested_size(true);
|
||||
let applet_padding = self.suggested_padding(true);
|
||||
let pixel_offset = 8;
|
||||
let (offset, anchor, gravity) = match self.anchor {
|
||||
PanelAnchor::Left => ((pixel_offset, 0), Anchor::Right, Gravity::Right),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue