2012-06-29 14:21:22 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright 2012 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#include "SkSettingsWidget.h"
|
2012-07-09 20:26:53 +00:00
|
|
|
#include <iostream>
|
|
|
|
#include <math.h>
|
|
|
|
|
2012-07-26 19:38:22 +00:00
|
|
|
// TODO(chudy): See if the layout can't be attached to the frame post construction.
|
2012-07-31 12:49:52 +00:00
|
|
|
SkSettingsWidget::SkSettingsWidget() : QWidget()
|
2012-07-09 20:26:53 +00:00
|
|
|
, mainFrameLayout(this)
|
|
|
|
, fVerticalLayout(&mainFrame)
|
|
|
|
, fVisibleFrameLayout(&fVisibleFrame)
|
|
|
|
, fVisibleOn(&fVisibleFrame)
|
|
|
|
, fVisibleOff(&fVisibleFrame)
|
|
|
|
, fCommandLayout(&fCommandFrame)
|
|
|
|
, fCurrentCommandBox(&fCommandFrame)
|
2012-07-12 14:31:25 +00:00
|
|
|
, fCommandHitBox(&fCommandFrame)
|
2012-07-26 19:38:22 +00:00
|
|
|
, fCanvasLayout(&fCanvasFrame)
|
2012-07-09 20:26:53 +00:00
|
|
|
, fZoomLayout(&fZoomFrame)
|
2012-07-31 12:49:52 +00:00
|
|
|
, fZoomBox(&fZoomFrame)
|
2012-07-09 20:26:53 +00:00
|
|
|
{
|
|
|
|
// Sets up the container and it's alignment around the settings widget.
|
|
|
|
mainFrame.setFrameShape(QFrame::StyledPanel);
|
|
|
|
mainFrame.setFrameShadow(QFrame::Raised);
|
|
|
|
mainFrameLayout.setSpacing(6);
|
|
|
|
mainFrameLayout.setContentsMargins(0,0,0,0);
|
|
|
|
mainFrameLayout.addWidget(&mainFrame);
|
|
|
|
|
|
|
|
// Vertical Layout is the alignment inside of the main frame.
|
|
|
|
fVerticalLayout.setContentsMargins(11,11,11,11);
|
|
|
|
fVerticalLayout.setAlignment(Qt::AlignTop);
|
|
|
|
|
|
|
|
// Visible Toggle
|
|
|
|
fVisibileText.setText("Visibility Filter");
|
|
|
|
fVisibleFrame.setFrameShape(QFrame::StyledPanel);
|
|
|
|
fVisibleFrame.setFrameShadow(QFrame::Raised);
|
|
|
|
fVisibleOn.setText("On");
|
|
|
|
fVisibleOff.setText("Off");
|
|
|
|
fVisibleOff.setChecked(true);
|
|
|
|
fVisibleFrameLayout.setSpacing(6);
|
|
|
|
fVisibleFrameLayout.setContentsMargins(11,11,11,11);
|
|
|
|
fVisibleFrameLayout.addWidget(&fVisibleOn);
|
|
|
|
fVisibleFrameLayout.addWidget(&fVisibleOff);
|
|
|
|
|
2012-07-26 19:38:22 +00:00
|
|
|
// Canvas
|
|
|
|
fCanvasToggle.setText("Render Targets");
|
|
|
|
fCanvasFrame.setFrameShape(QFrame::StyledPanel);
|
|
|
|
fCanvasFrame.setFrameShadow(QFrame::Raised);
|
|
|
|
|
|
|
|
fRasterLabel.setText("Raster: ");
|
|
|
|
fRasterLabel.setMinimumWidth(178);
|
|
|
|
fRasterLabel.setMaximumWidth(178);
|
|
|
|
|
|
|
|
fRasterCheckBox.setChecked(true);
|
|
|
|
|
|
|
|
fGLLabel.setText("OpenGL: ");
|
|
|
|
fGLLabel.setMinimumWidth(178);
|
|
|
|
fGLLabel.setMaximumWidth(178);
|
|
|
|
|
|
|
|
fRasterLayout.addWidget(&fRasterLabel);
|
|
|
|
fRasterLayout.addWidget(&fRasterCheckBox);
|
|
|
|
|
|
|
|
fGLLayout.addWidget(&fGLLabel);
|
|
|
|
fGLLayout.addWidget(&fGLCheckBox);
|
|
|
|
|
|
|
|
fCanvasLayout.setSpacing(6);
|
|
|
|
fCanvasLayout.setContentsMargins(11,11,11,11);
|
|
|
|
fCanvasLayout.addLayout(&fRasterLayout);
|
|
|
|
fCanvasLayout.addLayout(&fGLLayout);
|
|
|
|
|
2012-07-09 20:26:53 +00:00
|
|
|
// Command Toggle
|
|
|
|
fCommandToggle.setText("Command Scrolling Preferences");
|
|
|
|
fCommandFrame.setFrameShape(QFrame::StyledPanel);
|
|
|
|
fCommandFrame.setFrameShadow(QFrame::Raised);
|
|
|
|
|
|
|
|
fCurrentCommandLabel.setText("Current Command: ");
|
|
|
|
fCurrentCommandLabel.setMinimumWidth(178);
|
|
|
|
fCurrentCommandLabel.setMaximumWidth(178);
|
|
|
|
fCurrentCommandBox.setText("0");
|
|
|
|
fCurrentCommandBox.setMinimumSize(QSize(50,25));
|
|
|
|
fCurrentCommandBox.setMaximumSize(QSize(50,25));
|
|
|
|
fCurrentCommandBox.setAlignment(Qt::AlignRight);
|
|
|
|
|
|
|
|
fCurrentCommandLayout.setSpacing(0);
|
|
|
|
fCurrentCommandLayout.setContentsMargins(0,0,0,0);
|
|
|
|
fCurrentCommandLayout.setAlignment(Qt::AlignLeft);
|
|
|
|
fCurrentCommandLayout.addWidget(&fCurrentCommandLabel);
|
|
|
|
fCurrentCommandLayout.addWidget(&fCurrentCommandBox);
|
|
|
|
|
2012-07-12 14:31:25 +00:00
|
|
|
fCommandHitLabel.setText("Command HitBox: ");
|
|
|
|
fCommandHitLabel.setMinimumWidth(178);
|
|
|
|
fCommandHitLabel.setMaximumWidth(178);
|
|
|
|
fCommandHitBox.setText("0");
|
|
|
|
fCommandHitBox.setMinimumSize(QSize(50,25));
|
|
|
|
fCommandHitBox.setMaximumSize(QSize(50,25));
|
|
|
|
fCommandHitBox.setAlignment(Qt::AlignRight);
|
|
|
|
fCommandHitLayout.setSpacing(0);
|
|
|
|
fCommandHitLayout.setContentsMargins(0,0,0,0);
|
|
|
|
fCommandHitLayout.setAlignment(Qt::AlignLeft);
|
|
|
|
fCommandHitLayout.addWidget(&fCommandHitLabel);
|
|
|
|
fCommandHitLayout.addWidget(&fCommandHitBox);
|
|
|
|
|
2012-07-09 20:26:53 +00:00
|
|
|
fCommandLayout.setSpacing(6);
|
|
|
|
fCommandLayout.setContentsMargins(11,11,11,11);
|
|
|
|
fCommandLayout.addLayout(&fCurrentCommandLayout);
|
2012-07-12 14:31:25 +00:00
|
|
|
fCommandLayout.addLayout(&fCommandHitLayout);
|
2012-07-09 20:26:53 +00:00
|
|
|
|
|
|
|
// Zoom Info
|
|
|
|
fZoomSetting.setText("Zoom Level: ");
|
|
|
|
fZoomSetting.setMinimumWidth(178);
|
|
|
|
fZoomSetting.setMaximumWidth(178);
|
|
|
|
fZoomFrame.setFrameShape(QFrame::StyledPanel);
|
|
|
|
fZoomFrame.setFrameShadow(QFrame::Raised);
|
|
|
|
fZoomBox.setText("100%");
|
|
|
|
fZoomBox.setMinimumSize(QSize(50,25));
|
|
|
|
fZoomBox.setMaximumSize(QSize(50,25));
|
|
|
|
fZoomBox.setAlignment(Qt::AlignRight);
|
|
|
|
fZoomLayout.setSpacing(6);
|
|
|
|
fZoomLayout.setContentsMargins(11,11,11,11);
|
|
|
|
fZoomLayout.addWidget(&fZoomSetting);
|
|
|
|
fZoomLayout.addWidget(&fZoomBox);
|
|
|
|
|
|
|
|
// Adds all widgets to settings container
|
|
|
|
fVerticalLayout.addWidget(&fVisibileText);
|
|
|
|
fVerticalLayout.addWidget(&fVisibleFrame);
|
|
|
|
fVerticalLayout.addWidget(&fCommandToggle);
|
|
|
|
fVerticalLayout.addWidget(&fCommandFrame);
|
2012-07-26 19:38:22 +00:00
|
|
|
fVerticalLayout.addWidget(&fCanvasToggle);
|
|
|
|
fVerticalLayout.addWidget(&fCanvasFrame);
|
2012-07-09 20:26:53 +00:00
|
|
|
fVerticalLayout.addWidget(&fZoomFrame);
|
|
|
|
|
2012-07-12 14:31:25 +00:00
|
|
|
this->setDisabled(true);
|
2012-07-09 20:26:53 +00:00
|
|
|
}
|
2012-06-29 14:21:22 +00:00
|
|
|
|
|
|
|
|
2012-07-09 20:26:53 +00:00
|
|
|
void SkSettingsWidget::updateCommand(int newCommand) {
|
|
|
|
fCurrentCommandBox.setText(QString::number(newCommand));
|
|
|
|
}
|
2012-06-29 14:21:22 +00:00
|
|
|
|
2012-07-12 14:31:25 +00:00
|
|
|
void SkSettingsWidget::updateHit(int newHit) {
|
|
|
|
fCommandHitBox.setText(QString::number(newHit));
|
|
|
|
}
|
|
|
|
|
2012-07-09 20:26:53 +00:00
|
|
|
QRadioButton* SkSettingsWidget::getVisibilityButton() {
|
|
|
|
return &fVisibleOn;
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
2012-07-09 20:26:53 +00:00
|
|
|
void SkSettingsWidget::setZoomText(int scaleFactor) {
|
|
|
|
if(scaleFactor == 1 || scaleFactor == -1) {
|
|
|
|
fZoomBox.setText("100%");
|
|
|
|
} else if (scaleFactor > 1) {
|
|
|
|
fZoomBox.setText(QString::number(scaleFactor*100).append("%"));
|
|
|
|
} else if (scaleFactor < -1) {
|
|
|
|
fZoomBox.setText(QString::number(100 / pow(2, (-scaleFactor - 1))).append("%"));
|
|
|
|
}
|
|
|
|
}
|