| 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() : QWidget() |
| 16 , mainFrameLayout(this) | 16 , mainFrameLayout(this) |
| 17 , fVerticalLayout(&mainFrame) | 17 , fVerticalLayout(&mainFrame) |
| 18 , fVisibleFrameLayout(&fVisibleFrame) | 18 , fVisibleFrameLayout(&fVisibleFrame) |
| 19 , fVisibleOn(&fVisibleFrame) | |
| 20 , fVisibleOff(&fVisibleFrame) | |
| 21 , fCommandLayout(&fCommandFrame) | 19 , fCommandLayout(&fCommandFrame) |
| 22 , fCurrentCommandBox(&fCommandFrame) | 20 , fCurrentCommandBox(&fCommandFrame) |
| 23 , fCommandHitBox(&fCommandFrame) | 21 , fCommandHitBox(&fCommandFrame) |
| 24 , fCanvasLayout(&fCanvasFrame) | 22 , fCanvasLayout(&fCanvasFrame) |
| 25 , fZoomLayout(&fZoomFrame) | 23 , fZoomLayout(&fZoomFrame) |
| 26 , fZoomBox(&fZoomFrame) | 24 , fZoomBox(&fZoomFrame) |
| 27 { | 25 { |
| 28 // Sets up the container and it's alignment around the settings widget. | 26 // Sets up the container and it's alignment around the settings widget. |
| 29 mainFrame.setFrameShape(QFrame::StyledPanel); | 27 mainFrame.setFrameShape(QFrame::StyledPanel); |
| 30 mainFrame.setFrameShadow(QFrame::Raised); | 28 mainFrame.setFrameShadow(QFrame::Raised); |
| 31 mainFrameLayout.setSpacing(6); | 29 mainFrameLayout.setSpacing(6); |
| 32 mainFrameLayout.setContentsMargins(0,0,0,0); | 30 mainFrameLayout.setContentsMargins(0,0,0,0); |
| 33 mainFrameLayout.addWidget(&mainFrame); | 31 mainFrameLayout.addWidget(&mainFrame); |
| 34 | 32 |
| 35 // Vertical Layout is the alignment inside of the main frame. | 33 // Vertical Layout is the alignment inside of the main frame. |
| 36 fVerticalLayout.setContentsMargins(11,11,11,11); | 34 fVerticalLayout.setContentsMargins(11,11,11,11); |
| 37 fVerticalLayout.setAlignment(Qt::AlignTop); | 35 fVerticalLayout.setAlignment(Qt::AlignTop); |
| 38 | 36 |
| 39 // Visible Toggle | 37 // Visible Toggle |
| 40 fVisibileText.setText("Visibility Filter"); | 38 fVisibleText.setText("Visibility Filter"); |
| 41 fVisibleFrame.setFrameShape(QFrame::StyledPanel); | 39 fVisibleFrame.setFrameShape(QFrame::StyledPanel); |
| 42 fVisibleFrame.setFrameShadow(QFrame::Raised); | 40 fVisibleFrame.setFrameShadow(QFrame::Raised); |
| 43 fVisibleOn.setText("On"); | 41 |
| 44 fVisibleOff.setText("Off"); | 42 fVisibilityCombo.addItem("Off", QVariant(false)); |
| 45 fVisibleOff.setChecked(true); | 43 fVisibilityCombo.addItem("On", QVariant(true)); |
| 46 fVisibleFrameLayout.setSpacing(6); | 44 |
| 47 fVisibleFrameLayout.setContentsMargins(11,11,11,11); | 45 fVisibleFrameLayout.setContentsMargins(11, 5, 11, 5); |
| 48 fVisibleFrameLayout.addWidget(&fVisibleOn); | 46 fVisibleFrameLayout.addWidget(&fVisibilityCombo); |
| 49 fVisibleFrameLayout.addWidget(&fVisibleOff); | 47 connect(&fVisibilityCombo, SIGNAL(activated(int)), this, |
| 48 SIGNAL(visibilityFilterChanged())); |
| 50 | 49 |
| 51 // Canvas | 50 // Canvas |
| 52 fCanvasToggle.setText("Render Targets"); | 51 fCanvasToggle.setText("Render Targets"); |
| 53 fCanvasFrame.setFrameShape(QFrame::StyledPanel); | 52 fCanvasFrame.setFrameShape(QFrame::StyledPanel); |
| 54 fCanvasFrame.setFrameShadow(QFrame::Raised); | 53 fCanvasFrame.setFrameShadow(QFrame::Raised); |
| 55 | 54 |
| 56 fRasterLabel.setText("Raster: "); | 55 fRasterLabel.setText("Raster: "); |
| 57 fRasterLabel.setMinimumWidth(178); | 56 fRasterLabel.setMinimumWidth(178); |
| 58 fRasterLabel.setMaximumWidth(178); | 57 fRasterLabel.setMaximumWidth(178); |
| 59 | 58 |
| 60 fRasterCheckBox.setChecked(true); | 59 fRasterCheckBox.setChecked(true); |
| 61 | 60 |
| 62 fOverdrawVizLabel.setText(" Overdraw Viz: "); | 61 fOverdrawVizLabel.setText(" Overdraw Viz: "); |
| 63 fOverdrawVizLabel.setMinimumWidth(178); | 62 fOverdrawVizLabel.setMinimumWidth(178); |
| 64 fOverdrawVizLabel.setMaximumWidth(178); | 63 fOverdrawVizLabel.setMaximumWidth(178); |
| 65 | 64 |
| 66 #if SK_SUPPORT_GPU | 65 #if SK_SUPPORT_GPU |
| 67 fGLLabel.setText("OpenGL: "); | 66 fGLLabel.setText("OpenGL: "); |
| 68 fGLLabel.setMinimumWidth(178); | 67 fGLLabel.setMinimumWidth(178); |
| 69 fGLLabel.setMaximumWidth(178); | 68 fGLLabel.setMaximumWidth(178); |
| 70 | 69 |
| 71 fGLMSAAButtonGroup.setTitle("MSAA"); | 70 fGLMSAAButtonGroup.setTitle("MSAA"); |
| 72 fGLMSAAButtonGroup.setMinimumWidth(178); | 71 fGLMSAAButtonGroup.setMinimumWidth(178); |
| 73 fGLMSAAButtonGroup.setMaximumWidth(178); | 72 fGLMSAAButtonGroup.setMaximumWidth(178); |
| 74 fGLMSAAButtonGroup.setEnabled(fGLCheckBox.isChecked()); | 73 fGLMSAAButtonGroup.setEnabled(fGLCheckBox.isChecked()); |
| 75 | 74 |
| 76 fGLMSAAOff.setText("Off"); | 75 fGLMSAACombo.addItem("Off", QVariant(0)); |
| 77 fGLMSAA4On.setText("4"); | 76 fGLMSAACombo.addItem("4", QVariant(4)); |
| 78 fGLMSAA4On.setChecked(true); | 77 fGLMSAACombo.addItem("16", QVariant(16)); |
| 79 fGLMSAA16On.setText("16"); | |
| 80 | 78 |
| 81 fGLMSAALayout.addWidget(&fGLMSAAOff); | 79 fGLMSAALayout.addWidget(&fGLMSAACombo); |
| 82 fGLMSAALayout.addWidget(&fGLMSAA4On); | |
| 83 fGLMSAALayout.addWidget(&fGLMSAA16On); | |
| 84 | |
| 85 fGLMSAAButtonGroup.setLayout(&fGLMSAALayout); | 80 fGLMSAAButtonGroup.setLayout(&fGLMSAALayout); |
| 86 | 81 |
| 87 connect(&fGLCheckBox, SIGNAL(toggled(bool)), &fGLMSAAButtonGroup, SLOT(setEn
abled(bool))); | 82 connect(&fGLCheckBox, SIGNAL(toggled(bool)), &fGLMSAAButtonGroup, |
| 88 connect(&fGLCheckBox, SIGNAL(toggled(bool)), this, SIGNAL(glSettingsChanged(
))); | 83 SLOT(setEnabled(bool))); |
| 89 connect(&fGLMSAAOff, SIGNAL(toggled(bool)), this, SIGNAL(glSettingsChanged()
)); | 84 connect(&fGLCheckBox, SIGNAL(toggled(bool)), this, |
| 90 connect(&fGLMSAA4On, SIGNAL(toggled(bool)), this, SIGNAL(glSettingsChanged()
)); | 85 SIGNAL(glSettingsChanged())); |
| 91 connect(&fGLMSAA16On, SIGNAL(toggled(bool)), this, SIGNAL(glSettingsChanged(
))); | 86 connect(&fGLMSAACombo, SIGNAL(activated(int)), this, |
| 87 SIGNAL(glSettingsChanged())); |
| 92 #endif | 88 #endif |
| 93 | 89 |
| 94 { | 90 { |
| 95 // set up filter buttons | 91 // set up filter buttons |
| 96 fFilterButtonGroup.setTitle("Filtering"); | 92 fFilterButtonGroup.setTitle("Filtering"); |
| 97 fFilterButtonGroup.setMinimumWidth(178); | 93 fFilterButtonGroup.setMinimumWidth(178); |
| 98 fFilterButtonGroup.setMaximumWidth(178); | 94 fFilterButtonGroup.setMaximumWidth(178); |
| 99 | 95 |
| 100 fFilterDefault.setText("As encoded"); | 96 fFilterCombo.addItem("As encoded", QVariant(SkPaint::kNone_FilterLevel))
; |
| 101 fFilterDefault.setChecked(true); | 97 fFilterCombo.addItem("None", QVariant(SkPaint::kNone_FilterLevel)); |
| 102 fFilterNone.setText("None"); | 98 fFilterCombo.addItem("Low", QVariant(SkPaint::kLow_FilterLevel)); |
| 103 fFilterLow.setText("Low"); | 99 fFilterCombo.addItem("Medium", QVariant(SkPaint::kMedium_FilterLevel)); |
| 104 fFilterMed.setText("Med"); | 100 fFilterCombo.addItem("High", QVariant(SkPaint::kHigh_FilterLevel)); |
| 105 fFilterHigh.setText("High"); | |
| 106 | 101 |
| 107 fFilterLayout.addWidget(&fFilterDefault); | 102 fFilterLayout.addWidget(&fFilterCombo); |
| 108 fFilterLayout.addWidget(&fFilterNone); | |
| 109 fFilterLayout.addWidget(&fFilterLow); | |
| 110 fFilterLayout.addWidget(&fFilterMed); | |
| 111 fFilterLayout.addWidget(&fFilterHigh); | |
| 112 | |
| 113 fFilterButtonGroup.setLayout(&fFilterLayout); | 103 fFilterButtonGroup.setLayout(&fFilterLayout); |
| 114 | 104 |
| 115 connect(&fFilterDefault, SIGNAL(toggled(bool)), this, SIGNAL(texFilterSe
ttingsChanged())); | 105 connect(&fFilterCombo, SIGNAL(activated(int)), this, |
| 116 connect(&fFilterNone, SIGNAL(toggled(bool)), this, SIGNAL(texFilterSe
ttingsChanged())); | 106 SIGNAL(texFilterSettingsChanged())); |
| 117 connect(&fFilterLow, SIGNAL(toggled(bool)), this, SIGNAL(texFilterSe
ttingsChanged())); | |
| 118 connect(&fFilterMed, SIGNAL(toggled(bool)), this, SIGNAL(texFilterSe
ttingsChanged())); | |
| 119 connect(&fFilterHigh, SIGNAL(toggled(bool)), this, SIGNAL(texFilterSe
ttingsChanged())); | |
| 120 } | 107 } |
| 121 | 108 |
| 122 fRasterLayout.addWidget(&fRasterLabel); | 109 fRasterLayout.addWidget(&fRasterLabel); |
| 123 fRasterLayout.addWidget(&fRasterCheckBox); | 110 fRasterLayout.addWidget(&fRasterCheckBox); |
| 124 | 111 |
| 125 fOverdrawVizLayout.addWidget(&fOverdrawVizLabel); | 112 fOverdrawVizLayout.addWidget(&fOverdrawVizLabel); |
| 126 fOverdrawVizLayout.addWidget(&fOverdrawVizCheckBox); | 113 fOverdrawVizLayout.addWidget(&fOverdrawVizCheckBox); |
| 127 | 114 |
| 128 #if SK_SUPPORT_GPU | 115 #if SK_SUPPORT_GPU |
| 129 fGLLayout.addWidget(&fGLLabel); | 116 fGLLayout.addWidget(&fGLLabel); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 fZoomBox.setText("100%"); | 173 fZoomBox.setText("100%"); |
| 187 fZoomBox.setMinimumSize(QSize(50,25)); | 174 fZoomBox.setMinimumSize(QSize(50,25)); |
| 188 fZoomBox.setMaximumSize(QSize(50,25)); | 175 fZoomBox.setMaximumSize(QSize(50,25)); |
| 189 fZoomBox.setAlignment(Qt::AlignRight); | 176 fZoomBox.setAlignment(Qt::AlignRight); |
| 190 fZoomLayout.setSpacing(6); | 177 fZoomLayout.setSpacing(6); |
| 191 fZoomLayout.setContentsMargins(11,11,11,11); | 178 fZoomLayout.setContentsMargins(11,11,11,11); |
| 192 fZoomLayout.addWidget(&fZoomSetting); | 179 fZoomLayout.addWidget(&fZoomSetting); |
| 193 fZoomLayout.addWidget(&fZoomBox); | 180 fZoomLayout.addWidget(&fZoomBox); |
| 194 | 181 |
| 195 // Adds all widgets to settings container | 182 // Adds all widgets to settings container |
| 196 fVerticalLayout.addWidget(&fVisibileText); | 183 fVerticalLayout.addWidget(&fVisibleText); |
| 197 fVerticalLayout.addWidget(&fVisibleFrame); | 184 fVerticalLayout.addWidget(&fVisibleFrame); |
| 198 fVerticalLayout.addWidget(&fCommandToggle); | 185 fVerticalLayout.addWidget(&fCommandToggle); |
| 199 fVerticalLayout.addWidget(&fCommandFrame); | 186 fVerticalLayout.addWidget(&fCommandFrame); |
| 200 fVerticalLayout.addWidget(&fCanvasToggle); | 187 fVerticalLayout.addWidget(&fCanvasToggle); |
| 201 fVerticalLayout.addWidget(&fCanvasFrame); | 188 fVerticalLayout.addWidget(&fCanvasFrame); |
| 202 fVerticalLayout.addWidget(&fZoomFrame); | 189 fVerticalLayout.addWidget(&fZoomFrame); |
| 203 | 190 |
| 204 this->setDisabled(true); | 191 this->setDisabled(true); |
| 205 } | 192 } |
| 206 | 193 |
| 207 | 194 |
| 208 void SkSettingsWidget::updateCommand(int newCommand) { | 195 void SkSettingsWidget::updateCommand(int newCommand) { |
| 209 fCurrentCommandBox.setText(QString::number(newCommand)); | 196 fCurrentCommandBox.setText(QString::number(newCommand)); |
| 210 } | 197 } |
| 211 | 198 |
| 212 void SkSettingsWidget::updateHit(int newHit) { | 199 void SkSettingsWidget::updateHit(int newHit) { |
| 213 fCommandHitBox.setText(QString::number(newHit)); | 200 fCommandHitBox.setText(QString::number(newHit)); |
| 214 } | 201 } |
| 215 | 202 |
| 216 QRadioButton* SkSettingsWidget::getVisibilityButton() { | |
| 217 return &fVisibleOn; | |
| 218 } | |
| 219 | |
| 220 void SkSettingsWidget::setZoomText(float scale) { | 203 void SkSettingsWidget::setZoomText(float scale) { |
| 221 fZoomBox.setText(QString::number(scale*100, 'f', 0).append("%")); | 204 fZoomBox.setText(QString::number(scale*100, 'f', 0).append("%")); |
| 222 } | 205 } |
| OLD | NEW |