skia2/tools/viewer/RiveSlide.h
Michael Reed 14aa53bf38 Add rive to third_party
Add rive slide to Viewer

Change-Id: Id25a7ac2a65e816544159ff4b3f582249f9ba0ce
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/541742
Auto-Submit: Mike Reed <mike@reedtribe.org>
Reviewed-by: Florin Malita <fmalita@google.com>
Commit-Queue: Florin Malita <fmalita@google.com>
2022-05-20 13:33:30 +00:00

54 lines
1.2 KiB
C++

/*
* Copyright 2022 Rive Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef RiveSlide_DEFINED
#define RiveSlide_DEFINED
#include "tools/viewer/Slide.h"
#include "include/core/SkMatrix.h"
#include "include/core/SkRect.h"
#include <rive/artboard.hpp>
#include <rive/file.hpp>
#include <rive/animation/state_machine_instance.hpp>
#include <rive/animation/linear_animation_instance.hpp>
#include <vector>
class RiveSlide : public Slide {
public:
RiveSlide(const SkString& name, const SkString& path);
~RiveSlide() override = default;
void load(SkScalar winWidth, SkScalar winHeight) override;
void unload() override;
void resize(SkScalar, SkScalar) override;
SkISize getDimensions() const override;
void draw(SkCanvas*) override;
bool animate(double) override;
bool onMouse(SkScalar, SkScalar, skui::InputState, skui::ModifierKey) override;
private:
const SkString fPath;
SkSize fWinSize;
double fSecsBase = 0;
SkRect fBounds;
SkMatrix fMat;
std::unique_ptr<rive::File> fFile;
std::unique_ptr<rive::ArtboardInstance> fArtboard;
std::unique_ptr<rive::Scene> fScene;
using INHERITED = Slide;
};
#endif // RiveSlide_DEFINED