improv(segmented-button): extra padding for close icon
This commit is contained in:
parent
75e80857e2
commit
eb519782ac
2 changed files with 10 additions and 11 deletions
|
|
@ -1,4 +1,5 @@
|
||||||
use cosmic::iced::widget::row;
|
use apply::Apply;
|
||||||
|
use cosmic::iced::widget::{horizontal_space, row, scrollable};
|
||||||
use cosmic::iced::Length;
|
use cosmic::iced::Length;
|
||||||
use cosmic::iced_winit::Alignment;
|
use cosmic::iced_winit::Alignment;
|
||||||
use cosmic::widget::{button, segmented_button, view_switcher};
|
use cosmic::widget::{button, segmented_button, view_switcher};
|
||||||
|
|
@ -65,14 +66,14 @@ impl State {
|
||||||
.show_close_icon_on_hover(true)
|
.show_close_icon_on_hover(true)
|
||||||
.on_activate(Message::Activate)
|
.on_activate(Message::Activate)
|
||||||
.on_close(Message::Close)
|
.on_close(Message::Close)
|
||||||
.width(Length::Fill);
|
.width(Length::Shrink);
|
||||||
|
|
||||||
let new_tab_button = button(theme::Button::Text)
|
let new_tab_button = button(theme::Button::Text)
|
||||||
.icon(theme::Svg::Symbolic, "tab-new-symbolic", 20)
|
.icon(theme::Svg::Symbolic, "tab-new-symbolic", 20)
|
||||||
.on_press(Message::AddNew);
|
.on_press(Message::AddNew);
|
||||||
|
|
||||||
row!(tabs, new_tab_button)
|
let tab_header = row!(tabs, new_tab_button).align_items(Alignment::Center);
|
||||||
.align_items(Alignment::Center)
|
|
||||||
.into()
|
row!(tab_header, horizontal_space(Length::Fill)).into()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -234,7 +234,7 @@ where
|
||||||
// Add close button to measurement if found.
|
// Add close button to measurement if found.
|
||||||
if self.model.is_closable(key) {
|
if self.model.is_closable(key) {
|
||||||
button_height = button_height.max(f32::from(self.icon_size));
|
button_height = button_height.max(f32::from(self.icon_size));
|
||||||
button_width += f32::from(self.icon_size) + f32::from(self.button_spacing);
|
button_width += f32::from(self.icon_size) + f32::from(self.button_spacing) + 8.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
height = height.max(button_height);
|
height = height.max(button_height);
|
||||||
|
|
@ -656,13 +656,11 @@ impl From<Id> for widget::Id {
|
||||||
|
|
||||||
/// Calculates the bounds of the close button within the area of an item.
|
/// Calculates the bounds of the close button within the area of an item.
|
||||||
fn close_bounds(area: Rectangle<f32>, icon_size: f32, button_padding: [u16; 4]) -> Rectangle<f32> {
|
fn close_bounds(area: Rectangle<f32>, icon_size: f32, button_padding: [u16; 4]) -> Rectangle<f32> {
|
||||||
let top = f32::from(button_padding[1]);
|
let unpadded_height = area.height - f32::from(button_padding[1]) - f32::from(button_padding[3]);
|
||||||
let end = f32::from(button_padding[2]);
|
|
||||||
let unpadded_height = area.height - top - end;
|
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
x: area.x + area.width - icon_size - f32::from(button_padding[2]),
|
x: area.x + area.width - icon_size - 8.0,
|
||||||
y: area.y + f32::from(button_padding[1]) + (unpadded_height / 2.0),
|
y: area.y + (unpadded_height / 2.0) - (icon_size / 2.0),
|
||||||
width: icon_size,
|
width: icon_size,
|
||||||
height: icon_size,
|
height: icon_size,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue