Samples: simplify Sample::Event
Change-Id: I1daaa9dcf56812bfd29dab64ee04dae63c2660e1
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/225545
Commit-Queue: Ben Wagner <bungeman@google.com>
Auto-Submit: Hal Canary <halcanary@google.com>
Reviewed-by: Ben Wagner <bungeman@google.com>
diff --git a/samplecode/PerlinPatch.cpp b/samplecode/PerlinPatch.cpp
index b6fcc3e..2e404ad 100644
--- a/samplecode/PerlinPatch.cpp
+++ b/samplecode/PerlinPatch.cpp
@@ -112,15 +112,12 @@
protected:
SkString name() override { return SkString("PerlinPatch"); }
- bool onQuery(Sample::Event* evt) override {
- SkUnichar uni;
- if (Sample::CharQ(*evt, &uni)) {
+ bool onChar(SkUnichar uni) override {
switch (uni) {
case 'g': fShowGrid = !fShowGrid; return true;
default: break;
}
- }
- return this->INHERITED::onQuery(evt);
+ return false;
}
bool onAnimate(const AnimTimer& timer) override {
diff --git a/samplecode/Sample.cpp b/samplecode/Sample.cpp
index d528c12..9ee3b84 100644
--- a/samplecode/Sample.cpp
+++ b/samplecode/Sample.cpp
@@ -17,56 +17,6 @@
//////////////////////////////////////////////////////////////////////////////
-Sample::Event::Event() : Event("") {}
-
-Sample::Event::Event(const Event& that) {
- *this = that;
-}
-
-Sample::Event::Event(const char type[]) : fType(type), f32(0) {
- SkASSERT(type);
-}
-
-Sample::Event::~Event() {}
-
-bool Sample::Event::isType(const char type[]) const {
- return fType.equals(type);
-}
-
-const char* Sample::kCharEvtName = "SampleCode_Char_Event";
-
-bool Sample::CharQ(const Event& evt, SkUnichar* outUni) {
- if (evt.isType(kCharEvtName)) {
- if (outUni) {
- *outUni = evt.getFast32();
- }
- return true;
- }
- return false;
-}
-
-///////////////////////////////////////////////////////////////////////////////
-
-bool Sample::doEvent(const Event& evt) {
- return this->onEvent(evt);
-}
-
-bool Sample::onEvent(const Event&) {
- return false;
-}
-
-bool Sample::doQuery(Event* evt) {
- SkASSERT(evt);
- return this->onQuery(evt);
-}
-
-bool Sample::onQuery(Sample::Event* evt) {
- return false;
-}
-
-////////////////////////////////////////////////////////////////////////
-
-
void Sample::setSize(SkScalar width, SkScalar height) {
width = SkMaxScalar(0, width);
height = SkMaxScalar(0, height);
diff --git a/samplecode/Sample.h b/samplecode/Sample.h
index ed6fe1c..0d538d2 100644
--- a/samplecode/Sample.h
+++ b/samplecode/Sample.h
@@ -47,6 +47,8 @@
/** Call this to have the view draw into the specified canvas. */
virtual void draw(SkCanvas* canvas);
+ virtual bool onChar(SkUnichar) { return false; }
+
// Click handling
class Click {
public:
@@ -85,120 +87,7 @@
virtual SkString name() = 0;
- class Event {
- public:
- Event();
- explicit Event(const char type[]);
- Event(const Event& src);
- ~Event();
-
- /** Returns true if the event's type matches exactly the specified type (case sensitive) */
- bool isType(const char type[]) const;
-
- /** Return the event's unnamed 32bit field. Default value is 0 */
- uint32_t getFast32() const { return f32; }
-
- /** Set the event's unnamed 32bit field. */
- void setFast32(uint32_t x) { f32 = x; }
-
- /** Return true if the event contains the named 32bit field, and return the field
- in value (if value is non-null). If there is no matching named field, return false
- and ignore the value parameter.
- */
- bool findS32(const char name[], int32_t* value = nullptr) const {
- return fMeta.findS32(name, value);
- }
- /** Return true if the event contains the named SkScalar field, and return the field
- in value (if value is non-null). If there is no matching named field, return false
- and ignore the value parameter.
- */
- bool findScalar(const char name[], SkScalar* value = nullptr) const {
- return fMeta.findScalar(name, value);
- }
- /** Return true if the event contains the named SkScalar field, and return the fields
- in value[] (if value is non-null), and return the number of SkScalars in count
- (if count is non-null). If there is no matching named field, return false
- and ignore the value and count parameters.
- */
- const SkScalar* findScalars(const char name[], int* count, SkScalar values[]=nullptr) const{
- return fMeta.findScalars(name, count, values);
- }
- /** Return the value of the named string field, or nullptr. */
- const char* findString(const char name[]) const { return fMeta.findString(name); }
- /** Return true if the event contains the named pointer field, and return the field
- in value (if value is non-null). If there is no matching named field, return false
- and ignore the value parameter.
- */
- bool findPtr(const char name[], void** value) const { return fMeta.findPtr(name, value); }
- bool findBool(const char name[], bool* value) const { return fMeta.findBool(name, value); }
- const void* findData(const char name[], size_t* byteCount = nullptr) const {
- return fMeta.findData(name, byteCount);
- }
-
- /** Returns true if ethe event contains the named 32bit field, and if it equals the specified value */
- bool hasS32(const char name[], int32_t value) const { return fMeta.hasS32(name, value); }
- /** Returns true if ethe event contains the named SkScalar field, and if it equals the specified value */
- bool hasScalar(const char name[], SkScalar value) const { return fMeta.hasScalar(name, value); }
- /** Returns true if ethe event contains the named string field, and if it equals (using strcmp) the specified value */
- bool hasString(const char name[], const char value[]) const { return fMeta.hasString(name, value); }
- /** Returns true if ethe event contains the named pointer field, and if it equals the specified value */
- bool hasPtr(const char name[], void* value) const { return fMeta.hasPtr(name, value); }
- bool hasBool(const char name[], bool value) const { return fMeta.hasBool(name, value); }
- bool hasData(const char name[], const void* data, size_t byteCount) const {
- return fMeta.hasData(name, data, byteCount);
- }
-
- /** Add/replace the named 32bit field to the event. */
- void setS32(const char name[], int32_t value) { fMeta.setS32(name, value); }
- /** Add/replace the named SkScalar field to the event. */
- void setScalar(const char name[], SkScalar value) { fMeta.setScalar(name, value); }
- /** Add/replace the named SkScalar[] field to the event. */
- SkScalar* setScalars(const char name[], int count, const SkScalar values[] = nullptr) {
- return fMeta.setScalars(name, count, values);
- }
- /** Add/replace the named string field to the event. */
- void setString(const char name[], const char value[]) { fMeta.setString(name, value); }
- /** Add/replace the named pointer field to the event. */
- void setPtr(const char name[], void* value) { fMeta.setPtr(name, value); }
- void setBool(const char name[], bool value) { fMeta.setBool(name, value); }
- void setData(const char name[], const void* data, size_t byteCount) {
- fMeta.setData(name, data, byteCount);
- }
-
- /** Return the underlying metadata object */
- SkMetaData& getMetaData() { return fMeta; }
- /** Return the underlying metadata object */
- const SkMetaData& getMetaData() const { return fMeta; }
-
- ///////////////////////////////////////////////////////////////////////////
-
- private:
- SkMetaData fMeta;
- SkString fType;
- uint32_t f32;
- };
-
- /** Pass an event to this object for processing. Returns true if the event was handled. */
- bool doEvent(const Event&);
-
- /** Returns true if the sink (or one of its subclasses) understands the event as a query.
- If so, the sink may modify the event to communicate its "answer".
- */
- bool doQuery(Event* query);
-
- static const char* kCharEvtName;
- static const char* kTitleEvtName;
- static bool CharQ(const Event&, SkUnichar* outUni);
- static bool TitleQ(const Event&);
- static void TitleR(Event*, const char title[]);
-
protected:
- /** Override to handle events in your subclass.
- * Overriders must call the super class for unhandled events.
- */
- virtual bool onEvent(const Event&);
- virtual bool onQuery(Event*);
-
/** Override to be notified of size changes. Overriders must call the super class. */
virtual void onSizeChange();
diff --git a/samplecode/SampleAAGeometry.cpp b/samplecode/SampleAAGeometry.cpp
index fc47876..515f4f7 100644
--- a/samplecode/SampleAAGeometry.cpp
+++ b/samplecode/SampleAAGeometry.cpp
@@ -972,7 +972,7 @@
SkString name() override { return SkString("AAGeometry"); }
- bool onQuery(Sample::Event* evt) override;
+ bool onChar(SkUnichar) override;
void onSizeChange() override {
setControlButtonsPos();
@@ -1821,12 +1821,7 @@
}
}
-bool AAGeometryView::onQuery(Sample::Event* evt) {
- SkUnichar uni;
- if (false) {
- return this->INHERITED::onQuery(evt);
- }
- if (Sample::CharQ(*evt, &uni)) {
+bool AAGeometryView::onChar(SkUnichar uni) {
for (int index = 0; index < kButtonCount; ++index) {
Button* button = kButtonList[index].fButton;
if (button->fVisible && uni == button->fLabel) {
@@ -1853,8 +1848,7 @@
}
}
}
- }
- return this->INHERITED::onQuery(evt);
+ return false;
}
DEF_SAMPLE( return new AAGeometryView; )
diff --git a/samplecode/SampleAndroidShadows.cpp b/samplecode/SampleAndroidShadows.cpp
index e6c67a0..b5a02a6 100644
--- a/samplecode/SampleAndroidShadows.cpp
+++ b/samplecode/SampleAndroidShadows.cpp
@@ -108,9 +108,7 @@
SkString name() override { return SkString("AndroidShadows"); }
- bool onQuery(Sample::Event* evt) override {
- SkUnichar uni;
- if (Sample::CharQ(*evt, &uni)) {
+ bool onChar(SkUnichar uni) override {
bool handled = false;
switch (uni) {
case 'W':
@@ -154,8 +152,7 @@
if (handled) {
return true;
}
- }
- return this->INHERITED::onQuery(evt);
+ return false;
}
void drawBG(SkCanvas* canvas) {
diff --git a/samplecode/SampleAnimatedImage.cpp b/samplecode/SampleAnimatedImage.cpp
index 647ae26..0a8b5eb 100644
--- a/samplecode/SampleAnimatedImage.cpp
+++ b/samplecode/SampleAnimatedImage.cpp
@@ -98,9 +98,8 @@
SkString name() override { return SkString("AnimatedImage"); }
- bool onQuery(Sample::Event* evt) override {
- SkUnichar uni;
- if (fImage && Sample::CharQ(*evt, &uni)) {
+ bool onChar(SkUnichar uni) override {
+ if (fImage) {
switch (uni) {
case kPauseKey:
fRunning = !fRunning;
@@ -118,7 +117,7 @@
break;
}
}
- return this->INHERITED::onQuery(evt);
+ return false;
}
private:
diff --git a/samplecode/SampleAnimatedText.cpp b/samplecode/SampleAnimatedText.cpp
index bfd319e..13e81d6 100644
--- a/samplecode/SampleAnimatedText.cpp
+++ b/samplecode/SampleAnimatedText.cpp
@@ -49,9 +49,7 @@
protected:
SkString name() override { return SkString("AnimatedText"); }
- bool onQuery(Sample::Event* evt) override {
- SkUnichar uni;
- if (Sample::CharQ(*evt, &uni)) {
+ bool onChar(SkUnichar uni) override {
if ('2' == uni) {
if (fSizeScale == 2) {
fSizeScale = 1;
@@ -60,8 +58,7 @@
}
return true;
}
- }
- return this->INHERITED::onQuery(evt);
+ return false;
}
void onDrawContent(SkCanvas* canvas) override {
diff --git a/samplecode/SampleAtlas.cpp b/samplecode/SampleAtlas.cpp
index a05674f..043d3fd 100644
--- a/samplecode/SampleAtlas.cpp
+++ b/samplecode/SampleAtlas.cpp
@@ -213,15 +213,12 @@
protected:
SkString name() override { return SkString(fName); }
- bool onQuery(Sample::Event* evt) override {
- SkUnichar uni;
- if (Sample::CharQ(*evt, &uni)) {
+ bool onChar(SkUnichar uni) override {
switch (uni) {
case 'C': fDrawable->toggleUseColors(); return true;
default: break;
}
- }
- return this->INHERITED::onQuery(evt);
+ return false;
}
void onOnceBeforeDraw() override {
diff --git a/samplecode/SampleCCPRGeometry.cpp b/samplecode/SampleCCPRGeometry.cpp
index 63ea48a..dd9d298 100644
--- a/samplecode/SampleCCPRGeometry.cpp
+++ b/samplecode/SampleCCPRGeometry.cpp
@@ -50,7 +50,7 @@
Sample::Click* onFindClickHandler(SkScalar x, SkScalar y, unsigned) override;
bool onClick(Sample::Click*) override;
- bool onQuery(Sample::Event* evt) override;
+ bool onChar(SkUnichar) override;
SkString name() override { return SkString("CCPRGeometry"); }
private:
@@ -441,9 +441,7 @@
return true;
}
-bool CCPRGeometryView::onQuery(Sample::Event* evt) {
- SkUnichar unichar;
- if (Sample::CharQ(*evt, &unichar)) {
+bool CCPRGeometryView::onChar(SkUnichar unichar) {
if (unichar >= '1' && unichar <= '4') {
fPrimitiveType = PrimitiveType(unichar - '1');
if (fPrimitiveType >= PrimitiveType::kWeightedTriangles) {
@@ -493,8 +491,7 @@
fDoStroke = !fDoStroke;
this->updateAndInval();
}
- }
- return this->INHERITED::onQuery(evt);
+ return false;
}
DEF_SAMPLE(return new CCPRGeometryView;)
diff --git a/samplecode/SampleChineseFling.cpp b/samplecode/SampleChineseFling.cpp
index b250da4..bb749e5 100644
--- a/samplecode/SampleChineseFling.cpp
+++ b/samplecode/SampleChineseFling.cpp
@@ -124,9 +124,7 @@
protected:
SkString name() override { return SkString("chinese-zoom"); }
- bool onQuery(Sample::Event* evt) override {
- SkUnichar uni;
- if (Sample::CharQ(*evt, &uni)) {
+ bool onChar(SkUnichar uni) override {
if ('>' == uni) {
fScale += 0.125f;
return true;
@@ -135,8 +133,7 @@
fScale -= 0.125f;
return true;
}
- }
- return this->INHERITED::onQuery(evt);
+ return false;
}
void onDrawContent(SkCanvas* canvas) override {
diff --git a/samplecode/SampleClipDrawMatch.cpp b/samplecode/SampleClipDrawMatch.cpp
index e57c338..729e16a 100644
--- a/samplecode/SampleClipDrawMatch.cpp
+++ b/samplecode/SampleClipDrawMatch.cpp
@@ -135,9 +135,7 @@
protected:
SkString name() override { return SkString("ClipDrawMatch"); }
- bool onQuery(Sample::Event* evt) override {
- SkUnichar uni;
- if (Sample::CharQ(*evt, &uni)) {
+ bool onChar(SkUnichar uni) override {
switch (uni) {
case '1': fGeom = kRect_Geometry; return true;
case '2': fGeom = kRRect_Geometry; return true;
@@ -152,8 +150,7 @@
case 't': fClipFirst = !fClipFirst; return true;
default: break;
}
- }
- return this->INHERITED::onQuery(evt);
+ return false;
}
void drawClippedGeom(SkCanvas* canvas, const SkPoint& offset, bool useAA) {
diff --git a/samplecode/SampleDegenerateQuads.cpp b/samplecode/SampleDegenerateQuads.cpp
index 5b6c28e..895a6d2 100644
--- a/samplecode/SampleDegenerateQuads.cpp
+++ b/samplecode/SampleDegenerateQuads.cpp
@@ -383,7 +383,7 @@
Sample::Click* onFindClickHandler(SkScalar x, SkScalar y,
unsigned) override;
bool onClick(Sample::Click*) override;
- bool onQuery(Sample::Event* evt) override;
+ bool onChar(SkUnichar) override;
SkString name() override { return SkString("DegenerateQuad"); }
private:
@@ -496,9 +496,7 @@
return true;
}
-bool DegenerateQuadSample::onQuery(Sample::Event* event) {
- SkUnichar code;
- if (Sample::CharQ(*event, &code)) {
+bool DegenerateQuadSample::onChar(SkUnichar code) {
switch(code) {
case '1':
fEdgeAA[0] = !fEdgeAA[0];
@@ -522,8 +520,7 @@
fCoverageMode = CoverageMode::kGPUMesh;
return true;
}
- }
- return this->INHERITED::onQuery(event);
+ return false;
}
DEF_SAMPLE(return new DegenerateQuadSample(SkRect::MakeWH(4.f, 4.f));)
diff --git a/samplecode/SampleFatBits.cpp b/samplecode/SampleFatBits.cpp
index 73e1f523..0eaec1d 100644
--- a/samplecode/SampleFatBits.cpp
+++ b/samplecode/SampleFatBits.cpp
@@ -393,9 +393,7 @@
protected:
SkString name() override { return SkString("FatBits"); }
- bool onQuery(Sample::Event* evt) override {
- SkUnichar uni;
- if (Sample::CharQ(*evt, &uni)) {
+ bool onChar(SkUnichar uni) override {
switch (uni) {
case 'c':
fFB.setUseClip(!fFB.getUseClip());
@@ -442,8 +440,7 @@
fFB.fStrokeWidth += 0.125f;
return true;
}
- }
- return this->INHERITED::onQuery(evt);
+ return false;
}
void onDrawContent(SkCanvas* canvas) override {
diff --git a/samplecode/SampleFilterQuality.cpp b/samplecode/SampleFilterQuality.cpp
index 5b72149..ac97d52 100644
--- a/samplecode/SampleFilterQuality.cpp
+++ b/samplecode/SampleFilterQuality.cpp
@@ -168,9 +168,7 @@
protected:
SkString name() override { return SkString("FilterQuality"); }
- bool onQuery(Sample::Event* evt) override {
- SkUnichar uni;
- if (Sample::CharQ(*evt, &uni)) {
+ bool onChar(SkUnichar uni) override {
switch (uni) {
case '1': fAngle.inc(-ANGLE_DELTA); return true;
case '2': fAngle.inc( ANGLE_DELTA); return true;
@@ -179,8 +177,7 @@
case '5': fShowFatBits = !fShowFatBits; return true;
default: break;
}
- }
- return this->INHERITED::onQuery(evt);
+ return false;
}
void drawTheImage(SkCanvas* canvas, const SkISize& size, SkFilterQuality filter,
diff --git a/samplecode/SampleLitAtlas.cpp b/samplecode/SampleLitAtlas.cpp
index 1b804a8..94eb070 100644
--- a/samplecode/SampleLitAtlas.cpp
+++ b/samplecode/SampleLitAtlas.cpp
@@ -449,9 +449,7 @@
protected:
SkString name() override { return SkString("DrawLitAtlas"); }
- bool onQuery(Sample::Event* evt) override {
- SkUnichar uni;
- if (Sample::CharQ(*evt, &uni)) {
+ bool onChar(SkUnichar uni) override {
switch (uni) {
case 'C':
fDrawable->toggleUseColors();
@@ -471,8 +469,7 @@
default:
break;
}
- }
- return this->INHERITED::onQuery(evt);
+ return false;
}
void onDrawContent(SkCanvas* canvas) override {
diff --git a/samplecode/SampleLua.cpp b/samplecode/SampleLua.cpp
index 8dbf115..469d0a6 100644
--- a/samplecode/SampleLua.cpp
+++ b/samplecode/SampleLua.cpp
@@ -70,9 +70,7 @@
protected:
SkString name() override { return SkString("Lua"); }
- bool onQuery(Sample::Event* evt) override {
- SkUnichar uni;
- if (Sample::CharQ(*evt, &uni)) {
+ bool onChar(SkUnichar uni) override {
lua_State* L = this->ensureLua();
lua_getglobal(L, gUnicharName);
if (lua_isfunction(L, -1)) {
@@ -87,8 +85,7 @@
}
}
}
- }
- return this->INHERITED::onQuery(evt);
+ return false;
}
void onDrawContent(SkCanvas* canvas) override {
diff --git a/samplecode/SampleMegaStroke.cpp b/samplecode/SampleMegaStroke.cpp
index 43bb7b5..26e9588 100644
--- a/samplecode/SampleMegaStroke.cpp
+++ b/samplecode/SampleMegaStroke.cpp
@@ -28,15 +28,9 @@
protected:
SkString name() override { return SkString("MegaStroke"); }
- bool onQuery(Sample::Event* evt) override {
- SkUnichar uni;
- if (Sample::CharQ(*evt, &uni)) {
- fClip.set(0, 0, 950, 600);
- }
- if (evt->isType("SampleCode_Key_Event")) {
- fClip.set(0, 0, 950, 600);
- }
- return this->INHERITED::onQuery(evt);
+ bool onChar(SkUnichar uni) override {
+ fClip.set(0, 0, 950, 600);
+ return true;
}
void onDrawBackground(SkCanvas* canvas) override {
diff --git a/samplecode/SampleParagraph.cpp b/samplecode/SampleParagraph.cpp
index 72fca3b..109507d 100644
--- a/samplecode/SampleParagraph.cpp
+++ b/samplecode/SampleParagraph.cpp
@@ -1080,9 +1080,7 @@
protected:
SkString name() override { return SkString("Paragraph9"); }
- bool onQuery(Sample::Event* evt) override {
- SkUnichar uni;
- if (Sample::CharQ(*evt, &uni)) {
+ bool onChar(SkUnichar uni) override {
switch (uni) {
case 'w':
++wordSpacing;
@@ -1099,9 +1097,7 @@
default:
break;
}
- }
-
- return this->INHERITED::onQuery(evt);
+ return false;
}
void drawText(SkCanvas* canvas, SkColor background, SkScalar w, SkScalar h) {
diff --git a/samplecode/SamplePath.cpp b/samplecode/SamplePath.cpp
index 8ba8380..bdb51ab 100644
--- a/samplecode/SamplePath.cpp
+++ b/samplecode/SamplePath.cpp
@@ -246,17 +246,14 @@
protected:
SkString name() override { return SkString("ArcTo"); }
- bool onQuery(Sample::Event* evt) override {
- SkUnichar uni;
- if (Sample::CharQ(*evt, &uni)) {
+ bool onChar(SkUnichar uni) override {
switch (uni) {
case '1': this->toggle(fDoFrame); return true;
case '2': this->toggle(fDoCorner); return true;
case '3': this->toggle(fDoConic); return true;
default: break;
}
- }
- return this->INHERITED::onQuery(evt);
+ return false;
}
void makePath(SkPath* path) {
@@ -361,9 +358,7 @@
protected:
SkString name() override { return SkString("FatStroke"); }
- bool onQuery(Sample::Event* evt) override {
- SkUnichar uni;
- if (Sample::CharQ(*evt, &uni)) {
+ bool onChar(SkUnichar uni) override {
switch (uni) {
case '1': this->toggle(fShowSkeleton); return true;
case '2': this->toggle(fShowStroke); return true;
@@ -375,8 +370,7 @@
case '=': fWidth += 5; return true;
default: break;
}
- }
- return this->INHERITED::onQuery(evt);
+ return false;
}
void makePath(SkPath* path) {
@@ -603,21 +597,16 @@
protected:
SkString name() override { return SkString("CubicCurve2"); }
- bool onQuery(Sample::Event* evt) override {
- SkUnichar uni;
- if (Sample::CharQ(*evt, &uni)) {
+ bool onChar(SkUnichar uni) override {
switch (uni) {
case 's': fShowSub = !fShowSub; break;
case 'f': fShowFlatness = !fShowFlatness; break;
case '-': fT -= 1.0f / 32; break;
case '=': fT += 1.0f / 32; break;
- default: goto DONE;
+ default: return false;
}
fT = std::min(1.0f, std::max(0.0f, fT));
return true;
- }
- DONE:
- return this->INHERITED::onQuery(evt);
}
void showFrame(SkCanvas* canvas, const SkPoint pts[], int count, const SkPaint& p) {
diff --git a/samplecode/SamplePathOverstroke.cpp b/samplecode/SamplePathOverstroke.cpp
index 6346564..a01562b 100644
--- a/samplecode/SamplePathOverstroke.cpp
+++ b/samplecode/SamplePathOverstroke.cpp
@@ -34,9 +34,7 @@
protected:
SkString name() override { return SkString("PathOverstroke"); }
- bool onQuery(Sample::Event* evt) override {
- SkUnichar uni;
- if (Sample::CharQ(*evt, &uni)) {
+ bool onChar(SkUnichar uni) override {
switch (uni) {
case ',':
fStroke += 1.0;
@@ -59,8 +57,7 @@
default:
break;
}
- }
- return this->INHERITED::onQuery(evt);
+ return false;
}
SkPath quadPath(SkPoint p1, SkPoint p2) {
diff --git a/samplecode/SamplePathText.cpp b/samplecode/SamplePathText.cpp
index 288fe2e..c547802 100644
--- a/samplecode/SamplePathText.cpp
+++ b/samplecode/SamplePathText.cpp
@@ -56,15 +56,12 @@
SkString name() override { return SkString(this->getName()); }
- bool onQuery(Sample::Event* evt) override {
- SkUnichar unichar;
- if (Sample::CharQ(*evt, &unichar)) {
+ bool onChar(SkUnichar unichar) override {
if (unichar == 'X') {
fDoClip = !fDoClip;
return true;
}
- }
- return this->INHERITED::onQuery(evt);
+ return false;
}
void onDrawContent(SkCanvas* canvas) override {
diff --git a/samplecode/SampleQuadStroker.cpp b/samplecode/SampleQuadStroker.cpp
index c24d1d3..4de89e2 100644
--- a/samplecode/SampleQuadStroker.cpp
+++ b/samplecode/SampleQuadStroker.cpp
@@ -211,9 +211,8 @@
protected:
SkString name() override { return SkString("QuadStroker"); }
- bool onQuery(Sample::Event* evt) override {
- SkUnichar uni;
- if (fTextButton.fEnabled && Sample::CharQ(*evt, &uni)) {
+ bool onChar(SkUnichar uni) override {
+ if (fTextButton.fEnabled) {
switch (uni) {
case ' ':
fText = "";
@@ -230,7 +229,7 @@
}
return true;
}
- return this->INHERITED::onQuery(evt);
+ return false;
}
void onSizeChange() override {
diff --git a/samplecode/SampleRectanizer.cpp b/samplecode/SampleRectanizer.cpp
index 89a47c4..c9faa78 100644
--- a/samplecode/SampleRectanizer.cpp
+++ b/samplecode/SampleRectanizer.cpp
@@ -56,9 +56,7 @@
protected:
SkString name() override { return SkString("Rectanizer"); }
- bool onQuery(Sample::Event* evt) override {
- SkUnichar uni;
- if (Sample::CharQ(*evt, &uni)) {
+ bool onChar(SkUnichar uni) override {
char utf8[SkUTF::kMaxBytesInUTF8Sequence];
size_t size = SkUTF::ToUTF8(uni, utf8);
// Only consider events for single char keys
@@ -74,8 +72,7 @@
break;
}
}
- }
- return this->INHERITED::onQuery(evt);
+ return false;
}
void onDrawContent(SkCanvas* canvas) override {
diff --git a/samplecode/SampleShadowColor.cpp b/samplecode/SampleShadowColor.cpp
index 3affe79..e0dd7fe 100644
--- a/samplecode/SampleShadowColor.cpp
+++ b/samplecode/SampleShadowColor.cpp
@@ -46,9 +46,7 @@
SkString name() override { return SkString("ShadowColor"); }
- bool onQuery(Sample::Event* evt) override {
- SkUnichar uni;
- if (Sample::CharQ(*evt, &uni)) {
+ bool onChar(SkUnichar uni) override {
bool handled = false;
switch (uni) {
case 'W':
@@ -89,10 +87,10 @@
if (handled) {
return true;
}
- }
- return this->INHERITED::onQuery(evt);
+ return false;
}
+
void drawShadowedPath(SkCanvas* canvas, const SkPath& path,
const SkPoint3& zPlaneParams,
const SkPaint& paint, SkScalar ambientAlpha,
diff --git a/samplecode/SampleShadowReference.cpp b/samplecode/SampleShadowReference.cpp
index 22b17a1..db8e9db 100644
--- a/samplecode/SampleShadowReference.cpp
+++ b/samplecode/SampleShadowReference.cpp
@@ -40,9 +40,7 @@
SkString name() override { return SkString("ShadowReference"); }
- bool onQuery(Sample::Event* evt) override {
- SkUnichar uni;
- if (Sample::CharQ(*evt, &uni)) {
+ bool onChar(SkUnichar uni) override {
bool handled = false;
switch (uni) {
case 'W':
@@ -67,8 +65,7 @@
if (handled) {
return true;
}
- }
- return this->INHERITED::onQuery(evt);
+ return false;
}
void drawBG(SkCanvas* canvas) {
diff --git a/samplecode/SampleShadowUtils.cpp b/samplecode/SampleShadowUtils.cpp
index 36a2a7d..52d151d 100644
--- a/samplecode/SampleShadowUtils.cpp
+++ b/samplecode/SampleShadowUtils.cpp
@@ -75,9 +75,7 @@
SkString name() override { return SkString("ShadowUtils"); }
- bool onQuery(Sample::Event* evt) override {
- SkUnichar uni;
- if (Sample::CharQ(*evt, &uni)) {
+ bool onChar(SkUnichar uni) override {
bool handled = false;
switch (uni) {
case 'W':
@@ -114,8 +112,7 @@
if (handled) {
return true;
}
- }
- return this->INHERITED::onQuery(evt);
+ return false;
}
void drawBG(SkCanvas* canvas) {
diff --git a/samplecode/SampleThinAA.cpp b/samplecode/SampleThinAA.cpp
index bbf1475..ae301e9 100644
--- a/samplecode/SampleThinAA.cpp
+++ b/samplecode/SampleThinAA.cpp
@@ -375,9 +375,7 @@
SkString name() override { return SkString("Thin-AA"); }
- bool onQuery(Sample::Event* evt) override {
- SkUnichar key;
- if (Sample::CharQ(*evt, &key)) {
+ bool onChar(SkUnichar key) override {
switch(key) {
case 't':
// Toggle translation animation.
@@ -409,8 +407,7 @@
case '-': fStrokeWidth = SkMaxScalar(0.1f, fStrokeWidth - 0.05f); return true;
case '=': fStrokeWidth = SkMinScalar(1.f, fStrokeWidth + 0.05f); return true;
}
- }
- return this->INHERITED::onQuery(evt);
+ return false;
}
private:
diff --git a/samplecode/SampleUnpremul.cpp b/samplecode/SampleUnpremul.cpp
index 5fac3dc..ec58491 100644
--- a/samplecode/SampleUnpremul.cpp
+++ b/samplecode/SampleUnpremul.cpp
@@ -44,9 +44,7 @@
protected:
SkString name() override { return SkString("unpremul"); }
- bool onQuery(Sample::Event* evt) override {
- SkUnichar uni;
- if (Sample::CharQ(*evt, &uni)) {
+ bool onChar(SkUnichar uni) override {
char utf8[SkUTF::kMaxBytesInUTF8Sequence];
size_t size = SkUTF::ToUTF8(uni, utf8);
// Only consider events for single char keys
@@ -62,8 +60,7 @@
break;
}
}
- }
- return this->INHERITED::onQuery(evt);
+ return false;
}
void onDrawBackground(SkCanvas* canvas) override {