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