OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 #include "SampleCode.h" | 8 #include "SampleCode.h" |
9 #include "SkView.h" | 9 #include "SkView.h" |
10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
307 }; | 307 }; |
308 | 308 |
309 static bool hittest(const SkPoint& pt, SkScalar x, SkScalar y) { | 309 static bool hittest(const SkPoint& pt, SkScalar x, SkScalar y) { |
310 return SkPoint::Length(pt.fX - x, pt.fY - y) < SkIntToScalar(5); | 310 return SkPoint::Length(pt.fX - x, pt.fY - y) < SkIntToScalar(5); |
311 } | 311 } |
312 | 312 |
313 virtual SkView::Click* onFindClickHandler(SkScalar x, SkScalar y, | 313 virtual SkView::Click* onFindClickHandler(SkScalar x, SkScalar y, |
314 unsigned modi) SK_OVERRIDE { | 314 unsigned modi) SK_OVERRIDE { |
315 for (size_t i = 0; i < SK_ARRAY_COUNT(fPts); i++) { | 315 for (size_t i = 0; i < SK_ARRAY_COUNT(fPts); i++) { |
316 if (hittest(fPts[i], x, y)) { | 316 if (hittest(fPts[i], x, y)) { |
317 return new PtClick(this, i); | 317 return new PtClick(this, (int)i); |
318 } | 318 } |
319 } | 319 } |
320 return this->INHERITED::onFindClickHandler(x, y, modi); | 320 return this->INHERITED::onFindClickHandler(x, y, modi); |
321 } | 321 } |
322 | 322 |
323 virtual bool onClick(Click* click) { | 323 virtual bool onClick(Click* click) { |
324 fPts[((PtClick*)click)->fIndex].set(click->fCurr.fX, click->fCurr.fY); | 324 fPts[((PtClick*)click)->fIndex].set(click->fCurr.fX, click->fCurr.fY); |
325 this->inval(NULL); | 325 this->inval(NULL); |
326 return true; | 326 return true; |
327 } | 327 } |
328 | 328 |
329 private: | 329 private: |
330 typedef SampleView INHERITED; | 330 typedef SampleView INHERITED; |
331 }; | 331 }; |
332 | 332 |
333 ////////////////////////////////////////////////////////////////////////////// | 333 ////////////////////////////////////////////////////////////////////////////// |
334 | 334 |
335 static SkView* MyFactory() { return new PatchView; } | 335 static SkView* MyFactory() { return new PatchView; } |
336 static SkViewRegister reg(MyFactory); | 336 static SkViewRegister reg(MyFactory); |
OLD | NEW |