diff options
-rw-r--r-- | tools/viewer/Viewer.cpp | 22 | ||||
-rw-r--r-- | tools/viewer/Viewer.h | 2 |
2 files changed, 23 insertions, 1 deletions
diff --git a/tools/viewer/Viewer.cpp b/tools/viewer/Viewer.cpp index 7bd9a69508..16a91fa08a 100644 --- a/tools/viewer/Viewer.cpp +++ b/tools/viewer/Viewer.cpp @@ -176,6 +176,7 @@ Viewer::Viewer(int argc, char** argv, void* platformData) // Our UI can only tweak gamma (currently), so start out gamma-only , fColorSpaceTransferFn(g2Dot2_TransferFn) , fZoomLevel(0.0f) + , fRotation(0.0f) , fGestureDevice(GestureDevice::kNone) , fTileCnt(0) , fThreadCnt(0) @@ -861,8 +862,11 @@ void Viewer::setupCurrentSlide() { void Viewer::changeZoomLevel(float delta) { fZoomLevel += delta; fZoomLevel = SkScalarPin(fZoomLevel, MIN_ZOOM_LEVEL, MAX_ZOOM_LEVEL); + this->preTouchMatrixChanged(); +} - // Update the trans limit as the zoom level changes. +void Viewer::preTouchMatrixChanged() { + // Update the trans limit as the transform changes. const SkISize slideSize = fSlides[fCurrentSlide]->getDimensions(); const SkRect slideBounds = SkRect::MakeIWH(slideSize.width(), slideSize.height()); const SkRect windowRect = SkRect::MakeIWH(fWindow->width(), fWindow->height()); @@ -874,6 +878,7 @@ SkMatrix Viewer::computePreTouchMatrix() { SkScalar zoomScale = (fZoomLevel < 0) ? SK_Scalar1 / (SK_Scalar1 - fZoomLevel) : SK_Scalar1 + fZoomLevel; m.preScale(zoomScale, zoomScale); + m.preRotate(fRotation); return m; } @@ -1342,6 +1347,21 @@ void Viewer::drawImGui() { } } + if (ImGui::CollapsingHeader("Transform")) { + float zoom = fZoomLevel; + if (ImGui::SliderFloat("Zoom", &zoom, MIN_ZOOM_LEVEL, MAX_ZOOM_LEVEL)) { + fZoomLevel = zoom; + this->preTouchMatrixChanged(); + paramsChanged = true; + } + float deg = fRotation; + if (ImGui::SliderFloat("Rotate", °, -30, 360, "%.0f deg")) { + fRotation = deg; + this->preTouchMatrixChanged(); + paramsChanged = true; + } + } + if (ImGui::CollapsingHeader("Paint")) { int hintingIdx = 0; if (fPaintOverrides.fHinting) { diff --git a/tools/viewer/Viewer.h b/tools/viewer/Viewer.h index 760e3b8520..25cbed656c 100644 --- a/tools/viewer/Viewer.h +++ b/tools/viewer/Viewer.h @@ -100,6 +100,7 @@ private: void drawImGui(); void changeZoomLevel(float delta); + void preTouchMatrixChanged(); SkMatrix computePreTouchMatrix(); SkMatrix computeMatrix(); SkPoint mapEvent(float x, float y); @@ -141,6 +142,7 @@ private: // transform data SkScalar fZoomLevel; + SkScalar fRotation; sk_app::CommandSet fCommands; |