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 19 matching lines...) Expand all Loading... |
30 fOval.set(0, 0, SkIntToScalar(200), SkIntToScalar(50)); | 30 fOval.set(0, 0, SkIntToScalar(200), SkIntToScalar(50)); |
31 fCenter.set(SkIntToScalar(250), SkIntToScalar(250)); | 31 fCenter.set(SkIntToScalar(250), SkIntToScalar(250)); |
32 | 32 |
33 // test_ats(); | 33 // test_ats(); |
34 } | 34 } |
35 | 35 |
36 virtual ~PathClipView() {} | 36 virtual ~PathClipView() {} |
37 | 37 |
38 protected: | 38 protected: |
39 // overrides from SkEventSink | 39 // overrides from SkEventSink |
40 virtual bool onQuery(SkEvent* evt) { | 40 bool onQuery(SkEvent* evt) override { |
41 if (SampleCode::TitleQ(*evt)) { | 41 if (SampleCode::TitleQ(*evt)) { |
42 SampleCode::TitleR(evt, "PathClip"); | 42 SampleCode::TitleR(evt, "PathClip"); |
43 return true; | 43 return true; |
44 } | 44 } |
45 return this->INHERITED::onQuery(evt); | 45 return this->INHERITED::onQuery(evt); |
46 } | 46 } |
47 | 47 |
48 virtual void onDrawContent(SkCanvas* canvas) { | 48 void onDrawContent(SkCanvas* canvas) override { |
49 SkRect oval = fOval; | 49 SkRect oval = fOval; |
50 oval.offset(fCenter.fX - oval.centerX(), fCenter.fY - oval.centerY()); | 50 oval.offset(fCenter.fX - oval.centerX(), fCenter.fY - oval.centerY()); |
51 | 51 |
52 SkPaint p; | 52 SkPaint p; |
53 p.setAntiAlias(true); | 53 p.setAntiAlias(true); |
54 | 54 |
55 p.setStyle(SkPaint::kStroke_Style); | 55 p.setStyle(SkPaint::kStroke_Style); |
56 canvas->drawOval(oval, p); | 56 canvas->drawOval(oval, p); |
57 | 57 |
58 SkRect r; | 58 SkRect r; |
59 r.set(SkIntToScalar(200), SkIntToScalar(200), | 59 r.set(SkIntToScalar(200), SkIntToScalar(200), |
60 SkIntToScalar(300), SkIntToScalar(300)); | 60 SkIntToScalar(300), SkIntToScalar(300)); |
61 canvas->clipRect(r); | 61 canvas->clipRect(r); |
62 | 62 |
63 p.setStyle(SkPaint::kFill_Style); | 63 p.setStyle(SkPaint::kFill_Style); |
64 p.setColor(SK_ColorRED); | 64 p.setColor(SK_ColorRED); |
65 canvas->drawRect(r, p); | 65 canvas->drawRect(r, p); |
66 | 66 |
67 p.setColor(0x800000FF); | 67 p.setColor(0x800000FF); |
68 r.set(SkIntToScalar(150), SkIntToScalar(10), | 68 r.set(SkIntToScalar(150), SkIntToScalar(10), |
69 SkIntToScalar(250), SkIntToScalar(400)); | 69 SkIntToScalar(250), SkIntToScalar(400)); |
70 canvas->drawOval(oval, p); | 70 canvas->drawOval(oval, p); |
71 } | 71 } |
72 | 72 |
73 SkView::Click* onFindClickHandler(SkScalar x, SkScalar y, unsigned) override
{ | 73 SkView::Click* onFindClickHandler(SkScalar x, SkScalar y, unsigned) override
{ |
74 return new Click(this); | 74 return new Click(this); |
75 } | 75 } |
76 | 76 |
77 virtual bool onClick(Click* click) { | 77 bool onClick(Click* click) override { |
78 fCenter.set(click->fCurr.fX, click->fCurr.fY); | 78 fCenter.set(click->fCurr.fX, click->fCurr.fY); |
79 this->inval(NULL); | 79 this->inval(NULL); |
80 return false; | 80 return false; |
81 } | 81 } |
82 | 82 |
83 private: | 83 private: |
84 typedef SampleView INHERITED; | 84 typedef SampleView INHERITED; |
85 }; | 85 }; |
86 | 86 |
87 ////////////////////////////////////////////////////////////////////////////// | 87 ////////////////////////////////////////////////////////////////////////////// |
88 | 88 |
89 static SkView* MyFactory() { return new PathClipView; } | 89 static SkView* MyFactory() { return new PathClipView; } |
90 static SkViewRegister reg(MyFactory); | 90 static SkViewRegister reg(MyFactory); |
OLD | NEW |