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
#include "stdafx.h"

#include "Headers/GUIButton.h"

#include "Platform/Audio/Headers/SFXDevice.h"

#include <CEGUI/CEGUI.h>

namespace Divide {


GUIButton::AudioCallback GUIButton::s_soundCallback;

GUIButton::GUIButton(U64 guiID,
                     const stringImpl& name,
                     const stringImpl& text,
                     const stringImpl& guiScheme,
                     const RelativePosition2D& offset,
                     const RelativeScale2D& size,
                     CEGUI::Window* parent)
    : GUIElement(guiID, name, parent, GUIType::GUI_BUTTON),
      _btnWindow(nullptr)
{
    
    static stringImpl buttonInfo = guiScheme + "/Button";

    _btnWindow = CEGUI::WindowManager::getSingleton().createWindow(buttonInfo.c_str(), name.c_str());

    _btnWindow->setPosition(offset);

    _btnWindow->setSize(size);

    _btnWindow->setText(text.c_str());

    _btnWindow->subscribeEvent(CEGUI::PushButton::EventMouseMove,
                               CEGUI::Event::Subscriber(&GUIButton::onMove, this));
    _btnWindow->subscribeEvent(CEGUI::PushButton::EventMouseEntersArea,
                               CEGUI::Event::Subscriber(&GUIButton::onHoverEnter, this));
    _btnWindow->subscribeEvent(CEGUI::PushButton::EventMouseLeavesArea,
                               CEGUI::Event::Subscriber(&GUIButton::onHoverLeave, this));
    _btnWindow->subscribeEvent(CEGUI::PushButton::EventMouseButtonDown,
                               CEGUI::Event::Subscriber(&GUIButton::onButtonDown, this));
    _btnWindow->subscribeEvent(CEGUI::PushButton::EventMouseButtonUp,
                               CEGUI::Event::Subscriber(&GUIButton::onButtonUp, this));
    _btnWindow->subscribeEvent(CEGUI::PushButton::EventMouseClick,
                               CEGUI::Event::Subscriber(&GUIButton::onClick, this));
    _btnWindow->subscribeEvent(CEGUI::PushButton::EventMouseDoubleClick,
                               CEGUI::Event::Subscriber(&GUIButton::onDoubleClick, this));
    _btnWindow->subscribeEvent(CEGUI::PushButton::EventMouseDoubleClick,
                               CEGUI::Event::Subscriber(&GUIButton::onTripleClick, this));
    _parent->addChild(_btnWindow);

    setActive(true);
}

GUIButton::~GUIButton()
{
    _parent->removeChild(_btnWindow);
}

void GUIButton::setActive(const bool active) {
    if (isActive() != active) {
        _btnWindow->setEnabled(active);
        GUIElement::setActive(active);
    }
}

void GUIButton::setVisible(const bool visible) {
    if (isVisible() != visible) {
        _btnWindow->setVisible(visible);
        GUIElement::setVisible(visible);
    }
}

void GUIButton::setText(const stringImpl& text) {
    _btnWindow->setText(text.c_str());
}

void GUIButton::setTooltip(const stringImpl& tooltipText) {
    _btnWindow->setTooltipText(tooltipText.c_str());
}

void GUIButton::setFont(const stringImpl& fontName,
                        const stringImpl& fontFileName, U32 size) {
    if (!fontName.empty()) {
        if (!CEGUI::FontManager::getSingleton().isDefined(fontName.c_str())) {
             CEGUI::FontManager::getSingleton().createFreeTypeFont(
                fontName.c_str(), to_F32(size), true, fontFileName.c_str());
        }

        if (CEGUI::FontManager::getSingleton().isDefined(fontName.c_str())) {
            _btnWindow->setFont(fontName.c_str());
        }
    }
}

bool GUIButton::soundCallback(const AudioCallback& cbk) {
    bool hasCbk = s_soundCallback ? true : false;
    s_soundCallback = cbk;

    return hasCbk;
}

bool GUIButton::onEvent(Event event, const CEGUI::EventArgs& /*e*/) {
    if (_callbackFunction[to_base(event)]) {
        _callbackFunction[to_base(event)](getGUID());
        if (_eventSound[to_base(event)] && s_soundCallback) {
            s_soundCallback(_eventSound[to_base(event)]);
        }
        return true;
    }
    return false;
}

bool GUIButton::onMove(const CEGUI::EventArgs& e) {
    return onEvent(Event::MouseMove, e);
}

bool GUIButton::onHoverEnter(const CEGUI::EventArgs& e) {
    return onEvent(Event::HoverEnter, e);
}

bool GUIButton::onHoverLeave(const CEGUI::EventArgs& e) {
    return onEvent(Event::HoverLeave, e);
}

bool GUIButton::onButtonDown(const CEGUI::EventArgs& e) {
    return onEvent(Event::MouseDown, e);
}

bool GUIButton::onButtonUp(const CEGUI::EventArgs& e) {
    return onEvent(Event::MouseUp, e);
}

bool GUIButton::onClick(const CEGUI::EventArgs& e) {
    return onEvent(Event::MouseClick, e);
}

bool GUIButton::onDoubleClick(const CEGUI::EventArgs& e) {
    return onEvent(Event::MouseDoubleClick, e);
}

bool GUIButton::onTripleClick(const CEGUI::EventArgs& e) {
    return onEvent(Event::MouseTripleClick, e);
}

void GUIButton::setEventCallback(Event event, ButtonCallback callback) {
    _callbackFunction[to_base(event)] = callback;
}

void GUIButton::setEventSound(Event event, AudioDescriptor_ptr sound) {
    _eventSound[to_base(event)] = sound;
}

void GUIButton::setEventCallback(Event event, ButtonCallback callback, AudioDescriptor_ptr sound) {
    setEventCallback(event, callback);
    setEventSound(event, sound);
}

};

Commits for Divide-Framework/trunk/Source Code/GUI/GUIButton.cpp

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

1002 Diff Diff IonutCava picture IonutCava Mon 18 Dec, 2017 17:31:54 +0000

[Ionut]
- Cleanup GUI a bit
- Disable some nVidia GL warnings

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

969 Diff Diff IonutCava picture IonutCava Mon 13 Nov, 2017 00:15:57 +0000

[Ionut]
- Further improve DisplayWindow <-> Input relationship
- Add Flip-Y 2D camera (D3D style projection)
- Fix IMGUI rendering
- Add IMGUI sample and IMWINDOW sample rendering at the same time
- Improve IMWINDOW multi-window support
— Bug: nothing rendering in child platform windows
- Add draw command to move render context from one window to another

966 Diff Diff IonutCava picture IonutCava Mon 06 Nov, 2017 17:10:01 +0000

[Ionut]
- Remove old “add2DRenderFunction” and use command buffers instead
- Allow frame to blit to the screen or a render target of choice

952 Diff Diff IonutCava picture IonutCava Wed 25 Oct, 2017 00:35:37 +0000

[Ionut]
- Added the CEGUI rendering project to our solution for easier modification, debugging and integration
- Updated to OIS 1.4
- Some updates to the WindowHandle struct

  • Only compiled in Debug*
941 Diff Diff IonutCava picture IonutCava Mon 04 Sep, 2017 20:55:02 +0000

[Ionut]
- Update CEGUI from static to dynamic config (some dlls might still be missing)
- Attempt to work around a weird string issue with the newest VS2017 update

890 Diff Diff IonutCava picture IonutCava Sun 14 May, 2017 20:54:59 +0000

[Ionut]
- Add pre-compiled header support
- Initial code for per-stage tessellation computation

867 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.