Skip to content

Commit 8fba01f

Browse files
committed
WIP: implement text selection across multiple labels
1 parent a9c7768 commit 8fba01f

File tree

8 files changed

+491
-91
lines changed

8 files changed

+491
-91
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
}
@@ -1610,6 +1610,8 @@ impl Context {
16101610
crate::gui_zoom::zoom_with_keyboard(self);
16111611
}
16121612

1613+
crate::text_selection::LabelSelectionState::end_frame(self);
1614+
16131615
let debug_texts = self.write(|ctx| std::mem::take(&mut ctx.debug_texts));
16141616
if !debug_texts.is_empty() {
16151617
// Show debug-text next to the cursor.
@@ -2346,6 +2348,15 @@ impl Context {
23462348
let font_image_size = self.fonts(|f| f.font_image_size());
23472349
crate::introspection::font_texture_ui(ui, font_image_size);
23482350
});
2351+
2352+
CollapsingHeader::new("Label text selection state")
2353+
.default_open(false)
2354+
.show(ui, |ui| {
2355+
ui.label(format!(
2356+
"{:#?}",
2357+
crate::text_selection::LabelSelectionState::load(ui.ctx())
2358+
));
2359+
});
23492360
}
23502361

23512362
/// 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)