Refactored inspector widget such that creating custom tabs for information is straightforward for future developers.
Review URL: https://codereview.appspot.com/6463046 git-svn-id: http://skia.googlecode.com/svn/trunk@5093 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
parent
40fbb1810a
commit
6bd109a393
@ -310,7 +310,7 @@ void SkDebuggerGUI::registerListClick(QListWidgetItem *item) {
|
||||
info.append(QString((*currInfo)[i]->c_str()));
|
||||
info.append("<br/>");
|
||||
}
|
||||
fInspectorWidget.setDetailText(info);
|
||||
fInspectorWidget.setText(info, SkInspectorWidget::kDetail_TabType);
|
||||
fInspectorWidget.setDisabled(false);
|
||||
}
|
||||
}
|
||||
@ -649,7 +649,7 @@ void SkDebuggerGUI::setupComboBox(SkTDArray<SkString*>* command) {
|
||||
overview.append("SkPicture Height: ");
|
||||
overview.append(QString::number(fDebugger.pictureHeight()));
|
||||
overview.append("px");
|
||||
fInspectorWidget.setOverviewText(overview);
|
||||
fInspectorWidget.setText(overview, SkInspectorWidget::kOverview_TabType);
|
||||
|
||||
// NOTE(chudy): Makes first item unselectable.
|
||||
QStandardItemModel* model = qobject_cast<QStandardItemModel*>(
|
||||
|
@ -12,10 +12,6 @@
|
||||
|
||||
SkInspectorWidget::SkInspectorWidget() : QWidget()
|
||||
, fHorizontalLayout(this)
|
||||
, fOverviewTab()
|
||||
, fOverviewLayout(&fOverviewTab)
|
||||
, fDetailTab()
|
||||
, fDetailLayout(&fDetailTab)
|
||||
, fMatrixAndClipWidget(this)
|
||||
, fVerticalLayout(&fMatrixAndClipWidget)
|
||||
, fMatrixLabel(this)
|
||||
@ -24,20 +20,18 @@ SkInspectorWidget::SkInspectorWidget() : QWidget()
|
||||
fHorizontalLayout.setSpacing(6);
|
||||
fHorizontalLayout.setContentsMargins(11, 11, 11, 11);
|
||||
|
||||
fOverviewLayout.setSpacing(6);
|
||||
fOverviewLayout.setContentsMargins(11, 11, 11, 11);
|
||||
QString tabNames[kTotalTabCount];
|
||||
tabNames[kOverview_TabType] = "Overview";
|
||||
tabNames[kDetail_TabType] = "Details";
|
||||
|
||||
fOverviewText.setReadOnly(true);
|
||||
fOverviewLayout.addWidget(&fOverviewText);
|
||||
|
||||
fDetailLayout.setSpacing(6);
|
||||
fDetailLayout.setContentsMargins(11,11,11,11);
|
||||
|
||||
fDetailText.setReadOnly(true);
|
||||
fDetailLayout.addWidget(&fDetailText);
|
||||
|
||||
fTabWidget.addTab(&fOverviewTab, QString("Overview"));
|
||||
fTabWidget.addTab(&fDetailTab, QString("Details"));
|
||||
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);
|
||||
@ -46,9 +40,7 @@ SkInspectorWidget::SkInspectorWidget() : QWidget()
|
||||
* 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.
|
||||
*/
|
||||
|
||||
* line edits in each horizontal layout. */
|
||||
fMatrixAndClipWidget.setFixedSize(260,300);
|
||||
fMatrixAndClipWidget.setDisabled(true);
|
||||
|
||||
@ -58,12 +50,8 @@ SkInspectorWidget::SkInspectorWidget() : QWidget()
|
||||
fHorizontalLayout.addWidget(&fMatrixAndClipWidget);
|
||||
}
|
||||
|
||||
void SkInspectorWidget::setDetailText(QString text) {
|
||||
fDetailText.setHtml(text);
|
||||
}
|
||||
|
||||
void SkInspectorWidget::setOverviewText(QString text) {
|
||||
fOverviewText.setHtml(text);
|
||||
void SkInspectorWidget::setText(QString text, TabType type) {
|
||||
fTabTexts[type].setHtml(text);
|
||||
}
|
||||
|
||||
void SkInspectorWidget::setMatrix(const SkMatrix& matrix) {
|
||||
|
@ -28,6 +28,12 @@ class SkInspectorWidget : public QWidget {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
enum TabType {
|
||||
kOverview_TabType,
|
||||
kDetail_TabType,
|
||||
kTotalTabCount,
|
||||
};
|
||||
|
||||
/**
|
||||
Constructs a widget with the specified parent for layout purposes.
|
||||
@param parent The parent container of this widget
|
||||
@ -37,17 +43,12 @@ public:
|
||||
void setDisabled(bool isDisabled) {
|
||||
fMatrixAndClipWidget.setDisabled(isDisabled);
|
||||
}
|
||||
/**
|
||||
Sets the text in the detail tab.
|
||||
@param text
|
||||
*/
|
||||
void setDetailText(QString text);
|
||||
|
||||
/**
|
||||
Sets the text in the overview tab.
|
||||
Sets the text in tab at the specified index.
|
||||
@param text
|
||||
*/
|
||||
void setOverviewText(QString text);
|
||||
void setText(QString text, TabType type);
|
||||
|
||||
/**
|
||||
Sets the text in the current matrix.
|
||||
@ -61,17 +62,29 @@ public:
|
||||
*/
|
||||
void setClip(const SkIRect& clip);
|
||||
|
||||
class Tab : public QWidget {
|
||||
QWidget fTab;
|
||||
QHBoxLayout fTabLayout;
|
||||
QTextEdit fTabText;
|
||||
QString fName;
|
||||
|
||||
Tab(const char* name) {
|
||||
fTabText.setReadOnly(true);
|
||||
fTabLayout.setSpacing(6);
|
||||
fTabLayout.setContentsMargins(11, 11, 11, 11);
|
||||
fTabLayout.addWidget(&fTabText);
|
||||
fTab.setLayout(&fTabLayout);
|
||||
fName = QString(name);
|
||||
}
|
||||
};
|
||||
|
||||
private:
|
||||
QHBoxLayout fHorizontalLayout;
|
||||
QTabWidget fTabWidget;
|
||||
|
||||
QWidget fOverviewTab;
|
||||
QHBoxLayout fOverviewLayout;
|
||||
QTextEdit fOverviewText;
|
||||
|
||||
QWidget fDetailTab;
|
||||
QHBoxLayout fDetailLayout;
|
||||
QTextEdit fDetailText;
|
||||
QWidget fTabs[kTotalTabCount];
|
||||
QHBoxLayout fTabLayouts[kTotalTabCount];
|
||||
QTextEdit fTabTexts[kTotalTabCount];
|
||||
|
||||
QWidget fMatrixAndClipWidget;
|
||||
QVBoxLayout fVerticalLayout;
|
||||
|
Loading…
Reference in New Issue
Block a user