Add Response::with_new_rect
This commit is contained in:
parent
d01e4342f0
commit
5444ab269a
2 changed files with 10 additions and 9 deletions
|
@ -112,10 +112,7 @@ impl CollapsingState {
|
||||||
response.rect.center().y,
|
response.rect.center().y,
|
||||||
));
|
));
|
||||||
let openness = self.openness(ui.ctx());
|
let openness = self.openness(ui.ctx());
|
||||||
let small_icon_response = Response {
|
let small_icon_response = response.clone().with_new_rect(icon_rect);
|
||||||
rect: icon_rect,
|
|
||||||
..response.clone()
|
|
||||||
};
|
|
||||||
icon_fn(ui, openness, &small_icon_response);
|
icon_fn(ui, openness, &small_icon_response);
|
||||||
response
|
response
|
||||||
}
|
}
|
||||||
|
@ -576,10 +573,7 @@ impl CollapsingHeader {
|
||||||
header_response.rect.left() + ui.spacing().indent / 2.0,
|
header_response.rect.left() + ui.spacing().indent / 2.0,
|
||||||
header_response.rect.center().y,
|
header_response.rect.center().y,
|
||||||
));
|
));
|
||||||
let icon_response = Response {
|
let icon_response = header_response.clone().with_new_rect(icon_rect);
|
||||||
rect: icon_rect,
|
|
||||||
..header_response.clone()
|
|
||||||
};
|
|
||||||
if let Some(icon) = icon {
|
if let Some(icon) = icon {
|
||||||
icon(ui, openness, &icon_response);
|
icon(ui, openness, &icon_response);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -57,7 +57,7 @@ pub struct Response {
|
||||||
pub double_clicked: [bool; NUM_POINTER_BUTTONS],
|
pub double_clicked: [bool; NUM_POINTER_BUTTONS],
|
||||||
|
|
||||||
/// The thing was triple-clicked.
|
/// The thing was triple-clicked.
|
||||||
pub(crate) triple_clicked: [bool; NUM_POINTER_BUTTONS],
|
pub triple_clicked: [bool; NUM_POINTER_BUTTONS],
|
||||||
|
|
||||||
/// The widgets is being dragged
|
/// The widgets is being dragged
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
|
@ -744,6 +744,13 @@ impl Response {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Response {
|
||||||
|
/// Returns a response with a modified [`Self::rect`].
|
||||||
|
pub fn with_new_rect(self, rect: Rect) -> Self {
|
||||||
|
Self { rect, ..self }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// To summarize the response from many widgets you can use this pattern:
|
/// To summarize the response from many widgets you can use this pattern:
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
|
|
Loading…
Reference in a new issue