2012-06-29 14:21:22 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* 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>
|
|
|
|
|
2015-01-02 14:35:43 +00:00
|
|
|
static const int kSignificantNumbersInFields = 5;
|
|
|
|
|
2012-07-31 12:49:52 +00:00
|
|
|
SkInspectorWidget::SkInspectorWidget() : QWidget()
|
2012-07-03 16:05:59 +00:00
|
|
|
, fHorizontalLayout(this)
|
|
|
|
, fMatrixAndClipWidget(this)
|
2015-01-02 14:35:43 +00:00
|
|
|
, fVerticalLayout(&fMatrixAndClipWidget) {
|
2012-08-14 19:34:13 +00:00
|
|
|
QString tabNames[kTotalTabCount];
|
|
|
|
tabNames[kOverview_TabType] = "Overview";
|
|
|
|
tabNames[kDetail_TabType] = "Details";
|
2014-05-19 13:53:10 +00:00
|
|
|
tabNames[kClipStack_TabType] = "Clip Stack";
|
2012-08-14 19:34:13 +00:00
|
|
|
|
|
|
|
for (int i = 0; i < kTotalTabCount; i++) {
|
|
|
|
fTabTexts[i].setReadOnly(true);
|
|
|
|
fTabLayouts[i].addWidget(&fTabTexts[i]);
|
|
|
|
fTabs[i].setLayout(&fTabLayouts[i]);
|
|
|
|
fTabWidget.addTab(&fTabs[i], tabNames[i]);
|
|
|
|
}
|
2012-07-03 16:05:59 +00:00
|
|
|
|
|
|
|
fHorizontalLayout.setAlignment(Qt::AlignTop);
|
|
|
|
fHorizontalLayout.addWidget(&fTabWidget);
|
2012-06-29 14:21:22 +00:00
|
|
|
|
2015-01-02 14:35:43 +00:00
|
|
|
fMatrixAndClipWidget.setFrameStyle(QFrame::Panel);
|
2012-07-03 16:05:59 +00:00
|
|
|
fMatrixAndClipWidget.setDisabled(true);
|
|
|
|
fVerticalLayout.setAlignment(Qt::AlignVCenter);
|
2015-01-02 14:35:43 +00:00
|
|
|
this->setupMatrix();
|
|
|
|
this->setupClip();
|
|
|
|
fVerticalLayout.addWidget(&fMatrixGroup);
|
|
|
|
fVerticalLayout.addWidget(&fClipGroup);
|
2012-07-03 16:05:59 +00:00
|
|
|
fHorizontalLayout.addWidget(&fMatrixAndClipWidget);
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
2012-08-14 19:34:13 +00:00
|
|
|
void SkInspectorWidget::setText(QString text, TabType type) {
|
|
|
|
fTabTexts[type].setHtml(text);
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
2012-07-03 16:05:59 +00:00
|
|
|
void SkInspectorWidget::setMatrix(const SkMatrix& matrix) {
|
|
|
|
for(int i=0; i<9; i++) {
|
2015-01-02 14:35:43 +00:00
|
|
|
fMatrixEntry[i].setText(QString::number(matrix.get(i), 'g', kSignificantNumbersInFields));
|
2012-07-03 16:05:59 +00:00
|
|
|
}
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
2012-07-03 16:05:59 +00:00
|
|
|
void SkInspectorWidget::setClip(const SkIRect& clip) {
|
2015-01-02 14:35:43 +00:00
|
|
|
fClipEntry[0].setText(QString::number(clip.left(), 'g', kSignificantNumbersInFields));
|
|
|
|
fClipEntry[1].setText(QString::number(clip.top(), 'g', kSignificantNumbersInFields));
|
|
|
|
fClipEntry[2].setText(QString::number(clip.right(), 'g', kSignificantNumbersInFields));
|
|
|
|
fClipEntry[3].setText(QString::number(clip.bottom(), 'g', kSignificantNumbersInFields));
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
2015-01-02 14:35:43 +00:00
|
|
|
void SkInspectorWidget::setupMatrix() {
|
|
|
|
fMatrixGroup.setTitle("Current Matrix");
|
|
|
|
fMatrixGroup.setLayout(&fMatrixLayout);
|
|
|
|
for (int r = 0; r < 3; ++r) {
|
|
|
|
for(int c = 0; c < 3; c++) {
|
|
|
|
QLineEdit* entry = &fMatrixEntry[r * 3 + c];
|
|
|
|
fMatrixLayout.addWidget(entry, r, c, Qt::AlignTop | Qt::AlignHCenter);
|
|
|
|
entry->setReadOnly(true);
|
|
|
|
entry->setFixedWidth(70);
|
2012-07-03 16:05:59 +00:00
|
|
|
}
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-01-02 14:35:43 +00:00
|
|
|
void SkInspectorWidget::setupClip() {
|
|
|
|
fClipGroup.setTitle("Current Clip");
|
|
|
|
fClipGroup.setLayout(&fClipLayout);
|
|
|
|
for(int r = 0; r < 2; r++) {
|
|
|
|
for(int c = 0; c < 2; c++) {
|
|
|
|
QLineEdit* entry = &fClipEntry[r * 2 + c];
|
|
|
|
fClipLayout.addWidget(entry, r, c, Qt::AlignTop | Qt::AlignHCenter);
|
|
|
|
entry->setReadOnly(true);
|
|
|
|
entry->setFixedWidth(70);
|
2012-07-03 16:05:59 +00:00
|
|
|
}
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
}
|