MT Showcase SDK
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
SnapshotCaptureWidget.hpp
1 #ifndef SNAPSHOTCAPTUREWIDGET_HPP
2 #define SNAPSHOTCAPTUREWIDGET_HPP
3 
4 #include "Export.hpp"
5 #include "Utils.hpp"
6 
7 #include <MultiWidgets/Widget.hpp>
8 
9 #include <folly/futures/Future.h>
10 
11 namespace Showcase {
12 
13  enum { OVERSAMPLE = 2 };
14  enum { MAXSIZE = 4096 };
15  enum { DEFAULT_SNAPSHOT_MASK = Utils::OBJECT_MENU |
16  Utils::OBJECT_EXCLUDE_FROM_SNAPSHOT};
17 
20  class SHOWCASE_API SnapShottable
21  {
22  public:
23  typedef std::function<void(bool ok, QString title)> SnapShotCallback;
24 
25  virtual folly::Future<bool> requestSnapshot(const Nimble::SizeI & maximumDimensions,
26  const QString & filename,
27  const Nimble::SizeI & preferredDimensions = Nimble::SizeI(0, 0),
28  int oversample = OVERSAMPLE) = 0;
29  };
30 
31  class SnapShotCaptureWidget;
32  INTRUSIVE_PTR_TYPEDEF(SnapShotCaptureWidget);
33 
34  class SHOWCASE_API SnapShotCaptureWidget : public MultiWidgets::Widget
35  {
36  public:
37 
38  typedef SnapShottable::SnapShotCallback Callback;
39 
40  SnapShotCaptureWidget();
41  virtual ~SnapShotCaptureWidget();
42 
43  virtual void update(const MultiWidgets::FrameInfo &frameInfo) OVERRIDE;
44 
49  folly::Future<bool> requestSnapshot(MultiWidgets::WidgetPtr w,
50  const QString & filename,
51  const Nimble::SizeI & maximumDimensions = Nimble::SizeI(MAXSIZE, MAXSIZE),
52  const Nimble::SizeI & preferredDimensions = Nimble::SizeI(0, 0),
53  int oversample = OVERSAMPLE,
54  const Nimble::Vector2f & viewOffset = Nimble::Vector2f(0, 0),
55  const Nimble::SizeF & viewSize = Nimble::SizeF(0, 0),
56  bool forceSnapshot = false,
57  uint64_t objectMask = DEFAULT_SNAPSHOT_MASK);
58 
59  void addFlashEffect(MultiWidgets::WidgetPtr w);
60 
61  static folly::Future<bool> takeSnapshot(MultiWidgets::WidgetPtr w,
62  const QString & filePath, bool flash = false,
63  const Nimble::SizeI & maximumDimensions = Nimble::SizeI(MAXSIZE, MAXSIZE),
64  Nimble::Vector2f viewOffset = Nimble::Vector2f(0, 0),
65  Nimble::SizeF viewSize = Nimble::SizeF(0, 0),
66  uint64_t objectMask = DEFAULT_SNAPSHOT_MASK);
67 
68  static SnapShotCaptureWidgetPtr snapshotWidget();
69 
70  protected:
71 
72  virtual void renderContent(Luminous::RenderContext &r) const OVERRIDE;
73 
74  private:
75  class D;
76  D * m_d;
77  };
78 
79 }
80 
81 #endif // SNAPSHOTCAPTUREWIDGET_HPP