Editor API
UnigineEditor public API
UnigineRenderWindow.h
1 // Copyright (C), UNIGINE. All rights reserved.
2 #pragma once
3 
4 #include <editor/UnigineEditorGlobal.h>
5 
6 #include <UnigineCallback.h>
7 
8 #include <QWidget>
9 
10 
12 // Forward decl.
14 namespace UnigineEditor { class RenderWindowPrivate; }
15 
16 namespace UnigineEditor
17 {
18 
20 // RenderWindow.
26 class UNIGINE_EDITOR_API RenderWindow : public QWidget
27 {
28  Q_OBJECT
29  Q_DISABLE_COPY(RenderWindow)
30 
31 public:
36  {
38  RENDERING_POLICY_WINDOW_VISIBLE = 0,
43  };
44 
45 public:
46  explicit RenderWindow(QWidget *parent = nullptr);
47  ~RenderWindow() override;
48 
49  struct Callback;
50  using CallbackId = Callback *;
57  CallbackId addUpdateCallback(Unigine::CallbackBase *update_func);
64  CallbackId addRenderCallback(Unigine::CallbackBase *render_func);
71  CallbackId addSwapCallback(Unigine::CallbackBase *swap_func);
76  CallbackId addFocusChangedCallback(Unigine::CallbackBase *focus_changed_func);
83  CallbackId addFocusInChangedCallback(Unigine::CallbackBase *focus_in_func);
89  CallbackId addFocusOutChangedCallback(Unigine::CallbackBase *focus_out_func);
98  CallbackId addDragEnterCallback(Unigine::CallbackBase1<QDragEnterEvent *> *drag_enter_func);
107  CallbackId addDragMoveCallback(Unigine::CallbackBase1<QDragMoveEvent *> *drag_move_func);
116  CallbackId addDragLeaveCallback(Unigine::CallbackBase1<QDragLeaveEvent *> *drag_leave_func);
142  CallbackId addDropCallback(Unigine::CallbackBase1<QDropEvent *> *drop_func);
146  bool removeCallback(CallbackId callback_id);
148  void clearCallbacks();
149 
155  void setRenderingPolicy(RENDERING_POLICY rendering_policy);
161  RENDERING_POLICY getRenderingPolicy() const;
162 
163  QPaintEngine *paintEngine() const final override { return nullptr; }
164 
165 signals:
170  void focusChanged();
171 
172 protected:
179  virtual void onUpdate() {}
186  virtual void onRender() {}
193  virtual void onSwap() {}
194 
201  bool event(QEvent *event) override;
202  void paintEvent(QPaintEvent *) final override {}
211  void resizeEvent(QResizeEvent *event) override;
225  void focusInEvent(QFocusEvent *event) override;
239  void focusOutEvent(QFocusEvent *event) override;
249  void dragEnterEvent(QDragEnterEvent *event) override;
258  void dragMoveEvent(QDragMoveEvent *event) override;
266  void dragLeaveEvent(QDragLeaveEvent *event) override;
274  void dropEvent(QDropEvent *event) override;
275 
276 private:
277  void do_update();
278  void do_render();
279  void do_swap();
280  bool is_paused_rendering() const;
281 
282 private:
283  friend class ::UnigineEditor::RenderWindowPrivate;
284  ::UnigineEditor::RenderWindowPrivate *const d;
285 };
286 
287 } // namespace UnigineEditor
RENDERING_POLICY
Rendering policy for the window that defines when it should be rendered depending on its visibility a...
Definition: UnigineRenderWindow.h:35
virtual void onRender()
You can inherit your class from RenderWindow and override this method to define your custom actions t...
Definition: UnigineRenderWindow.h:186
The window is always rendered regardless of its visibility and focus status.
Definition: UnigineRenderWindow.h:42
virtual void onUpdate()
You can inherit your class from RenderWindow and override this method to define your custom actions t...
Definition: UnigineRenderWindow.h:179
virtual void onSwap()
You can inherit your class from RenderWindow and override this method to define your custom actions t...
Definition: UnigineRenderWindow.h:193
This class is used to represent a window widget to which an image can be rendered by the Engine....
Definition: UnigineRenderWindow.h:26
The window is rendered only when it is visible and focused.
Definition: UnigineRenderWindow.h:40