blob: ab634f8f04e286124308a47fe0e6808d1678059b [file] [log] [blame]
chudy@google.com902ebe52012-06-29 14:21:22 +00001
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
chudy@google.comea5488b2012-07-26 19:38:22 +000010#ifndef SKCANVASWIDGET_H_
11#define SKCANVASWIDGET_H_
chudy@google.com902ebe52012-06-29 14:21:22 +000012
chudy@google.com902ebe52012-06-29 14:21:22 +000013#include <QWidget>
chudy@google.comea5488b2012-07-26 19:38:22 +000014#include <QHBoxLayout>
15#include "SkStream.h"
16#include "SkRasterWidget.h"
17#include "SkGLWidget.h"
chudy@google.com607357f2012-08-07 16:12:23 +000018#include "SkDebugger.h"
chudy@google.com902ebe52012-06-29 14:21:22 +000019
chudy@google.com902ebe52012-06-29 14:21:22 +000020class SkCanvasWidget : public QWidget {
21 Q_OBJECT
22
23public:
chudy@google.com607357f2012-08-07 16:12:23 +000024 SkCanvasWidget(QWidget* parent, SkDebugger* debugger);
chudy@google.com902ebe52012-06-29 14:21:22 +000025
chudy@google.com2d537a12012-07-31 12:49:52 +000026 ~SkCanvasWidget();
chudy@google.com902ebe52012-06-29 14:21:22 +000027
chudy@google.comea5488b2012-07-26 19:38:22 +000028 enum WidgetType {
29 kRaster_8888_WidgetType = 1 << 0,
30 kGPU_WidgetType = 1 << 1,
31 };
chudy@google.com902ebe52012-06-29 14:21:22 +000032
chudy@google.comea5488b2012-07-26 19:38:22 +000033 void drawTo(int index);
34
35 void setWidgetVisibility(WidgetType type, bool isHidden);
36
chudy@google.coma1226312012-07-26 20:26:44 +000037 void zoom(float zoomIncrement);
chudy@google.com902ebe52012-06-29 14:21:22 +000038
chudy@google.com686e6802012-08-14 16:00:32 +000039 void resetWidgetTransform();
40
chudy@google.com7dcae672012-07-09 20:26:53 +000041signals:
42 void scaleFactorChanged(float newScaleFactor);
43 void commandChanged(int newCommand);
chudy@google.come606d6e2012-07-12 14:31:25 +000044 void hitChanged(int hit);
chudy@google.com7dcae672012-07-09 20:26:53 +000045
chudy@google.coma1226312012-07-26 20:26:44 +000046private slots:
47 void keyZoom(int zoomIncrement) {
48 zoom(zoomIncrement);
49 }
50
chudy@google.com902ebe52012-06-29 14:21:22 +000051private:
chudy@google.comea5488b2012-07-26 19:38:22 +000052 QHBoxLayout fHorizontalLayout;
53 SkRasterWidget fRasterWidget;
54 SkGLWidget fGLWidget;
chudy@google.com607357f2012-08-07 16:12:23 +000055 SkDebugger* fDebugger;
chudy@google.com2f891792012-07-03 16:05:59 +000056 SkIPoint fPreviousPoint;
chudy@google.com830b8792012-08-01 15:57:52 +000057 SkIPoint fUserOffset;
58 float fUserScaleFactor;
chudy@google.comea5488b2012-07-26 19:38:22 +000059
chudy@google.comea5488b2012-07-26 19:38:22 +000060 void mouseMoveEvent(QMouseEvent* event);
61
62 void mousePressEvent(QMouseEvent* event);
63
64 void mouseDoubleClickEvent(QMouseEvent* event);
65
chudy@google.coma1226312012-07-26 20:26:44 +000066 void wheelEvent(QWheelEvent* event) {
67 zoom(event->delta()/120);
68 }
chudy@google.com902ebe52012-06-29 14:21:22 +000069};
70
chudy@google.comea5488b2012-07-26 19:38:22 +000071
72#endif /* SKCANVASWIDGET_H_ */