1902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com
2902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com/*
3902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com * Copyright 2012 Google Inc.
4902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com *
5902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com * Use of this source code is governed by a BSD-style license that can be
6902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com * found in the LICENSE file.
7902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com */
8902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com
9902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com
10902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com#ifndef SKINSPECTORWIDGET_H_
11902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com#define SKINSPECTORWIDGET_H_
12902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com
132f891793957252b0262276c957c67798c905be80chudy@google.com#include "SkMatrix.h"
142f891793957252b0262276c957c67798c905be80chudy@google.com
15902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com#include <QWidget>
16902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com#include <QTabWidget>
17902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com#include <QTextEdit>
18902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com#include <QHBoxLayout>
19902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com#include <QLabel>
20902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com#include <QLineEdit>
217c339ae1e362e9f02cdfb9b32007f143dec0bc0ekkinnunen#include <QGroupBox>
227c339ae1e362e9f02cdfb9b32007f143dec0bc0ekkinnunen#include <QGridLayout>
23902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com
24902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com/** \class SkInspectorWidget
25902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com
26902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com    The InspectorWidget contains the overview and details tab. These contain
27902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com    information about the whole picture and details about each draw command.
28902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com */
29902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.comclass SkInspectorWidget : public QWidget {
30902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com    Q_OBJECT
31902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com
32902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.compublic:
336bd109a39370d21bfd4b48f5a28df8bcfc7f5ba2chudy@google.com    enum TabType {
346bd109a39370d21bfd4b48f5a28df8bcfc7f5ba2chudy@google.com        kOverview_TabType,
356bd109a39370d21bfd4b48f5a28df8bcfc7f5ba2chudy@google.com        kDetail_TabType,
362a67e123a3e559774a16a58cbe5106bc0fb86740commit-bot@chromium.org        kClipStack_TabType,
376bd109a39370d21bfd4b48f5a28df8bcfc7f5ba2chudy@google.com        kTotalTabCount,
386bd109a39370d21bfd4b48f5a28df8bcfc7f5ba2chudy@google.com    };
396bd109a39370d21bfd4b48f5a28df8bcfc7f5ba2chudy@google.com
40902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com    /**
41902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com        Constructs a widget with the specified parent for layout purposes.
42902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com        @param parent  The parent container of this widget
43902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com     */
442d537a18f49cb492358c2b051f4786075dd9406cchudy@google.com    SkInspectorWidget();
45902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com
462f891793957252b0262276c957c67798c905be80chudy@google.com    void setDisabled(bool isDisabled) {
472f891793957252b0262276c957c67798c905be80chudy@google.com        fMatrixAndClipWidget.setDisabled(isDisabled);
482f891793957252b0262276c957c67798c905be80chudy@google.com    }
49902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com
50902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com    /**
516bd109a39370d21bfd4b48f5a28df8bcfc7f5ba2chudy@google.com        Sets the text in tab at the specified index.
52902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com        @param text
53902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com     */
546bd109a39370d21bfd4b48f5a28df8bcfc7f5ba2chudy@google.com    void setText(QString text, TabType type);
55902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com
562f891793957252b0262276c957c67798c905be80chudy@google.com    /**
572f891793957252b0262276c957c67798c905be80chudy@google.com        Sets the text in the current matrix.
582f891793957252b0262276c957c67798c905be80chudy@google.com        @param matrixValues
592f891793957252b0262276c957c67798c905be80chudy@google.com     */
602f891793957252b0262276c957c67798c905be80chudy@google.com    void setMatrix(const SkMatrix& matrix);
612f891793957252b0262276c957c67798c905be80chudy@google.com
622f891793957252b0262276c957c67798c905be80chudy@google.com    /**
632f891793957252b0262276c957c67798c905be80chudy@google.com        Sets the text in the current clip.
642f891793957252b0262276c957c67798c905be80chudy@google.com        @param clipValues
652f891793957252b0262276c957c67798c905be80chudy@google.com     */
662f891793957252b0262276c957c67798c905be80chudy@google.com    void setClip(const SkIRect& clip);
672f891793957252b0262276c957c67798c905be80chudy@google.com
686bd109a39370d21bfd4b48f5a28df8bcfc7f5ba2chudy@google.com    class Tab : public QWidget {
696bd109a39370d21bfd4b48f5a28df8bcfc7f5ba2chudy@google.com        QWidget fTab;
706bd109a39370d21bfd4b48f5a28df8bcfc7f5ba2chudy@google.com        QHBoxLayout fTabLayout;
716bd109a39370d21bfd4b48f5a28df8bcfc7f5ba2chudy@google.com        QTextEdit fTabText;
726bd109a39370d21bfd4b48f5a28df8bcfc7f5ba2chudy@google.com        QString fName;
736bd109a39370d21bfd4b48f5a28df8bcfc7f5ba2chudy@google.com
746bd109a39370d21bfd4b48f5a28df8bcfc7f5ba2chudy@google.com        Tab(const char* name) {
756bd109a39370d21bfd4b48f5a28df8bcfc7f5ba2chudy@google.com            fTabText.setReadOnly(true);
766bd109a39370d21bfd4b48f5a28df8bcfc7f5ba2chudy@google.com            fTabLayout.addWidget(&fTabText);
776bd109a39370d21bfd4b48f5a28df8bcfc7f5ba2chudy@google.com            fTab.setLayout(&fTabLayout);
786bd109a39370d21bfd4b48f5a28df8bcfc7f5ba2chudy@google.com            fName = QString(name);
796bd109a39370d21bfd4b48f5a28df8bcfc7f5ba2chudy@google.com        }
806bd109a39370d21bfd4b48f5a28df8bcfc7f5ba2chudy@google.com    };
816bd109a39370d21bfd4b48f5a28df8bcfc7f5ba2chudy@google.com
82902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.comprivate:
832f891793957252b0262276c957c67798c905be80chudy@google.com    QHBoxLayout fHorizontalLayout;
842f891793957252b0262276c957c67798c905be80chudy@google.com    QTabWidget fTabWidget;
852f891793957252b0262276c957c67798c905be80chudy@google.com
866bd109a39370d21bfd4b48f5a28df8bcfc7f5ba2chudy@google.com    QWidget fTabs[kTotalTabCount];
876bd109a39370d21bfd4b48f5a28df8bcfc7f5ba2chudy@google.com    QHBoxLayout fTabLayouts[kTotalTabCount];
886bd109a39370d21bfd4b48f5a28df8bcfc7f5ba2chudy@google.com    QTextEdit fTabTexts[kTotalTabCount];
892f891793957252b0262276c957c67798c905be80chudy@google.com
907c339ae1e362e9f02cdfb9b32007f143dec0bc0ekkinnunen    QFrame fMatrixAndClipWidget;
912f891793957252b0262276c957c67798c905be80chudy@google.com    QVBoxLayout fVerticalLayout;
922f891793957252b0262276c957c67798c905be80chudy@google.com
937c339ae1e362e9f02cdfb9b32007f143dec0bc0ekkinnunen    QGroupBox fMatrixGroup;
947c339ae1e362e9f02cdfb9b32007f143dec0bc0ekkinnunen    QGridLayout fMatrixLayout;
952f891793957252b0262276c957c67798c905be80chudy@google.com    QLineEdit fMatrixEntry[9];
962f891793957252b0262276c957c67798c905be80chudy@google.com
977c339ae1e362e9f02cdfb9b32007f143dec0bc0ekkinnunen    QGroupBox fClipGroup;
987c339ae1e362e9f02cdfb9b32007f143dec0bc0ekkinnunen    QGridLayout fClipLayout;
992f891793957252b0262276c957c67798c905be80chudy@google.com    QLineEdit fClipEntry[4];
1002f891793957252b0262276c957c67798c905be80chudy@google.com
1017c339ae1e362e9f02cdfb9b32007f143dec0bc0ekkinnunen    void setupMatrix();
1027c339ae1e362e9f02cdfb9b32007f143dec0bc0ekkinnunen    void setupClip();
103902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com};
104902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com
105902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com#endif
106