OpenClonk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
C4ConsoleQtViewport.h
Go to the documentation of this file.
1 /*
2 * OpenClonk, http://www.openclonk.org
3 *
4 * Copyright (c) 2001-2009, RedWolf Design GmbH, http://www.clonk.de/
5 * Copyright (c) 2013, The OpenClonk Team and contributors
6 *
7 * Distributed under the terms of the ISC license; see accompanying file
8 * "COPYING" for details.
9 *
10 * "Clonk" is a registered trademark of Matthes Bender, used with permission.
11 * See accompanying file "TRADEMARK" for details.
12 *
13 * To redistribute this file separately, substitute the full license texts
14 * for the above references.
15 */
16 
17 /* Player and editor viewports in console */
18 
19 #ifndef INC_C4ConsoleQtViewport
20 #define INC_C4ConsoleQtViewport
21 #ifdef WITH_QT_EDITOR
22 
23 #include "C4Include.h" // needed for automoc
24 #include "editor/C4ConsoleGUI.h" // for glew.h
25 #include "editor/C4ConsoleQt.h"
26 
27 class C4ConsoleQtViewportView : public QOpenGLWidget
28 {
29  Q_OBJECT
30 
31  class C4ConsoleQtViewportDockWidget *dock;
32  class C4Viewport *cvp;
33 
34 private:
35  bool IsPlayViewport() const;
36  qreal GetDevicePixelRatio();
37  void ShowContextMenu(const QPoint &pos);
38  void AddSelectObjectContextEntry(C4Object *obj, QMenu *menu);
39  void UpdateCursor();
40 
41 protected:
42  void focusInEvent(QFocusEvent * event) override;
43  void focusOutEvent(QFocusEvent * event) override;
44  void mouseMoveEvent(QMouseEvent *eventMove) override;
45  void mousePressEvent(QMouseEvent *eventPress) override;
46  void mouseDoubleClickEvent(QMouseEvent *eventPress) override;
47  void mouseReleaseEvent(QMouseEvent *releaseEvent) override;
48  void wheelEvent(QWheelEvent *event) override;
49  void keyPressEvent(QKeyEvent * event) override;
50  void keyReleaseEvent(QKeyEvent * event) override;
51  void enterEvent(QEvent *) override;
52  void leaveEvent(QEvent *) override;
53 
54 public:
55  C4ConsoleQtViewportView(class C4ConsoleQtViewportScrollArea *scrollarea);
56 
57  // QOpenGLWidget functions
58  void initializeGL() override;
59  void resizeGL(int w, int h) override;
60  void paintGL() override;
61 };
62 
63 class C4ConsoleQtViewportScrollArea : public QAbstractScrollArea
64 {
65  Q_OBJECT
66 
67  class C4ConsoleQtViewportDockWidget *dock;
68  class C4Viewport *cvp;
69  int32_t is_updating_scrollbars;
70 
71 protected:
72  void scrollContentsBy(int dx, int dy) override;
73  bool viewportEvent(QEvent *e) override;
74 
75 public:
76  C4ConsoleQtViewportScrollArea(class C4ConsoleQtViewportDockWidget *dock);
77 
78  void setupViewport(QWidget *viewport) override;
80  void setScrollBarVisibility(bool visible);
81 
83 };
84 
85 class C4ConsoleQtViewportDockWidget : public QDockWidget
86 {
87  Q_OBJECT
88 
89  class C4ConsoleQtMainWindow *main_window;
90  class C4ViewportWindow *cvp;
91  C4ConsoleQtViewportView *view;
92 
93 protected:
94  void mousePressEvent(QMouseEvent *eventPress) override;
95  void OnActiveChanged(bool active);
96 
97 public:
98  C4ConsoleQtViewportDockWidget(class C4ConsoleQtMainWindow *main_window, QMainWindow *parent, class C4ViewportWindow *window);
99  void closeEvent(QCloseEvent * event) override;
100  class C4ViewportWindow *GetViewportWindow() const { return cvp; }
101  void SetFocus() { raise(); view->setFocus(); } // forward focus to view
102  bool HasFocus() { return view->hasFocus(); } // forward focus to view
103  bool event(QEvent *e) override;
104 
105 private slots :
106  void TopLevelChanged(bool is_floating);
107 
108  friend C4ConsoleQtViewportView;
109  friend C4ConsoleQtViewportScrollArea;
110 };
111 
112 
113 #endif // WITH_QT_EDITOR
114 #endif // INC_C4ConsoleQtViewport
C4Viewport * cvp
friend class C4ConsoleQtViewportView
Definition: C4Viewport.h:138
bool ScrollBarsByViewPosition()
Definition: C4Console.cpp:709