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
/*
   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_BUTTON_H_
#define _GUI_BUTTON_H_

#include "GUIElement.h"
#include "GUIText.h"

namespace CEGUI {
class Window;
class Font;
class EventArgs;
};

namespace Divide {

class AudioDescriptor;
TYPEDEF_SMART_POINTERS_FOR_CLASS(AudioDescriptor);

class GUIButton : public GUIElement {
    typedef DELEGATE_CBK<void, I64> ButtonCallback;
    typedef DELEGATE_CBK<void, AudioDescriptor_ptr> AudioCallback;

    friend class GUIInterface;
    friend class SceneGUIElements;

    public:
    enum class Event : U8 {
        HoverEnter = 0,
        HoverLeave,
        MouseDown,
        MouseUp,
        MouseMove,
        MouseClick,
        MouseDoubleClick,
        MouseTripleClick,
        COUNT
    };

   public:
    void setTooltip(const stringImpl& tooltipText);
    void setText(const stringImpl& text);
    void setFont(const stringImpl& fontName, const stringImpl& fontFileName, U32 size);
    void setActive(const bool active) override;
    void setVisible(const bool visible) override;

    void setEventCallback(Event event, ButtonCallback callback);
    void setEventSound(Event event, AudioDescriptor_ptr sound);
    void setEventCallback(Event event, ButtonCallback callback, AudioDescriptor_ptr sound);

    // return false if we replace an existing callback
    static bool soundCallback(const AudioCallback& cbk);

   protected:
    GUIButton(U64 guiID,
              const stringImpl& name,
              const stringImpl& text,
              const stringImpl& guiScheme, 
              const RelativePosition2D& offset,
              const RelativeScale2D& size,
              CEGUI::Window* parent);

    ~GUIButton();

    bool onEvent(Event event, const CEGUI::EventArgs& /*e*/);
    bool onMove(const CEGUI::EventArgs& e);
    bool onHoverEnter(const CEGUI::EventArgs& e);
    bool onHoverLeave(const CEGUI::EventArgs& e);
    bool onButtonDown(const CEGUI::EventArgs& e);
    bool onButtonUp(const CEGUI::EventArgs& e);
    bool onClick(const CEGUI::EventArgs& e);
    bool onDoubleClick(const CEGUI::EventArgs& e);
    bool onTripleClick(const CEGUI::EventArgs& e);

   protected:;
    /// A pointer to a function to call if the button is pressed
    std::array<ButtonCallback, to_base(Event::COUNT)> _callbackFunction;
    std::array<AudioDescriptor_ptr, to_base(Event::COUNT)> _eventSound;

    CEGUI::Window* _btnWindow;

    static AudioCallback s_soundCallback;
};

};  // namespace Divide

#endif

Commits for Divide-Framework/trunk/Source Code/GUI/Headers/GUIButton.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

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*
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

836 Diff Diff IonutCava picture IonutCava Fri 27 Jan, 2017 14:59:56 +0000

[IonutCava]
- Update copyright notice

804 IonutCava picture IonutCava Thu 01 Dec, 2016 17:20:59 +0000

[IonutCava]
- Singleton elimination update Part I: get it to compile
— The following classes are no longer Singletons: GFXDevice, GL_API, DX_API, SFXWrapper, FmodWrapper, SDLWrapper, ALWrapper, PXDevice, InputInterface, RenderPassManager, SceneManager and ResourceManager;
— Refactor system to a Context / Component based implementation (Pass relevant context to objects: e.g. GFXDevice object to Textures, GUI to GUIElements, etc)
— Make devices and managers components of the kernel
— Allow multiple Resource caches to co-exist. This may prove useful for later when a more fragmented memory model is need (per frame / per scene / global caches / etc)

  • next steps: part II – cleanup/refactor new code, part III – optimise code, part IV – remove remaining Singletons (e.g. Application, ParamHandler, FrameListenerManager, Recast, PostFX and DebugInterface)