OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2012 Google Inc. | 3 * Copyright 2012 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 | 9 |
10 #include "SkCanvasWidget.h" | 10 #include "SkCanvasWidget.h" |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 } | 48 } |
49 | 49 |
50 SkCanvasWidget::~SkCanvasWidget() {} | 50 SkCanvasWidget::~SkCanvasWidget() {} |
51 | 51 |
52 void SkCanvasWidget::drawTo(int index) { | 52 void SkCanvasWidget::drawTo(int index) { |
53 fDebugger->setIndex(index); | 53 fDebugger->setIndex(index); |
54 fRasterWidget.updateImage(); | 54 fRasterWidget.updateImage(); |
55 #if SK_SUPPORT_GPU | 55 #if SK_SUPPORT_GPU |
56 fGLWidget.updateImage(); | 56 fGLWidget.updateImage(); |
57 #endif | 57 #endif |
58 emit commandChanged(fDebugger->index()); | 58 Q_EMIT commandChanged(fDebugger->index()); |
59 } | 59 } |
60 | 60 |
61 void SkCanvasWidget::mouseMoveEvent(QMouseEvent* event) { | 61 void SkCanvasWidget::mouseMoveEvent(QMouseEvent* event) { |
62 SkIPoint eventPoint = SkIPoint::Make(event->globalX(), event->globalY()); | 62 SkIPoint eventPoint = SkIPoint::Make(event->globalX(), event->globalY()); |
63 SkIPoint eventOffset = eventPoint - fPreviousPoint; | 63 SkIPoint eventOffset = eventPoint - fPreviousPoint; |
64 fPreviousPoint = eventPoint; | 64 fPreviousPoint = eventPoint; |
65 fUserMatrix.postTranslate(eventOffset.fX, eventOffset.fY); | 65 fUserMatrix.postTranslate(eventOffset.fX, eventOffset.fY); |
66 fDebugger->setUserMatrix(fUserMatrix); | 66 fDebugger->setUserMatrix(fUserMatrix); |
67 drawTo(fDebugger->index()); | 67 drawTo(fDebugger->index()); |
68 } | 68 } |
69 | 69 |
70 void SkCanvasWidget::mousePressEvent(QMouseEvent* event) { | 70 void SkCanvasWidget::mousePressEvent(QMouseEvent* event) { |
71 fPreviousPoint.set(event->globalX(), event->globalY()); | 71 fPreviousPoint.set(event->globalX(), event->globalY()); |
72 emit hitChanged(fDebugger->getCommandAtPoint(event->x(), event->y(), | 72 Q_EMIT hitChanged(fDebugger->getCommandAtPoint(event->x(), event->y(), |
73 fDebugger->index())); | 73 fDebugger->index())); |
74 } | 74 } |
75 | 75 |
76 void SkCanvasWidget::mouseDoubleClickEvent(QMouseEvent* event) { | 76 void SkCanvasWidget::mouseDoubleClickEvent(QMouseEvent* event) { |
77 Qt::KeyboardModifiers modifiers = event->modifiers(); | 77 Qt::KeyboardModifiers modifiers = event->modifiers(); |
78 if (modifiers.testFlag(Qt::ControlModifier)) { | 78 if (modifiers.testFlag(Qt::ControlModifier)) { |
79 snapWidgetTransform(); | 79 snapWidgetTransform(); |
80 } else { | 80 } else { |
81 resetWidgetTransform(); | 81 resetWidgetTransform(); |
82 } | 82 } |
(...skipping 27 matching lines...) Expand all Loading... |
110 modf(fUserMatrix.getTranslateY(), &y); | 110 modf(fUserMatrix.getTranslateY(), &y); |
111 fUserMatrix[SkMatrix::kMTransX] = x; | 111 fUserMatrix[SkMatrix::kMTransX] = x; |
112 fUserMatrix[SkMatrix::kMTransY] = y; | 112 fUserMatrix[SkMatrix::kMTransY] = y; |
113 fDebugger->setUserMatrix(fUserMatrix); | 113 fDebugger->setUserMatrix(fUserMatrix); |
114 drawTo(fDebugger->index()); | 114 drawTo(fDebugger->index()); |
115 } | 115 } |
116 | 116 |
117 void SkCanvasWidget::resetWidgetTransform() { | 117 void SkCanvasWidget::resetWidgetTransform() { |
118 fUserMatrix.reset(); | 118 fUserMatrix.reset(); |
119 fDebugger->setUserMatrix(fUserMatrix); | 119 fDebugger->setUserMatrix(fUserMatrix); |
120 emit scaleFactorChanged(fUserMatrix.getScaleX()); | 120 Q_EMIT scaleFactorChanged(fUserMatrix.getScaleX()); |
121 drawTo(fDebugger->index()); | 121 drawTo(fDebugger->index()); |
122 } | 122 } |
123 | 123 |
124 void SkCanvasWidget::setWidgetVisibility(WidgetType type, bool isHidden) { | 124 void SkCanvasWidget::setWidgetVisibility(WidgetType type, bool isHidden) { |
125 if (type == kRaster_8888_WidgetType) { | 125 if (type == kRaster_8888_WidgetType) { |
126 fRasterWidget.setHidden(isHidden); | 126 fRasterWidget.setHidden(isHidden); |
127 } | 127 } |
128 #if SK_SUPPORT_GPU | 128 #if SK_SUPPORT_GPU |
129 else if (type == kGPU_WidgetType) { | 129 else if (type == kGPU_WidgetType) { |
130 fGLWidget.setHidden(isHidden); | 130 fGLWidget.setHidden(isHidden); |
131 } | 131 } |
132 #endif | 132 #endif |
133 } | 133 } |
134 | 134 |
135 #if SK_SUPPORT_GPU | 135 #if SK_SUPPORT_GPU |
136 void SkCanvasWidget::setGLSampleCount(int sampleCount) | 136 void SkCanvasWidget::setGLSampleCount(int sampleCount) |
137 { | 137 { |
138 fGLWidget.setSampleCount(sampleCount); | 138 fGLWidget.setSampleCount(sampleCount); |
139 } | 139 } |
140 #endif | 140 #endif |
141 | 141 |
142 void SkCanvasWidget::zoom(float scale, int px, int py) { | 142 void SkCanvasWidget::zoom(float scale, int px, int py) { |
143 fUserMatrix.postScale(scale, scale, px, py); | 143 fUserMatrix.postScale(scale, scale, px, py); |
144 emit scaleFactorChanged(fUserMatrix.getScaleX()); | 144 Q_EMIT scaleFactorChanged(fUserMatrix.getScaleX()); |
145 fDebugger->setUserMatrix(fUserMatrix); | 145 fDebugger->setUserMatrix(fUserMatrix); |
146 drawTo(fDebugger->index()); | 146 drawTo(fDebugger->index()); |
147 } | 147 } |
OLD | NEW |