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 "Slide.h" 12 13 #include "SkTArray.h" 14 15 class SkString; 16 17 namespace sksg { 18 19 class Group; 20 class Scene; 21 22 } 23 24 class SlideDir final : public Slide { 25 public: 26 SlideDir(const SkString& name, SkTArray<sk_sp<Slide>, true>&&, 27 int columns = kDefaultColumnCount); 28 29 protected: 30 void load(SkScalar winWidth, SkScalar winHeight) override; 31 void unload() override; 32 33 SkISize getDimensions() const override; 34 35 void draw(SkCanvas*) override; 36 bool animate(const SkAnimTimer&) override; 37 38 bool onChar(SkUnichar) override; 39 bool onMouse(SkScalar x, SkScalar y, sk_app::Window::InputState, uint32_t modifiers) override; 40 41 private: 42 struct Rec; 43 class FocusController; 44 45 static constexpr int kDefaultColumnCount = 4; 46 47 const Rec* findCell(float x, float y) const; 48 49 const SkTArray<sk_sp<Slide>, true> fSlides; 50 std::unique_ptr<FocusController> fFocusController; 51 const int fColumns; 52 53 SkTArray<Rec, true> fRecs; 54 std::unique_ptr<sksg::Scene> fScene; 55 sk_sp<sksg::Group> fRoot; 56 57 SkSize fWinSize = SkSize::MakeEmpty(); 58 SkSize fCellSize = SkSize::MakeEmpty(); 59 SkMSec fTimeBase = 0; 60 61 const Rec* fTrackingCell = nullptr; 62 SkPoint fTrackingPos = SkPoint::Make(0, 0); 63 64 using INHERITED = Slide; 65 }; 66 67 #endif // SlideDir_DEFINED 68