aboutsummaryrefslogtreecommitdiffhomepage
path: root/samplecode/SampleGM.cpp
diff options
context:
space:
mode:
authorGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2011-01-11 19:45:38 +0000
committerGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2011-01-11 19:45:38 +0000
commit9b2135a923c8344ef4c4f52907b7ffe4fc575136 (patch)
tree8eb1efc85183dab9762019d3e2a83c4d223847c2 /samplecode/SampleGM.cpp
parent7b201d22541957b128528bc481c6fd4ef0ed2258 (diff)
git-svn-id: http://skia.googlecode.com/svn/trunk@685 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'samplecode/SampleGM.cpp')
-rw-r--r--samplecode/SampleGM.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/samplecode/SampleGM.cpp b/samplecode/SampleGM.cpp
index d85cad1227..5c9ea76c93 100644
--- a/samplecode/SampleGM.cpp
+++ b/samplecode/SampleGM.cpp
@@ -15,6 +15,10 @@ public:
fReg = GMRegistry::Head();
}
+ void reset() {
+ fReg = GMRegistry::Head();
+ }
+
GM* next() {
if (fReg) {
GMRegistry::Factory fact = fReg->factory();
@@ -46,6 +50,7 @@ class GMView : public SkView {
public:
GMView() {
fGM = fIter.next();
+ this->postNextGM();
}
protected:
@@ -58,6 +63,20 @@ protected:
return this->INHERITED::onQuery(evt);
}
+ virtual bool onEvent(const SkEvent& evt) {
+ if (evt.isType("next-gm")) {
+ delete fGM;
+ if (!(fGM = fIter.next())) {
+ fIter.reset();
+ fGM = fIter.next();
+ }
+ this->inval(NULL);
+ this->postNextGM();
+ return true;
+ }
+ return this->INHERITED::onEvent(evt);
+ }
+
void drawBG(SkCanvas* canvas) {
canvas->drawColor(0xFFDDDDDD);
}
@@ -67,6 +86,10 @@ protected:
}
private:
+ void postNextGM() {
+ (new SkEvent("next-gm"))->post(this->getSinkID(), 1500);
+ }
+
typedef SkView INHERITED;
};