OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 "sk_tool_utils.h" | 8 #include "sk_tool_utils.h" |
9 #include "SampleCode.h" | 9 #include "SampleCode.h" |
10 #include "SkView.h" | 10 #include "SkView.h" |
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
387 fPts[2].set(48 * 2, 48 * 6); | 387 fPts[2].set(48 * 2, 48 * 6); |
388 fIsRect = false; | 388 fIsRect = false; |
389 } | 389 } |
390 | 390 |
391 void setStyle(FatBits::Style s) { | 391 void setStyle(FatBits::Style s) { |
392 fFB.setStyle(s); | 392 fFB.setStyle(s); |
393 this->inval(NULL); | 393 this->inval(NULL); |
394 } | 394 } |
395 | 395 |
396 protected: | 396 protected: |
397 bool onQuery(SkEvent* evt) SK_OVERRIDE { | 397 bool onQuery(SkEvent* evt) override { |
398 if (SampleCode::TitleQ(*evt)) { | 398 if (SampleCode::TitleQ(*evt)) { |
399 SampleCode::TitleR(evt, "FatBits"); | 399 SampleCode::TitleR(evt, "FatBits"); |
400 return true; | 400 return true; |
401 } | 401 } |
402 SkUnichar uni; | 402 SkUnichar uni; |
403 if (SampleCode::CharQ(*evt, &uni)) { | 403 if (SampleCode::CharQ(*evt, &uni)) { |
404 switch (uni) { | 404 switch (uni) { |
405 case 'c': | 405 case 'c': |
406 fFB.setUseClip(!fFB.getUseClip()); | 406 fFB.setUseClip(!fFB.getUseClip()); |
407 this->inval(NULL); | 407 this->inval(NULL); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
467 fFB.getUseClip() ? "clip" : "noclip"); | 467 fFB.getUseClip() ? "clip" : "noclip"); |
468 SkPaint paint; | 468 SkPaint paint; |
469 paint.setAntiAlias(true); | 469 paint.setAntiAlias(true); |
470 paint.setTextSize(16); | 470 paint.setTextSize(16); |
471 paint.setColor(SK_ColorBLUE); | 471 paint.setColor(SK_ColorBLUE); |
472 canvas->drawText(str.c_str(), str.size(), 10, 16, paint); | 472 canvas->drawText(str.c_str(), str.size(), 10, 16, paint); |
473 } | 473 } |
474 } | 474 } |
475 | 475 |
476 virtual SkView::Click* onFindClickHandler(SkScalar x, SkScalar y, | 476 virtual SkView::Click* onFindClickHandler(SkScalar x, SkScalar y, |
477 unsigned modi) SK_OVERRIDE { | 477 unsigned modi) override { |
478 SkPoint pt = { x, y }; | 478 SkPoint pt = { x, y }; |
479 int index = -1; | 479 int index = -1; |
480 int count = fFB.getTriangle() ? 3 : 2; | 480 int count = fFB.getTriangle() ? 3 : 2; |
481 SkScalar tol = 12; | 481 SkScalar tol = 12; |
482 | 482 |
483 for (int i = 0; i < count; ++i) { | 483 for (int i = 0; i < count; ++i) { |
484 if (fPts[i].equalsWithinTolerance(pt, tol)) { | 484 if (fPts[i].equalsWithinTolerance(pt, tol)) { |
485 index = i; | 485 index = i; |
486 break; | 486 break; |
487 } | 487 } |
488 } | 488 } |
489 return new IndexClick(this, index); | 489 return new IndexClick(this, index); |
490 } | 490 } |
491 | 491 |
492 bool onClick(Click* click) SK_OVERRIDE { | 492 bool onClick(Click* click) override { |
493 int index = IndexClick::GetIndex(click); | 493 int index = IndexClick::GetIndex(click); |
494 if (index >= 0 && index <= 2) { | 494 if (index >= 0 && index <= 2) { |
495 fPts[index] = click->fCurr; | 495 fPts[index] = click->fCurr; |
496 } else { | 496 } else { |
497 SkScalar dx = click->fCurr.fX - click->fPrev.fX; | 497 SkScalar dx = click->fCurr.fX - click->fPrev.fX; |
498 SkScalar dy = click->fCurr.fY - click->fPrev.fY; | 498 SkScalar dy = click->fCurr.fY - click->fPrev.fY; |
499 fPts[0].offset(dx, dy); | 499 fPts[0].offset(dx, dy); |
500 fPts[1].offset(dx, dy); | 500 fPts[1].offset(dx, dy); |
501 fPts[2].offset(dx, dy); | 501 fPts[2].offset(dx, dy); |
502 } | 502 } |
503 this->inval(NULL); | 503 this->inval(NULL); |
504 return true; | 504 return true; |
505 } | 505 } |
506 | 506 |
507 private: | 507 private: |
508 | 508 |
509 typedef SampleView INHERITED; | 509 typedef SampleView INHERITED; |
510 }; | 510 }; |
511 | 511 |
512 ////////////////////////////////////////////////////////////////////////////// | 512 ////////////////////////////////////////////////////////////////////////////// |
513 | 513 |
514 static SkView* MyFactory() { return new DrawLineView; } | 514 static SkView* MyFactory() { return new DrawLineView; } |
515 static SkViewRegister reg(MyFactory); | 515 static SkViewRegister reg(MyFactory); |
OLD | NEW |