2016-03-09 02:21:34 +00:00
|
|
|
/*
|
|
|
|
* OpenClonk, http://www.openclonk.org
|
|
|
|
*
|
|
|
|
* Copyright (c) 2001-2009, RedWolf Design GmbH, http://www.clonk.de/
|
|
|
|
* Copyright (c) 2013, The OpenClonk Team and contributors
|
|
|
|
*
|
|
|
|
* Distributed under the terms of the ISC license; see accompanying file
|
|
|
|
* "COPYING" for details.
|
|
|
|
*
|
|
|
|
* "Clonk" is a registered trademark of Matthes Bender, used with permission.
|
|
|
|
* See accompanying file "TRADEMARK" for details.
|
|
|
|
*
|
|
|
|
* To redistribute this file separately, substitute the full license texts
|
|
|
|
* for the above references.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Player and editor viewports in console */
|
|
|
|
|
|
|
|
#ifndef INC_C4ConsoleQtViewport
|
|
|
|
#define INC_C4ConsoleQtViewport
|
|
|
|
#ifdef WITH_QT_EDITOR
|
|
|
|
|
2016-04-03 19:06:32 +00:00
|
|
|
#include "C4Include.h" // needed for automoc
|
|
|
|
#include "editor/C4ConsoleGUI.h" // for glew.h
|
|
|
|
#include "editor/C4ConsoleQt.h"
|
2016-03-09 02:21:34 +00:00
|
|
|
|
2016-03-20 19:43:37 +00:00
|
|
|
class C4ConsoleQtViewportView : public QOpenGLWidget
|
2016-03-09 02:21:34 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
class C4ConsoleQtViewportDockWidget *dock;
|
|
|
|
class C4Viewport *cvp;
|
|
|
|
|
|
|
|
private:
|
|
|
|
bool IsPlayViewport() const;
|
2016-06-11 20:36:48 +00:00
|
|
|
qreal GetDevicePixelRatio();
|
2016-06-19 22:19:43 +00:00
|
|
|
void ShowContextMenu(const QPoint &pos);
|
|
|
|
void AddSelectObjectContextEntry(C4Object *obj, QMenu *menu);
|
2016-11-02 13:24:14 +00:00
|
|
|
void UpdateCursor();
|
2016-03-09 02:21:34 +00:00
|
|
|
|
|
|
|
protected:
|
2016-03-16 02:58:41 +00:00
|
|
|
void focusInEvent(QFocusEvent * event) override;
|
|
|
|
void focusOutEvent(QFocusEvent * event) override;
|
2016-03-09 02:21:34 +00:00
|
|
|
void mouseMoveEvent(QMouseEvent *eventMove) override;
|
|
|
|
void mousePressEvent(QMouseEvent *eventPress) override;
|
|
|
|
void mouseDoubleClickEvent(QMouseEvent *eventPress) override;
|
|
|
|
void mouseReleaseEvent(QMouseEvent *releaseEvent) override;
|
|
|
|
void wheelEvent(QWheelEvent *event) override;
|
2016-03-16 02:58:41 +00:00
|
|
|
void keyPressEvent(QKeyEvent * event) override;
|
|
|
|
void keyReleaseEvent(QKeyEvent * event) override;
|
2016-03-18 03:18:29 +00:00
|
|
|
void enterEvent(QEvent *) override;
|
|
|
|
void leaveEvent(QEvent *) override;
|
2016-03-09 02:21:34 +00:00
|
|
|
|
|
|
|
public:
|
2016-03-28 20:07:43 +00:00
|
|
|
C4ConsoleQtViewportView(class C4ConsoleQtViewportScrollArea *scrollarea);
|
2016-03-20 19:43:37 +00:00
|
|
|
|
|
|
|
// QOpenGLWidget functions
|
|
|
|
void initializeGL() override;
|
|
|
|
void resizeGL(int w, int h) override;
|
|
|
|
void paintGL() override;
|
2016-03-09 02:21:34 +00:00
|
|
|
};
|
|
|
|
|
2016-03-28 20:07:43 +00:00
|
|
|
class C4ConsoleQtViewportScrollArea : public QAbstractScrollArea
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
class C4ConsoleQtViewportDockWidget *dock;
|
|
|
|
class C4Viewport *cvp;
|
2016-10-08 23:04:09 +00:00
|
|
|
int32_t is_updating_scrollbars;
|
2016-03-28 20:07:43 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
void scrollContentsBy(int dx, int dy) override;
|
|
|
|
bool viewportEvent(QEvent *e) override;
|
|
|
|
|
|
|
|
public:
|
|
|
|
C4ConsoleQtViewportScrollArea(class C4ConsoleQtViewportDockWidget *dock);
|
|
|
|
|
|
|
|
void setupViewport(QWidget *viewport) override;
|
|
|
|
void ScrollBarsByViewPosition();
|
|
|
|
void setScrollBarVisibility(bool visible);
|
|
|
|
|
|
|
|
friend C4ConsoleQtViewportView;
|
|
|
|
};
|
|
|
|
|
2016-03-09 02:21:34 +00:00
|
|
|
class C4ConsoleQtViewportDockWidget : public QDockWidget
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
2016-03-16 02:58:41 +00:00
|
|
|
class C4ConsoleQtMainWindow *main_window;
|
2016-03-09 02:21:34 +00:00
|
|
|
class C4ViewportWindow *cvp;
|
|
|
|
C4ConsoleQtViewportView *view;
|
|
|
|
|
|
|
|
protected:
|
2017-05-07 11:50:00 +00:00
|
|
|
void mousePressEvent(QMouseEvent *eventPress) override;
|
2016-03-16 02:58:41 +00:00
|
|
|
void OnActiveChanged(bool active);
|
2016-03-09 02:21:34 +00:00
|
|
|
|
|
|
|
public:
|
2016-03-16 02:58:41 +00:00
|
|
|
C4ConsoleQtViewportDockWidget(class C4ConsoleQtMainWindow *main_window, QMainWindow *parent, class C4ViewportWindow *window);
|
2017-05-07 11:50:00 +00:00
|
|
|
void closeEvent(QCloseEvent * event) override;
|
2016-03-09 02:21:34 +00:00
|
|
|
class C4ViewportWindow *GetViewportWindow() const { return cvp; }
|
2016-10-08 23:07:21 +00:00
|
|
|
void SetFocus() { raise(); view->setFocus(); } // forward focus to view
|
2016-09-10 05:17:19 +00:00
|
|
|
bool HasFocus() { return view->hasFocus(); } // forward focus to view
|
2016-08-07 03:39:44 +00:00
|
|
|
bool event(QEvent *e) override;
|
2016-03-09 02:21:34 +00:00
|
|
|
|
|
|
|
private slots :
|
2016-03-16 02:58:41 +00:00
|
|
|
void TopLevelChanged(bool is_floating);
|
2016-03-09 02:21:34 +00:00
|
|
|
|
|
|
|
friend C4ConsoleQtViewportView;
|
2016-03-28 20:07:43 +00:00
|
|
|
friend C4ConsoleQtViewportScrollArea;
|
2016-03-09 02:21:34 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif // WITH_QT_EDITOR
|
|
|
|
#endif // INC_C4ConsoleQtViewport
|