1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
|
/*
* 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 "SkSettingsWidget.h"
#include <iostream>
#include <math.h>
// TODO(chudy): See if the layout can't be attached to the frame post construction.
SkSettingsWidget::SkSettingsWidget() : QWidget()
, mainFrameLayout(this)
, fVerticalLayout(&mainFrame)
, fVisibleFrameLayout(&fVisibleFrame)
, fCommandLayout(&fCommandFrame)
, fCurrentCommandBox(&fCommandFrame)
, fCommandHitBox(&fCommandFrame)
, fCanvasLayout(&fCanvasFrame)
, fZoomLayout(&fZoomFrame)
, fZoomBox(&fZoomFrame)
{
// Sets up the container and it's alignment around the settings widget.
mainFrame.setFrameShape(QFrame::StyledPanel);
mainFrame.setFrameShadow(QFrame::Raised);
mainFrameLayout.setSpacing(6);
mainFrameLayout.setContentsMargins(0,0,0,0);
mainFrameLayout.addWidget(&mainFrame);
// Vertical Layout is the alignment inside of the main frame.
fVerticalLayout.setContentsMargins(11,11,11,11);
fVerticalLayout.setAlignment(Qt::AlignTop);
// Visible Toggle
fVisibleText.setText("Visibility Filter");
fVisibleFrame.setFrameShape(QFrame::StyledPanel);
fVisibleFrame.setFrameShadow(QFrame::Raised);
fVisibilityCombo.addItem("Off", QVariant(false));
fVisibilityCombo.addItem("On", QVariant(true));
fVisibleFrameLayout.setContentsMargins(11, 5, 11, 5);
fVisibleFrameLayout.addWidget(&fVisibilityCombo);
connect(&fVisibilityCombo, SIGNAL(activated(int)), this,
SIGNAL(visibilityFilterChanged()));
// Canvas
fCanvasToggle.setText("Render Targets");
fCanvasFrame.setFrameShape(QFrame::StyledPanel);
fCanvasFrame.setFrameShadow(QFrame::Raised);
fRasterLabel.setText("Raster: ");
fRasterLabel.setMinimumWidth(178);
fRasterLabel.setMaximumWidth(178);
fPathOpsLabel.setText("PathOps: ");
fPathOpsLabel.setMinimumWidth(178);
fPathOpsLabel.setMaximumWidth(178);
fRasterCheckBox.setChecked(true);
fOverdrawVizLabel.setText(" Overdraw Viz: ");
fOverdrawVizLabel.setMinimumWidth(178);
fOverdrawVizLabel.setMaximumWidth(178);
fMegaVizLabel.setText(" Mega Viz: ");
fMegaVizLabel.setMinimumWidth(178);
fMegaVizLabel.setMaximumWidth(178);
#if SK_SUPPORT_GPU
fGLLabel.setText("OpenGL: ");
fGLLabel.setMinimumWidth(178);
fGLLabel.setMaximumWidth(178);
fGLMSAAButtonGroup.setTitle("MSAA");
fGLMSAAButtonGroup.setMinimumWidth(178);
fGLMSAAButtonGroup.setMaximumWidth(178);
fGLMSAAButtonGroup.setEnabled(fGLCheckBox.isChecked());
fGLMSAACombo.addItem("Off", QVariant(0));
fGLMSAACombo.addItem("4", QVariant(4));
fGLMSAACombo.addItem("16", QVariant(16));
fGLMSAALayout.addWidget(&fGLMSAACombo);
fGLMSAAButtonGroup.setLayout(&fGLMSAALayout);
connect(&fGLCheckBox, SIGNAL(toggled(bool)), &fGLMSAAButtonGroup,
SLOT(setEnabled(bool)));
connect(&fGLCheckBox, SIGNAL(toggled(bool)), this,
SIGNAL(glSettingsChanged()));
connect(&fGLMSAACombo, SIGNAL(activated(int)), this,
SIGNAL(glSettingsChanged()));
#endif
{
// set up filter buttons
fFilterButtonGroup.setTitle("Filtering");
fFilterButtonGroup.setMinimumWidth(178);
fFilterButtonGroup.setMaximumWidth(178);
fFilterCombo.addItem("As encoded", QVariant(SkPaint::kNone_FilterLevel));
fFilterCombo.addItem("None", QVariant(SkPaint::kNone_FilterLevel));
fFilterCombo.addItem("Low", QVariant(SkPaint::kLow_FilterLevel));
fFilterCombo.addItem("Medium", QVariant(SkPaint::kMedium_FilterLevel));
fFilterCombo.addItem("High", QVariant(SkPaint::kHigh_FilterLevel));
fFilterLayout.addWidget(&fFilterCombo);
fFilterButtonGroup.setLayout(&fFilterLayout);
connect(&fFilterCombo, SIGNAL(activated(int)), this,
SIGNAL(texFilterSettingsChanged()));
}
fRasterLayout.addWidget(&fRasterLabel);
fRasterLayout.addWidget(&fRasterCheckBox);
fRasterLayout.addWidget(&fPathOpsLabel);
fRasterLayout.addWidget(&fPathOpsCheckBox);
fVizLayout.addWidget(&fOverdrawVizLabel);
fVizLayout.addWidget(&fOverdrawVizCheckBox);
fVizLayout.addWidget(&fMegaVizLabel);
fVizLayout.addWidget(&fMegaVizCheckBox);
#if SK_SUPPORT_GPU
fGLLayout.addWidget(&fGLLabel);
fGLLayout.addWidget(&fGLCheckBox);
#endif
fCanvasLayout.setSpacing(6);
fCanvasLayout.setContentsMargins(11,11,11,11);
fCanvasLayout.addLayout(&fRasterLayout);
fCanvasLayout.addLayout(&fVizLayout);
#if SK_SUPPORT_GPU
fCanvasLayout.addLayout(&fGLLayout);
fCanvasLayout.addWidget(&fGLMSAAButtonGroup);
#endif
fCanvasLayout.addWidget(&fFilterButtonGroup);
// Command Toggle
fCommandToggle.setText("Command Scrolling Preferences");
fCommandFrame.setFrameShape(QFrame::StyledPanel);
fCommandFrame.setFrameShadow(QFrame::Raised);
fCurrentCommandLabel.setText("Current Command: ");
fCurrentCommandLabel.setMinimumWidth(178);
fCurrentCommandLabel.setMaximumWidth(178);
fCurrentCommandBox.setText("0");
fCurrentCommandBox.setMinimumSize(QSize(50,25));
fCurrentCommandBox.setMaximumSize(QSize(50,25));
fCurrentCommandBox.setAlignment(Qt::AlignRight);
fCurrentCommandLayout.setSpacing(0);
fCurrentCommandLayout.setContentsMargins(0,0,0,0);
fCurrentCommandLayout.setAlignment(Qt::AlignLeft);
fCurrentCommandLayout.addWidget(&fCurrentCommandLabel);
fCurrentCommandLayout.addWidget(&fCurrentCommandBox);
fCommandHitLabel.setText("Command HitBox: ");
fCommandHitLabel.setMinimumWidth(178);
fCommandHitLabel.setMaximumWidth(178);
fCommandHitBox.setText("0");
fCommandHitBox.setMinimumSize(QSize(50,25));
fCommandHitBox.setMaximumSize(QSize(50,25));
fCommandHitBox.setAlignment(Qt::AlignRight);
fCommandHitLayout.setSpacing(0);
fCommandHitLayout.setContentsMargins(0,0,0,0);
fCommandHitLayout.setAlignment(Qt::AlignLeft);
fCommandHitLayout.addWidget(&fCommandHitLabel);
fCommandHitLayout.addWidget(&fCommandHitBox);
fCommandLayout.setSpacing(6);
fCommandLayout.setContentsMargins(11,11,11,11);
fCommandLayout.addLayout(&fCurrentCommandLayout);
fCommandLayout.addLayout(&fCommandHitLayout);
// Zoom Info
fZoomSetting.setText("Zoom Level: ");
fZoomSetting.setMinimumWidth(178);
fZoomSetting.setMaximumWidth(178);
fZoomFrame.setFrameShape(QFrame::StyledPanel);
fZoomFrame.setFrameShadow(QFrame::Raised);
fZoomBox.setText("100%");
fZoomBox.setMinimumSize(QSize(50,25));
fZoomBox.setMaximumSize(QSize(50,25));
fZoomBox.setAlignment(Qt::AlignRight);
fZoomLayout.setSpacing(6);
fZoomLayout.setContentsMargins(11,11,11,11);
fZoomLayout.addWidget(&fZoomSetting);
fZoomLayout.addWidget(&fZoomBox);
// Adds all widgets to settings container
fVerticalLayout.addWidget(&fVisibleText);
fVerticalLayout.addWidget(&fVisibleFrame);
fVerticalLayout.addWidget(&fCommandToggle);
fVerticalLayout.addWidget(&fCommandFrame);
fVerticalLayout.addWidget(&fCanvasToggle);
fVerticalLayout.addWidget(&fCanvasFrame);
fVerticalLayout.addWidget(&fZoomFrame);
this->setDisabled(true);
}
void SkSettingsWidget::updateCommand(int newCommand) {
fCurrentCommandBox.setText(QString::number(newCommand));
}
void SkSettingsWidget::updateHit(int newHit) {
fCommandHitBox.setText(QString::number(newHit));
}
void SkSettingsWidget::setZoomText(float scale) {
fZoomBox.setText(QString::number(scale*100, 'f', 0).append("%"));
}
|