blob: 09196fbc5e190c8b11b438f185643641e4a33524 [file] [log] [blame]
chudy@google.com902ebe52012-06-29 14:21:22 +00001
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.com7dcae672012-07-09 20:26:53 +000011#include <iostream>
12#include <math.h>
chudy@google.com902ebe52012-06-29 14:21:22 +000013
chudy@google.comea5488b2012-07-26 19:38:22 +000014// TODO(chudy): See if the layout can't be attached to the frame post construction.
chudy@google.com2d537a12012-07-31 12:49:52 +000015SkSettingsWidget::SkSettingsWidget() : QWidget()
chudy@google.com7dcae672012-07-09 20:26:53 +000016 , mainFrameLayout(this)
17 , fVerticalLayout(&mainFrame)
18 , fVisibleFrameLayout(&fVisibleFrame)
19 , fVisibleOn(&fVisibleFrame)
20 , fVisibleOff(&fVisibleFrame)
21 , fCommandLayout(&fCommandFrame)
22 , fCurrentCommandBox(&fCommandFrame)
chudy@google.come606d6e2012-07-12 14:31:25 +000023 , fCommandHitBox(&fCommandFrame)
chudy@google.comea5488b2012-07-26 19:38:22 +000024 , fCanvasLayout(&fCanvasFrame)
chudy@google.com7dcae672012-07-09 20:26:53 +000025 , fZoomLayout(&fZoomFrame)
chudy@google.com2d537a12012-07-31 12:49:52 +000026 , fZoomBox(&fZoomFrame)
chudy@google.com7dcae672012-07-09 20:26:53 +000027{
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.com902ebe52012-06-29 14:21:22 +000034
chudy@google.com7dcae672012-07-09 20:26:53 +000035 // Vertical Layout is the alignment inside of the main frame.
36 fVerticalLayout.setContentsMargins(11,11,11,11);
37 fVerticalLayout.setAlignment(Qt::AlignTop);
chudy@google.com902ebe52012-06-29 14:21:22 +000038
chudy@google.com7dcae672012-07-09 20:26:53 +000039 // 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.com902ebe52012-06-29 14:21:22 +000050
chudy@google.comea5488b2012-07-26 19:38:22 +000051 // 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.comf4741c12013-02-06 20:13:54 +000062 fOverdrawVizLabel.setText(" Overdraw Viz: ");
63 fOverdrawVizLabel.setMinimumWidth(178);
64 fOverdrawVizLabel.setMaximumWidth(178);
65
chudy@google.comea5488b2012-07-26 19:38:22 +000066 fGLLabel.setText("OpenGL: ");
67 fGLLabel.setMinimumWidth(178);
68 fGLLabel.setMaximumWidth(178);
69
70 fRasterLayout.addWidget(&fRasterLabel);
71 fRasterLayout.addWidget(&fRasterCheckBox);
72
robertphillips@google.comf4741c12013-02-06 20:13:54 +000073 fOverdrawVizLayout.addWidget(&fOverdrawVizLabel);
74 fOverdrawVizLayout.addWidget(&fOverdrawVizCheckBox);
75
chudy@google.comea5488b2012-07-26 19:38:22 +000076 fGLLayout.addWidget(&fGLLabel);
77 fGLLayout.addWidget(&fGLCheckBox);
78
79 fCanvasLayout.setSpacing(6);
80 fCanvasLayout.setContentsMargins(11,11,11,11);
chudy@google.comea5488b2012-07-26 19:38:22 +000081 fCanvasLayout.addLayout(&fRasterLayout);
robertphillips@google.comf4741c12013-02-06 20:13:54 +000082 fCanvasLayout.addLayout(&fOverdrawVizLayout);
chudy@google.comea5488b2012-07-26 19:38:22 +000083 fCanvasLayout.addLayout(&fGLLayout);
84
chudy@google.com7dcae672012-07-09 20:26:53 +000085 // Command Toggle
86 fCommandToggle.setText("Command Scrolling Preferences");
87 fCommandFrame.setFrameShape(QFrame::StyledPanel);
88 fCommandFrame.setFrameShadow(QFrame::Raised);
chudy@google.com902ebe52012-06-29 14:21:22 +000089
chudy@google.com7dcae672012-07-09 20:26:53 +000090 fCurrentCommandLabel.setText("Current Command: ");
91 fCurrentCommandLabel.setMinimumWidth(178);
92 fCurrentCommandLabel.setMaximumWidth(178);
93 fCurrentCommandBox.setText("0");
94 fCurrentCommandBox.setMinimumSize(QSize(50,25));
95 fCurrentCommandBox.setMaximumSize(QSize(50,25));
96 fCurrentCommandBox.setAlignment(Qt::AlignRight);
chudy@google.com902ebe52012-06-29 14:21:22 +000097
chudy@google.com7dcae672012-07-09 20:26:53 +000098 fCurrentCommandLayout.setSpacing(0);
99 fCurrentCommandLayout.setContentsMargins(0,0,0,0);
100 fCurrentCommandLayout.setAlignment(Qt::AlignLeft);
101 fCurrentCommandLayout.addWidget(&fCurrentCommandLabel);
102 fCurrentCommandLayout.addWidget(&fCurrentCommandBox);
chudy@google.com902ebe52012-06-29 14:21:22 +0000103
chudy@google.come606d6e2012-07-12 14:31:25 +0000104 fCommandHitLabel.setText("Command HitBox: ");
105 fCommandHitLabel.setMinimumWidth(178);
106 fCommandHitLabel.setMaximumWidth(178);
107 fCommandHitBox.setText("0");
108 fCommandHitBox.setMinimumSize(QSize(50,25));
109 fCommandHitBox.setMaximumSize(QSize(50,25));
110 fCommandHitBox.setAlignment(Qt::AlignRight);
111 fCommandHitLayout.setSpacing(0);
112 fCommandHitLayout.setContentsMargins(0,0,0,0);
113 fCommandHitLayout.setAlignment(Qt::AlignLeft);
114 fCommandHitLayout.addWidget(&fCommandHitLabel);
115 fCommandHitLayout.addWidget(&fCommandHitBox);
116
chudy@google.com7dcae672012-07-09 20:26:53 +0000117 fCommandLayout.setSpacing(6);
118 fCommandLayout.setContentsMargins(11,11,11,11);
119 fCommandLayout.addLayout(&fCurrentCommandLayout);
chudy@google.come606d6e2012-07-12 14:31:25 +0000120 fCommandLayout.addLayout(&fCommandHitLayout);
chudy@google.com902ebe52012-06-29 14:21:22 +0000121
chudy@google.com7dcae672012-07-09 20:26:53 +0000122 // Zoom Info
123 fZoomSetting.setText("Zoom Level: ");
124 fZoomSetting.setMinimumWidth(178);
125 fZoomSetting.setMaximumWidth(178);
126 fZoomFrame.setFrameShape(QFrame::StyledPanel);
127 fZoomFrame.setFrameShadow(QFrame::Raised);
128 fZoomBox.setText("100%");
129 fZoomBox.setMinimumSize(QSize(50,25));
130 fZoomBox.setMaximumSize(QSize(50,25));
131 fZoomBox.setAlignment(Qt::AlignRight);
132 fZoomLayout.setSpacing(6);
133 fZoomLayout.setContentsMargins(11,11,11,11);
134 fZoomLayout.addWidget(&fZoomSetting);
135 fZoomLayout.addWidget(&fZoomBox);
chudy@google.com902ebe52012-06-29 14:21:22 +0000136
chudy@google.com7dcae672012-07-09 20:26:53 +0000137 // Adds all widgets to settings container
138 fVerticalLayout.addWidget(&fVisibileText);
139 fVerticalLayout.addWidget(&fVisibleFrame);
140 fVerticalLayout.addWidget(&fCommandToggle);
141 fVerticalLayout.addWidget(&fCommandFrame);
chudy@google.comea5488b2012-07-26 19:38:22 +0000142 fVerticalLayout.addWidget(&fCanvasToggle);
143 fVerticalLayout.addWidget(&fCanvasFrame);
chudy@google.com7dcae672012-07-09 20:26:53 +0000144 fVerticalLayout.addWidget(&fZoomFrame);
chudy@google.com902ebe52012-06-29 14:21:22 +0000145
chudy@google.come606d6e2012-07-12 14:31:25 +0000146 this->setDisabled(true);
chudy@google.com902ebe52012-06-29 14:21:22 +0000147}
148
chudy@google.com7dcae672012-07-09 20:26:53 +0000149
150void SkSettingsWidget::updateCommand(int newCommand) {
151 fCurrentCommandBox.setText(QString::number(newCommand));
152}
153
chudy@google.come606d6e2012-07-12 14:31:25 +0000154void SkSettingsWidget::updateHit(int newHit) {
155 fCommandHitBox.setText(QString::number(newHit));
156}
157
chudy@google.com7dcae672012-07-09 20:26:53 +0000158QRadioButton* SkSettingsWidget::getVisibilityButton() {
159 return &fVisibleOn;
160}
161
bungeman@google.come8cc6e82013-01-17 16:30:56 +0000162void SkSettingsWidget::setZoomText(float scale) {
163 fZoomBox.setText(QString::number(scale*100, 'f', 0).append("%"));
chudy@google.com7dcae672012-07-09 20:26:53 +0000164}