aboutsummaryrefslogtreecommitdiffhomepage
path: root/experimental/CocoaDebugger/SkDebuggerViews.h
blob: e8bcb9fc7c6e6bae331c6d21599f859559b150b8 (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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#include "SkView.h"
#include "SkColor.h"
#include "SkBitmap.h"
#include "SkCanvas.h"
#include "SkGPipe.h"
#include "SkPaint.h"

#include "SkDebugDumper.h"
#include <deque> 
#define SkDebugger_TextSize 14

#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"

/*
 * Debugger - Main Content
 */
class SkContentView : public SkView {
public:
    SkContentView(SkEventSinkID clID, SkEventSinkID ipID);
    ~SkContentView();
    
    void init();
    void reinit(const char* fileName);
    void toggleClip();
    void goToAtom(int atom);
    
protected:
    virtual bool onEvent(const SkEvent& evt);
    virtual void onDraw(SkCanvas* canvas);
    
private:
    SkColor         fBGColor;
    int             fAtomsToRead;
    std::deque<int> fAtomBounds;
    std::deque<int> fFrameBounds;
    bool            fDisplayClip;
    SkString        fFilePath;
    SkDebugDumper   fDumper;
    typedef SkView INHERITED;
};

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

/*
 * Debugger - Commands List
 */
class SkCommandListView : public SkView {
public:
    SkCommandListView();
    void reinit();
    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        fCentered;
    std::deque<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;
    }
    
}