mirror of
https://github.com/aseprite/aseprite.git
synced 2025-02-11 09:40:42 +00:00
Avoid running ui::Entry timer when it's not needed
This commit is contained in:
parent
3b810701ce
commit
ab9883e260
@ -91,12 +91,15 @@ void Entry::setReadOnly(bool state)
|
||||
void Entry::showCaret()
|
||||
{
|
||||
m_hidden = false;
|
||||
if (shouldStartTimer(hasFocus()))
|
||||
m_timer.start();
|
||||
invalidate();
|
||||
}
|
||||
|
||||
void Entry::hideCaret()
|
||||
{
|
||||
m_hidden = true;
|
||||
m_timer.stop();
|
||||
invalidate();
|
||||
}
|
||||
|
||||
@ -131,7 +134,8 @@ void Entry::setCaretPos(int pos)
|
||||
}
|
||||
}
|
||||
|
||||
m_timer.start();
|
||||
if (shouldStartTimer(hasFocus()))
|
||||
m_timer.start();
|
||||
m_state = true;
|
||||
|
||||
invalidate();
|
||||
@ -227,7 +231,8 @@ bool Entry::onProcessMessage(Message* msg)
|
||||
break;
|
||||
|
||||
case kFocusEnterMessage:
|
||||
m_timer.start();
|
||||
if (shouldStartTimer(true))
|
||||
m_timer.start();
|
||||
|
||||
m_state = true;
|
||||
invalidate();
|
||||
@ -392,7 +397,8 @@ bool Entry::onProcessMessage(Message* msg)
|
||||
|
||||
// Show the caret
|
||||
if (is_dirty) {
|
||||
m_timer.start();
|
||||
if (shouldStartTimer(true))
|
||||
m_timer.start();
|
||||
m_state = true;
|
||||
}
|
||||
|
||||
@ -885,4 +891,9 @@ void Entry::recalcCharBoxes(const std::string& text)
|
||||
m_boxes.push_back(box);
|
||||
}
|
||||
|
||||
bool Entry::shouldStartTimer(bool hasFocus)
|
||||
{
|
||||
return (!m_hidden && hasFocus && isEnabled());
|
||||
}
|
||||
|
||||
} // namespace ui
|
||||
|
@ -94,6 +94,7 @@ namespace ui {
|
||||
bool isPosInSelection(int pos);
|
||||
void showEditPopupMenu(const gfx::Point& pt);
|
||||
void recalcCharBoxes(const std::string& text);
|
||||
bool shouldStartTimer(const bool hasFocus);
|
||||
|
||||
class CalcBoxesTextDelegate;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user