From 22d39332bdba4e2e36aa050220392dcd33d81c19 Mon Sep 17 00:00:00 2001 From: "commit-bot@chromium.org" Date: Thu, 21 Nov 2013 15:37:29 +0000 Subject: [PATCH] Convert debugger settings controls to combo boxes. This reduces the height of the settings panel significantly compared to radio buttons. With some luck, the debugger may now fit on non-4K monitors :) R=bungeman@google.com, robertphillips@google.com Author: fmalita@chromium.org Review URL: https://codereview.chromium.org/78843005 git-svn-id: http://skia.googlecode.com/svn/trunk@12342 2bbb7eff-a529-9590-31e7-b0007b416f81 --- debugger/QT/SkDebuggerGUI.cpp | 7 ++- debugger/QT/SkSettingsWidget.cpp | 73 ++++++++++++-------------------- debugger/QT/SkSettingsWidget.h | 54 +++++++---------------- 3 files changed, 47 insertions(+), 87 deletions(-) diff --git a/debugger/QT/SkDebuggerGUI.cpp b/debugger/QT/SkDebuggerGUI.cpp index f500dcf9e8..e5bdf9f28e 100644 --- a/debugger/QT/SkDebuggerGUI.cpp +++ b/debugger/QT/SkDebuggerGUI.cpp @@ -90,7 +90,7 @@ SkDebuggerGUI::SkDebuggerGUI(QWidget *parent) : connect(&fActionClearBreakpoints, SIGNAL(triggered()), this, SLOT(actionClearBreakpoints())); connect(&fActionClearDeletes, SIGNAL(triggered()), this, SLOT(actionClearDeletes())); connect(&fActionClose, SIGNAL(triggered()), this, SLOT(actionClose())); - connect(fSettingsWidget.getVisibilityButton(), SIGNAL(toggled(bool)), this, SLOT(actionCommandFilter())); + connect(&fSettingsWidget, SIGNAL(visibilityFilterChanged()), this, SLOT(actionCommandFilter())); #if SK_SUPPORT_GPU connect(&fSettingsWidget, SIGNAL(glSettingsChanged()), this, SLOT(actionGLWidget())); #endif @@ -440,8 +440,7 @@ void SkDebuggerGUI::actionClearDeletes() { } void SkDebuggerGUI::actionCommandFilter() { - fDebugger.highlightCurrentCommand( - fSettingsWidget.getVisibilityButton()->isChecked()); + fDebugger.highlightCurrentCommand(fSettingsWidget.getVisibilityFilter()); fCanvasWidget.drawTo(fListWidget.currentRow()); fImageWidget.draw(); } @@ -968,7 +967,7 @@ void SkDebuggerGUI::loadPicture(const SkString& fileName) { * TODO(chudy): This should be deprecated since fDebugger is not * recreated. * */ - fDebugger.highlightCurrentCommand(fSettingsWidget.getVisibilityButton()->isChecked()); + fDebugger.highlightCurrentCommand(fSettingsWidget.getVisibilityFilter()); setupListWidget(commands); setupComboBox(commands); diff --git a/debugger/QT/SkSettingsWidget.cpp b/debugger/QT/SkSettingsWidget.cpp index ca0436e182..dc40b40a9e 100644 --- a/debugger/QT/SkSettingsWidget.cpp +++ b/debugger/QT/SkSettingsWidget.cpp @@ -16,8 +16,6 @@ SkSettingsWidget::SkSettingsWidget() : QWidget() , mainFrameLayout(this) , fVerticalLayout(&mainFrame) , fVisibleFrameLayout(&fVisibleFrame) - , fVisibleOn(&fVisibleFrame) - , fVisibleOff(&fVisibleFrame) , fCommandLayout(&fCommandFrame) , fCurrentCommandBox(&fCommandFrame) , fCommandHitBox(&fCommandFrame) @@ -37,16 +35,17 @@ SkSettingsWidget::SkSettingsWidget() : QWidget() fVerticalLayout.setAlignment(Qt::AlignTop); // Visible Toggle - fVisibileText.setText("Visibility Filter"); + fVisibleText.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); + + 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())); // Canvas fCanvasToggle.setText("Render Targets"); @@ -73,22 +72,19 @@ SkSettingsWidget::SkSettingsWidget() : QWidget() fGLMSAAButtonGroup.setMaximumWidth(178); fGLMSAAButtonGroup.setEnabled(fGLCheckBox.isChecked()); - fGLMSAAOff.setText("Off"); - fGLMSAA4On.setText("4"); - fGLMSAA4On.setChecked(true); - fGLMSAA16On.setText("16"); - - fGLMSAALayout.addWidget(&fGLMSAAOff); - fGLMSAALayout.addWidget(&fGLMSAA4On); - fGLMSAALayout.addWidget(&fGLMSAA16On); + fGLMSAACombo.addItem("Off", QVariant(0)); + fGLMSAACombo.addItem("4", QVariant(4)); + fGLMSAACombo.addItem("16", QVariant(16)); + fGLMSAALayout.addWidget(&fGLMSAACombo); fGLMSAAButtonGroup.setLayout(&fGLMSAALayout); - connect(&fGLCheckBox, SIGNAL(toggled(bool)), &fGLMSAAButtonGroup, SLOT(setEnabled(bool))); - connect(&fGLCheckBox, SIGNAL(toggled(bool)), this, SIGNAL(glSettingsChanged())); - connect(&fGLMSAAOff, SIGNAL(toggled(bool)), this, SIGNAL(glSettingsChanged())); - connect(&fGLMSAA4On, SIGNAL(toggled(bool)), this, SIGNAL(glSettingsChanged())); - connect(&fGLMSAA16On, SIGNAL(toggled(bool)), this, SIGNAL(glSettingsChanged())); + 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())); #endif { @@ -97,26 +93,17 @@ SkSettingsWidget::SkSettingsWidget() : QWidget() fFilterButtonGroup.setMinimumWidth(178); fFilterButtonGroup.setMaximumWidth(178); - fFilterDefault.setText("As encoded"); - fFilterDefault.setChecked(true); - fFilterNone.setText("None"); - fFilterLow.setText("Low"); - fFilterMed.setText("Med"); - fFilterHigh.setText("High"); - - fFilterLayout.addWidget(&fFilterDefault); - fFilterLayout.addWidget(&fFilterNone); - fFilterLayout.addWidget(&fFilterLow); - fFilterLayout.addWidget(&fFilterMed); - fFilterLayout.addWidget(&fFilterHigh); + 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)); + fFilterLayout.addWidget(&fFilterCombo); fFilterButtonGroup.setLayout(&fFilterLayout); - connect(&fFilterDefault, SIGNAL(toggled(bool)), this, SIGNAL(texFilterSettingsChanged())); - connect(&fFilterNone, SIGNAL(toggled(bool)), this, SIGNAL(texFilterSettingsChanged())); - connect(&fFilterLow, SIGNAL(toggled(bool)), this, SIGNAL(texFilterSettingsChanged())); - connect(&fFilterMed, SIGNAL(toggled(bool)), this, SIGNAL(texFilterSettingsChanged())); - connect(&fFilterHigh, SIGNAL(toggled(bool)), this, SIGNAL(texFilterSettingsChanged())); + connect(&fFilterCombo, SIGNAL(activated(int)), this, + SIGNAL(texFilterSettingsChanged())); } fRasterLayout.addWidget(&fRasterLabel); @@ -193,7 +180,7 @@ SkSettingsWidget::SkSettingsWidget() : QWidget() fZoomLayout.addWidget(&fZoomBox); // Adds all widgets to settings container - fVerticalLayout.addWidget(&fVisibileText); + fVerticalLayout.addWidget(&fVisibleText); fVerticalLayout.addWidget(&fVisibleFrame); fVerticalLayout.addWidget(&fCommandToggle); fVerticalLayout.addWidget(&fCommandFrame); @@ -213,10 +200,6 @@ void SkSettingsWidget::updateHit(int newHit) { fCommandHitBox.setText(QString::number(newHit)); } -QRadioButton* SkSettingsWidget::getVisibilityButton() { - return &fVisibleOn; -} - void SkSettingsWidget::setZoomText(float scale) { fZoomBox.setText(QString::number(scale*100, 'f', 0).append("%")); } diff --git a/debugger/QT/SkSettingsWidget.h b/debugger/QT/SkSettingsWidget.h index fc8fda7c6e..23100118b1 100644 --- a/debugger/QT/SkSettingsWidget.h +++ b/debugger/QT/SkSettingsWidget.h @@ -16,9 +16,9 @@ #include #include #include -#include #include #include +#include #include "SkPaint.h" @@ -40,41 +40,26 @@ public: /** Sets the displayed user zoom level. A scale of 1.0 represents no zoom. */ void setZoomText(float scale); - QRadioButton* getVisibilityButton(); + bool getVisibilityFilter() const { + return fVisibilityCombo.itemData(fVisibilityCombo.currentIndex()).toBool(); + } #if SK_SUPPORT_GPU - bool isGLActive() { + bool isGLActive() const { return fGLCheckBox.isChecked(); } - int getGLSampleCount() { - if (fGLMSAA4On.isChecked()) { - return 4; - } else if (fGLMSAA16On.isChecked()) { - return 16; - } - return 0; + int getGLSampleCount() const { + return fGLMSAACombo.itemData(fGLMSAACombo.currentIndex()).toInt(); } #endif - bool getFilterOverride(SkPaint::FilterLevel* filterLevel) { - if (fFilterDefault.isChecked()) { - *filterLevel = SkPaint::kNone_FilterLevel; - return false; - } + bool getFilterOverride(SkPaint::FilterLevel* filterLevel) const { + int index = fFilterCombo.currentIndex(); + *filterLevel = (SkPaint::FilterLevel)fFilterCombo.itemData(index).toUInt(); - if (fFilterNone.isChecked()) { - *filterLevel = SkPaint::kNone_FilterLevel; - } else if (fFilterLow.isChecked()) { - *filterLevel = SkPaint::kLow_FilterLevel; - } else if (fFilterMed.isChecked()) { - *filterLevel = SkPaint::kMedium_FilterLevel; - } else { - *filterLevel = SkPaint::kHigh_FilterLevel; - } - - return true; + return index > 0; } QCheckBox* getRasterCheckBox() { @@ -92,7 +77,7 @@ private slots: signals: void scrollingPreferences(bool isStickyActivate); void showStyle(bool isSingleCommand); - void visibilityFilter(bool isEnabled); + void visibilityFilterChanged(); void texFilterSettingsChanged(); #if SK_SUPPORT_GPU void glSettingsChanged(); @@ -103,11 +88,10 @@ private: QFrame mainFrame; QVBoxLayout fVerticalLayout; - QLabel fVisibileText; + QLabel fVisibleText; QFrame fVisibleFrame; QVBoxLayout fVisibleFrameLayout; - QRadioButton fVisibleOn; - QRadioButton fVisibleOff; + QComboBox fVisibilityCombo; QLabel fCommandToggle; QFrame fCommandFrame; @@ -139,19 +123,13 @@ private: QCheckBox fGLCheckBox; QGroupBox fGLMSAAButtonGroup; QVBoxLayout fGLMSAALayout; - QRadioButton fGLMSAAOff; - QRadioButton fGLMSAA4On; - QRadioButton fGLMSAA16On; + QComboBox fGLMSAACombo; #endif // for filtering group QGroupBox fFilterButtonGroup; + QComboBox fFilterCombo; QVBoxLayout fFilterLayout; - QRadioButton fFilterDefault; - QRadioButton fFilterNone; - QRadioButton fFilterLow; - QRadioButton fFilterMed; - QRadioButton fFilterHigh; QFrame fZoomFrame; QHBoxLayout fZoomLayout;