Home | History | Annotate | Download | only in QT
      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 #ifndef SKSETTINGSWIDGET_H_
     11 #define SKSETTINGSWIDGET_H_
     12 
     13 #include <QWidget>
     14 #include <QHBoxLayout>
     15 #include <QTextEdit>
     16 #include <QFrame>
     17 #include <QGroupBox>
     18 #include <QLabel>
     19 #include <QCheckBox>
     20 #include <QLineEdit>
     21 #include <QComboBox>
     22 
     23 #include "SkPaint.h"
     24 
     25 /** \class SkSettingsWidget
     26 
     27     The SettingsWidget contains multiple checkboxes and toggles for altering
     28     the visibility.
     29  */
     30 class SkSettingsWidget : public QWidget {
     31     Q_OBJECT
     32 
     33 public:
     34     /**
     35         Constructs a widget with the specified parent for layout purposes.
     36         @param parent  The parent container of this widget
     37      */
     38     SkSettingsWidget();
     39 
     40     /** Sets the displayed user zoom level. A scale of 1.0 represents no zoom. */
     41     void setZoomText(float scale);
     42 
     43     bool getVisibilityFilter() const {
     44         return fVisibilityCombo.itemData(fVisibilityCombo.currentIndex()).toBool();
     45     }
     46 
     47 #if SK_SUPPORT_GPU
     48     bool isGLActive() const {
     49         return fGLCheckBox.isChecked();
     50     }
     51 
     52     int getGLSampleCount() const {
     53         return fGLMSAACombo.itemData(fGLMSAACombo.currentIndex()).toInt();
     54     }
     55 
     56 #endif
     57 
     58     bool getFilterOverride(SkPaint::FilterLevel* filterLevel) const {
     59         int index = fFilterCombo.currentIndex();
     60         *filterLevel = (SkPaint::FilterLevel)fFilterCombo.itemData(index).toUInt();
     61 
     62         return index > 0;
     63     }
     64 
     65     QCheckBox* getRasterCheckBox() {
     66         return &fRasterCheckBox;
     67     }
     68 
     69     QCheckBox* getOverdrawVizCheckBox() {
     70         return &fOverdrawVizCheckBox;
     71     }
     72 
     73     QCheckBox* getMegaVizCheckBox() {
     74         return &fMegaVizCheckBox;
     75     }
     76 
     77     QCheckBox* getPathOpsCheckBox() {
     78         return &fPathOpsCheckBox;
     79     }
     80 
     81 private slots:
     82     void updateCommand(int newCommand);
     83     void updateHit(int newHit);
     84 
     85 signals:
     86     void scrollingPreferences(bool isStickyActivate);
     87     void showStyle(bool isSingleCommand);
     88     void visibilityFilterChanged();
     89     void texFilterSettingsChanged();
     90 #if SK_SUPPORT_GPU
     91     void glSettingsChanged();
     92 #endif
     93 
     94 private:
     95     QVBoxLayout mainFrameLayout;
     96     QFrame mainFrame;
     97     QVBoxLayout fVerticalLayout;
     98 
     99     QLabel fVisibleText;
    100     QFrame fVisibleFrame;
    101     QVBoxLayout fVisibleFrameLayout;
    102     QComboBox fVisibilityCombo;
    103 
    104     QLabel fCommandToggle;
    105     QFrame fCommandFrame;
    106     QVBoxLayout fCommandLayout;
    107 
    108     QHBoxLayout fCurrentCommandLayout;
    109     QLabel fCurrentCommandLabel;
    110     QLineEdit fCurrentCommandBox;
    111 
    112     QHBoxLayout fCommandHitLayout;
    113     QLabel fCommandHitLabel;
    114     QLineEdit fCommandHitBox;
    115 
    116     QFrame fCanvasFrame;
    117     QVBoxLayout fCanvasLayout;
    118     QLabel fCanvasToggle;
    119 
    120     QHBoxLayout fRasterLayout;
    121     QLabel fRasterLabel;
    122     QCheckBox fRasterCheckBox;
    123 
    124     QHBoxLayout fVizLayout;
    125     QLabel fOverdrawVizLabel;
    126     QCheckBox fOverdrawVizCheckBox;
    127     QLabel fMegaVizLabel;
    128     QCheckBox fMegaVizCheckBox;
    129     QLabel fPathOpsLabel;
    130     QCheckBox fPathOpsCheckBox;
    131 
    132 #if SK_SUPPORT_GPU
    133     QHBoxLayout fGLLayout;
    134     QLabel fGLLabel;
    135     QCheckBox fGLCheckBox;
    136     QGroupBox fGLMSAAButtonGroup;
    137     QVBoxLayout fGLMSAALayout;
    138     QComboBox fGLMSAACombo;
    139 #endif
    140 
    141     // for filtering group
    142     QGroupBox fFilterButtonGroup;
    143     QComboBox fFilterCombo;
    144     QVBoxLayout fFilterLayout;
    145 
    146     QFrame fZoomFrame;
    147     QHBoxLayout fZoomLayout;
    148     QLabel fZoomSetting;
    149     QLineEdit fZoomBox;
    150 };
    151 
    152 #endif /* SKSETTINGSWIDGET_H_ */
    153