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 SKINSPECTORWIDGET_H_
     11 #define SKINSPECTORWIDGET_H_
     12 
     13 #include "SkMatrix.h"
     14 
     15 #include <QWidget>
     16 #include <QTabWidget>
     17 #include <QTextEdit>
     18 #include <QHBoxLayout>
     19 #include <QLabel>
     20 #include <QLineEdit>
     21 #include <QGroupBox>
     22 #include <QGridLayout>
     23 
     24 /** \class SkInspectorWidget
     25 
     26     The InspectorWidget contains the overview and details tab. These contain
     27     information about the whole picture and details about each draw command.
     28  */
     29 class SkInspectorWidget : public QWidget {
     30     Q_OBJECT
     31 
     32 public:
     33     enum TabType {
     34         kOverview_TabType,
     35         kDetail_TabType,
     36         kClipStack_TabType,
     37         kTotalTabCount,
     38     };
     39 
     40     /**
     41         Constructs a widget with the specified parent for layout purposes.
     42         @param parent  The parent container of this widget
     43      */
     44     SkInspectorWidget();
     45 
     46     void setDisabled(bool isDisabled) {
     47         fMatrixAndClipWidget.setDisabled(isDisabled);
     48     }
     49 
     50     /**
     51         Sets the text in tab at the specified index.
     52         @param text
     53      */
     54     void setText(QString text, TabType type);
     55 
     56     /**
     57         Sets the text in the current matrix.
     58         @param matrixValues
     59      */
     60     void setMatrix(const SkMatrix& matrix);
     61 
     62     /**
     63         Sets the text in the current clip.
     64         @param clipValues
     65      */
     66     void setClip(const SkIRect& clip);
     67 
     68     class Tab : public QWidget {
     69         QWidget fTab;
     70         QHBoxLayout fTabLayout;
     71         QTextEdit fTabText;
     72         QString fName;
     73 
     74         Tab(const char* name) {
     75             fTabText.setReadOnly(true);
     76             fTabLayout.addWidget(&fTabText);
     77             fTab.setLayout(&fTabLayout);
     78             fName = QString(name);
     79         }
     80     };
     81 
     82 private:
     83     QHBoxLayout fHorizontalLayout;
     84     QTabWidget fTabWidget;
     85 
     86     QWidget fTabs[kTotalTabCount];
     87     QHBoxLayout fTabLayouts[kTotalTabCount];
     88     QTextEdit fTabTexts[kTotalTabCount];
     89 
     90     QFrame fMatrixAndClipWidget;
     91     QVBoxLayout fVerticalLayout;
     92 
     93     QGroupBox fMatrixGroup;
     94     QGridLayout fMatrixLayout;
     95     QLineEdit fMatrixEntry[9];
     96 
     97     QGroupBox fClipGroup;
     98     QGridLayout fClipLayout;
     99     QLineEdit fClipEntry[4];
    100 
    101     void setupMatrix();
    102     void setupClip();
    103 };
    104 
    105 #endif
    106