bsalomon@google.com | 48dd1a2 | 2011-10-31 14:18:20 +0000 | [diff] [blame] | 1 | |
| 2 | /* |
| 3 | * Copyright 2011 Google Inc. |
| 4 | * |
| 5 | * Use of this source code is governed by a BSD-style license that can be |
| 6 | * found in the LICENSE file. |
| 7 | */ |
| 8 | |
| 9 | |
| 10 | #ifndef GMSampleView_DEFINED |
| 11 | #define GMSampleView_DEFINED |
| 12 | |
| 13 | #include "SampleCode.h" |
| 14 | #include "gm.h" |
| 15 | |
| 16 | class GMSampleView : public SampleView { |
| 17 | private: |
| 18 | typedef skiagm::GM GM; |
| 19 | |
| 20 | public: |
| 21 | GMSampleView(GM* gm) |
| 22 | : fGM(gm) {} |
rmistry@google.com | ae933ce | 2012-08-23 18:19:56 +0000 | [diff] [blame] | 23 | |
bsalomon@google.com | 48dd1a2 | 2011-10-31 14:18:20 +0000 | [diff] [blame] | 24 | virtual ~GMSampleView() { |
| 25 | delete fGM; |
| 26 | } |
rmistry@google.com | ae933ce | 2012-08-23 18:19:56 +0000 | [diff] [blame] | 27 | |
bsalomon@google.com | 48dd1a2 | 2011-10-31 14:18:20 +0000 | [diff] [blame] | 28 | protected: |
| 29 | virtual bool onQuery(SkEvent* evt) { |
| 30 | if (SampleCode::TitleQ(*evt)) { |
bsalomon@google.com | e9f091d | 2011-12-09 19:50:48 +0000 | [diff] [blame] | 31 | SkString name("GM:"); |
reed@google.com | ac7aa1b | 2011-11-08 15:06:34 +0000 | [diff] [blame] | 32 | name.append(fGM->shortName()); |
| 33 | SampleCode::TitleR(evt, name.c_str()); |
bsalomon@google.com | 48dd1a2 | 2011-10-31 14:18:20 +0000 | [diff] [blame] | 34 | return true; |
| 35 | } |
| 36 | return this->INHERITED::onQuery(evt); |
| 37 | } |
rmistry@google.com | ae933ce | 2012-08-23 18:19:56 +0000 | [diff] [blame] | 38 | |
bsalomon@google.com | 48dd1a2 | 2011-10-31 14:18:20 +0000 | [diff] [blame] | 39 | virtual void onDrawContent(SkCanvas* canvas) { |
| 40 | fGM->drawContent(canvas); |
| 41 | } |
| 42 | |
| 43 | virtual void onDrawBackground(SkCanvas* canvas) { |
| 44 | fGM->drawBackground(canvas); |
| 45 | } |
| 46 | |
| 47 | private: |
| 48 | GM* fGM; |
| 49 | typedef SampleView INHERITED; |
| 50 | }; |
| 51 | |
| 52 | #endif |