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 #ifndef SampleCode_DEFINED | 8 #ifndef SampleCode_DEFINED |
9 #define SampleCode_DEFINED | 9 #define SampleCode_DEFINED |
10 | 10 |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 }; | 100 }; |
101 | 101 |
102 /////////////////////////////////////////////////////////////////////////////// | 102 /////////////////////////////////////////////////////////////////////////////// |
103 | 103 |
104 class SampleView : public SkView { | 104 class SampleView : public SkView { |
105 public: | 105 public: |
106 SampleView() | 106 SampleView() |
107 : fPipeState(SkOSMenu::kOffState) | 107 : fPipeState(SkOSMenu::kOffState) |
108 , fBGColor(SK_ColorWHITE) | 108 , fBGColor(SK_ColorWHITE) |
109 , fRepeatCount(1) | 109 , fRepeatCount(1) |
| 110 , fHaveCalledOnceBeforeDraw(false) |
110 {} | 111 {} |
111 | 112 |
112 void setBGColor(SkColor color) { fBGColor = color; } | 113 void setBGColor(SkColor color) { fBGColor = color; } |
113 bool animate(const SkAnimTimer& timer) { return this->onAnimate(timer); } | 114 bool animate(const SkAnimTimer& timer) { return this->onAnimate(timer); } |
114 | 115 |
115 static bool IsSampleView(SkView*); | 116 static bool IsSampleView(SkView*); |
116 static bool SetRepeatDraw(SkView*, int count); | 117 static bool SetRepeatDraw(SkView*, int count); |
117 static bool SetUsePipe(SkView*, SkOSMenu::TriState); | 118 static bool SetUsePipe(SkView*, SkOSMenu::TriState); |
118 | 119 |
119 /** | 120 /** |
120 * Call this to request menu items from a SampleView. | 121 * Call this to request menu items from a SampleView. |
121 * Subclassing notes: A subclass of SampleView can overwrite this method | 122 * Subclassing notes: A subclass of SampleView can overwrite this method |
122 * to add new items of various types to the menu and change its title. | 123 * to add new items of various types to the menu and change its title. |
123 * The events attached to any new menu items must be handled in its onEvent | 124 * The events attached to any new menu items must be handled in its onEvent |
124 * method. See SkOSMenu.h for helper functions. | 125 * method. See SkOSMenu.h for helper functions. |
125 */ | 126 */ |
126 virtual void requestMenu(SkOSMenu* menu) {} | 127 virtual void requestMenu(SkOSMenu* menu) {} |
127 | 128 |
128 virtual void onTileSizeChanged(const SkSize& tileSize) {} | 129 virtual void onTileSizeChanged(const SkSize& tileSize) {} |
129 | 130 |
130 protected: | 131 protected: |
131 virtual void onDrawBackground(SkCanvas*); | 132 virtual void onDrawBackground(SkCanvas*); |
132 virtual void onDrawContent(SkCanvas*) = 0; | 133 virtual void onDrawContent(SkCanvas*) = 0; |
133 virtual bool onAnimate(const SkAnimTimer&) { return false; } | 134 virtual bool onAnimate(const SkAnimTimer&) { return false; } |
| 135 virtual void onOnceBeforeDraw() {} |
134 | 136 |
135 // overrides | 137 // overrides |
136 virtual bool onEvent(const SkEvent& evt); | 138 virtual bool onEvent(const SkEvent& evt); |
137 virtual bool onQuery(SkEvent* evt); | 139 virtual bool onQuery(SkEvent* evt); |
138 virtual void draw(SkCanvas*); | 140 virtual void draw(SkCanvas*); |
139 virtual void onDraw(SkCanvas*); | 141 virtual void onDraw(SkCanvas*); |
140 | 142 |
141 SkOSMenu::TriState fPipeState; | 143 SkOSMenu::TriState fPipeState; |
142 SkColor fBGColor; | 144 SkColor fBGColor; |
143 | 145 |
144 private: | 146 private: |
145 int fRepeatCount; | 147 int fRepeatCount; |
146 | 148 bool fHaveCalledOnceBeforeDraw; |
147 typedef SkView INHERITED; | 149 typedef SkView INHERITED; |
148 }; | 150 }; |
149 | 151 |
150 #endif | 152 #endif |
OLD | NEW |