| 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 "SampleCode.h" | 8 #include "SampleCode.h" |
| 9 #include "SkView.h" | 9 #include "SkView.h" |
| 10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
| (...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 397 fPts[2].set(48 * 2, 48 * 6); | 397 fPts[2].set(48 * 2, 48 * 6); |
| 398 fIsRect = false; | 398 fIsRect = false; |
| 399 } | 399 } |
| 400 | 400 |
| 401 void setStyle(FatBits::Style s) { | 401 void setStyle(FatBits::Style s) { |
| 402 fFB.setStyle(s); | 402 fFB.setStyle(s); |
| 403 this->inval(NULL); | 403 this->inval(NULL); |
| 404 } | 404 } |
| 405 | 405 |
| 406 protected: | 406 protected: |
| 407 virtual bool onQuery(SkEvent* evt) SK_OVERRIDE { | 407 bool onQuery(SkEvent* evt) SK_OVERRIDE { |
| 408 if (SampleCode::TitleQ(*evt)) { | 408 if (SampleCode::TitleQ(*evt)) { |
| 409 SampleCode::TitleR(evt, "FatBits"); | 409 SampleCode::TitleR(evt, "FatBits"); |
| 410 return true; | 410 return true; |
| 411 } | 411 } |
| 412 SkUnichar uni; | 412 SkUnichar uni; |
| 413 if (SampleCode::CharQ(*evt, &uni)) { | 413 if (SampleCode::CharQ(*evt, &uni)) { |
| 414 switch (uni) { | 414 switch (uni) { |
| 415 case 'c': | 415 case 'c': |
| 416 fFB.setUseClip(!fFB.getUseClip()); | 416 fFB.setUseClip(!fFB.getUseClip()); |
| 417 this->inval(NULL); | 417 this->inval(NULL); |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 492 | 492 |
| 493 for (int i = 0; i < count; ++i) { | 493 for (int i = 0; i < count; ++i) { |
| 494 if (fPts[i].equalsWithinTolerance(pt, tol)) { | 494 if (fPts[i].equalsWithinTolerance(pt, tol)) { |
| 495 index = i; | 495 index = i; |
| 496 break; | 496 break; |
| 497 } | 497 } |
| 498 } | 498 } |
| 499 return new IndexClick(this, index); | 499 return new IndexClick(this, index); |
| 500 } | 500 } |
| 501 | 501 |
| 502 virtual bool onClick(Click* click) SK_OVERRIDE { | 502 bool onClick(Click* click) SK_OVERRIDE { |
| 503 int index = IndexClick::GetIndex(click); | 503 int index = IndexClick::GetIndex(click); |
| 504 if (index >= 0 && index <= 2) { | 504 if (index >= 0 && index <= 2) { |
| 505 fPts[index] = click->fCurr; | 505 fPts[index] = click->fCurr; |
| 506 } else { | 506 } else { |
| 507 SkScalar dx = click->fCurr.fX - click->fPrev.fX; | 507 SkScalar dx = click->fCurr.fX - click->fPrev.fX; |
| 508 SkScalar dy = click->fCurr.fY - click->fPrev.fY; | 508 SkScalar dy = click->fCurr.fY - click->fPrev.fY; |
| 509 fPts[0].offset(dx, dy); | 509 fPts[0].offset(dx, dy); |
| 510 fPts[1].offset(dx, dy); | 510 fPts[1].offset(dx, dy); |
| 511 fPts[2].offset(dx, dy); | 511 fPts[2].offset(dx, dy); |
| 512 } | 512 } |
| 513 this->inval(NULL); | 513 this->inval(NULL); |
| 514 return true; | 514 return true; |
| 515 } | 515 } |
| 516 | 516 |
| 517 private: | 517 private: |
| 518 | 518 |
| 519 typedef SampleView INHERITED; | 519 typedef SampleView INHERITED; |
| 520 }; | 520 }; |
| 521 | 521 |
| 522 ////////////////////////////////////////////////////////////////////////////// | 522 ////////////////////////////////////////////////////////////////////////////// |
| 523 | 523 |
| 524 static SkView* MyFactory() { return new DrawLineView; } | 524 static SkView* MyFactory() { return new DrawLineView; } |
| 525 static SkViewRegister reg(MyFactory); | 525 static SkViewRegister reg(MyFactory); |
| OLD | NEW |