Skip to content

Commit

Permalink
Don't repaint background
Browse files Browse the repository at this point in the history
  • Loading branch information
jrmoulton committed Nov 8, 2023
1 parent 886f070 commit 7385292
Showing 1 changed file with 1 addition and 10 deletions.
11 changes: 1 addition & 10 deletions src/widgets/toggle_button.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,17 +205,8 @@ impl View for ToggleButton {
fn paint(&mut self, cx: &mut crate::context::PaintCx) {
let layout = cx.get_layout(self.id).unwrap();
let size = Size::new(layout.size.width as f64, layout.size.height as f64);
let border_radius = match self.style.border_radius() {
PxPct::Px(px) => px,
PxPct::Pct(pct) => size.min_side() * (pct / 100.),
};
let rounded_rect = size.to_rounded_rect(border_radius);
let circle_point = Point::new(self.position as f64, rounded_rect.center().y);
let circle_point = Point::new(self.position as f64, size.to_rect().center().y);
let circle = crate::kurbo::Circle::new(circle_point, self.radius as f64);
// here fill default themes
if let Some(color) = self.style.background() {
cx.fill(&rounded_rect, color, 0.);
}
if let Some(color) = self.style.foreground() {
cx.fill(&circle, color, 0.);
}
Expand Down

0 comments on commit 7385292

Please sign in to comment.