fix(segmented_button): use correct divider color when vertical
This commit is contained in:
parent
2faaeddb05
commit
c497c227ce
3 changed files with 15 additions and 8 deletions
|
|
@ -92,10 +92,13 @@ where
|
||||||
let mut divider = None;
|
let mut divider = None;
|
||||||
|
|
||||||
if self.dividers && segmetned_control && nth + 1 < num {
|
if self.dividers && segmetned_control && nth + 1 < num {
|
||||||
divider = Some(ItemBounds::Divider(Rectangle {
|
divider = Some(ItemBounds::Divider(
|
||||||
width: 1.0,
|
Rectangle {
|
||||||
..bounds
|
width: 1.0,
|
||||||
}));
|
..bounds
|
||||||
|
},
|
||||||
|
true,
|
||||||
|
));
|
||||||
|
|
||||||
bounds.x += 1.0;
|
bounds.x += 1.0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,7 @@ where
|
||||||
divider_bounds.x += f32::from(self.button_padding[0]);
|
divider_bounds.x += f32::from(self.button_padding[0]);
|
||||||
divider_bounds.width -= f32::from(self.button_padding[0]);
|
divider_bounds.width -= f32::from(self.button_padding[0]);
|
||||||
divider_bounds.width -= f32::from(self.button_padding[2]);
|
divider_bounds.width -= f32::from(self.button_padding[2]);
|
||||||
divider = Some(ItemBounds::Divider(divider_bounds));
|
divider = Some(ItemBounds::Divider(divider_bounds, false));
|
||||||
|
|
||||||
bounds.y += divider_bounds.height + spacing;
|
bounds.y += divider_bounds.height + spacing;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@ pub fn focus<Message: 'static>(id: Id) -> Command<Message> {
|
||||||
|
|
||||||
pub enum ItemBounds {
|
pub enum ItemBounds {
|
||||||
Button(Entity, Rectangle),
|
Button(Entity, Rectangle),
|
||||||
Divider(Rectangle),
|
Divider(Rectangle, bool),
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Isolates variant-specific behaviors from [`SegmentedButton`].
|
/// Isolates variant-specific behaviors from [`SegmentedButton`].
|
||||||
|
|
@ -1299,7 +1299,7 @@ where
|
||||||
ItemBounds::Button(entity, bounds) => (entity, bounds),
|
ItemBounds::Button(entity, bounds) => (entity, bounds),
|
||||||
|
|
||||||
// Draw a divider between buttons
|
// Draw a divider between buttons
|
||||||
ItemBounds::Divider(bounds) => {
|
ItemBounds::Divider(bounds, accented) => {
|
||||||
renderer.fill_quad(
|
renderer.fill_quad(
|
||||||
renderer::Quad {
|
renderer::Quad {
|
||||||
bounds,
|
bounds,
|
||||||
|
|
@ -1308,7 +1308,11 @@ where
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
let theme = crate::theme::active();
|
let theme = crate::theme::active();
|
||||||
Background::Color(theme.cosmic().small_widget_divider().into())
|
if accented {
|
||||||
|
Background::Color(theme.cosmic().small_widget_divider().into())
|
||||||
|
} else {
|
||||||
|
Background::Color(theme.cosmic().primary_container_divider().into())
|
||||||
|
}
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue