aboutsummaryrefslogtreecommitdiffhomepage
path: root/debugger/QT/SkInspectorWidget.cpp
blob: 6bcac1db357bf592f4212c3508d02de5479552f9 (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
115

/*
 * Copyright 2012 Google Inc.
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */


#include "SkInspectorWidget.h"
#include <iostream>

SkInspectorWidget::SkInspectorWidget() : QWidget()
    , fHorizontalLayout(this)
    , fMatrixAndClipWidget(this)
    , fVerticalLayout(&fMatrixAndClipWidget)
    , fMatrixLabel(this)
    , fClipLabel(this) {

    fHorizontalLayout.setSpacing(6);
    fHorizontalLayout.setContentsMargins(11, 11, 11, 11);

    QString tabNames[kTotalTabCount];
    tabNames[kOverview_TabType] = "Overview";
    tabNames[kDetail_TabType] = "Details";
    tabNames[kClipStack_TabType] = "Clip Stack";

    for (int i = 0; i < kTotalTabCount; i++) {
        fTabTexts[i].setReadOnly(true);
        fTabLayouts[i].setSpacing(6);
        fTabLayouts[i].setContentsMargins(11, 11, 11, 11);
        fTabLayouts[i].addWidget(&fTabTexts[i]);
        fTabs[i].setLayout(&fTabLayouts[i]);
        fTabWidget.addTab(&fTabs[i], tabNames[i]);
    }

    fHorizontalLayout.setAlignment(Qt::AlignTop);
    fHorizontalLayout.addWidget(&fTabWidget);

    /* NOTE(chudy): We add all the line edits to (this). Then we lay them out
     * by adding them to horizontal layouts.
     *
     * We will have 1 big vertical layout, 3 horizontal layouts and then 3
     * line edits in each horizontal layout. */
    fMatrixAndClipWidget.setFixedSize(260,300);
    fMatrixAndClipWidget.setDisabled(true);

    fVerticalLayout.setAlignment(Qt::AlignVCenter);
    fVerticalLayout.addLayout(setupMatrix());
    fVerticalLayout.addLayout(setupClip());
    fHorizontalLayout.addWidget(&fMatrixAndClipWidget);
}

void SkInspectorWidget::setText(QString text, TabType type) {
    fTabTexts[type].setHtml(text);
}

void SkInspectorWidget::setMatrix(const SkMatrix& matrix) {
    for(int i=0; i<9; i++) {
        fMatrixEntry[i].setText(QString::number(matrix.get(i)));
    }
}

void SkInspectorWidget::setClip(const SkIRect& clip) {
    fClipEntry[0].setText(QString::number(clip.left()));
    fClipEntry[1].setText(QString::number(clip.top()));
    fClipEntry[2].setText(QString::number(clip.right()));
    fClipEntry[3].setText(QString::number(clip.bottom()));
}

QVBoxLayout* SkInspectorWidget::setupMatrix() {
    fMatrixLabel.setText("Current Matrix");
    fMatrixLabel.setAlignment(Qt::AlignHCenter);

    fMatrixLayout.setSpacing(6);
    fMatrixLayout.setContentsMargins(11,11,11,0);
    fMatrixLayout.setAlignment(Qt::AlignTop | Qt::AlignHCenter);
    fMatrixLayout.addWidget(&fMatrixLabel);

    for(int i =0; i<9; i++) {
        fMatrixEntry[i].setMinimumSize(QSize(70,25));
        fMatrixEntry[i].setMaximumSize(QSize(70,16777215));
        fMatrixEntry[i].setReadOnly(true);

        fMatrixRow[i/3].addWidget(&fMatrixEntry[i]);
        if(i%3 == 2) {
            fMatrixLayout.addLayout(&fMatrixRow[i/3]);
        }
    }

    return &fMatrixLayout;
}

QVBoxLayout* SkInspectorWidget::setupClip() {
    fClipLabel.setText("Current Clip");
    fClipLabel.setAlignment(Qt::AlignHCenter);

    fClipLayout.setSpacing(6);
    fClipLayout.setContentsMargins(11,11,11,0);
    fClipLayout.setAlignment(Qt::AlignTop | Qt::AlignHCenter);
    fClipLayout.addWidget(&fClipLabel);

    for(int i =0; i<4; i++) {
        fClipEntry[i].setMinimumSize(QSize(70,25));
        fClipEntry[i].setMaximumSize(QSize(70,16777215));
        fClipEntry[i].setReadOnly(true);

        fClipRow[i/2].addWidget(&fClipEntry[i]);
        if(i%2 == 1) {
            fClipLayout.addLayout(&fClipRow[i/2]);
        }
    }

    return &fClipLayout;
}