OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "SampleCode.h" | 8 #include "SampleCode.h" |
9 #include "SkAnimTimer.h" | 9 #include "SkAnimTimer.h" |
10 #include "SkView.h" | 10 #include "SkView.h" |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 this->setBGColor(SK_ColorGRAY); | 255 this->setBGColor(SK_ColorGRAY); |
256 } | 256 } |
257 | 257 |
258 virtual ~PatchView() { | 258 virtual ~PatchView() { |
259 SkSafeUnref(fShader0); | 259 SkSafeUnref(fShader0); |
260 SkSafeUnref(fShader1); | 260 SkSafeUnref(fShader1); |
261 } | 261 } |
262 | 262 |
263 protected: | 263 protected: |
264 // overrides from SkEventSink | 264 // overrides from SkEventSink |
265 virtual bool onQuery(SkEvent* evt) { | 265 bool onQuery(SkEvent* evt) override { |
266 if (SampleCode::TitleQ(*evt)) { | 266 if (SampleCode::TitleQ(*evt)) { |
267 SampleCode::TitleR(evt, "Patch"); | 267 SampleCode::TitleR(evt, "Patch"); |
268 return true; | 268 return true; |
269 } | 269 } |
270 return this->INHERITED::onQuery(evt); | 270 return this->INHERITED::onQuery(evt); |
271 } | 271 } |
272 | 272 |
273 virtual void onDrawContent(SkCanvas* canvas) { | 273 void onDrawContent(SkCanvas* canvas) override { |
274 const int nu = 10; | 274 const int nu = 10; |
275 const int nv = 10; | 275 const int nv = 10; |
276 | 276 |
277 SkPaint paint; | 277 SkPaint paint; |
278 paint.setDither(true); | 278 paint.setDither(true); |
279 paint.setFilterQuality(kLow_SkFilterQuality); | 279 paint.setFilterQuality(kLow_SkFilterQuality); |
280 | 280 |
281 canvas->translate(DX, DY); | 281 canvas->translate(DX, DY); |
282 | 282 |
283 Patch patch; | 283 Patch patch; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
327 class PtClick : public Click { | 327 class PtClick : public Click { |
328 public: | 328 public: |
329 int fIndex; | 329 int fIndex; |
330 PtClick(SkView* view, int index) : Click(view), fIndex(index) {} | 330 PtClick(SkView* view, int index) : Click(view), fIndex(index) {} |
331 }; | 331 }; |
332 | 332 |
333 static bool hittest(const SkPoint& pt, SkScalar x, SkScalar y) { | 333 static bool hittest(const SkPoint& pt, SkScalar x, SkScalar y) { |
334 return SkPoint::Length(pt.fX - x, pt.fY - y) < SkIntToScalar(5); | 334 return SkPoint::Length(pt.fX - x, pt.fY - y) < SkIntToScalar(5); |
335 } | 335 } |
336 | 336 |
337 virtual SkView::Click* onFindClickHandler(SkScalar x, SkScalar y, | 337 SkView::Click* onFindClickHandler(SkScalar x, SkScalar y, unsigned modi) ove
rride { |
338 unsigned modi) override { | |
339 x -= DX; | 338 x -= DX; |
340 y -= DY; | 339 y -= DY; |
341 for (size_t i = 0; i < SK_ARRAY_COUNT(fPts); i++) { | 340 for (size_t i = 0; i < SK_ARRAY_COUNT(fPts); i++) { |
342 if (hittest(fPts[i], x, y)) { | 341 if (hittest(fPts[i], x, y)) { |
343 return new PtClick(this, (int)i); | 342 return new PtClick(this, (int)i); |
344 } | 343 } |
345 } | 344 } |
346 return this->INHERITED::onFindClickHandler(x, y, modi); | 345 return this->INHERITED::onFindClickHandler(x, y, modi); |
347 } | 346 } |
348 | 347 |
349 virtual bool onClick(Click* click) { | 348 bool onClick(Click* click) override { |
350 fPts[((PtClick*)click)->fIndex].set(click->fCurr.fX - DX, click->fCurr.f
Y - DY); | 349 fPts[((PtClick*)click)->fIndex].set(click->fCurr.fX - DX, click->fCurr.f
Y - DY); |
351 this->inval(NULL); | 350 this->inval(NULL); |
352 return true; | 351 return true; |
353 } | 352 } |
354 | 353 |
355 private: | 354 private: |
356 typedef SampleView INHERITED; | 355 typedef SampleView INHERITED; |
357 }; | 356 }; |
358 | 357 |
359 ////////////////////////////////////////////////////////////////////////////// | 358 ////////////////////////////////////////////////////////////////////////////// |
360 | 359 |
361 static SkView* MyFactory() { return new PatchView; } | 360 static SkView* MyFactory() { return new PatchView; } |
362 static SkViewRegister reg(MyFactory); | 361 static SkViewRegister reg(MyFactory); |
OLD | NEW |