-
Notifications
You must be signed in to change notification settings - Fork 69
Expand file tree
/
Copy pathBaseWindow.h
More file actions
97 lines (75 loc) · 2.58 KB
/
Copy pathBaseWindow.h
File metadata and controls
97 lines (75 loc) · 2.58 KB
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
/*
BaseWindow.h -- base menu window
Copyright (C) 2017 a1batross
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
*/
#ifndef BASEWINDOW_H
#define BASEWINDOW_H
#include "ItemsHolder.h"
#include "BackgroundBitmap.h"
// Base class for windows.
// Should be used for message boxes, dialogs, root menus(e.g. frameworks)
class CMenuBaseWindow : public CMenuItemsHolder
{
public:
typedef CMenuItemsHolder BaseClass;
CMenuBaseWindow( const char *name = "Unnamed Window", CWindowStack *pStack = &uiStatic.menu );
// Overloaded functions
// Window visibility is switched through window stack
void Hide() override;
void Show() override;
bool IsVisible() const override;
bool KeyUp( int key ) override;
bool KeyDown( int key ) override;
void Draw() override;
bool KeyValueData(const char *key, const char *data) override;
enum EAnimation
{
ANIM_NO = 0, // no animation
ANIM_CLOSING, // window closing animation
ANIM_OPENING, // window showing animation
};
// Override this method to draw custom animations
// For example, during transitions
// Return false when animation is still going
// Otherwise return true, so window will be marked as "no animation"
// and this method will not be called anymore(until next menu transition)
virtual bool DrawAnimation();
// Check current window is a root
virtual bool IsRoot() const { return false; }
// Hide current window and save changes
virtual void SaveAndPopMenu();
bool IsWindow() override { return true; }
void EnableTransition( EAnimation type );
void DisableTransition() { eTransitionType = ANIM_NO; }
// set parent of window
void Link( CMenuItemsHolder *h )
{
m_pParent = h;
}
bool bAllowDrag;
EAnimation eTransitionType; // valid only when in transition
const CWindowStack *WindowStack() const
{
return m_pStack;
}
protected:
int m_iTransitionStartTime;
CWindowStack *m_pStack;
private:
CMenuBaseWindow(); // remove
friend void UI_DrawMouseCursor( void ); // HACKHACK: Cursor should be set by menu item
friend void UI_UpdateMenu( float flTime );
bool IsAbsolutePositioned( void ) const override { return true; }
void DragDrop( int down );
bool m_bHolding;
Point m_bHoldOffset;
};
#endif // BASEWINDOW_H