Index: samplecode/SampleApp.cpp |
diff --git a/samplecode/SampleApp.cpp b/samplecode/SampleApp.cpp |
index dd771cec2d47d160b634ed7e0a33d703215de7f8..5b8ed96905ae64434b5d9348e424efc0595beb67 100644 |
--- a/samplecode/SampleApp.cpp |
+++ b/samplecode/SampleApp.cpp |
@@ -662,6 +662,19 @@ static bool curr_title(SkWindow* wind, SkString* title) { |
return false; |
} |
+bool SampleWindow::sendAnimatePulse() { |
+ SkView* view = curr_view(this); |
+ if (SampleView::IsSampleView(view)) { |
+ if (fDoAnimate) { |
+ return ((SampleView*)view)->animatePulse(gAnimTime, gAnimTimePrev); |
+ } else { |
+ // 0 signals the view that we are no longer animating |
+ ((SampleView*)view)->animatePulse(0, 0); |
+ } |
+ } |
+ return false; |
+} |
+ |
void SampleWindow::setZoomCenter(float x, float y) |
{ |
fZoomCenterX = x; |
@@ -823,6 +836,7 @@ SampleWindow::SampleWindow(void* hwnd, int argc, char** argv, DeviceManager* dev |
fDeviceType = kANGLE_DeviceType; |
#endif |
+ fDoAnimate = true; |
fUseClip = false; |
fNClip = false; |
fAnimating = false; |
@@ -1130,6 +1144,10 @@ void SampleWindow::draw(SkCanvas* canvas) { |
this->postInvalDelay(); |
} |
+ if (this->sendAnimatePulse()) { |
+ this->inval(NULL); |
+ } |
+ |
// do this last |
fDevManager->publishCanvas(fDeviceType, canvas, this); |
} |
@@ -1709,6 +1727,12 @@ bool SampleWindow::onHandleChar(SkUnichar uni) { |
} |
switch (uni) { |
+ case ' ': |
+ fDoAnimate = !fDoAnimate; |
+ if (this->sendAnimatePulse()) { |
+ this->inval(NULL); |
+ } |
+ break; |
case 'B': |
post_event_to_sink(SkNEW_ARGS(SkEvent, ("PictFileView::toggleBBox")), curr_view(this)); |
// Cannot call updateTitle() synchronously, because the toggleBBox event is still in |