blob: 0dcb470405e3b60082ed1c7bc75b56228c0d6f0f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
/*
* Copyright 2012 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef SKCANVASWIDGET_H_
#define SKCANVASWIDGET_H_
#include <QWidget>
#include <QHBoxLayout>
#include "SkStream.h"
#include "SkRasterWidget.h"
#include "SkGLWidget.h"
#include "SkDebugger.h"
class SkCanvasWidget : public QWidget {
Q_OBJECT
public:
SkCanvasWidget(QWidget* parent, SkDebugger* debugger);
~SkCanvasWidget();
enum WidgetType {
kRaster_8888_WidgetType = 1 << 0,
#if SK_SUPPORT_GPU
kGPU_WidgetType = 1 << 1,
#endif
};
void drawTo(int index);
void setWidgetVisibility(WidgetType type, bool isHidden);
/** Zooms the canvas by scale with the transformation centered at the widget point (px, py). */
void zoom(float scale, int px, int py);
void resetWidgetTransform();
enum ZoomCommandTypes {
kIn_ZoomCommand,
kOut_ZoomCommand,
};
public slots:
/**
* Zooms in or out (see ZoomCommandTypes) by the standard zoom factor
* with the transformation centered in the middle of the widget.
*/
void zoom(int zoomCommand);
signals:
void scaleFactorChanged(float newScaleFactor);
void commandChanged(int newCommand);
void hitChanged(int hit);
private:
QHBoxLayout fHorizontalLayout;
SkRasterWidget fRasterWidget;
#if SK_SUPPORT_GPU
SkGLWidget fGLWidget;
#endif
SkDebugger* fDebugger;
SkIPoint fPreviousPoint;
SkMatrix fUserMatrix;
void mouseMoveEvent(QMouseEvent* event);
void mousePressEvent(QMouseEvent* event);
void mouseDoubleClickEvent(QMouseEvent* event);
void wheelEvent(QWheelEvent* event);
void snapWidgetTransform();
};
#endif /* SKCANVASWIDGET_H_ */
|