Conversation
|
It's changes were completed. |
emilk
left a comment
There was a problem hiding this comment.
This is feeling much better now!
crates/egui/src/style.rs
Outdated
| /// show where the text cursor would be if you clicked | ||
| pub text_cursor_preview: bool, | ||
|
|
||
| /// set the text cursor to blink | ||
| pub text_cursor_blink: bool, | ||
|
|
||
| /// set the text cursor on duration | ||
| pub text_cursor_on_duration: f64, | ||
|
|
||
| /// set the text cursor off duration | ||
| pub text_cursor_off_duration: f64, |
There was a problem hiding this comment.
I think it's time to group all these in a struct TextCursorStyle
crates/egui/src/style.rs
Outdated
| ui.checkbox(text_cursor_preview, "Preview text cursor on hover"); | ||
| ui.add(Slider::new(clip_rect_margin, 0.0..=20.0).text("clip_rect_margin")); | ||
|
|
||
| ui.add(Slider::new(resize_corner_size, 0.0..=20.0).text("resize_corner_size")); |
There was a problem hiding this comment.
| ui.add(Slider::new(resize_corner_size, 0.0..=20.0).text("resize_corner_size")); |
| .request_repaint_after(std::time::Duration::from_millis( | ||
| (on_duration * 1000.0) as u64, | ||
| )); | ||
| } | ||
| if !is_cursor_visible { | ||
| ui.ctx() | ||
| .request_repaint_after(std::time::Duration::from_millis( | ||
| (off_duration * 1000.0) as u64, | ||
| )); |
There was a problem hiding this comment.
| .request_repaint_after(std::time::Duration::from_millis( | |
| (on_duration * 1000.0) as u64, | |
| )); | |
| } | |
| if !is_cursor_visible { | |
| ui.ctx() | |
| .request_repaint_after(std::time::Duration::from_millis( | |
| (off_duration * 1000.0) as u64, | |
| )); | |
| .request_repaint_after(std::time::Duration::from_secs_f32( | |
| on_duration | |
| )); | |
| } | |
| if !is_cursor_visible { | |
| ui.ctx() | |
| .request_repaint_after(std::time::Duration::from_secs_f32( | |
| off_duration | |
| )); |
| /// Paint text cursor. | ||
| pub fn paint_text_cursor( |
There was a problem hiding this comment.
fn paint_text_cursor and fn paint_cursor have very similar names, but one does blinking, and one does not. We should document that. fn paint_cursor should probably be made non-pub too
| primary_cursor_rect: Rect, | ||
| is_stay_cursor: bool, | ||
| ) { | ||
| let i_time = ui.input(|i| i.time); |
There was a problem hiding this comment.
Currently the cursor still blinks while typing, which is quite annoying. If we instead reset a timer each time the user presses a key, it won't blink until text_cursor_on_duration after the user last stopped typing.
So, I think you were right to put this timer in TextEditState. We could put a last_edit_time: Option<f64> there fed by ui.input(|i| i.time), and then paint_text_cursor is fed with time_since_last_edit which will be used as the basis for the animation
|
I'll fix the rest of the things in this PR |
Yes, Thank you emilk. |
On by default. Can be set with `style.text_cursor.blink`. * Closes emilk#4121
text cursor blink in TextEdit