b77d502946
Remove SkAnimTimer from the module interface entirely. Clean up some other SkParticleEffect methods. Simplify VisitTypes to just visit all of them, it's easier for the client to do any filtering. In the slide, make the UI far nicer. Load all files in a given directory, and allow editing (and saving) them all at once, or adding a new entry. Support multiple playing effects, with a draggable handle to set the position. Bug: skia: Change-Id: I0bec4077f9135bc122569f1410bebc96d5439480 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/197243 Reviewed-by: Brian Osman <brianosman@google.com> Commit-Queue: Brian Osman <brianosman@google.com>
57 lines
1.3 KiB
C++
57 lines
1.3 KiB
C++
/*
|
|
* Copyright 2019 Google LLC
|
|
*
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
* found in the LICENSE file.
|
|
*/
|
|
|
|
#ifndef ParticlesSlide_DEFINED
|
|
#define ParticlesSlide_DEFINED
|
|
|
|
#include "Slide.h"
|
|
|
|
#include "SkPath.h"
|
|
#include "SkRandom.h"
|
|
#include "SkTArray.h"
|
|
|
|
class SkAnimTimer;
|
|
class SkParticleEffect;
|
|
class SkParticleEffectParams;
|
|
|
|
class ParticlesSlide : public Slide {
|
|
public:
|
|
ParticlesSlide();
|
|
|
|
// TODO: We need a way for primarily interactive slides to always be as large as the window
|
|
SkISize getDimensions() const override { return SkISize::MakeEmpty(); }
|
|
|
|
void load(SkScalar winWidth, SkScalar winHeight) override;
|
|
void draw(SkCanvas* canvas) override;
|
|
bool animate(const SkAnimTimer& timer) override;
|
|
|
|
bool onMouse(SkScalar x, SkScalar y, sk_app::Window::InputState state,
|
|
uint32_t modifiers) override;
|
|
|
|
private:
|
|
void loadEffects(const char* dirname);
|
|
|
|
SkRandom fRandom;
|
|
const SkAnimTimer* fTimer;
|
|
SkPoint fPlayPosition;
|
|
|
|
struct LoadedEffect {
|
|
SkString fName;
|
|
sk_sp<SkParticleEffectParams> fParams;
|
|
};
|
|
SkTArray<LoadedEffect> fLoaded;
|
|
|
|
struct RunningEffect {
|
|
SkPoint fPosition;
|
|
SkString fName;
|
|
sk_sp<SkParticleEffect> fEffect;
|
|
};
|
|
SkTArray<RunningEffect> fRunning;
|
|
};
|
|
|
|
#endif
|