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