diff options
author | Ben Wagner <bungeman@google.com> | 2018-04-23 12:55:06 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-04-23 17:21:30 +0000 |
commit | d02a74d649d4382a2bb6340dc27a89293a97f708 (patch) | |
tree | 78f5007a8df97ba5f22ab6b26aa997a013fd836b /tools | |
parent | b57b9310c0dd6e3f97dbfb415405b88ac22320e6 (diff) |
Add Transform section to viewer tools window.
This adds sliders for Zoom and Rotate.
Change-Id: Ie568e5381d76bd5a457760e2d6224e42e64c7f16
Reviewed-on: https://skia-review.googlesource.com/123027
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Ben Wagner <bungeman@google.com>
Diffstat (limited to 'tools')
-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; |