aboutsummaryrefslogtreecommitdiff
path: root/src-qt5/core/libLumina/obsolete/RootSubWindow.h
blob: 598298e25b0cf4180605745413935fc74463180c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
//===========================================
//  Lumina Desktop source code
//  Copyright (c) 2017, Ken Moore
//  Available under the 3-clause BSD license
//  See the LICENSE file for full details
//===========================================
//  This class embeds a native window
//  within the RootWindow area
//===========================================
#ifndef _LUMINA_ROOT_WINDOW_SUB_WINDOW_H
#define _LUMINA_ROOT_WINDOW_SUB_WINDOW_H

#include <QWindow>
#include <QWidget>
#include <QCloseEvent>
#include <QFrame>
#include <QBoxLayout>
#include <QLabel>
#include <QToolButton>
#include <QMenu>
#include <QPropertyAnimation>
#include <NativeWindow.h>
#include <NativeEmbedWidget.h>

class RootSubWindow : public QFrame{
	Q_OBJECT
public:
	RootSubWindow(QWidget *root, NativeWindow *win);
	~RootSubWindow();

	WId id();
	NativeWindow* nativeWindow();

private:
	//Window status
	enum ModState{Normal, Move, ResizeTop, ResizeTopRight, ResizeRight, ResizeBottomRight, ResizeBottom, ResizeBottomLeft, ResizeLeft, ResizeTopLeft};
	ModState activeState;
	ModState currentCursor;
	QPoint offset; //needed for movement calculations (offset from mouse click to movement point)
	//Functions for getting/setting state
	ModState getStateAtPoint(QPoint pt, bool setoffset = false); //generally used for mouse location detection
	void setMouseCursor(ModState, bool override = false);  //Update the mouse cursor based on state

	//Native window embed objects
	NativeWindow *WIN;
	NativeEmbedWidget *WinWidget;
	bool closing;
	//Title bar objects
	QBoxLayout *titleBarL, *mainLayout;
	QToolButton *closeB, *maxB, *minB, *otherB;
	QLabel *titleLabel;
	QMenu *otherM; //menu of other actions
	QWidget *titleBar;
	//Other random objects (animations,etc)
	QPropertyAnimation *anim;
	QVariant animResetProp;
	QTimer *moveTimer;
	QRect lastGeom, lastMaxGeom; //frame coordinates

	void initWindowFrame();
	void enableFrame(bool);
	void enableFrame(QList<NativeWindow::Type> types);

	void LoadProperties( QList< NativeWindow::Property> list);

	static QStringList validAnimations(NativeWindow::Property);

public slots:
	void ensureVisible(){ WIN->setProperty(NativeWindow::Visible, true); }
	void giveMouseFocus(){ WinWidget->raiseWindow(); }
	void removeMouseFocus(){ WinWidget->lowerWindow(); }
	void giveKeyboardFocus(){ WIN->requestProperty(NativeWindow::Active, true, true); }

	void clientClosed();
	void LoadAllProperties();

	QRect clientGlobalGeom();

	//Button Actions - public so they can be tied to key shortcuts and stuff as well
	void toggleMinimize();
	void toggleMaximize();
	void triggerClose();
	void toggleSticky();
	void activate();

	//Mouse Interactivity
	void startMoving();
	void startResizing();

private slots:
	void propertiesChanged(QList<NativeWindow::Property>, QList<QVariant>);

	void loadAnimation(QString name, NativeWindow::Property, QVariant nval); //new val
	void animFinished();

protected:
	void mousePressEvent(QMouseEvent*);
	void mouseMoveEvent(QMouseEvent*);
	void mouseReleaseEvent(QMouseEvent*);
	//void leaveEvent(QEvent *ev);
	//void enterEvent(QEvent *ev);
	void moveEvent(QMoveEvent *ev);

signals:
	void windowMoved(RootSubWindow*);
	void windowAnimFinished();
};

#endif
bgstack15