Skip to content

Commit 9f0b0ec

Browse files
committed
WIP: implement text selection across multiple labels
1 parent b132f1a commit 9f0b0ec

File tree

10 files changed

+600
-95
lines changed

10 files changed

+600
-95
lines changed

crates/egui/src/context.rs

+12-1
Original file line numberDiff line numberDiff line change
@@ -625,7 +625,7 @@ impl Context {
625625
/// ```
626626
pub fn begin_frame(&self, new_input: RawInput) {
627627
crate::profile_function!();
628-
628+
crate::text_selection::LabelSelectionState::begin_frame(self);
629629
self.write(|ctx| ctx.begin_frame_mut(new_input));
630630
}
631631
}
@@ -1616,6 +1616,8 @@ impl Context {
16161616
crate::gui_zoom::zoom_with_keyboard(self);
16171617
}
16181618

1619+
crate::text_selection::LabelSelectionState::end_frame(self);
1620+
16191621
let debug_texts = self.write(|ctx| std::mem::take(&mut ctx.debug_texts));
16201622
if !debug_texts.is_empty() {
16211623
// Show debug-text next to the cursor.
@@ -2352,6 +2354,15 @@ impl Context {
23522354
let font_image_size = self.fonts(|f| f.font_image_size());
23532355
crate::introspection::font_texture_ui(ui, font_image_size);
23542356
});
2357+
2358+
CollapsingHeader::new("Label text selection state")
2359+
.default_open(false)
2360+
.show(ui, |ui| {
2361+
ui.label(format!(
2362+
"{:#?}",
2363+
crate::text_selection::LabelSelectionState::load(ui.ctx())
2364+
));
2365+
});
23552366
}
23562367

23572368
/// Show stats about the allocated textures.

crates/egui/src/input_state.rs

+1
Original file line numberDiff line numberDiff line change
@@ -840,6 +840,7 @@ impl PointerState {
840840
}
841841

842842
/// Was any pointer button pressed (`!down -> down`) this frame?
843+
///
843844
/// This can sometimes return `true` even if `any_down() == false`
844845
/// because a press can be shorted than one frame.
845846
pub fn any_pressed(&self) -> bool {

crates/egui/src/text_selection/cursor_range.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -234,10 +234,10 @@ impl CCursorRange {
234234
}
235235

236236
#[inline]
237-
pub fn two(min: CCursor, max: CCursor) -> Self {
237+
pub fn two(min: impl Into<CCursor>, max: impl Into<CCursor>) -> Self {
238238
Self {
239-
primary: max,
240-
secondary: min,
239+
primary: max.into(),
240+
secondary: min.into(),
241241
}
242242
}
243243

0 commit comments

Comments
 (0)