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,
|
||||
));
|
||||
let openness = self.openness(ui.ctx());
|
||||
let small_icon_response = Response {
|
||||
rect: icon_rect,
|
||||
..response.clone()
|
||||
};
|
||||
let small_icon_response = response.clone().with_new_rect(icon_rect);
|
||||
icon_fn(ui, openness, &small_icon_response);
|
||||
response
|
||||
}
|
||||
|
@ -576,10 +573,7 @@ impl CollapsingHeader {
|
|||
header_response.rect.left() + ui.spacing().indent / 2.0,
|
||||
header_response.rect.center().y,
|
||||
));
|
||||
let icon_response = Response {
|
||||
rect: icon_rect,
|
||||
..header_response.clone()
|
||||
};
|
||||
let icon_response = header_response.clone().with_new_rect(icon_rect);
|
||||
if let Some(icon) = icon {
|
||||
icon(ui, openness, &icon_response);
|
||||
} else {
|
||||
|
|
|
@ -57,7 +57,7 @@ pub struct Response {
|
|||
pub double_clicked: [bool; NUM_POINTER_BUTTONS],
|
||||
|
||||
/// 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
|
||||
#[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:
|
||||
///
|
||||
/// ```
|
||||
|
|
Loading…
Reference in a new issue