Skip to content
Draft
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
935 changes: 465 additions & 470 deletions Cargo.lock

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,10 @@ lto = "thin"
[workspace.metadata.cargo-machete]
ignored = ["libcosmic"]

# [patch."https://github.com/pop-os/libcosmic"]
[patch."https://github.com/pop-os/libcosmic"]
cosmic-config = { git = "https://github.com/pop-os/libcosmic//", branch = "shrinkable-applets" }
libcosmic = { git = "https://github.com/pop-os/libcosmic//", branch = "shrinkable-applets" }
iced_futures = { git = "https://github.com/pop-os/libcosmic//", branch = "shrinkable-applets" }
# cosmic-config = { path = "../libcosmic/cosmic-config" }
# libcosmic = { path = "../libcosmic" }
# iced_futures = { path = "../libcosmic/iced/futures" }
Expand Down
56 changes: 39 additions & 17 deletions cosmic-app-list/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,13 @@ static DND_FAVORITES: u64 = u64::MAX;
impl AppletIconData {
fn new(applet: &Context) -> Self {
let icon_size = applet.suggested_size(false).0;
let padding = applet.suggested_padding(false);
let icon_spacing = 4.0;
let (major_padding, cross_padding) = applet.suggested_padding(false);
let (h_padding, v_padding) = if applet.is_horizontal() {
(major_padding as f32, cross_padding as f32)
} else {
(cross_padding as f32, major_padding as f32)
};
let icon_spacing = applet.spacing as f32;

let (dot_radius, bar_size) = match applet.size {
Size::Hardcoded(_) => (2.0, 8.0),
Expand All @@ -97,14 +102,31 @@ impl AppletIconData {
}
}
};

let padding = padding as f32;

let padding = match applet.anchor {
PanelAnchor::Top => [padding - (dot_radius * 2. + 1.), padding, padding, padding],
PanelAnchor::Bottom => [padding, padding, padding - (dot_radius * 2. + 1.), padding],
PanelAnchor::Left => [padding, padding, padding, padding - (dot_radius * 2. + 1.)],
PanelAnchor::Right => [padding, padding - (dot_radius * 2. + 1.), padding, padding],
PanelAnchor::Top => [
v_padding - (dot_radius * 2. + 1.),
h_padding,
v_padding,
h_padding,
],
PanelAnchor::Bottom => [
v_padding,
h_padding,
v_padding - (dot_radius * 2. + 1.),
h_padding,
],
PanelAnchor::Left => [
v_padding,
h_padding,
v_padding,
h_padding - (dot_radius * 2. + 1.),
],
PanelAnchor::Right => [
v_padding,
h_padding - (dot_radius * 2. + 1.),
v_padding,
h_padding,
],
};
AppletIconData {
icon_size,
Expand Down Expand Up @@ -919,7 +941,7 @@ impl cosmic::Application for CosmicAppList {
}
Message::DndEnter(x, y) => {
let item_size = self.core.applet.suggested_size(false).0
+ 2 * self.core.applet.suggested_padding(false);
+ 2 * self.core.applet.suggested_padding(false).0;
let pos_in_list = match self.core.applet.anchor {
PanelAnchor::Top | PanelAnchor::Bottom => x as f32,
PanelAnchor::Left | PanelAnchor::Right => y as f32,
Expand All @@ -941,7 +963,7 @@ impl cosmic::Application for CosmicAppList {
}
Message::DndMotion(x, y) => {
let item_size = self.core.applet.suggested_size(false).0
+ 2 * self.core.applet.suggested_padding(false);
+ 2 * self.core.applet.suggested_padding(false).0;
let pos_in_list = match self.core.applet.anchor {
PanelAnchor::Top | PanelAnchor::Bottom => x as f32,
PanelAnchor::Left | PanelAnchor::Right => y as f32,
Expand Down Expand Up @@ -1349,7 +1371,7 @@ impl cosmic::Application for CosmicAppList {
};
}
let applet_suggested_size = self.core.applet.suggested_size(false).0
+ 2 * self.core.applet.suggested_padding(false);
+ 2 * self.core.applet.suggested_padding(false).0;
let (_favorite_popup_cutoff, active_popup_cutoff) =
self.panel_overflow_lengths();
let popup_applet_count =
Expand Down Expand Up @@ -1406,7 +1428,7 @@ impl cosmic::Application for CosmicAppList {
};
}
let applet_suggested_size = self.core.applet.suggested_size(false).0
+ 2 * self.core.applet.suggested_padding(false);
+ 2 * self.core.applet.suggested_padding(false).0;
let (favorite_popup_cutoff, _active_popup_cutoff) =
self.panel_overflow_lengths();
let popup_applet_count =
Expand Down Expand Up @@ -1572,7 +1594,7 @@ impl cosmic::Application for CosmicAppList {
icon::from_name("starred-symbolic.symbolic")
.size(self.core.applet.suggested_size(false).0),
)
.padding(self.core.applet.suggested_padding(false))
.padding(self.core.applet.suggested_padding(false).1) // TODO
.into(),
);
}
Expand Down Expand Up @@ -1642,13 +1664,13 @@ impl cosmic::Application for CosmicAppList {
let window_size = self.core.applet.suggested_bounds.as_ref();
let max_num = if self.core.applet.is_horizontal() {
let suggested_width = self.core.applet.suggested_size(false).0
+ self.core.applet.suggested_padding(false) * 2;
+ self.core.applet.suggested_padding(false).0 * 2;
window_size
.map(|w| w.width)
.map_or(u32::MAX, |b| (b / suggested_width as f32) as u32) as usize
} else {
let suggested_height = self.core.applet.suggested_size(false).1
+ self.core.applet.suggested_padding(false) * 2;
+ self.core.applet.suggested_padding(false).0 * 2;
window_size
.map(|w| w.height)
.map_or(u32::MAX, |b| (b / suggested_height as f32) as u32) as usize
Expand Down Expand Up @@ -2246,7 +2268,7 @@ impl CosmicAppList {
let applet_icon = AppletIconData::new(&self.core.applet);

let button_total_size = self.core.applet.suggested_size(true).0
+ self.core.applet.suggested_padding(true) * 2
+ self.core.applet.suggested_padding(true).0 * 2
+ applet_icon.icon_spacing as u16;

let favorite_active_cnt = self
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Icon=preferences-desktop-accessibility-symbolic
StartupNotify=true
NoDisplay=true
X-CosmicApplet=true
X-CosmicShrinkable=true
# Indicates that the auto-hover click should go to the "end" of the hover popup
X-CosmicHoverPopup=Auto
X-OverflowPriority=10
3 changes: 2 additions & 1 deletion cosmic-applet-audio/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ i18n-embed-fl.workspace = true
i18n-embed.workspace = true
libcosmic.workspace = true
libpulse-binding = "2.30.1"
mpris2-zbus = { git = "https://github.com/pop-os/dbus-settings-bindings" }
mpris2-zbus = { git = "https://github.com/pop-os/dbus-settings-bindings", branch = "precise-capturing" }
# mpris2-zbus = { path = "../../dbus-settings-bindings/mpris2" }
rust-embed.workspace = true
serde.workspace = true
tokio.workspace = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Icon=com.system76.CosmicAppletAudio-symbolic
StartupNotify=true
NoDisplay=true
X-CosmicApplet=true
X-CosmicShrinkable=true
# Indicates that the auto-hover click should go to the "end" of the hover popup
X-CosmicHoverPopup=End
X-OverflowPriority=10
69 changes: 41 additions & 28 deletions cosmic-applet-audio/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ use config::{AudioAppletConfig, amplification_sink, amplification_source};
use cosmic::{
Element, Renderer, Task, Theme, app,
applet::{
column as applet_column,
cosmic_panel_config::PanelAnchor,
menu_button, menu_control_padding, padded_control,
menu_button, menu_control_padding, padded_control, row as applet_row,
token::subscription::{TokenRequest, TokenUpdate, activation_token_subscription},
},
cctk::sctk::reexports::calloop,
Expand Down Expand Up @@ -166,10 +167,16 @@ pub enum Message {
Surface(surface::Action),
}

// TODO
// mouse area with on enter and a stack widget for all buttons
// most recently entered button is on top
// position is a multiple of button size
// on leave of applet, popup button is on top again

impl Audio {
fn playback_buttons(&self) -> Option<Element<'_, Message>> {
fn playback_buttons(&self) -> Vec<Element<'_, Message>> {
let mut elements: Vec<Element<'_, Message>> = Vec::new();
if self.player_status.is_some() && self.config.show_media_controls_in_top_panel {
let mut elements = Vec::with_capacity(3);
if self
.player_status
.as_ref()
Expand Down Expand Up @@ -205,18 +212,8 @@ impl Audio {
.into(),
)
}

Some(match self.core.applet.anchor {
PanelAnchor::Left | PanelAnchor::Right => Column::with_children(elements)
.align_x(Alignment::Center)
.into(),
PanelAnchor::Top | PanelAnchor::Bottom => Row::with_children(elements)
.align_y(Alignment::Center)
.into(),
})
} else {
None
}
elements
}

fn go_previous(&self, icon_size: u16) -> Option<Element<'_, Message>> {
Expand Down Expand Up @@ -724,21 +721,37 @@ impl cosmic::Application for Audio {

self.core
.applet
.autosize_window(if let Some(Some(playback_buttons)) = playback_buttons {
match self.core.applet.anchor {
PanelAnchor::Left | PanelAnchor::Right => Element::from(
Column::with_children([playback_buttons, btn.into()])
.align_x(Alignment::Center),
),
PanelAnchor::Top | PanelAnchor::Bottom => {
Row::with_children([playback_buttons, btn.into()])
.align_y(Alignment::Center)
.into()
.autosize_window(
if let Some(playback_buttons) = playback_buttons
&& !playback_buttons.is_empty()
{
match self.core.applet.anchor {
PanelAnchor::Left | PanelAnchor::Right => Element::from(
applet_column::Column::with_children(playback_buttons)
.push(btn)
.align_x(Alignment::Center)
// TODO configurable variable from the panel?
.spacing(
-(self.core.applet.suggested_padding(true).0 as f32)
* self.core.applet.padding_overlap,
),
),
PanelAnchor::Top | PanelAnchor::Bottom => {
applet_row::Row::with_children(playback_buttons)
.push(btn)
.align_y(Alignment::Center)
// TODO configurable variable from the panel?
.spacing(
-(self.core.applet.suggested_padding(true).0 as f32)
* self.core.applet.padding_overlap,
)
.into()
}
}
}
} else {
btn.into()
})
} else {
btn.into()
},
)
.into()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,6 @@ Icon=com.system76.CosmicAppletBattery-symbolic
StartupNotify=true
NoDisplay=true
X-CosmicApplet=true
X-CosmicShrinkable=true
X-CosmicHoverPopup=Start
X-OverflowPriority=10
31 changes: 19 additions & 12 deletions cosmic-applet-battery/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ impl cosmic::Application for CosmicBatteryApplet {
}

fn view(&self) -> Element<'_, Message> {
let btn = self
let btn: Element<'_, Message> = self
.core
.applet
.icon_button(&self.icon_name)
Expand All @@ -503,17 +503,24 @@ impl cosmic::Application for CosmicBatteryApplet {
shadow: Shadow::default(),
icon_color: Some(Color::TRANSPARENT),
}
})))
.into();
})));
let (dot_align_x, dot_align_y) = match self.core.applet.anchor {
PanelAnchor::Left => (Alignment::Start, Alignment::Center),
PanelAnchor::Right => (Alignment::End, Alignment::Center),
PanelAnchor::Top => (Alignment::Center, Alignment::Start),
PanelAnchor::Bottom => (Alignment::Center, Alignment::End),
};

