Editor API
UnigineEditor public API
RenderWindow.h
1 // Copyright (C), UNIGINE. All rights reserved.
2 #pragma once
3 
4 #include <editor/EditorGlobal.h>
5 
6 #include <UnigineCallback.h>
7 
8 #include <QWidget>
9 
10 namespace Editor { class RenderWindowPrivate; }
11 
12 namespace Editor
13 {
14 
16 // RenderWindow.
22 class EDITOR_API RenderWindow : public QWidget
23 {
24  Q_OBJECT
25  Q_DISABLE_COPY(RenderWindow)
26 
27 public:
32  {
34  RENDERING_POLICY_WINDOW_VISIBLE = 0,
39  };
40 
41 public:
42  explicit RenderWindow(QWidget *parent = nullptr);
43  ~RenderWindow() override;
44 
45  struct Callback;
46  using CallbackId = Callback *;
53  CallbackId addUpdateCallback(Unigine::CallbackBase *update_func);
60  CallbackId addRenderCallback(Unigine::CallbackBase *render_func);
67  CallbackId addSwapCallback(Unigine::CallbackBase *swap_func);
72  CallbackId addFocusChangedCallback(Unigine::CallbackBase *focus_changed_func);
79  CallbackId addFocusInChangedCallback(Unigine::CallbackBase *focus_in_func);
85  CallbackId addFocusOutChangedCallback(Unigine::CallbackBase *focus_out_func);
94  CallbackId addDragEnterCallback(Unigine::CallbackBase1<QDragEnterEvent *> *drag_enter_func);
103  CallbackId addDragMoveCallback(Unigine::CallbackBase1<QDragMoveEvent *> *drag_move_func);
112  CallbackId addDragLeaveCallback(Unigine::CallbackBase1<QDragLeaveEvent *> *drag_leave_func);
138  CallbackId addDropCallback(Unigine::CallbackBase1<QDropEvent *> *drop_func);
142  bool removeCallback(CallbackId callback_id);
144  void clearCallbacks();
145 
151  void setRenderingPolicy(RENDERING_POLICY rendering_policy);
157  RENDERING_POLICY getRenderingPolicy() const;
158 
159  QPaintEngine *paintEngine() const final override { return nullptr; }
160 
161 signals:
166  void focusChanged();
167 
168 protected:
175  virtual void onUpdate() {}
182  virtual void onRender() {}
189  virtual void onSwap() {}
190 
197  bool event(QEvent *event) override;
198  void paintEvent(QPaintEvent *) final override {}
207  void resizeEvent(QResizeEvent *event) override;
221  void focusInEvent(QFocusEvent *event) override;
235  void focusOutEvent(QFocusEvent *event) override;
245  void dragEnterEvent(QDragEnterEvent *event) override;
254  void dragMoveEvent(QDragMoveEvent *event) override;
262  void dragLeaveEvent(QDragLeaveEvent *event) override;
270  void dropEvent(QDropEvent *event) override;
271 
272 private:
273  void do_update();
274  void do_render();
275  void do_swap();
276  bool is_paused_rendering() const;
277 
278 private:
279  friend class RenderWindowPrivate;
280  RenderWindowPrivate *const d;
281 };
282 
283 } // namespace Editor
Definition: Actions.h:11
void paintEvent(QPaintEvent *) final override
Definition: RenderWindow.h:198
The window is rendered only when it is visible and focused.
Definition: RenderWindow.h:36
QPaintEngine * paintEngine() const final override
Definition: RenderWindow.h:159
virtual void onRender()
You can inherit your class from RenderWindow and override this method to define your custom actions t...
Definition: RenderWindow.h:182
RENDERING_POLICY
Rendering policy for the window that defines when it should be rendered depending on its visibility a...
Definition: RenderWindow.h:31
virtual void onSwap()
You can inherit your class from RenderWindow and override this method to define your custom actions t...
Definition: RenderWindow.h:189
Callback * CallbackId
Definition: RenderWindow.h:46
This class is used to represent a window widget to which an image can be rendered by the Engine....
Definition: RenderWindow.h:22
virtual void onUpdate()
You can inherit your class from RenderWindow and override this method to define your custom actions t...
Definition: RenderWindow.h:175
The window is always rendered regardless of its visibility and focus status.
Definition: RenderWindow.h:38