skia2/debugger/QT/SkInspectorWidget.cpp
kkinnunen 7c339ae1e3 debugger: Make inspector widget smaller
Make inspector widget a bit smaller by letting the Qt widget system
layout the widgets.

Let the inspector widget calculate its own smallest size. Use stretch
factor of 0 for inspector, 1 for picture canvas.

Group the matrix and clip widgets in groups. Put the text edits in a grid
layout instead of a handwritted column layout containing row layouts.

This commit is part of work that tries to make the debugger window to be
a bit more resizeable, so that it would fit 1900x1200 screen.

Review URL: https://codereview.chromium.org/830743002
2015-01-02 06:35:43 -08:00

86 lines
2.8 KiB
C++

/*
* 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>
static const int kSignificantNumbersInFields = 5;
SkInspectorWidget::SkInspectorWidget() : QWidget()
, fHorizontalLayout(this)
, fMatrixAndClipWidget(this)
, fVerticalLayout(&fMatrixAndClipWidget) {
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].addWidget(&fTabTexts[i]);
fTabs[i].setLayout(&fTabLayouts[i]);
fTabWidget.addTab(&fTabs[i], tabNames[i]);
}
fHorizontalLayout.setAlignment(Qt::AlignTop);
fHorizontalLayout.addWidget(&fTabWidget);
fMatrixAndClipWidget.setFrameStyle(QFrame::Panel);
fMatrixAndClipWidget.setDisabled(true);
fVerticalLayout.setAlignment(Qt::AlignVCenter);
this->setupMatrix();
this->setupClip();
fVerticalLayout.addWidget(&fMatrixGroup);
fVerticalLayout.addWidget(&fClipGroup);
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), 'g', kSignificantNumbersInFields));
}
}
void SkInspectorWidget::setClip(const SkIRect& clip) {
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));
}
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);
}
}
}
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);
}
}
}