yangsu@google.com | ef7bdfa | 2011-08-12 14:27:47 +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 | #include "DebuggerViews.h" |
| 9 | #include "SkRect.h" |
| 10 | |
| 11 | DebuggerStateView::DebuggerStateView() { |
| 12 | fBGColor = 0xFF999999; |
| 13 | fPaint.setColor(fBGColor); |
| 14 | fResizing = false; |
| 15 | } |
| 16 | |
| 17 | bool DebuggerStateView::onEvent(const SkEvent& evt) { |
| 18 | if (evt.isType(SKDEBUGGER_STATETYPE)) { |
| 19 | fMatrix = evt.findString(SKDEBUGGER_MATRIX); |
| 20 | fClip = evt.findString(SKDEBUGGER_CLIP); |
| 21 | |
| 22 | SkPaint* ptr; |
| 23 | if (evt.getMetaData().findPtr(SKDEBUGGER_PAINT, (void**)&ptr)) { |
| 24 | fPaint = *ptr; |
| 25 | fPaintInfo = evt.findString(SKDEBUGGER_PAINTINFO); |
| 26 | } |
| 27 | this->inval(NULL); |
| 28 | return true; |
| 29 | } |
| 30 | return this->INHERITED::onEvent(evt); |
| 31 | } |
| 32 | |
| 33 | void DebuggerStateView::onDraw(SkCanvas* canvas) { |
| 34 | canvas->drawColor(fBGColor); |
| 35 | |
| 36 | //Display Current Paint |
| 37 | SkRect r = {10, 20, 40, 50}; |
| 38 | canvas->drawRect(r, fPaint); |
| 39 | //Display Information |
| 40 | SkPaint p; |
| 41 | p.setTextSize(SKDEBUGGER_TEXTSIZE); |
| 42 | p.setAntiAlias(true); |
bsalomon@google.com | 8e06dab | 2011-10-07 20:03:39 +0000 | [diff] [blame] | 43 | SkScalar x = 50 * SK_Scalar1; |
yangsu@google.com | ef7bdfa | 2011-08-12 14:27:47 +0000 | [diff] [blame] | 44 | canvas->drawText(fPaintInfo.c_str(), fPaintInfo.size(), x, 30, p); |
| 45 | canvas->drawText(fMatrix.c_str(), fMatrix.size(), x, 60, p); |
| 46 | canvas->drawText(fClip.c_str(), fClip.size(), x, 90, p); |
| 47 | |
| 48 | p.setColor(SKDEBUGGER_RESIZEBARCOLOR); |
| 49 | r = SkRect::MakeXYWH(0, 0, this->width(), SKDEBUGGER_RESIZEBARSIZE); |
| 50 | canvas->drawRect(r, p); |
yangsu@google.com | ef7bdfa | 2011-08-12 14:27:47 +0000 | [diff] [blame] | 51 | } |