aboutsummaryrefslogtreecommitdiffhomepage
path: root/experimental/Debugger/DebuggerViews.h
blob: acaa68b36d8c7b58d69caefc12188558c7ac9a3c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100

/*
 * Copyright 2011 Google Inc.
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */
#include "SkView.h"
#include "SkColor.h"
#include "SkBitmap.h"
#include "SkCanvas.h"
#include "SkGPipe.h"
#include "SkPaint.h"

#include "SkDebugDumper.h"

#define SKDEBUGGER_COMMANDTYPE  "SKDEBUGGER_COMMAND"
#define SKDEBUGGER_STATETYPE    "SKDEBUGGER_STATE"

#define SKDEBUGGER_ATOM         "SKDEBUGGER_ATOM"
#define SKDEBUGGER_MATRIX       "SKDEBUGGER_MATRIX"
#define SKDEBUGGER_CLIP         "SKDEBUGGER_CLIP"
#define SKDEBUGGER_PAINTINFO    "SKDEBUGGER_PAINTINFO"
#define SKDEBUGGER_PAINT        "SKDEBUGGER_PAINT"

#define SKDEBUGGER_TEXTSIZE         14
#define CMD_WIDTH                   200
#define INFO_HEIGHT                 150.0
#define SKDEBUGGER_HIGHLIGHTCOLOR   0xFF113399
#define SKDEBUGGER_TEXTCOLOR        0xFF000000
#define SKDEBUGGER_RESIZEBARCOLOR   0xFF333333
#define SKDEBUGGER_RESIZEBARSIZE    5

/*
 * Debugger - Info Panel
 */
class DebuggerStateView : public SkView {
public:
    DebuggerStateView();
    
protected:
    virtual bool onEvent(const SkEvent& evt);
    virtual void onDraw(SkCanvas* canvas);
private:
    SkColor     fBGColor;
    SkPaint     fPaint;
    SkString    fMatrix;
    SkString    fPaintInfo;
    SkString    fClip;
    bool        fResizing;
    typedef SkView INHERITED;
};

/*
 * Debugger - Commands List
 */
class DebuggerCommandsView : public SkView {
public:
    DebuggerCommandsView();
    ~DebuggerCommandsView();
    int nextItem();
    int prevItem();
    int scrollUp();
    int scrollDown();
    void highlight(int index);
    int  selectHighlight(int ypos);
    void toggleCentered();
    
protected:
    virtual bool onEvent(const SkEvent& evt);
    virtual void onSizeChange();
    virtual void onDraw(SkCanvas* canvas);
private:
    void        init();
    void        alignCenter();
    SkColor     fBGColor;
    int         fTopIndex;
    int         fHighlight;
    SkScalar    fSpacing;
    int         fRange;
    bool        fResizing;
    bool        fCentered;
    SkTDArray<SkString*> fList;
    typedef SkView INHERITED;
};


static void* PaintProc(void* ptr, bool doRef) {
    SkPaint* p = (SkPaint*) ptr;
    
    if (doRef) {
        return new SkPaint(*p);
    }
    else {
        delete p;
        return NULL;
    }
    
}