Skip to content

Commit

Permalink
fix: rounded rectangle crop position
Browse files Browse the repository at this point in the history
  • Loading branch information
wash2 committed Nov 27, 2024
1 parent abf1a64 commit 734e3fa
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 12 deletions.
10 changes: 3 additions & 7 deletions cosmic-panel-bin/src/iced/elements/overflow_button.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,10 @@ use std::{
};

use calloop::LoopHandle;
use cctk::wayland_client::protocol::wl_subsurface::WlSubsurface;
// element for rendering a button that toggles the overflow popup when clicked
use crate::xdg_shell_wrapper::{self, shared_state::GlobalState};
use cosmic::{
iced::{
alignment::{Horizontal, Vertical},
Length, Padding,
},
iced::{Length, Padding},
iced_core::id,
theme::{self, Button},
widget::{button, layer_container, Id},
Expand Down Expand Up @@ -184,8 +180,8 @@ impl Program for OverflowButton {
.width(Length::Fixed(self.icon_size as f32))
.height(Length::Fixed(self.icon_size as f32)),
)
.align_x(Horizontal::Center)
.align_y(Vertical::Center)
.align_x(cosmic::iced::Alignment::Center)
.align_y(cosmic::iced::Alignment::Center)
.width(Length::Fixed(self.icon_size as f32 + self.button_padding.horizontal()))
.height(Length::Fixed(self.icon_size as f32 + self.button_padding.horizontal())),
)
Expand Down
19 changes: 15 additions & 4 deletions cosmic-panel-bin/src/space/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ use crate::{
},
minimize::MinimizeApplet,
space::{corner_element::RoundedRectangleSettings, Alignment},
xdg_shell_wrapper::space::Visibility,
};

use super::{
Expand Down Expand Up @@ -643,6 +644,10 @@ impl PanelSpace {
p.logical_height == h && p.logical_width == w && self.bg_color() == p.color
})
}) || self.animate_state.as_ref().is_some()
|| matches!(
self.visibility,
Visibility::TransitionToHidden { .. } | Visibility::TransitionToVisible { .. }
)
{
if let Some(bg) = self.background_element.take() {
self.space.unmap_elem(&CosmicMappedInternal::Background(bg));
Expand All @@ -658,11 +663,17 @@ impl PanelSpace {
(PanelAnchor::Top, 0) => (0., 0., border_radius, border_radius),
_ => (border_radius, border_radius, border_radius, border_radius),
};

let anim_gap_scaled = self.anchor_gap as f32 * self.scale as f32;
let loc = match self.config.anchor {
PanelAnchor::Left => [gap_scaled as f32, container_lengthwise_pos_scaled],
PanelAnchor::Right => [0., container_lengthwise_pos_scaled],
PanelAnchor::Top => [container_lengthwise_pos_scaled, 0.],
PanelAnchor::Bottom => [container_lengthwise_pos_scaled, gap_scaled as f32],
PanelAnchor::Left => {
[gap_scaled as f32 + anim_gap_scaled, container_lengthwise_pos_scaled]
},
PanelAnchor::Right => [-anim_gap_scaled, container_lengthwise_pos_scaled],
PanelAnchor::Top => [container_lengthwise_pos_scaled, -anim_gap_scaled],
PanelAnchor::Bottom => {
[container_lengthwise_pos_scaled, gap_scaled as f32 + anim_gap_scaled]
},
};
self.panel_rect_settings = RoundedRectangleSettings {
rad_tl: rad_tl as f32,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::xdg_shell_wrapper::{
};
use sctk::{
delegate_keyboard,
seat::keyboard::{KeyCode, KeyboardHandler, Keysym, RepeatInfo},
seat::keyboard::{KeyCode, KeyboardHandler, Keysym, RawModifiers, RepeatInfo},
shell::WaylandSurface,
};
use smithay::{backend::input::KeyState, input::keyboard::FilterResult, utils::SERIAL_COUNTER};
Expand Down Expand Up @@ -263,6 +263,7 @@ impl KeyboardHandler for GlobalState {
_keyboard: &sctk::reexports::client::protocol::wl_keyboard::WlKeyboard,
_serial: u32,
_modifiers: sctk::seat::keyboard::Modifiers,
_: RawModifiers,
_: u32,
) {
// TODO should these be handled specially
Expand Down

0 comments on commit 734e3fa

Please sign in to comment.