From c6dd730d786177854ae3334ccb922f9315e9ebdd Mon Sep 17 00:00:00 2001 From: Ashley Wulber Date: Tue, 21 May 2024 15:34:20 -0400 Subject: [PATCH] fix(input sources): button size --- cosmic-applet-input-sources/src/lib.rs | 2 +- cosmic-applet-input-sources/src/window.rs | 41 +++++++++++++++++------ 2 files changed, 32 insertions(+), 11 deletions(-) diff --git a/cosmic-applet-input-sources/src/lib.rs b/cosmic-applet-input-sources/src/lib.rs index 7c695b69..8ff79e14 100644 --- a/cosmic-applet-input-sources/src/lib.rs +++ b/cosmic-applet-input-sources/src/lib.rs @@ -63,5 +63,5 @@ pub fn run() -> cosmic::iced::Result { config, layouts, }; - cosmic::applet::run::(true, flags) + cosmic::applet::run::(false, flags) } diff --git a/cosmic-applet-input-sources/src/window.rs b/cosmic-applet-input-sources/src/window.rs index 3bdbd5ae..d53d445e 100644 --- a/cosmic-applet-input-sources/src/window.rs +++ b/cosmic-applet-input-sources/src/window.rs @@ -8,6 +8,7 @@ use cosmic::app::Core; use cosmic::applet::{self}; use cosmic::cosmic_config::{self, ConfigSet}; use cosmic::iced::wayland::popup::{destroy_popup, get_popup}; +use cosmic::iced::widget::{column, row}; use cosmic::iced::window::Id; #[allow(unused_imports)] use cosmic::iced::{alignment, Alignment, Length}; @@ -16,7 +17,7 @@ use cosmic::iced_futures::Subscription; use cosmic::iced_runtime::core::window; use cosmic::iced_style::application; use cosmic::prelude::*; -use cosmic::widget; +use cosmic::widget::{self, horizontal_space, vertical_space}; use cosmic_comp_config::CosmicCompConfig; use xkb_data::KeyboardLayouts; @@ -161,17 +162,37 @@ impl cosmic::Application for Window { } fn view(&self) -> Element { - let suggested = self.core.applet.suggested_padding(true); - widget::button( - self.core.applet.text( - self.active_layouts - .first() - .map_or(String::new(), |l| l.layout.clone()), - ), + let input_source_text = self.core.applet.text( + self.active_layouts + .first() + .map_or(String::new(), |l| l.layout.clone()), + ); + + cosmic::widget::button( + row!( + column!( + input_source_text, + horizontal_space(Length::Fixed( + (self.core.applet.suggested_size(true).0 + + 2 * self.core.applet.suggested_padding(true)) + as f32 + )) + ) + .width(Length::Shrink) + .height(Length::Shrink) + .align_items(Alignment::Center), + vertical_space(Length::Fixed( + (self.core.applet.suggested_size(true).1 + + 2 * self.core.applet.suggested_padding(true)) as f32 + )) + ) + .align_items(Alignment::Center) + .width(Length::Shrink) + .height(Length::Shrink), ) - .style(cosmic::theme::Button::AppletIcon) - .padding([suggested / 2, suggested]) .on_press(Message::TogglePopup) + .padding(self.core.applet.suggested_padding(true)) + .style(cosmic::theme::Button::AppletIcon) .into() }