VPS
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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
/*
Copyright (c) 2018 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 _DIVIDE_EDITOR_H_
#define _DIVIDE_EDITOR_H_

#include "Core/Math/Headers/MathVectors.h"
#include "Core/Time/Headers/ProfileTimer.h"
#include "Core/Headers/PlatformContextComponent.h"

#include "Rendering/Headers/FrameListener.h"
#include "Platform/Input/Headers/InputAggregatorInterface.h"

struct ImDrawData;
namespace Divide {

namespace Attorney {
    class EditorWindowManager;
    class EditorPanelManager;
    class EditorOutputWindow;
};

class MenuBar;
class OutputWindow;
class PanelManager;
class DisplayWindow;
class PlatformContext;
class ApplicationOutput;

FWD_DECLARE_MANAGED_CLASS(Texture);
FWD_DECLARE_MANAGED_CLASS(ShaderProgram);

struct SizeChangeParams;

class Editor : public PlatformContextComponent,
               public FrameListener,
               public Input::InputAggregatorInterface {

    friend class Attorney::EditorWindowManager;
    friend class Attorney::EditorPanelManager;
    friend class Attorney::EditorOutputWindow;

  public:
    // Basically, the IMGUI default themes
    enum class Theme : U8 {
        IMGUI_Default = 0,
        IMGUI_Default_Dark,
        Gray,
        OSX,
        Dark_Opaque,
        OSX_Opaque,
        Soft,
        Edin_Black,
        Edin_White,
        Maya,
        COUNT
    };

  public:
    explicit Editor(PlatformContext& context,
                    Theme theme = Theme::OSX_Opaque,
                    Theme lostFocusTheme = Theme::OSX,
                    Theme dimmedTheme = Theme::Gray);
    ~Editor();

    bool init(const vec2<U16>& renderResolution);
    void close();
    void idle();
    void update(const U64 deltaTimeUS);

    void toggle(const bool state);
    bool running() const;

    bool shouldPauseSimulation() const;

    inline const Rect<I32>& getScenePreviewRect() const { return _scenePreviewRect; }

    void onSizeChange(const SizeChangeParams& params);

  protected: //frame listener
    bool frameStarted(const FrameEvent& evt);
    bool framePreRenderStarted(const FrameEvent& evt);
    bool framePreRenderEnded(const FrameEvent& evt);
    bool frameRenderingQueued(const FrameEvent& evt);
    bool framePostRenderStarted(const FrameEvent& evt);
    bool framePostRenderEnded(const FrameEvent& evt);
    bool frameEnded(const FrameEvent& evt);

  public: // input
    /// Key pressed: return true if input was consumed
    bool onKeyDown(const Input::KeyEvent& key);
    /// Key released: return true if input was consumed
    bool onKeyUp(const Input::KeyEvent& key);
    /// Mouse moved: return true if input was consumed
    bool mouseMoved(const Input::MouseEvent& arg);
    /// Mouse button pressed: return true if input was consumed
    bool mouseButtonPressed(const Input::MouseEvent& arg, Input::MouseButton button);
    /// Mouse button released: return true if input was consumed
    bool mouseButtonReleased(const Input::MouseEvent& arg, Input::MouseButton button);

    bool joystickButtonPressed(const Input::JoystickEvent &arg, Input::JoystickButton button) override;
    bool joystickButtonReleased(const Input::JoystickEvent &arg, Input::JoystickButton button) override;
    bool joystickAxisMoved(const Input::JoystickEvent &arg, I8 axis) override;
    bool joystickPovMoved(const Input::JoystickEvent &arg, I8 pov) override;
    bool joystickSliderMoved(const Input::JoystickEvent &arg, I8 index) override;
    bool joystickvector3Moved(const Input::JoystickEvent &arg, I8 index) override;

  protected:
    void drawIMGUIDebug(const U64 deltaTime);
    bool renderMinimal(const U64 deltaTime);
    bool renderFull(const U64 deltaTime);
    bool needInput();

  protected: // window events
    bool OnClose();
    void OnFocus(bool bHasFocus);
    void OnSize(int iWidth, int iHeight);
    void OnUTF8(const char* text);
    void dim(bool hovered, bool focused);
    bool toggleScenePreview(bool state);
    void setScenePreviewRect(const Rect<I32>& rect, bool hovered);

  protected: // attorney
    void renderDrawList(ImDrawData* pDrawData, I64 windowGUID);
    void savePanelLayout() const;
    void loadPanelLayout();
    void saveTabLayout() const;
    void loadTabLayout();
    void drawOutputWindow();
    void drawMenuBar();
    void showDebugWindow(bool state);
    void showSampleWindow(bool state);
    bool showDebugWindow() const;
    bool showSampleWindow() const;

  private:
    Theme _currentTheme;
    Theme _currentLostFocusTheme;
    Theme _currentDimmedTheme;

    Rect<I32> _scenePreviewRect;

    I64 _activeWindowGUID = -1;
    std::unique_ptr<MenuBar> _menuBar;
    std::unique_ptr<PanelManager> _panelManager;
    std::unique_ptr<ApplicationOutput> _applicationOutput;

    bool              _running;
    bool              _sceneHovered;
    bool              _sceneWasHovered;
    bool              _scenePreviewFocused;
    bool              _scenePreviewWasFocused;
    bool              _showDebugWindow;
    bool              _showSampleWindow;
    DisplayWindow*    _mainWindow;
    Texture_ptr       _fontTexture;
    ShaderProgram_ptr _imguiProgram;

    Time::ProfileTimer& _editorUpdateTimer;
    Time::ProfileTimer& _editorRenderTimer;

    size_t _consoleCallbackIndex;
}; //Editor

namespace Attorney {
    class EditorOutputWindow {
        private:
        static void drawOutputWindow(Editor& editor) {
            editor.drawOutputWindow();
        }

        friend class Divide::OutputWindow;
    };

    class EditorPanelManager {
        //private:
        public: //ToDo: fix this -Ionut
        static void setScenePreviewRect(Editor& editor, const Rect<I32>& rect, bool hovered) {
            editor.setScenePreviewRect(rect, hovered);
        }
        static void savePanelLayout(const Editor& editor) {
            editor.savePanelLayout();
        }
        static void loadPanelLayout(Editor& editor) {
            editor.loadPanelLayout();
        }
        static void saveTabLayout(const Editor& editor) {
            editor.saveTabLayout();
        }
        static void loadTabLayout(Editor& editor) {
            editor.loadTabLayout();
        }
        static void showDebugWindow(Editor& editor, bool state) {
            editor.showDebugWindow(state);
        }
        static void showSampleWindow(Editor& editor, bool state) {
            editor.showSampleWindow(state);
        }
        static bool showDebugWindow(Editor& editor) {
            return editor.showDebugWindow();
        }
        static bool showSampleWindow(Editor& editor) {
            return editor.showSampleWindow();
        }
        friend class Divide::MenuBar;
        friend class Divide::PanelManager;
    };
};


}; //namespace Divide

#endif //_DIVIDE_EDITOR_H_

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

Diff revisions: vs.
Revision Author Commited Message
1029 Diff Diff IonutCava picture IonutCava Tue 30 Jan, 2018 17:28:39 +0000

[Ionut]
- Update copyright notices

1027 Diff Diff IonutCava picture IonutCava Mon 29 Jan, 2018 23:29:31 +0000

[Ionut]
- More work on the editor:
— Attempt to fix resizing. Failed.

1024 Diff Diff IonutCava picture IonutCava Sun 28 Jan, 2018 19:25:54 +0000

[Ionut]
- Update IMGUI (and addons) to 1.54 (latest commit as of 28/01/18)
- Remove ImwWindow code as IMGUI will support docking and platform windows soon enough

1022 Diff Diff IonutCava picture IonutCava Thu 25 Jan, 2018 16:13:30 +0000

[Ionut]
- Editor work: move docked windows to their own classes and files

989 Diff Diff IonutCava picture IonutCava Fri 01 Dec, 2017 16:10:10 +0000

[Ionut]
- Moved MainMenuBar out of PanelManager and modified it a bit
- Updated Imgui and addons to the latest version
- Added “Step 1 frame” and “Step 60 frames” buttons to the editor (when the simulation is paused, these advance time by the given number of frames only)
- Removed per-scene base camera and added a utility default camera, also used by the editor

988 Diff Diff IonutCava picture IonutCava Thu 30 Nov, 2017 23:08:51 +0000

[Ionut]
- Add a Rect class (basic wrapper around a vec4)
- More work on MouseEvent system

977 Diff Diff IonutCava picture IonutCava Mon 20 Nov, 2017 17:13:16 +0000

[Ionut]
- Add an “ApplicationOutput” class that the Editor uses to show console entries and parse commands
- Add “Warning” messages to console outputs

976 Diff Diff IonutCava picture IonutCava Sun 19 Nov, 2017 23:10:18 +0000

[Ionut]
- Texture mipmaps are now compute before bind if they need a refresh (to avoid recalculation if they’re not used)
- More work on the editor: cleanup, load/save functionality, etc
- Input scaling: Mouse position is now relative to the scene preview position in editor mode. (the scene preview rect is used to re-map X/Y absolute and relative mouse positions)

975 Diff Diff IonutCava picture IonutCava Thu 16 Nov, 2017 14:49:12 +0000

[Ionut]
- Editor work. Port most of imgui-addons demo2.
- Add Editor render target into which we will render the scene when the editor is on

971 IonutCava picture IonutCava Mon 13 Nov, 2017 22:49:24 +0000

[Ionut]
- Fix various timing issues
- Add a framerate limiter
- Rework framerate calculations
- Add an adaptive sync option in config