add OVerView slide to samplecode
change inline functions in SkColorPriv.h to static inline
git-svn-id: http://skia.googlecode.com/svn/trunk@415 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/samplecode/SampleApp.cpp b/samplecode/SampleApp.cpp
index 263b898..4000ed7 100644
--- a/samplecode/SampleApp.cpp
+++ b/samplecode/SampleApp.cpp
@@ -10,6 +10,8 @@
#include "SampleCode.h"
+SkView* create_overview(int, const SkViewFactory*);
+
//#define SK_SUPPORT_GL
#ifdef SK_SUPPORT_GL
@@ -122,6 +124,7 @@
//////////////////////////////////////////////////////////////////////////////
class SampleWindow : public SkOSWindow {
+ SkTDArray<SkViewFactory> fSamples;
public:
SampleWindow(void* hwnd);
virtual ~SampleWindow();
@@ -150,7 +153,7 @@
virtual bool onHandleKeyUp(SkKey key);
#endif
private:
- const SkViewRegister* fCurr;
+ int fCurrIndex;
SkPicture* fPicture;
SkGLCanvas* fGLCanvas;
@@ -218,8 +221,15 @@
this->setConfig(SkBitmap::kARGB_8888_Config);
this->setVisibleP(true);
- fCurr = SkViewRegister::Head();
- this->loadView(fCurr->factory()());
+ {
+ const SkViewRegister* reg = SkViewRegister::Head();
+ while (reg) {
+ *fSamples.append() = reg->factory();
+ reg = reg->next();
+ }
+ }
+ fCurrIndex = 0;
+ this->loadView(NULL);
}
SampleWindow::~SampleWindow() {
@@ -386,15 +396,9 @@
}
bool SampleWindow::nextSample() {
- if (fCurr) {
- fCurr = fCurr->next();
- if (NULL == fCurr) {
- fCurr = SkViewRegister::Head();
- }
- this->loadView(fCurr->factory()());
- return true;
- }
- return false;
+ fCurrIndex = (fCurrIndex + 1) % fSamples.count();
+ this->loadView(fSamples[fCurrIndex]());
+ return true;
}
bool SampleWindow::onEvent(const SkEvent& evt) {
@@ -405,6 +409,11 @@
}
return true;
}
+ if (evt.isType("set-curr-index")) {
+ fCurrIndex = evt.getFast32() % fSamples.count();
+ this->loadView(fSamples[fCurrIndex]());
+ return true;
+ }
return this->INHERITED::onEvent(evt);
}
@@ -522,6 +531,9 @@
}
}
return true;
+ case kBack_SkKey:
+ this->loadView(NULL);
+ return true;
default:
break;
}
@@ -534,6 +546,10 @@
if (prev) {
prev->detachFromParent();
}
+
+ if (NULL == view) {
+ view = create_overview(fSamples.count(), fSamples.begin());
+ }
view->setVisibleP(true);
this->attachChildToFront(view)->unref();
view->setSize(this->width(), this->height());