blob: b4d5d2b28ed0162e766e111bb084b233c901db74 [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
34 void draw(SkCanvas* canvas) override;
35 void load(SkScalar winWidth, SkScalar winHeight) override;
36 void unload() override;
37 bool animate(const SkAnimTimer& timer) override;
38
39 bool onChar(SkUnichar c) override;
40 bool onMouse(SkScalar x, SkScalar y, sk_app::Window::InputState state,
41 uint32_t modifiers) override;
42
43private:
44 void resetActor();
45
46 void renderGUI();
47
48private:
49 std::string fBasePath;
50 std::unique_ptr<NIMAActor> fActor;
51
52 bool fPlaying;
53 float fTime;
Ruiqi Mao46656e22018-07-20 14:18:50 -040054 uint32_t fRenderFlags;
Ruiqi Maof5101492018-06-29 14:32:21 -040055
56 nima::ActorAnimationInstance* fAnimation;
57 int fAnimationIndex;
58};
59
60#endif