From 961ddb04a0a7aba843032d829ab867518e52559e Mon Sep 17 00:00:00 2001 From: "reed@google.com" Date: Thu, 5 May 2011 14:03:48 +0000 Subject: update to SampleView git-svn-id: http://skia.googlecode.com/svn/trunk@1252 2bbb7eff-a529-9590-31e7-b0007b416f81 --- samplecode/SampleArc.cpp | 42 +++++++++++++----------------------------- 1 file changed, 13 insertions(+), 29 deletions(-) (limited to 'samplecode/SampleArc.cpp') diff --git a/samplecode/SampleArc.cpp b/samplecode/SampleArc.cpp index bba5f6f123..504d8d812d 100644 --- a/samplecode/SampleArc.cpp +++ b/samplecode/SampleArc.cpp @@ -28,33 +28,25 @@ static void testparse() { SkParsePath::ToSVGString(p2, &str2); } -class ArcsView : public SkView { +class ArcsView : public SampleView { public: - ArcsView() - { + ArcsView() { testparse(); fSweep = SkIntToScalar(100); + this->setBGColor(0xFFDDDDDD); } protected: // overrides from SkEventSink - virtual bool onQuery(SkEvent* evt) - { - if (SampleCode::TitleQ(*evt)) - { + virtual bool onQuery(SkEvent* evt) { + if (SampleCode::TitleQ(*evt)) { SampleCode::TitleR(evt, "Arcs"); return true; } return this->INHERITED::onQuery(evt); } - void drawBG(SkCanvas* canvas) - { - canvas->drawColor(0xFFDDDDDD); - } - - static void drawRectWithLines(SkCanvas* canvas, const SkRect& r, const SkPaint& p) - { + static void drawRectWithLines(SkCanvas* canvas, const SkRect& r, const SkPaint& p) { canvas->drawRect(r, p); canvas->drawLine(r.fLeft, r.fTop, r.fRight, r.fBottom, p); canvas->drawLine(r.fLeft, r.fBottom, r.fRight, r.fTop, p); @@ -63,8 +55,7 @@ protected: } static void draw_label(SkCanvas* canvas, const SkRect& rect, - int start, int sweep) - { + int start, int sweep) { SkPaint paint; paint.setAntiAlias(true); @@ -79,8 +70,7 @@ protected: rect.fBottom + paint.getTextSize() * 5/4, paint); } - static void drawArcs(SkCanvas* canvas) - { + static void drawArcs(SkCanvas* canvas) { SkPaint paint; SkRect r; SkScalar w = SkIntToScalar(75); @@ -107,8 +97,7 @@ protected: 225, 90 }; - for (int i = 0; i < SK_ARRAY_COUNT(gAngles); i += 2) - { + for (int i = 0; i < SK_ARRAY_COUNT(gAngles); i += 2) { paint.setColor(SK_ColorBLACK); drawRectWithLines(canvas, r, paint); @@ -124,10 +113,7 @@ protected: canvas->restore(); } - virtual void onDraw(SkCanvas* canvas) - { - this->drawBG(canvas); - + virtual void onDrawContent(SkCanvas* canvas) { fSweep = SampleCode::GetAnimScalar(SkIntToScalar(360)/24, SkIntToScalar(360)); // fSweep = SkFloatToScalar(359.99f); @@ -175,22 +161,20 @@ protected: this->inval(NULL); } - virtual SkView::Click* onFindClickHandler(SkScalar x, SkScalar y) - { + virtual SkView::Click* onFindClickHandler(SkScalar x, SkScalar y) { // fSweep += SK_Scalar1; this->inval(NULL); return this->INHERITED::onFindClickHandler(x, y); } - virtual bool onClick(Click* click) - { + virtual bool onClick(Click* click) { return this->INHERITED::onClick(click); } private: SkScalar fSweep; - typedef SkView INHERITED; + typedef SampleView INHERITED; }; ////////////////////////////////////////////////////////////////////////////// -- cgit v1.2.3