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