chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 1 | |
| 2 | /* |
| 3 | * Copyright 2012 Google Inc. |
| 4 | * |
| 5 | * Use of this source code is governed by a BSD-style license that can be |
| 6 | * found in the LICENSE file. |
| 7 | */ |
| 8 | |
| 9 | |
| 10 | #include "SkSettingsWidget.h" |
chudy@google.com | 7dcae67 | 2012-07-09 20:26:53 +0000 | [diff] [blame] | 11 | #include <iostream> |
| 12 | #include <math.h> |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 13 | |
chudy@google.com | ea5488b | 2012-07-26 19:38:22 +0000 | [diff] [blame] | 14 | // TODO(chudy): See if the layout can't be attached to the frame post construction. |
chudy@google.com | 2d537a1 | 2012-07-31 12:49:52 +0000 | [diff] [blame] | 15 | SkSettingsWidget::SkSettingsWidget() : QWidget() |
chudy@google.com | 7dcae67 | 2012-07-09 20:26:53 +0000 | [diff] [blame] | 16 | , mainFrameLayout(this) |
| 17 | , fVerticalLayout(&mainFrame) |
| 18 | , fVisibleFrameLayout(&fVisibleFrame) |
| 19 | , fVisibleOn(&fVisibleFrame) |
| 20 | , fVisibleOff(&fVisibleFrame) |
| 21 | , fCommandLayout(&fCommandFrame) |
| 22 | , fCurrentCommandBox(&fCommandFrame) |
chudy@google.com | e606d6e | 2012-07-12 14:31:25 +0000 | [diff] [blame] | 23 | , fCommandHitBox(&fCommandFrame) |
chudy@google.com | ea5488b | 2012-07-26 19:38:22 +0000 | [diff] [blame] | 24 | , fCanvasLayout(&fCanvasFrame) |
chudy@google.com | 7dcae67 | 2012-07-09 20:26:53 +0000 | [diff] [blame] | 25 | , fZoomLayout(&fZoomFrame) |
chudy@google.com | 2d537a1 | 2012-07-31 12:49:52 +0000 | [diff] [blame] | 26 | , fZoomBox(&fZoomFrame) |
chudy@google.com | 7dcae67 | 2012-07-09 20:26:53 +0000 | [diff] [blame] | 27 | { |
| 28 | // Sets up the container and it's alignment around the settings widget. |
| 29 | mainFrame.setFrameShape(QFrame::StyledPanel); |
| 30 | mainFrame.setFrameShadow(QFrame::Raised); |
| 31 | mainFrameLayout.setSpacing(6); |
| 32 | mainFrameLayout.setContentsMargins(0,0,0,0); |
| 33 | mainFrameLayout.addWidget(&mainFrame); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 34 | |
chudy@google.com | 7dcae67 | 2012-07-09 20:26:53 +0000 | [diff] [blame] | 35 | // Vertical Layout is the alignment inside of the main frame. |
| 36 | fVerticalLayout.setContentsMargins(11,11,11,11); |
| 37 | fVerticalLayout.setAlignment(Qt::AlignTop); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 38 | |
chudy@google.com | 7dcae67 | 2012-07-09 20:26:53 +0000 | [diff] [blame] | 39 | // Visible Toggle |
| 40 | fVisibileText.setText("Visibility Filter"); |
| 41 | fVisibleFrame.setFrameShape(QFrame::StyledPanel); |
| 42 | fVisibleFrame.setFrameShadow(QFrame::Raised); |
| 43 | fVisibleOn.setText("On"); |
| 44 | fVisibleOff.setText("Off"); |
| 45 | fVisibleOff.setChecked(true); |
| 46 | fVisibleFrameLayout.setSpacing(6); |
| 47 | fVisibleFrameLayout.setContentsMargins(11,11,11,11); |
| 48 | fVisibleFrameLayout.addWidget(&fVisibleOn); |
| 49 | fVisibleFrameLayout.addWidget(&fVisibleOff); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 50 | |
chudy@google.com | ea5488b | 2012-07-26 19:38:22 +0000 | [diff] [blame] | 51 | // Canvas |
| 52 | fCanvasToggle.setText("Render Targets"); |
| 53 | fCanvasFrame.setFrameShape(QFrame::StyledPanel); |
| 54 | fCanvasFrame.setFrameShadow(QFrame::Raised); |
| 55 | |
| 56 | fRasterLabel.setText("Raster: "); |
| 57 | fRasterLabel.setMinimumWidth(178); |
| 58 | fRasterLabel.setMaximumWidth(178); |
| 59 | |
| 60 | fRasterCheckBox.setChecked(true); |
| 61 | |
robertphillips@google.com | f4741c1 | 2013-02-06 20:13:54 +0000 | [diff] [blame] | 62 | fOverdrawVizLabel.setText(" Overdraw Viz: "); |
| 63 | fOverdrawVizLabel.setMinimumWidth(178); |
| 64 | fOverdrawVizLabel.setMaximumWidth(178); |
| 65 | |
robertphillips@google.com | e8fe4bc | 2013-02-13 13:26:13 +0000 | [diff] [blame] | 66 | #if SK_SUPPORT_GPU |
chudy@google.com | ea5488b | 2012-07-26 19:38:22 +0000 | [diff] [blame] | 67 | fGLLabel.setText("OpenGL: "); |
| 68 | fGLLabel.setMinimumWidth(178); |
| 69 | fGLLabel.setMaximumWidth(178); |
commit-bot@chromium.org | fde1e7c | 2013-08-02 13:59:50 +0000 | [diff] [blame] | 70 | |
| 71 | fGLMSAAButtonGroup.setTitle("MSAA"); |
| 72 | fGLMSAAButtonGroup.setMinimumWidth(178); |
| 73 | fGLMSAAButtonGroup.setMaximumWidth(178); |
| 74 | fGLMSAAButtonGroup.setEnabled(fGLCheckBox.isChecked()); |
| 75 | |
| 76 | fGLMSAAOff.setText("Off"); |
| 77 | fGLMSAA4On.setText("4"); |
| 78 | fGLMSAA4On.setChecked(true); |
| 79 | fGLMSAA16On.setText("16"); |
| 80 | |
| 81 | fGLMSAALayout.addWidget(&fGLMSAAOff); |
| 82 | fGLMSAALayout.addWidget(&fGLMSAA4On); |
| 83 | fGLMSAALayout.addWidget(&fGLMSAA16On); |
| 84 | |
| 85 | fGLMSAAButtonGroup.setLayout(&fGLMSAALayout); |
| 86 | |
| 87 | connect(&fGLCheckBox, SIGNAL(toggled(bool)), &fGLMSAAButtonGroup, SLOT(setEnabled(bool))); |
| 88 | connect(&fGLCheckBox, SIGNAL(toggled(bool)), this, SIGNAL(glSettingsChanged())); |
| 89 | connect(&fGLMSAAOff, SIGNAL(toggled(bool)), this, SIGNAL(glSettingsChanged())); |
| 90 | connect(&fGLMSAA4On, SIGNAL(toggled(bool)), this, SIGNAL(glSettingsChanged())); |
| 91 | connect(&fGLMSAA16On, SIGNAL(toggled(bool)), this, SIGNAL(glSettingsChanged())); |
robertphillips@google.com | e8fe4bc | 2013-02-13 13:26:13 +0000 | [diff] [blame] | 92 | #endif |
chudy@google.com | ea5488b | 2012-07-26 19:38:22 +0000 | [diff] [blame] | 93 | |
robertphillips@google.com | 32bbcf8 | 2013-10-17 17:56:10 +0000 | [diff] [blame^] | 94 | { |
| 95 | // set up filter buttons |
| 96 | fFilterButtonGroup.setTitle("Filtering"); |
| 97 | fFilterButtonGroup.setMinimumWidth(178); |
| 98 | fFilterButtonGroup.setMaximumWidth(178); |
| 99 | |
| 100 | fFilterDefault.setText("As encoded"); |
| 101 | fFilterDefault.setChecked(true); |
| 102 | fFilterNone.setText("None"); |
| 103 | fFilterLow.setText("Low"); |
| 104 | fFilterMed.setText("Med"); |
| 105 | fFilterHigh.setText("High"); |
| 106 | |
| 107 | fFilterLayout.addWidget(&fFilterDefault); |
| 108 | fFilterLayout.addWidget(&fFilterNone); |
| 109 | fFilterLayout.addWidget(&fFilterLow); |
| 110 | fFilterLayout.addWidget(&fFilterMed); |
| 111 | fFilterLayout.addWidget(&fFilterHigh); |
| 112 | |
| 113 | fFilterButtonGroup.setLayout(&fFilterLayout); |
| 114 | |
| 115 | connect(&fFilterDefault, SIGNAL(toggled(bool)), this, SIGNAL(texFilterSettingsChanged())); |
| 116 | connect(&fFilterNone, SIGNAL(toggled(bool)), this, SIGNAL(texFilterSettingsChanged())); |
| 117 | connect(&fFilterLow, SIGNAL(toggled(bool)), this, SIGNAL(texFilterSettingsChanged())); |
| 118 | connect(&fFilterMed, SIGNAL(toggled(bool)), this, SIGNAL(texFilterSettingsChanged())); |
| 119 | connect(&fFilterHigh, SIGNAL(toggled(bool)), this, SIGNAL(texFilterSettingsChanged())); |
| 120 | } |
| 121 | |
chudy@google.com | ea5488b | 2012-07-26 19:38:22 +0000 | [diff] [blame] | 122 | fRasterLayout.addWidget(&fRasterLabel); |
| 123 | fRasterLayout.addWidget(&fRasterCheckBox); |
| 124 | |
robertphillips@google.com | f4741c1 | 2013-02-06 20:13:54 +0000 | [diff] [blame] | 125 | fOverdrawVizLayout.addWidget(&fOverdrawVizLabel); |
| 126 | fOverdrawVizLayout.addWidget(&fOverdrawVizCheckBox); |
| 127 | |
robertphillips@google.com | e8fe4bc | 2013-02-13 13:26:13 +0000 | [diff] [blame] | 128 | #if SK_SUPPORT_GPU |
chudy@google.com | ea5488b | 2012-07-26 19:38:22 +0000 | [diff] [blame] | 129 | fGLLayout.addWidget(&fGLLabel); |
| 130 | fGLLayout.addWidget(&fGLCheckBox); |
robertphillips@google.com | e8fe4bc | 2013-02-13 13:26:13 +0000 | [diff] [blame] | 131 | #endif |
chudy@google.com | ea5488b | 2012-07-26 19:38:22 +0000 | [diff] [blame] | 132 | |
| 133 | fCanvasLayout.setSpacing(6); |
| 134 | fCanvasLayout.setContentsMargins(11,11,11,11); |
chudy@google.com | ea5488b | 2012-07-26 19:38:22 +0000 | [diff] [blame] | 135 | fCanvasLayout.addLayout(&fRasterLayout); |
robertphillips@google.com | f4741c1 | 2013-02-06 20:13:54 +0000 | [diff] [blame] | 136 | fCanvasLayout.addLayout(&fOverdrawVizLayout); |
robertphillips@google.com | e8fe4bc | 2013-02-13 13:26:13 +0000 | [diff] [blame] | 137 | #if SK_SUPPORT_GPU |
chudy@google.com | ea5488b | 2012-07-26 19:38:22 +0000 | [diff] [blame] | 138 | fCanvasLayout.addLayout(&fGLLayout); |
commit-bot@chromium.org | fde1e7c | 2013-08-02 13:59:50 +0000 | [diff] [blame] | 139 | fCanvasLayout.addWidget(&fGLMSAAButtonGroup); |
robertphillips@google.com | e8fe4bc | 2013-02-13 13:26:13 +0000 | [diff] [blame] | 140 | #endif |
robertphillips@google.com | 32bbcf8 | 2013-10-17 17:56:10 +0000 | [diff] [blame^] | 141 | fCanvasLayout.addWidget(&fFilterButtonGroup); |
chudy@google.com | ea5488b | 2012-07-26 19:38:22 +0000 | [diff] [blame] | 142 | |
chudy@google.com | 7dcae67 | 2012-07-09 20:26:53 +0000 | [diff] [blame] | 143 | // Command Toggle |
| 144 | fCommandToggle.setText("Command Scrolling Preferences"); |
| 145 | fCommandFrame.setFrameShape(QFrame::StyledPanel); |
| 146 | fCommandFrame.setFrameShadow(QFrame::Raised); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 147 | |
chudy@google.com | 7dcae67 | 2012-07-09 20:26:53 +0000 | [diff] [blame] | 148 | fCurrentCommandLabel.setText("Current Command: "); |
| 149 | fCurrentCommandLabel.setMinimumWidth(178); |
| 150 | fCurrentCommandLabel.setMaximumWidth(178); |
| 151 | fCurrentCommandBox.setText("0"); |
| 152 | fCurrentCommandBox.setMinimumSize(QSize(50,25)); |
| 153 | fCurrentCommandBox.setMaximumSize(QSize(50,25)); |
| 154 | fCurrentCommandBox.setAlignment(Qt::AlignRight); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 155 | |
chudy@google.com | 7dcae67 | 2012-07-09 20:26:53 +0000 | [diff] [blame] | 156 | fCurrentCommandLayout.setSpacing(0); |
| 157 | fCurrentCommandLayout.setContentsMargins(0,0,0,0); |
| 158 | fCurrentCommandLayout.setAlignment(Qt::AlignLeft); |
| 159 | fCurrentCommandLayout.addWidget(&fCurrentCommandLabel); |
| 160 | fCurrentCommandLayout.addWidget(&fCurrentCommandBox); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 161 | |
chudy@google.com | e606d6e | 2012-07-12 14:31:25 +0000 | [diff] [blame] | 162 | fCommandHitLabel.setText("Command HitBox: "); |
| 163 | fCommandHitLabel.setMinimumWidth(178); |
| 164 | fCommandHitLabel.setMaximumWidth(178); |
| 165 | fCommandHitBox.setText("0"); |
| 166 | fCommandHitBox.setMinimumSize(QSize(50,25)); |
| 167 | fCommandHitBox.setMaximumSize(QSize(50,25)); |
| 168 | fCommandHitBox.setAlignment(Qt::AlignRight); |
| 169 | fCommandHitLayout.setSpacing(0); |
| 170 | fCommandHitLayout.setContentsMargins(0,0,0,0); |
| 171 | fCommandHitLayout.setAlignment(Qt::AlignLeft); |
| 172 | fCommandHitLayout.addWidget(&fCommandHitLabel); |
| 173 | fCommandHitLayout.addWidget(&fCommandHitBox); |
| 174 | |
chudy@google.com | 7dcae67 | 2012-07-09 20:26:53 +0000 | [diff] [blame] | 175 | fCommandLayout.setSpacing(6); |
| 176 | fCommandLayout.setContentsMargins(11,11,11,11); |
| 177 | fCommandLayout.addLayout(&fCurrentCommandLayout); |
chudy@google.com | e606d6e | 2012-07-12 14:31:25 +0000 | [diff] [blame] | 178 | fCommandLayout.addLayout(&fCommandHitLayout); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 179 | |
chudy@google.com | 7dcae67 | 2012-07-09 20:26:53 +0000 | [diff] [blame] | 180 | // Zoom Info |
| 181 | fZoomSetting.setText("Zoom Level: "); |
| 182 | fZoomSetting.setMinimumWidth(178); |
| 183 | fZoomSetting.setMaximumWidth(178); |
| 184 | fZoomFrame.setFrameShape(QFrame::StyledPanel); |
| 185 | fZoomFrame.setFrameShadow(QFrame::Raised); |
| 186 | fZoomBox.setText("100%"); |
| 187 | fZoomBox.setMinimumSize(QSize(50,25)); |
| 188 | fZoomBox.setMaximumSize(QSize(50,25)); |
| 189 | fZoomBox.setAlignment(Qt::AlignRight); |
| 190 | fZoomLayout.setSpacing(6); |
| 191 | fZoomLayout.setContentsMargins(11,11,11,11); |
| 192 | fZoomLayout.addWidget(&fZoomSetting); |
| 193 | fZoomLayout.addWidget(&fZoomBox); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 194 | |
chudy@google.com | 7dcae67 | 2012-07-09 20:26:53 +0000 | [diff] [blame] | 195 | // Adds all widgets to settings container |
| 196 | fVerticalLayout.addWidget(&fVisibileText); |
| 197 | fVerticalLayout.addWidget(&fVisibleFrame); |
| 198 | fVerticalLayout.addWidget(&fCommandToggle); |
| 199 | fVerticalLayout.addWidget(&fCommandFrame); |
chudy@google.com | ea5488b | 2012-07-26 19:38:22 +0000 | [diff] [blame] | 200 | fVerticalLayout.addWidget(&fCanvasToggle); |
| 201 | fVerticalLayout.addWidget(&fCanvasFrame); |
chudy@google.com | 7dcae67 | 2012-07-09 20:26:53 +0000 | [diff] [blame] | 202 | fVerticalLayout.addWidget(&fZoomFrame); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 203 | |
chudy@google.com | e606d6e | 2012-07-12 14:31:25 +0000 | [diff] [blame] | 204 | this->setDisabled(true); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 205 | } |
| 206 | |
chudy@google.com | 7dcae67 | 2012-07-09 20:26:53 +0000 | [diff] [blame] | 207 | |
| 208 | void SkSettingsWidget::updateCommand(int newCommand) { |
| 209 | fCurrentCommandBox.setText(QString::number(newCommand)); |
| 210 | } |
| 211 | |
chudy@google.com | e606d6e | 2012-07-12 14:31:25 +0000 | [diff] [blame] | 212 | void SkSettingsWidget::updateHit(int newHit) { |
| 213 | fCommandHitBox.setText(QString::number(newHit)); |
| 214 | } |
| 215 | |
chudy@google.com | 7dcae67 | 2012-07-09 20:26:53 +0000 | [diff] [blame] | 216 | QRadioButton* SkSettingsWidget::getVisibilityButton() { |
| 217 | return &fVisibleOn; |
| 218 | } |
| 219 | |
bungeman@google.com | e8cc6e8 | 2013-01-17 16:30:56 +0000 | [diff] [blame] | 220 | void SkSettingsWidget::setZoomText(float scale) { |
| 221 | fZoomBox.setText(QString::number(scale*100, 'f', 0).append("%")); |
chudy@google.com | 7dcae67 | 2012-07-09 20:26:53 +0000 | [diff] [blame] | 222 | } |