Subversion Repository Public Repository

Divide-Framework

This repository has no backups
This repository's network speed is throttled to 100KB/sec

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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
/*
Copyright (c) 2017 DIVIDE-Studio
Copyright (c) 2009 Ionut Cava

This file is part of DIVIDE Framework.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software
and associated documentation files (the "Software"), to deal in the Software
without restriction,
including without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so,
subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED,
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
IN CONNECTION WITH THE SOFTWARE
OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

*/

#ifndef _GUI_INTERFACE_H_
#define _GUI_INTERFACE_H_

#include "GUIElement.h"

namespace Divide {

class GUIText;
class GUIFlash;
class GUIButton;
class GUIMessageBox;

class GUIInterface {
public:
    typedef hashMapImpl<U64, std::pair<GUIElement*, bool/*last state*/>> GUIMap;
    typedef DELEGATE_CBK<void, I64> ButtonCallback;

public:
    explicit GUIInterface(GUI& context);
    virtual ~GUIInterface();

    virtual void onSizeChange(const SizeChangeParams& params);

    virtual void onLanguageChange(const char* newLanguage);

    inline GUI& getParentContext() { return *_context; }
    inline const GUI& getParentContext() const { return *_context; }
    /// Get a pointer to an element by name/id
    template<typename T = GUIElement>
    inline T* getGUIElement(U64 elementName) const {
        static_assert(std::is_base_of<GUIElement, T>::value,
            "getGuiElement error: Target is not a valid GUI item");

        return static_cast<T*>(getGUIElementImpl(elementName, getTypeEnum<T>()));
    }

    template<typename T = GUIElement>
    inline T* getGUIElement(I64 elementID) const {
        static_assert(std::is_base_of<GUIElement, T>::value,
            "getGuiElement error: Target is not a valid GUI item");

        return static_cast<T*>(getGUIElementImpl(elementID, getTypeEnum<T>()));
    }

    virtual GUIText* addText(U64 guiID,
                             const stringImpl& name,
                             const RelativePosition2D& position,
                             const stringImpl& font,
                             const UColour& colour,
                             const stringImpl& text,
                             U8 fontSize = 16u);

    inline GUIText* addText(const stringImpl& name,
                            const RelativePosition2D& position,
                            const stringImpl& font,
                            const UColour& colour,
                            const stringImpl& text,
                            U8 fontSize = 16u) {

        return addText(_ID_RT(name.c_str()), name, position, font, colour, text, fontSize);
    }

    virtual GUIText* modifyText(U64 guiID,
                                const stringImpl& text);

    inline GUIText* modifyText(const stringImpl& name,
                               const stringImpl& text) {
        return modifyText(_ID_RT(name.c_str()), text);
    }

    virtual GUIMessageBox* addMsgBox(U64 guiID,
                                     const stringImpl& name,
                                     const stringImpl& title,
                                     const stringImpl& message,
                                     const vec2<I32>& offsetFromCentre = vec2<I32>(0));

    inline GUIMessageBox* addMsgBox(U64 guiID,
                                    const stringImpl& title,
                                    const stringImpl& message,
                                    const vec2<I32>& offsetFromCentre = vec2<I32>(0)) {
        return addMsgBox(guiID, title, title, message, offsetFromCentre);
    }

    virtual GUIButton* addButton(U64 guiID,
                                 const stringImpl& name,
                                 const stringImpl& text,
                                 const RelativePosition2D& offset,
                                 const RelativeScale2D& size,
                                 const stringImpl& rootSheetID = "");

    inline GUIButton* addButton(U64 guiID,
                                const stringImpl& text,
                                const RelativePosition2D& offset,
                                const RelativeScale2D& size,
                                const stringImpl& rootSheetID = "") {
        return addButton(guiID, text, text, offset, size, rootSheetID);
   }

    virtual GUIFlash* addFlash(U64 guiID,
                               const stringImpl& name,
                               stringImpl movie,
                               const RelativePosition2D& position,
                               const RelativeScale2D& size);

    inline GUIFlash* addFlash(U64 guiID,
                              stringImpl movie,
                              const RelativePosition2D& position,
                              const RelativeScale2D& size) {
        return addFlash(guiID, movie, movie, position, size);
    }

    // Return true if input was consumed
    virtual bool mouseMoved(const GUIEvent& event);
    // Return true if input was consumed
    virtual bool onMouseUp(const GUIEvent& event);
    // Return true if input was consumed
    virtual bool onMouseDown(const GUIEvent& event);

protected:
    void addElement(U64 id, GUIElement* element);
    virtual GUIElement* getGUIElementImpl(U64 elementName, GUIType type) const;
    virtual GUIElement* getGUIElementImpl(I64 elementID, GUIType type) const;

protected:
    GUI* _context;

    std::array<GUIMap, to_base(GUIType::COUNT)> _guiElements;
};

}; //namespace Divide
#endif //_GUI_INTERFACE_H_

Commits for Divide-Framework/trunk/Source Code/GUI/Headers/GUIInterface.h

Diff revisions: vs.
Revision Author Commited Message
1004 Diff Diff IonutCava picture IonutCava Wed 20 Dec, 2017 17:16:32 +0000

[Ionut]
- More GUI cleanup (added multiple GUIButton events)
- Typedef vec4<U8> and vec4<F32> to UColour and FColour respectively for easier to read code.

1003 Diff Diff IonutCava picture IonutCava Tue 19 Dec, 2017 17:08:06 +0000

[Ionut]
- GUI cleanup

979 Diff Diff IonutCava picture IonutCava Tue 21 Nov, 2017 23:24:57 +0000

[Ionut]
- W.I.P. Rework GUI element positioning and scaling
- Update ImGUI and IMGUI_ADDONS

978 Diff Diff IonutCava picture IonutCava Mon 20 Nov, 2017 23:42:23 +0000

[Ionut]
- More decoupling between window size and render resolution.
- Attempt to preserve render target aspect on window resize events

  • Resolution change is currently broken *
955 Diff Diff IonutCava picture IonutCava Sun 29 Oct, 2017 20:45:04 +0000

[Ionut]
- Modify the CEGUI opengl renderer to interact with the state in GLWrapper better
- Performance optimizations

902 Diff Diff IonutCava picture IonutCava Sun 25 Jun, 2017 16:56:57 +0000

[Ionut]
- Rework input system a bit for easier maintenance and readability
- Toggle AntTweakBar display using CTRL+F11

872 Diff Diff IonutCava picture IonutCava Mon 06 Mar, 2017 23:23:20 +0000

[IonutCava]
- Optimise static casts

867 Diff Diff IonutCava picture IonutCava Mon 20 Feb, 2017 17:01:12 +0000

[IonutCava]
- Rename to_XNN and to_const_XNN functions to reflect the target data type they are converting to.
- Cleanup Angle namespace and remove all “inDegrees” parameters from rotation functions. Use aliases to differentiate between Degree and Radian parameters.
- Profile guided optimizations.

842 Diff Diff IonutCava picture IonutCava Wed 01 Feb, 2017 17:25:15 +0000

[IonutCava]
- Start to implement scripting support via ChaiScript: http://chaiscript.com/
- Cleanup DELEGATE_CBK alias

841 IonutCava picture IonutCava Wed 01 Feb, 2017 14:47:57 +0000

[IonutCava]
- Add callbacks to Localization so that listeners can be informed of language changes
— First callback added to GUIInterface