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 
     22 /** \class SkInspectorWidget
     23 
     24     The InspectorWidget contains the overview and details tab. These contain
     25     information about the whole picture and details about each draw command.
     26  */
     27 class SkInspectorWidget : public QWidget {
     28     Q_OBJECT
     29 
     30 public:
     31     enum TabType {
     32         kOverview_TabType,
     33         kDetail_TabType,
     34         kClipStack_TabType,
     35         kTotalTabCount,
     36     };
     37 
     38     /**
     39         Constructs a widget with the specified parent for layout purposes.
     40         @param parent  The parent container of this widget
     41      */
     42     SkInspectorWidget();
     43 
     44     void setDisabled(bool isDisabled) {
     45         fMatrixAndClipWidget.setDisabled(isDisabled);
     46     }
     47 
     48     /**
     49         Sets the text in tab at the specified index.
     50         @param text
     51      */
     52     void setText(QString text, TabType type);
     53 
     54     /**
     55         Sets the text in the current matrix.
     56         @param matrixValues
     57      */
     58     void setMatrix(const SkMatrix& matrix);
     59 
     60     /**
     61         Sets the text in the current clip.
     62         @param clipValues
     63      */
     64     void setClip(const SkIRect& clip);
     65 
     66     class Tab : public QWidget {
     67         QWidget fTab;
     68         QHBoxLayout fTabLayout;
     69         QTextEdit fTabText;
     70         QString fName;
     71 
     72         Tab(const char* name) {
     73             fTabText.setReadOnly(true);
     74             fTabLayout.setSpacing(6);
     75             fTabLayout.setContentsMargins(11, 11, 11, 11);
     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     QWidget fMatrixAndClipWidget;
     91     QVBoxLayout fVerticalLayout;
     92 
     93     QLabel fMatrixLabel;
     94     QVBoxLayout fMatrixLayout;
     95     QHBoxLayout fMatrixRow[3];
     96     QLineEdit fMatrixEntry[9];
     97 
     98     QLabel fClipLabel;
     99     QVBoxLayout fClipLayout;
    100     QHBoxLayout fClipRow[2];
    101     QLineEdit fClipEntry[4];
    102 
    103     QVBoxLayout* setupMatrix();
    104     QVBoxLayout* setupClip();
    105 };
    106 
    107 #endif
    108