blob: 76dce914acf51aa5cdb97f044f9cfba4ffdeb743 [file] [log] [blame]
chudy@google.com902ebe52012-06-29 14:21:22 +00001
2/*
3 * Copyright 2012 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
9
10#include "SkInspectorWidget.h"
11#include <iostream>
12
13SkInspectorWidget::SkInspectorWidget(QWidget *parent) : QWidget(parent) {
14 // NOTE(chudy): Keeps the inspector widget fully expanded.
15 fHorizontalLayout = new QHBoxLayout(this);
16 fHorizontalLayout->setSpacing(6);
17 fHorizontalLayout->setContentsMargins(11, 11, 11, 11);
18
19 fTabWidget = new QTabWidget();
20
21 fOverviewTab = new QWidget();
22 fOverviewLayout = new QHBoxLayout(fOverviewTab);
23 fOverviewLayout->setSpacing(6);
24 fOverviewLayout->setContentsMargins(11, 11, 11, 11);
25 fOverviewText = new QTextEdit();
26 fOverviewText->setReadOnly(true);
27 fOverviewLayout->addWidget(fOverviewText);
28
29 fDetailTab = new QWidget();
30 fDetailLayout = new QHBoxLayout(fDetailTab);
31 fDetailLayout->setSpacing(6);
32 fDetailLayout->setContentsMargins(11,11,11,11);
33 fDetailText = new QTextEdit();
34 fDetailText->setReadOnly(true);
35 fDetailLayout->addWidget(fDetailText);
36
37 fTabWidget->addTab(fOverviewTab, QString("Overview"));
38 fTabWidget->addTab(fDetailTab, QString("Details"));
39
40 fHorizontalLayout->setAlignment(Qt::AlignTop);
41 fHorizontalLayout->addWidget(fTabWidget);
42
43 /* NOTE(chudy): We add all the line edits to (this). Then we lay them out
44 * by adding them to horizontal layouts.
45 *
46 * We will have 1 big vertical layout, 3 horizontal layouts and then 3
47 * line edits in each horizontal layout.
48 */
49
50 fMatrixAndClipWidget = new QWidget(this);
51 fMatrixAndClipWidget->setFixedSize(200,300);
52 fMatrixAndClipWidget->setDisabled(true);
53
54 fVerticalLayout = new QVBoxLayout(fMatrixAndClipWidget);
55 fVerticalLayout->setAlignment(Qt::AlignVCenter);
56 fVerticalLayout->addLayout(currentMatrix());
57 fVerticalLayout->addLayout(currentClip());
58 fHorizontalLayout->addWidget(fMatrixAndClipWidget);
59
60
61}
62
63SkInspectorWidget::~SkInspectorWidget() {}
64
65QString SkInspectorWidget::getDetailText() {
66 return fDetailText->toHtml();
67}
68
69QString SkInspectorWidget::getOverviewText() {
70 return fOverviewText->toHtml();
71}
72
73void SkInspectorWidget::setDetailText(QString text) {
74 fDetailText->setHtml(text);
75}
76
77void SkInspectorWidget::setOverviewText(QString text) {
78 fOverviewText->setHtml(text);
79}
80
81QVBoxLayout* SkInspectorWidget::currentMatrix() {
82 fMatrixLabel = new QLabel(this);
83 fMatrixLabel->setText("Current Matrix");
84 fMatrixLabel->setAlignment(Qt::AlignHCenter);
85 fMatrixLayout = new QVBoxLayout();
86 fMatrixLayout->setSpacing(6);
87 fMatrixLayout->setContentsMargins(11,11,11,0);
88 fMatrixLayout->setAlignment(Qt::AlignTop | Qt::AlignHCenter);
89 fMatrixLayout->addWidget(fMatrixLabel);
90
91 for(int i =0; i<9; i++) {
92 fMatrixEntry[i] = new QLineEdit();
93 fMatrixEntry[i]->setMinimumSize(QSize(50,25));
94 fMatrixEntry[i]->setMaximumSize(QSize(50,16777215));
95 fMatrixEntry[i]->setReadOnly(true);
96
97 if(!(i%3)) fMatrixRow[i/3] = new QHBoxLayout();
98 fMatrixRow[i/3]->addWidget(fMatrixEntry[i]);
99 if(i%3 == 2) fMatrixLayout->addLayout(fMatrixRow[i/3]);
100 }
101
102 return fMatrixLayout;
103}
104
105QVBoxLayout* SkInspectorWidget::currentClip() {
106 fClipLabel = new QLabel(this);
107 fClipLabel->setText("Current Clip");
108 fClipLabel->setAlignment(Qt::AlignHCenter);
109 fClipLayout = new QVBoxLayout();
110 fClipLayout->setSpacing(6);
111 fClipLayout->setContentsMargins(11,11,11,0);
112 fClipLayout->setAlignment(Qt::AlignTop | Qt::AlignHCenter);
113 fClipLayout->addWidget(fClipLabel);
114
115 for(int i =0; i<4; i++) {
116 fClipEntry[i] = new QLineEdit();
117 fClipEntry[i]->setMinimumSize(QSize(50,25));
118 fClipEntry[i]->setMaximumSize(QSize(50,16777215));
119 fClipEntry[i]->setReadOnly(true);
120
121 if(!(i%2)) fClipRow[i/2] = new QHBoxLayout();
122 fClipRow[i/2]->addWidget(fClipEntry[i]);
123 if(i%2 == 1) fClipLayout->addLayout(fClipRow[i/2]);
124 }
125
126 return fClipLayout;
127}