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)
|
|
|
|
, 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
|
2013-11-21 15:37:29 +00:00
|
|
|
fVisibleText.setText("Visibility Filter");
|
2012-07-09 20:26:53 +00:00
|
|
|
fVisibleFrame.setFrameShape(QFrame::StyledPanel);
|
|
|
|
fVisibleFrame.setFrameShadow(QFrame::Raised);
|
2013-11-21 15:37:29 +00:00
|
|
|
|
|
|
|
fVisibilityCombo.addItem("Off", QVariant(false));
|
|
|
|
fVisibilityCombo.addItem("On", QVariant(true));
|
|
|
|
|
|
|
|
fVisibleFrameLayout.setContentsMargins(11, 5, 11, 5);
|
|
|
|
fVisibleFrameLayout.addWidget(&fVisibilityCombo);
|
|
|
|
connect(&fVisibilityCombo, SIGNAL(activated(int)), this,
|
|
|
|
SIGNAL(visibilityFilterChanged()));
|
2012-07-09 20:26:53 +00:00
|
|
|
|
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);
|
|
|
|
|
2014-05-19 13:53:10 +00:00
|
|
|
fPathOpsLabel.setText("PathOps: ");
|
|
|
|
fPathOpsLabel.setMinimumWidth(178);
|
|
|
|
fPathOpsLabel.setMaximumWidth(178);
|
|
|
|
|
2012-07-26 19:38:22 +00:00
|
|
|
fRasterCheckBox.setChecked(true);
|
|
|
|
|
2013-02-06 20:13:54 +00:00
|
|
|
fOverdrawVizLabel.setText(" Overdraw Viz: ");
|
|
|
|
fOverdrawVizLabel.setMinimumWidth(178);
|
|
|
|
fOverdrawVizLabel.setMaximumWidth(178);
|
|
|
|
|
2014-03-03 16:32:17 +00:00
|
|
|
fMegaVizLabel.setText(" Mega Viz: ");
|
|
|
|
fMegaVizLabel.setMinimumWidth(178);
|
|
|
|
fMegaVizLabel.setMaximumWidth(178);
|
|
|
|
|
2013-02-13 13:26:13 +00:00
|
|
|
#if SK_SUPPORT_GPU
|
2012-07-26 19:38:22 +00:00
|
|
|
fGLLabel.setText("OpenGL: ");
|
|
|
|
fGLLabel.setMinimumWidth(178);
|
|
|
|
fGLLabel.setMaximumWidth(178);
|
2013-08-02 13:59:50 +00:00
|
|
|
|
|
|
|
fGLMSAAButtonGroup.setTitle("MSAA");
|
|
|
|
fGLMSAAButtonGroup.setMinimumWidth(178);
|
|
|
|
fGLMSAAButtonGroup.setMaximumWidth(178);
|
|
|
|
fGLMSAAButtonGroup.setEnabled(fGLCheckBox.isChecked());
|
|
|
|
|
2013-11-21 15:37:29 +00:00
|
|
|
fGLMSAACombo.addItem("Off", QVariant(0));
|
|
|
|
fGLMSAACombo.addItem("4", QVariant(4));
|
|
|
|
fGLMSAACombo.addItem("16", QVariant(16));
|
2013-08-02 13:59:50 +00:00
|
|
|
|
2013-11-21 15:37:29 +00:00
|
|
|
fGLMSAALayout.addWidget(&fGLMSAACombo);
|
2013-08-02 13:59:50 +00:00
|
|
|
fGLMSAAButtonGroup.setLayout(&fGLMSAALayout);
|
|
|
|
|
2013-11-21 15:37:29 +00:00
|
|
|
connect(&fGLCheckBox, SIGNAL(toggled(bool)), &fGLMSAAButtonGroup,
|
|
|
|
SLOT(setEnabled(bool)));
|
|
|
|
connect(&fGLCheckBox, SIGNAL(toggled(bool)), this,
|
|
|
|
SIGNAL(glSettingsChanged()));
|
|
|
|
connect(&fGLMSAACombo, SIGNAL(activated(int)), this,
|
|
|
|
SIGNAL(glSettingsChanged()));
|
2013-02-13 13:26:13 +00:00
|
|
|
#endif
|
2012-07-26 19:38:22 +00:00
|
|
|
|
2013-10-17 17:56:10 +00:00
|
|
|
{
|
|
|
|
// set up filter buttons
|
|
|
|
fFilterButtonGroup.setTitle("Filtering");
|
|
|
|
fFilterButtonGroup.setMinimumWidth(178);
|
|
|
|
fFilterButtonGroup.setMaximumWidth(178);
|
|
|
|
|
2013-11-21 15:37:29 +00:00
|
|
|
fFilterCombo.addItem("As encoded", QVariant(SkPaint::kNone_FilterLevel));
|
|
|
|
fFilterCombo.addItem("None", QVariant(SkPaint::kNone_FilterLevel));
|
|
|
|
fFilterCombo.addItem("Low", QVariant(SkPaint::kLow_FilterLevel));
|
|
|
|
fFilterCombo.addItem("Medium", QVariant(SkPaint::kMedium_FilterLevel));
|
|
|
|
fFilterCombo.addItem("High", QVariant(SkPaint::kHigh_FilterLevel));
|
2013-10-17 17:56:10 +00:00
|
|
|
|
2013-11-21 15:37:29 +00:00
|
|
|
fFilterLayout.addWidget(&fFilterCombo);
|
2013-10-17 17:56:10 +00:00
|
|
|
fFilterButtonGroup.setLayout(&fFilterLayout);
|
|
|
|
|
2013-11-21 15:37:29 +00:00
|
|
|
connect(&fFilterCombo, SIGNAL(activated(int)), this,
|
|
|
|
SIGNAL(texFilterSettingsChanged()));
|
2013-10-17 17:56:10 +00:00
|
|
|
}
|
|
|
|
|
2012-07-26 19:38:22 +00:00
|
|
|
fRasterLayout.addWidget(&fRasterLabel);
|
|
|
|
fRasterLayout.addWidget(&fRasterCheckBox);
|
2014-05-19 13:53:10 +00:00
|
|
|
fRasterLayout.addWidget(&fPathOpsLabel);
|
|
|
|
fRasterLayout.addWidget(&fPathOpsCheckBox);
|
2012-07-26 19:38:22 +00:00
|
|
|
|
2014-03-03 16:32:17 +00:00
|
|
|
fVizLayout.addWidget(&fOverdrawVizLabel);
|
|
|
|
fVizLayout.addWidget(&fOverdrawVizCheckBox);
|
|
|
|
fVizLayout.addWidget(&fMegaVizLabel);
|
|
|
|
fVizLayout.addWidget(&fMegaVizCheckBox);
|
2013-02-06 20:13:54 +00:00
|
|
|
|
2013-02-13 13:26:13 +00:00
|
|
|
#if SK_SUPPORT_GPU
|
2012-07-26 19:38:22 +00:00
|
|
|
fGLLayout.addWidget(&fGLLabel);
|
|
|
|
fGLLayout.addWidget(&fGLCheckBox);
|
2013-02-13 13:26:13 +00:00
|
|
|
#endif
|
2012-07-26 19:38:22 +00:00
|
|
|
|
|
|
|
fCanvasLayout.setSpacing(6);
|
|
|
|
fCanvasLayout.setContentsMargins(11,11,11,11);
|
|
|
|
fCanvasLayout.addLayout(&fRasterLayout);
|
2014-03-03 16:32:17 +00:00
|
|
|
fCanvasLayout.addLayout(&fVizLayout);
|
2013-02-13 13:26:13 +00:00
|
|
|
#if SK_SUPPORT_GPU
|
2012-07-26 19:38:22 +00:00
|
|
|
fCanvasLayout.addLayout(&fGLLayout);
|
2013-08-02 13:59:50 +00:00
|
|
|
fCanvasLayout.addWidget(&fGLMSAAButtonGroup);
|
2013-02-13 13:26:13 +00:00
|
|
|
#endif
|
2013-10-17 17:56:10 +00:00
|
|
|
fCanvasLayout.addWidget(&fFilterButtonGroup);
|
2012-07-26 19:38:22 +00:00
|
|
|
|
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
|
2013-11-21 15:37:29 +00:00
|
|
|
fVerticalLayout.addWidget(&fVisibleText);
|
2012-07-09 20:26:53 +00:00
|
|
|
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));
|
|
|
|
}
|
|
|
|
|
2013-01-17 16:30:56 +00:00
|
|
|
void SkSettingsWidget::setZoomText(float scale) {
|
|
|
|
fZoomBox.setText(QString::number(scale*100, 'f', 0).append("%"));
|
2012-07-09 20:26:53 +00:00
|
|
|
}
|