blob: d1b129832598aed311bce83acef4dc92eb271c4b [file] [log] [blame]
Ruiqi Maof5101492018-06-29 14:32:21 -04001/*
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 NIMASlide_DEFINED
9#define NIMASlide_DEFINED
10
11#include "Slide.h"
12
13#include "SkCanvas.h"
14#include "SkVertices.h"
15#include <nima/Actor.hpp>
16#include <nima/ActorImage.hpp>
17#include <nima/Animation/ActorAnimationInstance.hpp>
18#include <nima/Vec2D.hpp>
19
20class NIMAActor;
21class NIMAActorImage;
22
Ruiqi Mao46656e22018-07-20 14:18:50 -040023enum RenderFlags {
24 kImmediate_RenderFlag = 0x1,
25 kCache_RenderFlag = 0x2,
26 kBounds_RenderFlag = 0x4,
Ruiqi Maof5101492018-06-29 14:32:21 -040027};
28
29class NIMASlide : public Slide {
30public:
31 NIMASlide(const SkString& name, const SkString& path);
32 ~NIMASlide() override;
33
Ben Wagner21151122018-09-04 18:35:20 -040034 SkISize getDimensions() const override;
35
Ruiqi Maof5101492018-06-29 14:32:21 -040036 void draw(SkCanvas* canvas) override;
37 void load(SkScalar winWidth, SkScalar winHeight) override;
38 void unload() override;
39 bool animate(const SkAnimTimer& timer) override;
40
41 bool onChar(SkUnichar c) override;
42 bool onMouse(SkScalar x, SkScalar y, sk_app::Window::InputState state,
43 uint32_t modifiers) override;
44
45private:
46 void resetActor();
47
48 void renderGUI();
49
50private:
51 std::string fBasePath;
52 std::unique_ptr<NIMAActor> fActor;
53
54 bool fPlaying;
55 float fTime;
Ruiqi Mao46656e22018-07-20 14:18:50 -040056 uint32_t fRenderFlags;
Ruiqi Maof5101492018-06-29 14:32:21 -040057
58 nima::ActorAnimationInstance* fAnimation;
59 int fAnimationIndex;
60};
61
62#endif