SlideDir.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. #ifndef SlideDir_DEFINED
  8. #define SlideDir_DEFINED
  9. #include "tools/viewer/Slide.h"
  10. #include "include/private/SkTArray.h"
  11. class SkString;
  12. namespace sksg {
  13. class Group;
  14. class Scene;
  15. }
  16. class SlideDir final : public Slide {
  17. public:
  18. SlideDir(const SkString& name, SkTArray<sk_sp<Slide>>&&,
  19. int columns = kDefaultColumnCount);
  20. protected:
  21. void load(SkScalar winWidth, SkScalar winHeight) override;
  22. void unload() override;
  23. SkISize getDimensions() const override;
  24. void draw(SkCanvas*) override;
  25. bool animate(double) override;
  26. bool onChar(SkUnichar) override;
  27. bool onMouse(SkScalar x, SkScalar y, InputState, ModifierKey modifiers) override;
  28. private:
  29. struct Rec;
  30. class FocusController;
  31. static constexpr int kDefaultColumnCount = 4;
  32. const Rec* findCell(float x, float y) const;
  33. const SkTArray<sk_sp<Slide>> fSlides;
  34. std::unique_ptr<FocusController> fFocusController;
  35. const int fColumns;
  36. SkTArray<Rec, true> fRecs;
  37. std::unique_ptr<sksg::Scene> fScene;
  38. sk_sp<sksg::Group> fRoot;
  39. SkSize fWinSize = SkSize::MakeEmpty();
  40. SkSize fCellSize = SkSize::MakeEmpty();
  41. SkMSec fTimeBase = 0;
  42. const Rec* fTrackingCell = nullptr;
  43. SkPoint fTrackingPos = SkPoint::Make(0, 0);
  44. using INHERITED = Slide;
  45. };
  46. #endif // SlideDir_DEFINED