2012-06-29 14:21:22 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright 2012 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2012-07-26 19:38:22 +00:00
|
|
|
#ifndef SKCANVASWIDGET_H_
|
|
|
|
#define SKCANVASWIDGET_H_
|
2012-06-29 14:21:22 +00:00
|
|
|
|
2012-07-26 19:38:22 +00:00
|
|
|
#include <QWidget>
|
|
|
|
#include <QHBoxLayout>
|
|
|
|
#include "SkStream.h"
|
|
|
|
#include "SkRasterWidget.h"
|
|
|
|
#include "SkGLWidget.h"
|
2012-08-07 16:12:23 +00:00
|
|
|
#include "SkDebugger.h"
|
2012-06-29 14:21:22 +00:00
|
|
|
|
|
|
|
class SkCanvasWidget : public QWidget {
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2012-08-07 16:12:23 +00:00
|
|
|
SkCanvasWidget(QWidget* parent, SkDebugger* debugger);
|
2012-06-29 14:21:22 +00:00
|
|
|
|
2012-07-31 12:49:52 +00:00
|
|
|
~SkCanvasWidget();
|
2012-06-29 14:21:22 +00:00
|
|
|
|
2012-07-26 19:38:22 +00:00
|
|
|
enum WidgetType {
|
|
|
|
kRaster_8888_WidgetType = 1 << 0,
|
2013-02-13 13:26:13 +00:00
|
|
|
#if SK_SUPPORT_GPU
|
2012-07-26 19:38:22 +00:00
|
|
|
kGPU_WidgetType = 1 << 1,
|
2013-02-13 13:26:13 +00:00
|
|
|
#endif
|
2012-07-26 19:38:22 +00:00
|
|
|
};
|
2012-06-29 14:21:22 +00:00
|
|
|
|
2012-07-26 19:38:22 +00:00
|
|
|
void drawTo(int index);
|
|
|
|
|
|
|
|
void setWidgetVisibility(WidgetType type, bool isHidden);
|
|
|
|
|
2013-01-17 16:30:56 +00:00
|
|
|
/** Zooms the canvas by scale with the transformation centered at the widget point (px, py). */
|
|
|
|
void zoom(float scale, int px, int py);
|
2012-06-29 14:21:22 +00:00
|
|
|
|
2012-08-14 16:00:32 +00:00
|
|
|
void resetWidgetTransform();
|
|
|
|
|
2013-01-17 16:30:56 +00:00
|
|
|
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);
|
|
|
|
|
2012-07-09 20:26:53 +00:00
|
|
|
signals:
|
|
|
|
void scaleFactorChanged(float newScaleFactor);
|
|
|
|
void commandChanged(int newCommand);
|
2012-07-12 14:31:25 +00:00
|
|
|
void hitChanged(int hit);
|
2012-07-09 20:26:53 +00:00
|
|
|
|
2012-06-29 14:21:22 +00:00
|
|
|
private:
|
2012-07-26 19:38:22 +00:00
|
|
|
QHBoxLayout fHorizontalLayout;
|
|
|
|
SkRasterWidget fRasterWidget;
|
2013-02-13 13:26:13 +00:00
|
|
|
#if SK_SUPPORT_GPU
|
2012-07-26 19:38:22 +00:00
|
|
|
SkGLWidget fGLWidget;
|
2013-02-13 13:26:13 +00:00
|
|
|
#endif
|
2012-08-07 16:12:23 +00:00
|
|
|
SkDebugger* fDebugger;
|
2012-07-03 16:05:59 +00:00
|
|
|
SkIPoint fPreviousPoint;
|
2013-01-17 16:30:56 +00:00
|
|
|
SkMatrix fUserMatrix;
|
2012-07-26 19:38:22 +00:00
|
|
|
|
|
|
|
void mouseMoveEvent(QMouseEvent* event);
|
|
|
|
|
|
|
|
void mousePressEvent(QMouseEvent* event);
|
|
|
|
|
|
|
|
void mouseDoubleClickEvent(QMouseEvent* event);
|
|
|
|
|
2013-01-17 16:30:56 +00:00
|
|
|
void wheelEvent(QWheelEvent* event);
|
|
|
|
|
|
|
|
void snapWidgetTransform();
|
2012-06-29 14:21:22 +00:00
|
|
|
};
|
|
|
|
|
2012-07-26 19:38:22 +00:00
|
|
|
|
|
|
|
#endif /* SKCANVASWIDGET_H_ */
|