match self.core.applet.anchor {
PanelAnchor::Left | PanelAnchor::Right => Column::with_children([btn, dot])
.align_x(Alignment::Center)
.into(),
PanelAnchor::Top | PanelAnchor::Bottom => Row::with_children([btn, dot])
.align_y(Alignment::Center)
.into(),
}
cosmic::iced::widget::stack![
btn,
container(dot)
.width(Length::Fill)
.height(Length::Fill)
.align_y(dot_align_y)
.align_x(dot_align_x)
.padding(2.0)
]
.into()
};

self.core.applet.autosize_window(content).into()
Expand Down Expand Up @@ -785,7 +792,7 @@ impl cosmic::Application for CosmicBatteryApplet {
if gpu.toggled
&& !self.core.applet.suggested_bounds.as_ref().is_some_and(|c| {
let suggested_size = self.core.applet.suggested_size(true);
let padding = self.core.applet.suggested_padding(true);
let padding = self.core.applet.suggested_padding(true).1;
let w = suggested_size.0 + 2 * padding;
let h = suggested_size.1 + 2 * padding;
// if we have a configure for width and height, we're in a overflow popup
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ Icon=com.system76.CosmicAppletBluetooth-symbolic
StartupNotify=true
NoDisplay=true
X-CosmicApplet=true
X-CosmicShrinkable=true
X-CosmicHoverPopup=Auto
X-OverflowPriority=10
7 changes: 0 additions & 7 deletions cosmic-applet-bluetooth/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,13 +223,6 @@ impl cosmic::Application for CosmicBluetoothApplet {
) => {
// my headphones seem to always request this
// doesn't seem to be defined in the UX mockups
// dbg!(
// "request service authorization",
// d.name,
// bluer::id::Service::try_from(service)
// .map(|s| s.to_string())
// .unwrap_or_else(|_| "unknown".to_string())
// );
}
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,6 @@ Icon=com.system76.CosmicAppletInputSources-symbolic
StartupNotify=true
NoDisplay=true
X-CosmicApplet=true
X-CosmicShrinkable=true
X-CosmicHoverPopup=Auto
X-OverflowPriority=10
Loading
Loading