mirror of
https://github.com/emilk/egui.git
synced 2026-09-02 06:40:06 -04:00
Cross-widget text select (#3870)
* Closes https://github.com/emilk/egui/issues/3816  Turn off with `style.interaction.multi_widget_text_select`. There is an API for this in `LabelSelectionState`, but it's pretty bare-bones. This became really hairy implementation-wise, but it works decently well. # Limitations * Drag-select to scroll doesn't work * A selection disappears if you scroll past one of its end-points * Only the text of labels and links are selectable ## TODO * [x] An option to turn it off * [x] An API for querying about the selected text, and to deselect it. * [x] Scrolling past selection behaves weird * [x] Shift-click to select a range
This commit is contained in:
@@ -125,6 +125,21 @@ impl Rangef {
|
||||
max: self.max.min(other.max),
|
||||
}
|
||||
}
|
||||
|
||||
/// Do the two ranges intersect?
|
||||
///
|
||||
/// ```
|
||||
/// # use emath::Rangef;
|
||||
/// assert!(Rangef::new(0.0, 10.0).intersects(Rangef::new(5.0, 15.0)));
|
||||
/// assert!(Rangef::new(0.0, 10.0).intersects(Rangef::new(5.0, 6.0)));
|
||||
/// assert!(Rangef::new(0.0, 10.0).intersects(Rangef::new(10.0, 20.0)));
|
||||
/// assert!(!Rangef::new(0.0, 10.0).intersects(Rangef::new(20.0, 30.0)));
|
||||
/// ```
|
||||
#[inline]
|
||||
#[must_use]
|
||||
pub fn intersects(self, other: Self) -> bool {
|
||||
other.min <= self.max && self.min <= other.max
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Rangef> for RangeInclusive<f32> {
|
||||
|
||||
Reference in New Issue
Block a user