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 | |
robertphillips@google.com | e8fe4bc | 2013-02-13 13:26:13 +0000 | [diff] [blame] | 65 | #if SK_SUPPORT_GPU |
chudy@google.com | ea5488b | 2012-07-26 19:38:22 +0000 | [diff] [blame] | 66 | fGLLabel.setText("OpenGL: "); |
| 67 | fGLLabel.setMinimumWidth(178); |
| 68 | fGLLabel.setMaximumWidth(178); |
commit-bot@chromium.org | fde1e7c | 2013-08-02 13:59:50 +0000 | [diff] [blame] | 69 | |
| 70 | fGLMSAAButtonGroup.setTitle("MSAA"); |
| 71 | fGLMSAAButtonGroup.setMinimumWidth(178); |
| 72 | fGLMSAAButtonGroup.setMaximumWidth(178); |
| 73 | fGLMSAAButtonGroup.setEnabled(fGLCheckBox.isChecked()); |
| 74 | |
commit-bot@chromium.org | 22d3933 | 2013-11-21 15:37:29 +0000 | [diff] [blame] | 75 | fGLMSAACombo.addItem("Off", QVariant(0)); |
| 76 | fGLMSAACombo.addItem("4", QVariant(4)); |
| 77 | fGLMSAACombo.addItem("16", QVariant(16)); |
commit-bot@chromium.org | fde1e7c | 2013-08-02 13:59:50 +0000 | [diff] [blame] | 78 | |
commit-bot@chromium.org | 22d3933 | 2013-11-21 15:37:29 +0000 | [diff] [blame] | 79 | fGLMSAALayout.addWidget(&fGLMSAACombo); |
commit-bot@chromium.org | fde1e7c | 2013-08-02 13:59:50 +0000 | [diff] [blame] | 80 | fGLMSAAButtonGroup.setLayout(&fGLMSAALayout); |
| 81 | |
commit-bot@chromium.org | 22d3933 | 2013-11-21 15:37:29 +0000 | [diff] [blame] | 82 | connect(&fGLCheckBox, SIGNAL(toggled(bool)), &fGLMSAAButtonGroup, |
| 83 | SLOT(setEnabled(bool))); |
| 84 | connect(&fGLCheckBox, SIGNAL(toggled(bool)), this, |
| 85 | SIGNAL(glSettingsChanged())); |
| 86 | connect(&fGLMSAACombo, SIGNAL(activated(int)), this, |
| 87 | SIGNAL(glSettingsChanged())); |
robertphillips@google.com | e8fe4bc | 2013-02-13 13:26:13 +0000 | [diff] [blame] | 88 | #endif |
chudy@google.com | ea5488b | 2012-07-26 19:38:22 +0000 | [diff] [blame] | 89 | |
robertphillips@google.com | 32bbcf8 | 2013-10-17 17:56:10 +0000 | [diff] [blame] | 90 | { |
| 91 | // set up filter buttons |
| 92 | fFilterButtonGroup.setTitle("Filtering"); |
| 93 | fFilterButtonGroup.setMinimumWidth(178); |
| 94 | fFilterButtonGroup.setMaximumWidth(178); |
| 95 | |
commit-bot@chromium.org | 22d3933 | 2013-11-21 15:37:29 +0000 | [diff] [blame] | 96 | fFilterCombo.addItem("As encoded", QVariant(SkPaint::kNone_FilterLevel)); |
| 97 | fFilterCombo.addItem("None", QVariant(SkPaint::kNone_FilterLevel)); |
| 98 | fFilterCombo.addItem("Low", QVariant(SkPaint::kLow_FilterLevel)); |
| 99 | fFilterCombo.addItem("Medium", QVariant(SkPaint::kMedium_FilterLevel)); |
| 100 | fFilterCombo.addItem("High", QVariant(SkPaint::kHigh_FilterLevel)); |
robertphillips@google.com | 32bbcf8 | 2013-10-17 17:56:10 +0000 | [diff] [blame] | 101 | |
commit-bot@chromium.org | 22d3933 | 2013-11-21 15:37:29 +0000 | [diff] [blame] | 102 | fFilterLayout.addWidget(&fFilterCombo); |
robertphillips@google.com | 32bbcf8 | 2013-10-17 17:56:10 +0000 | [diff] [blame] | 103 | fFilterButtonGroup.setLayout(&fFilterLayout); |
| 104 | |
commit-bot@chromium.org | 22d3933 | 2013-11-21 15:37:29 +0000 | [diff] [blame] | 105 | connect(&fFilterCombo, SIGNAL(activated(int)), this, |
| 106 | SIGNAL(texFilterSettingsChanged())); |
robertphillips@google.com | 32bbcf8 | 2013-10-17 17:56:10 +0000 | [diff] [blame] | 107 | } |
| 108 | |
chudy@google.com | ea5488b | 2012-07-26 19:38:22 +0000 | [diff] [blame] | 109 | fRasterLayout.addWidget(&fRasterLabel); |
| 110 | fRasterLayout.addWidget(&fRasterCheckBox); |
| 111 | |
robertphillips@google.com | f4741c1 | 2013-02-06 20:13:54 +0000 | [diff] [blame] | 112 | fOverdrawVizLayout.addWidget(&fOverdrawVizLabel); |
| 113 | fOverdrawVizLayout.addWidget(&fOverdrawVizCheckBox); |
| 114 | |
robertphillips@google.com | e8fe4bc | 2013-02-13 13:26:13 +0000 | [diff] [blame] | 115 | #if SK_SUPPORT_GPU |
chudy@google.com | ea5488b | 2012-07-26 19:38:22 +0000 | [diff] [blame] | 116 | fGLLayout.addWidget(&fGLLabel); |
| 117 | fGLLayout.addWidget(&fGLCheckBox); |
robertphillips@google.com | e8fe4bc | 2013-02-13 13:26:13 +0000 | [diff] [blame] | 118 | #endif |
chudy@google.com | ea5488b | 2012-07-26 19:38:22 +0000 | [diff] [blame] | 119 | |
| 120 | fCanvasLayout.setSpacing(6); |
| 121 | fCanvasLayout.setContentsMargins(11,11,11,11); |
chudy@google.com | ea5488b | 2012-07-26 19:38:22 +0000 | [diff] [blame] | 122 | fCanvasLayout.addLayout(&fRasterLayout); |
robertphillips@google.com | f4741c1 | 2013-02-06 20:13:54 +0000 | [diff] [blame] | 123 | fCanvasLayout.addLayout(&fOverdrawVizLayout); |
robertphillips@google.com | e8fe4bc | 2013-02-13 13:26:13 +0000 | [diff] [blame] | 124 | #if SK_SUPPORT_GPU |
chudy@google.com | ea5488b | 2012-07-26 19:38:22 +0000 | [diff] [blame] | 125 | fCanvasLayout.addLayout(&fGLLayout); |
commit-bot@chromium.org | fde1e7c | 2013-08-02 13:59:50 +0000 | [diff] [blame] | 126 | fCanvasLayout.addWidget(&fGLMSAAButtonGroup); |
robertphillips@google.com | e8fe4bc | 2013-02-13 13:26:13 +0000 | [diff] [blame] | 127 | #endif |
robertphillips@google.com | 32bbcf8 | 2013-10-17 17:56:10 +0000 | [diff] [blame] | 128 | fCanvasLayout.addWidget(&fFilterButtonGroup); |
chudy@google.com | ea5488b | 2012-07-26 19:38:22 +0000 | [diff] [blame] | 129 | |
chudy@google.com | 7dcae67 | 2012-07-09 20:26:53 +0000 | [diff] [blame] | 130 | // Command Toggle |
| 131 | fCommandToggle.setText("Command Scrolling Preferences"); |
| 132 | fCommandFrame.setFrameShape(QFrame::StyledPanel); |
| 133 | fCommandFrame.setFrameShadow(QFrame::Raised); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 134 | |
chudy@google.com | 7dcae67 | 2012-07-09 20:26:53 +0000 | [diff] [blame] | 135 | fCurrentCommandLabel.setText("Current Command: "); |
| 136 | fCurrentCommandLabel.setMinimumWidth(178); |
| 137 | fCurrentCommandLabel.setMaximumWidth(178); |
| 138 | fCurrentCommandBox.setText("0"); |
| 139 | fCurrentCommandBox.setMinimumSize(QSize(50,25)); |
| 140 | fCurrentCommandBox.setMaximumSize(QSize(50,25)); |
| 141 | fCurrentCommandBox.setAlignment(Qt::AlignRight); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 142 | |
chudy@google.com | 7dcae67 | 2012-07-09 20:26:53 +0000 | [diff] [blame] | 143 | fCurrentCommandLayout.setSpacing(0); |
| 144 | fCurrentCommandLayout.setContentsMargins(0,0,0,0); |
| 145 | fCurrentCommandLayout.setAlignment(Qt::AlignLeft); |
| 146 | fCurrentCommandLayout.addWidget(&fCurrentCommandLabel); |
| 147 | fCurrentCommandLayout.addWidget(&fCurrentCommandBox); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 148 | |
chudy@google.com | e606d6e | 2012-07-12 14:31:25 +0000 | [diff] [blame] | 149 | fCommandHitLabel.setText("Command HitBox: "); |
| 150 | fCommandHitLabel.setMinimumWidth(178); |
| 151 | fCommandHitLabel.setMaximumWidth(178); |
| 152 | fCommandHitBox.setText("0"); |
| 153 | fCommandHitBox.setMinimumSize(QSize(50,25)); |
| 154 | fCommandHitBox.setMaximumSize(QSize(50,25)); |
| 155 | fCommandHitBox.setAlignment(Qt::AlignRight); |
| 156 | fCommandHitLayout.setSpacing(0); |
| 157 | fCommandHitLayout.setContentsMargins(0,0,0,0); |
| 158 | fCommandHitLayout.setAlignment(Qt::AlignLeft); |
| 159 | fCommandHitLayout.addWidget(&fCommandHitLabel); |
| 160 | fCommandHitLayout.addWidget(&fCommandHitBox); |
| 161 | |
chudy@google.com | 7dcae67 | 2012-07-09 20:26:53 +0000 | [diff] [blame] | 162 | fCommandLayout.setSpacing(6); |
| 163 | fCommandLayout.setContentsMargins(11,11,11,11); |
| 164 | fCommandLayout.addLayout(&fCurrentCommandLayout); |
chudy@google.com | e606d6e | 2012-07-12 14:31:25 +0000 | [diff] [blame] | 165 | fCommandLayout.addLayout(&fCommandHitLayout); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 166 | |
chudy@google.com | 7dcae67 | 2012-07-09 20:26:53 +0000 | [diff] [blame] | 167 | // Zoom Info |
| 168 | fZoomSetting.setText("Zoom Level: "); |
| 169 | fZoomSetting.setMinimumWidth(178); |
| 170 | fZoomSetting.setMaximumWidth(178); |
| 171 | fZoomFrame.setFrameShape(QFrame::StyledPanel); |
| 172 | fZoomFrame.setFrameShadow(QFrame::Raised); |
| 173 | fZoomBox.setText("100%"); |
| 174 | fZoomBox.setMinimumSize(QSize(50,25)); |
| 175 | fZoomBox.setMaximumSize(QSize(50,25)); |
| 176 | fZoomBox.setAlignment(Qt::AlignRight); |
| 177 | fZoomLayout.setSpacing(6); |
| 178 | fZoomLayout.setContentsMargins(11,11,11,11); |
| 179 | fZoomLayout.addWidget(&fZoomSetting); |
| 180 | fZoomLayout.addWidget(&fZoomBox); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 181 | |
chudy@google.com | 7dcae67 | 2012-07-09 20:26:53 +0000 | [diff] [blame] | 182 | // Adds all widgets to settings container |
commit-bot@chromium.org | 22d3933 | 2013-11-21 15:37:29 +0000 | [diff] [blame] | 183 | fVerticalLayout.addWidget(&fVisibleText); |
chudy@google.com | 7dcae67 | 2012-07-09 20:26:53 +0000 | [diff] [blame] | 184 | fVerticalLayout.addWidget(&fVisibleFrame); |
| 185 | fVerticalLayout.addWidget(&fCommandToggle); |
| 186 | fVerticalLayout.addWidget(&fCommandFrame); |
chudy@google.com | ea5488b | 2012-07-26 19:38:22 +0000 | [diff] [blame] | 187 | fVerticalLayout.addWidget(&fCanvasToggle); |
| 188 | fVerticalLayout.addWidget(&fCanvasFrame); |
chudy@google.com | 7dcae67 | 2012-07-09 20:26:53 +0000 | [diff] [blame] | 189 | fVerticalLayout.addWidget(&fZoomFrame); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 190 | |
chudy@google.com | e606d6e | 2012-07-12 14:31:25 +0000 | [diff] [blame] | 191 | this->setDisabled(true); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 192 | } |
| 193 | |
chudy@google.com | 7dcae67 | 2012-07-09 20:26:53 +0000 | [diff] [blame] | 194 | |
| 195 | void SkSettingsWidget::updateCommand(int newCommand) { |
| 196 | fCurrentCommandBox.setText(QString::number(newCommand)); |
| 197 | } |
| 198 | |
chudy@google.com | e606d6e | 2012-07-12 14:31:25 +0000 | [diff] [blame] | 199 | void SkSettingsWidget::updateHit(int newHit) { |
| 200 | fCommandHitBox.setText(QString::number(newHit)); |
| 201 | } |
| 202 | |
bungeman@google.com | e8cc6e8 | 2013-01-17 16:30:56 +0000 | [diff] [blame] | 203 | void SkSettingsWidget::setZoomText(float scale) { |
| 204 | fZoomBox.setText(QString::number(scale*100, 'f', 0).append("%")); |
chudy@google.com | 7dcae67 | 2012-07-09 20:26:53 +0000 | [diff] [blame] | 205 | } |