• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2 * Copyright 2016 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 Slide_DEFINED
9 #define Slide_DEFINED
10 
11 #include "include/core/SkRefCnt.h"
12 #include "include/core/SkSize.h"
13 #include "include/core/SkString.h"
14 #include "tools/Registry.h"
15 #include "tools/sk_app/Window.h"
16 
17 class SkCanvas;
18 class SkMetaData;
19 class Slide;
20 
21 using SlideFactory = Slide* (*)();
22 using SlideRegistry = sk_tools::Registry<SlideFactory>;
23 
24 #define DEF_SLIDE(code) \
25     static Slide*          SK_MACRO_APPEND_LINE(F_)() { code } \
26     static SlideRegistry   SK_MACRO_APPEND_LINE(R_)(SK_MACRO_APPEND_LINE(F_));
27 
28 class Slide : public SkRefCnt {
29 public:
30     /**
31      * A slide may have a content dimensions that is independent of the current window size. An
32      * empty size indicates that the Slide's dimensions are equal to the window's dimensions.
33      */
getDimensions()34     virtual SkISize getDimensions() const { return SkISize::MakeEmpty(); }
35 
gpuTeardown()36     virtual void gpuTeardown() { }
37     virtual void draw(SkCanvas* canvas) = 0;
animate(double nanos)38     virtual bool animate(double nanos) { return false; }
load(SkScalar winWidth,SkScalar winHeight)39     virtual void load(SkScalar winWidth, SkScalar winHeight) {}
resize(SkScalar winWidth,SkScalar winHeight)40     virtual void resize(SkScalar winWidth, SkScalar winHeight) {}
unload()41     virtual void unload() {}
42 
onChar(SkUnichar c)43     virtual bool onChar(SkUnichar c) { return false; }
onMouse(SkScalar x,SkScalar y,skui::InputState state,skui::ModifierKey modifiers)44     virtual bool onMouse(SkScalar x, SkScalar y, skui::InputState state,
45                          skui::ModifierKey modifiers) { return false; }
46 
onGetControls(SkMetaData *)47     virtual bool onGetControls(SkMetaData*) { return false; }
onSetControls(const SkMetaData &)48     virtual void onSetControls(const SkMetaData&) {}
49 
getName()50     const SkString& getName() { return fName; }
51 
52 protected:
53     SkString    fName;
54 };
55 
56 #endif
57