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 "OverView.h" | 8 #include "OverView.h" |
9 #include "SampleCode.h" | 9 #include "SampleCode.h" |
10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 if (SampleCode::TitleQ(*evt)) { | 53 if (SampleCode::TitleQ(*evt)) { |
54 SampleCode::TitleR(evt, "Overview"); | 54 SampleCode::TitleR(evt, "Overview"); |
55 return true; | 55 return true; |
56 } | 56 } |
57 if (evt->isType(gIsOverview)) { | 57 if (evt->isType(gIsOverview)) { |
58 return true; | 58 return true; |
59 } | 59 } |
60 SkUnichar uni; | 60 SkUnichar uni; |
61 if (SampleCode::CharQ(*evt, &uni)) { | 61 if (SampleCode::CharQ(*evt, &uni)) { |
62 fMatchStr.appendUnichar(uni); | 62 fMatchStr.appendUnichar(uni); |
63 this->inval(NULL); | 63 this->inval(nullptr); |
64 return true; | 64 return true; |
65 } | 65 } |
66 return this->INHERITED::onQuery(evt); | 66 return this->INHERITED::onQuery(evt); |
67 } | 67 } |
68 | 68 |
69 void onDraw(SkCanvas* canvas) override; | 69 void onDraw(SkCanvas* canvas) override; |
70 | 70 |
71 bool onSendClickToChildren(SkScalar x, SkScalar y, unsigned modi) override { | 71 bool onSendClickToChildren(SkScalar x, SkScalar y, unsigned modi) override { |
72 return false; | 72 return false; |
73 } | 73 } |
74 | 74 |
75 Click* onFindClickHandler(SkScalar cx, SkScalar cy, unsigned modi) override
{ | 75 Click* onFindClickHandler(SkScalar cx, SkScalar cy, unsigned modi) override
{ |
76 const SkRect crect = SkRect::MakeXYWH(cx - 0.5f, cy - 0.5f, 1, 1); | 76 const SkRect crect = SkRect::MakeXYWH(cx - 0.5f, cy - 0.5f, 1, 1); |
77 SkPoint loc = this->start(); | 77 SkPoint loc = this->start(); |
78 for (int i = 0; i < fCount; ++i) { | 78 for (int i = 0; i < fCount; ++i) { |
79 if (draw_this_name(fNames[i], fMatchStr)) { | 79 if (draw_this_name(fNames[i], fMatchStr)) { |
80 if (this->bounds(loc).intersects(crect)) { | 80 if (this->bounds(loc).intersects(crect)) { |
81 SkEvent evt("set-curr-index"); | 81 SkEvent evt("set-curr-index"); |
82 evt.setFast32(i); | 82 evt.setFast32(i); |
83 this->sendEventToParents(evt); | 83 this->sendEventToParents(evt); |
84 break; | 84 break; |
85 } | 85 } |
86 this->next(&loc); | 86 this->next(&loc); |
87 } | 87 } |
88 } | 88 } |
89 return NULL; | 89 return nullptr; |
90 } | 90 } |
91 | 91 |
92 private: | 92 private: |
93 int fCount; | 93 int fCount; |
94 const SkViewFactory** fFactories; | 94 const SkViewFactory** fFactories; |
95 SkString* fNames; | 95 SkString* fNames; |
96 SkString fMatchStr; | 96 SkString fMatchStr; |
97 SkPaint fNamePaint; | 97 SkPaint fNamePaint; |
98 SkPaint::FontMetrics fNameMetrics; | 98 SkPaint::FontMetrics fNameMetrics; |
99 SkScalar fNameW; | 99 SkScalar fNameW; |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 SkPoint loc = this->start(); | 164 SkPoint loc = this->start(); |
165 for (int i = 0; i < fCount; ++i) { | 165 for (int i = 0; i < fCount; ++i) { |
166 if (draw_this_name(fNames[i], fMatchStr)) { | 166 if (draw_this_name(fNames[i], fMatchStr)) { |
167 canvas->drawRect(this->bounds(loc), paint); | 167 canvas->drawRect(this->bounds(loc), paint); |
168 canvas->drawText(fNames[i].c_str(), fNames[i].size(), loc.x(), loc.y
(), fNamePaint); | 168 canvas->drawText(fNames[i].c_str(), fNames[i].size(), loc.x(), loc.y
(), fNamePaint); |
169 this->next(&loc); | 169 this->next(&loc); |
170 } | 170 } |
171 } | 171 } |
172 } | 172 } |
173 | 173 |
OLD | NEW |