Only invalidate parent view on click/hover if we read that state when rendering

Co-Authored-By: Max Brunsfeld <max@zed.dev>
This commit is contained in:
Nathan Sobo
2022-10-14 18:09:15 -06:00
co-authored by Max Brunsfeld
parent 934474f87e
commit bc03592912
19 changed files with 124 additions and 55 deletions
+3 -3
View File
@@ -645,12 +645,12 @@ pub struct Interactive<T> {
}
impl<T> Interactive<T> {
pub fn style_for(&self, state: MouseState, active: bool) -> &T {
pub fn style_for(&self, state: &mut MouseState, active: bool) -> &T {
if active {
self.active.as_ref().unwrap_or(&self.default)
} else if state.clicked == Some(gpui::MouseButton::Left) && self.clicked.is_some() {
} else if state.clicked() == Some(gpui::MouseButton::Left) && self.clicked.is_some() {
self.clicked.as_ref().unwrap()
} else if state.hovered {
} else if state.hovered() {
self.hover.as_ref().unwrap_or(&self.default)
} else {
&self.default