Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(69)

Side by Side Diff: debugger/QT/SkInspectorWidget.cpp

Issue 830743002: debugger: Make inspector widget smaller (Closed) Base URL: https://skia.googlesource.com/skia.git@debugger-resize-02-drawop-view-resize
Patch Set: address review comments Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « debugger/QT/SkInspectorWidget.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2012 Google Inc. 3 * Copyright 2012 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 9
10 #include "SkInspectorWidget.h" 10 #include "SkInspectorWidget.h"
11 #include <iostream> 11 #include <iostream>
12 12
13 static const int kSignificantNumbersInFields = 5;
14
13 SkInspectorWidget::SkInspectorWidget() : QWidget() 15 SkInspectorWidget::SkInspectorWidget() : QWidget()
14 , fHorizontalLayout(this) 16 , fHorizontalLayout(this)
15 , fMatrixAndClipWidget(this) 17 , fMatrixAndClipWidget(this)
16 , fVerticalLayout(&fMatrixAndClipWidget) 18 , fVerticalLayout(&fMatrixAndClipWidget) {
17 , fMatrixLabel(this)
18 , fClipLabel(this) {
19
20 fHorizontalLayout.setSpacing(6);
21 fHorizontalLayout.setContentsMargins(11, 11, 11, 11);
22
23 QString tabNames[kTotalTabCount]; 19 QString tabNames[kTotalTabCount];
24 tabNames[kOverview_TabType] = "Overview"; 20 tabNames[kOverview_TabType] = "Overview";
25 tabNames[kDetail_TabType] = "Details"; 21 tabNames[kDetail_TabType] = "Details";
26 tabNames[kClipStack_TabType] = "Clip Stack"; 22 tabNames[kClipStack_TabType] = "Clip Stack";
27 23
28 for (int i = 0; i < kTotalTabCount; i++) { 24 for (int i = 0; i < kTotalTabCount; i++) {
29 fTabTexts[i].setReadOnly(true); 25 fTabTexts[i].setReadOnly(true);
30 fTabLayouts[i].setSpacing(6);
31 fTabLayouts[i].setContentsMargins(11, 11, 11, 11);
32 fTabLayouts[i].addWidget(&fTabTexts[i]); 26 fTabLayouts[i].addWidget(&fTabTexts[i]);
33 fTabs[i].setLayout(&fTabLayouts[i]); 27 fTabs[i].setLayout(&fTabLayouts[i]);
34 fTabWidget.addTab(&fTabs[i], tabNames[i]); 28 fTabWidget.addTab(&fTabs[i], tabNames[i]);
35 } 29 }
36 30
37 fHorizontalLayout.setAlignment(Qt::AlignTop); 31 fHorizontalLayout.setAlignment(Qt::AlignTop);
38 fHorizontalLayout.addWidget(&fTabWidget); 32 fHorizontalLayout.addWidget(&fTabWidget);
39 33
40 /* NOTE(chudy): We add all the line edits to (this). Then we lay them out 34 fMatrixAndClipWidget.setFrameStyle(QFrame::Panel);
41 * by adding them to horizontal layouts.
42 *
43 * We will have 1 big vertical layout, 3 horizontal layouts and then 3
44 * line edits in each horizontal layout. */
45 fMatrixAndClipWidget.setFixedSize(260,300);
46 fMatrixAndClipWidget.setDisabled(true); 35 fMatrixAndClipWidget.setDisabled(true);
47
48 fVerticalLayout.setAlignment(Qt::AlignVCenter); 36 fVerticalLayout.setAlignment(Qt::AlignVCenter);
49 fVerticalLayout.addLayout(setupMatrix()); 37 this->setupMatrix();
50 fVerticalLayout.addLayout(setupClip()); 38 this->setupClip();
39 fVerticalLayout.addWidget(&fMatrixGroup);
40 fVerticalLayout.addWidget(&fClipGroup);
51 fHorizontalLayout.addWidget(&fMatrixAndClipWidget); 41 fHorizontalLayout.addWidget(&fMatrixAndClipWidget);
52 } 42 }
53 43
54 void SkInspectorWidget::setText(QString text, TabType type) { 44 void SkInspectorWidget::setText(QString text, TabType type) {
55 fTabTexts[type].setHtml(text); 45 fTabTexts[type].setHtml(text);
56 } 46 }
57 47
58 void SkInspectorWidget::setMatrix(const SkMatrix& matrix) { 48 void SkInspectorWidget::setMatrix(const SkMatrix& matrix) {
59 for(int i=0; i<9; i++) { 49 for(int i=0; i<9; i++) {
60 fMatrixEntry[i].setText(QString::number(matrix.get(i))); 50 fMatrixEntry[i].setText(QString::number(matrix.get(i), 'g', kSignificant NumbersInFields));
61 } 51 }
62 } 52 }
63 53
64 void SkInspectorWidget::setClip(const SkIRect& clip) { 54 void SkInspectorWidget::setClip(const SkIRect& clip) {
65 fClipEntry[0].setText(QString::number(clip.left())); 55 fClipEntry[0].setText(QString::number(clip.left(), 'g', kSignificantNumbersI nFields));
66 fClipEntry[1].setText(QString::number(clip.top())); 56 fClipEntry[1].setText(QString::number(clip.top(), 'g', kSignificantNumbersIn Fields));
67 fClipEntry[2].setText(QString::number(clip.right())); 57 fClipEntry[2].setText(QString::number(clip.right(), 'g', kSignificantNumbers InFields));
68 fClipEntry[3].setText(QString::number(clip.bottom())); 58 fClipEntry[3].setText(QString::number(clip.bottom(), 'g', kSignificantNumber sInFields));
69 } 59 }
70 60
71 QVBoxLayout* SkInspectorWidget::setupMatrix() { 61 void SkInspectorWidget::setupMatrix() {
72 fMatrixLabel.setText("Current Matrix"); 62 fMatrixGroup.setTitle("Current Matrix");
73 fMatrixLabel.setAlignment(Qt::AlignHCenter); 63 fMatrixGroup.setLayout(&fMatrixLayout);
74 64 for (int r = 0; r < 3; ++r) {
75 fMatrixLayout.setSpacing(6); 65 for(int c = 0; c < 3; c++) {
76 fMatrixLayout.setContentsMargins(11,11,11,0); 66 QLineEdit* entry = &fMatrixEntry[r * 3 + c];
77 fMatrixLayout.setAlignment(Qt::AlignTop | Qt::AlignHCenter); 67 fMatrixLayout.addWidget(entry, r, c, Qt::AlignTop | Qt::AlignHCenter );
78 fMatrixLayout.addWidget(&fMatrixLabel); 68 entry->setReadOnly(true);
79 69 entry->setFixedWidth(70);
80 for(int i =0; i<9; i++) {
81 fMatrixEntry[i].setMinimumSize(QSize(70,25));
82 fMatrixEntry[i].setMaximumSize(QSize(70,16777215));
83 fMatrixEntry[i].setReadOnly(true);
84
85 fMatrixRow[i/3].addWidget(&fMatrixEntry[i]);
86 if(i%3 == 2) {
87 fMatrixLayout.addLayout(&fMatrixRow[i/3]);
88 } 70 }
89 } 71 }
90
91 return &fMatrixLayout;
92 } 72 }
93 73
94 QVBoxLayout* SkInspectorWidget::setupClip() { 74 void SkInspectorWidget::setupClip() {
95 fClipLabel.setText("Current Clip"); 75 fClipGroup.setTitle("Current Clip");
96 fClipLabel.setAlignment(Qt::AlignHCenter); 76 fClipGroup.setLayout(&fClipLayout);
97 77 for(int r = 0; r < 2; r++) {
98 fClipLayout.setSpacing(6); 78 for(int c = 0; c < 2; c++) {
99 fClipLayout.setContentsMargins(11,11,11,0); 79 QLineEdit* entry = &fClipEntry[r * 2 + c];
100 fClipLayout.setAlignment(Qt::AlignTop | Qt::AlignHCenter); 80 fClipLayout.addWidget(entry, r, c, Qt::AlignTop | Qt::AlignHCenter);
101 fClipLayout.addWidget(&fClipLabel); 81 entry->setReadOnly(true);
102 82 entry->setFixedWidth(70);
103 for(int i =0; i<4; i++) {
104 fClipEntry[i].setMinimumSize(QSize(70,25));
105 fClipEntry[i].setMaximumSize(QSize(70,16777215));
106 fClipEntry[i].setReadOnly(true);
107
108 fClipRow[i/2].addWidget(&fClipEntry[i]);
109 if(i%2 == 1) {
110 fClipLayout.addLayout(&fClipRow[i/2]);
111 } 83 }
112 } 84 }
113
114 return &fClipLayout;
115 } 85 }
OLDNEW
« no previous file with comments | « debugger/QT/SkInspectorWidget.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698