Timeline: Redraw only marching ants on timer tick (fix #1537)

This commit is contained in:
David Capello 2017-07-18 17:07:35 -03:00
parent dd3ce20133
commit 147f36077b
3 changed files with 25 additions and 3 deletions

View File

@ -209,6 +209,7 @@ Timeline::Timeline()
, m_confPopup(NULL)
, m_clipboard_timer(100, this)
, m_offset_count(0)
, m_redrawMarchingAntsOnly(false)
, m_scroll(false)
, m_fromTimeline(false)
{
@ -518,18 +519,23 @@ bool Timeline::onProcessMessage(Message* msg)
&clipboard_document,
&clipboard_range);
if (isVisible() && m_document && clipboard_document == m_document) {
if (isVisible() &&
m_document &&
m_document == clipboard_document) {
// Set offset to make selection-movement effect
if (m_offset_count < 7)
m_offset_count++;
else
m_offset_count = 0;
bool redrawOnlyMarchingAnts = getUpdateRegion().isEmpty();
invalidateRect(gfx::Rect(getRangeBounds(clipboard_range)).offset(origin()));
if (redrawOnlyMarchingAnts)
m_redrawMarchingAntsOnly = true;
}
else if (m_clipboard_timer.isRunning()) {
m_clipboard_timer.stop();
}
invalidate();
}
break;
@ -1236,6 +1242,12 @@ bool Timeline::onProcessMessage(Message* msg)
return Widget::onProcessMessage(msg);
}
void Timeline::onInvalidateRegion(const gfx::Region& region)
{
Widget::onInvalidateRegion(region);
m_redrawMarchingAntsOnly = false;
}
void Timeline::onSizeHint(SizeHintEvent& ev)
{
// This doesn't matter, the AniEditor'll use the entire screen anyway.
@ -1270,6 +1282,12 @@ void Timeline::onPaint(ui::PaintEvent& ev)
// the background thread is making a backup.
const DocumentReader documentReader(m_document, 250);
if (m_redrawMarchingAntsOnly) {
drawClipboardRange(g);
m_redrawMarchingAntsOnly = false;
return;
}
layer_t layer, firstLayer, lastLayer;
frame_t frame, firstFrame, lastFrame;

View File

@ -114,6 +114,7 @@ namespace app {
protected:
bool onProcessMessage(ui::Message* msg) override;
void onInvalidateRegion(const gfx::Region& region) override;
void onSizeHint(ui::SizeHintEvent& ev) override;
void onResize(ui::ResizeEvent& ev) override;
void onPaint(ui::PaintEvent& ev) override;
@ -352,6 +353,7 @@ namespace app {
// TODO merge this with the marching ants of the sprite editor (ui::Editor)
ui::Timer m_clipboard_timer;
int m_offset_count;
bool m_redrawMarchingAntsOnly;
bool m_scroll; // True if the drag-and-drop operation is a scroll operation.
bool m_copy; // True if the drag-and-drop operation is a copy.

View File

@ -1044,6 +1044,8 @@ void Widget::setTransparent(bool transparent)
void Widget::invalidate()
{
// TODO we should use invalidateRect(bounds()) here.
if (isVisible()) {
m_updateRegion.clear();
getDrawableRegion(m_updateRegion, kCutTopWindows);