1 /* 2 * Copyright 2018 Google Inc. 3 * 4 * Use of this source code is governed by a BSD-style license that can be 5 * found in the LICENSE file. 6 */ 7 8 #ifndef SlideDir_DEFINED 9 #define SlideDir_DEFINED 10 11 #include "tools/viewer/Slide.h" 12 13 #include "include/private/SkTArray.h" 14 15 #include <memory> 16 #include <vector> 17 18 class SkString; 19 20 namespace sksg { 21 22 class Group; 23 class Scene; 24 25 } // namespace sksg 26 27 class SlideDir final : public Slide { 28 public: 29 SlideDir(const SkString& name, SkTArray<sk_sp<Slide>>&&, 30 int columns = kDefaultColumnCount); 31 32 class Animator; 33 34 protected: 35 void load(SkScalar winWidth, SkScalar winHeight) override; 36 void unload() override; 37 38 SkISize getDimensions() const override; 39 40 void draw(SkCanvas*) override; 41 bool animate(double) override; 42 43 bool onChar(SkUnichar) override; 44 bool onMouse(SkScalar x, SkScalar y, skui::InputState, skui::ModifierKey modifiers) override; 45 46 private: 47 struct Rec; 48 class FocusController; 49 50 static constexpr int kDefaultColumnCount = 4; 51 52 const Rec* findCell(float x, float y) const; 53 54 const SkTArray<sk_sp<Slide>> fSlides; 55 std::unique_ptr<FocusController> fFocusController; 56 const int fColumns; 57 58 SkTArray<Rec, true> fRecs; 59 std::unique_ptr<sksg::Scene> fScene; 60 std::vector<sk_sp<Animator>> fSceneAnimators; 61 sk_sp<sksg::Group> fRoot; 62 63 SkSize fWinSize = SkSize::MakeEmpty(); 64 SkSize fCellSize = SkSize::MakeEmpty(); 65 SkMSec fTimeBase = 0; 66 67 const Rec* fTrackingCell = nullptr; 68 SkPoint fTrackingPos = SkPoint::Make(0, 0); 69 70 using INHERITED = Slide; 71 }; 72 73 #endif // SlideDir_DEFINED 74