Improve context menu aside layout via custom logic (#22154)
* Presence of the aside no longer affects position or size of the context menu. * Prefers to fit to the right, then on same side of line, then other side of line, within the following preference order: - Max possible size within text area. - Max possible size within window. - Actual size within window. This is the only case that could cause it to jump around with less stability. A further enhancement atop this might be to dynamically resize aside height to fit. Release notes are N/A as they are covered by the notes for #22102. Closes #8523 Release Notes: * N/A
This commit is contained in:
parent
6aad616165
commit
5d7b6141fd
4 changed files with 277 additions and 120 deletions
|
@ -1003,6 +1003,18 @@ where
|
|||
size: self.size.clone() + size(double_amount.clone(), double_amount),
|
||||
}
|
||||
}
|
||||
|
||||
/// Extends the bounds different amounts in each direction.
|
||||
pub fn extend(&self, amount: Edges<T>) -> Bounds<T> {
|
||||
Bounds {
|
||||
origin: self.origin.clone() - point(amount.left.clone(), amount.top.clone()),
|
||||
size: self.size.clone()
|
||||
+ size(
|
||||
amount.left.clone() + amount.right.clone(),
|
||||
amount.top.clone() + amount.bottom.clone(),
|
||||
),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> Bounds<T>
|
||||
|
@ -1097,6 +1109,21 @@ impl<T: Clone + Default + Debug + PartialOrd + Add<T, Output = T> + Sub<Output =
|
|||
}
|
||||
}
|
||||
|
||||
impl<T> Bounds<T>
|
||||
where
|
||||
T: Clone + Debug + Add<T, Output = T> + Sub<T, Output = T> + Default,
|
||||
{
|
||||
/// Computes the space available within outer bounds.
|
||||
pub fn space_within(&self, outer: &Self) -> Edges<T> {
|
||||
Edges {
|
||||
top: self.top().clone() - outer.top().clone(),
|
||||
right: outer.right().clone() - self.right().clone(),
|
||||
bottom: outer.bottom().clone() - self.bottom().clone(),
|
||||
left: self.left().clone() - outer.left().clone(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<T, Rhs> Mul<Rhs> for Bounds<T>
|
||||
where
|
||||
T: Mul<Rhs, Output = Rhs> + Clone + Default + Debug,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue