gui2/ttext_: Disable blinking cursor

There's an issue with textboxes across separate window instances (e.g.
when firing up the New Folder dialog in the file dialog) each getting a
blinking cursor simultaneously displayed on the screen due to timer
events persisting even when a GUI2 window isn't running. This may cause
repaint issues since the whole textbox may need to be redrawn each time
the timer fires, so it's best to disable it until I figure out a better
way to implement a unique global blinking cursor.
This commit is contained in:
Ignacio R. Morelle 2016-10-14 01:02:33 -03:00
parent 1d820b2fa6
commit 6e5633929b
2 changed files with 11 additions and 2 deletions

View file

@ -66,7 +66,8 @@
x2 = "(cursor_offset + {X_OFFSET})"
y2 = "(text_y_offset + text_font_height - 2)"
color = "255, 255, 255, 255"
alpha = "(cursor_alpha)"
# TODO: disabled until there's a way to deal with textboxes on multiple windows
#alpha = "(cursor_alpha)"
thickness = 1
[/line]
#enddef

View file

@ -40,7 +40,7 @@ ttext_::ttext_()
, selection_length_(0)
, cursor_timer_(0)
, cursor_alpha_(0)
, cursor_blink_rate_ms_(750)
, cursor_blink_rate_ms_(0) // TODO: disabled until there's a way to deal with textboxes on multiple windows
, text_changed_callback_()
{
#ifdef __unix__
@ -254,6 +254,10 @@ void ttext_::set_state(const tstate state)
void ttext_::toggle_cursor_timer(bool enable)
{
if(!cursor_blink_rate_ms_) {
return;
}
if(cursor_timer_) {
remove_timer(cursor_timer_);
}
@ -285,6 +289,10 @@ void ttext_::cursor_timer_callback()
void ttext_::reset_cursor_state()
{
if(!cursor_blink_rate_ms_) {
return;
}
cursor_alpha_ = 255;
for(auto& tmp : canvas()) {