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

#include "Headers/ImWindowDivide.h"
#include "Headers/ImWindowManagerDivide.h"

#include "Core/Headers/Kernel.h"
#include "Core/Headers/Configuration.h"
#include "Core/Headers/PlatformContext.h"

namespace Divide {

ImwWindowDivide::ImwWindowDivide(ImwWindowManagerDivide& parent, PlatformContext& context, ImWindow::EPlatformWindowType eType, bool bCreateState)
    : ImwPlatformWindow(eType, bCreateState)
    , PlatformContextComponent(context)
    , _parent(parent)
    , _pWindow(nullptr)
    , _isMainWindow(false)
    , _windowGUID(-1)
{
    Attorney::WindowManagerWindow::onCreateWindow(_parent, this);
}

ImwWindowDivide::~ImwWindowDivide()
{
    Attorney::WindowManagerWindow::onDestroyWindow(_parent, this);
}

void ImwWindowDivide::onDestroyPlatformWindow() {
    _pWindow = nullptr;
}

bool ImwWindowDivide::Init(ImwPlatformWindow* parent)
{
    ImwWindowDivide* pMainDivide= ((ImwWindowDivide*)parent);

    if (pMainDivide != nullptr) {
        WindowDescriptor descriptor;
        descriptor.title = "ImWindow";
        descriptor.targetDisplay = 0;
        descriptor.dimensions.set(_context.config().runtime.resolution);
        descriptor.clearColour.set(DefaultColours::RED);
        SetBit(descriptor.flags, to_base(WindowDescriptor::Flags::HIDDEN));

        if (GetType() != ImWindow::E_PLATFORM_WINDOW_TYPE_MAIN && 
            GetType() != ImWindow::E_PLATFORM_WINDOW_TYPE_SECONDARY)
        {
            ClearBit(descriptor.flags, to_base(WindowDescriptor::Flags::DECORATED));
        }

        ErrorCode err = ErrorCode::NO_ERR;
        U32 idx = _context.app().windowManager().createWindow(descriptor, err);
        if (err != ErrorCode::NO_ERR) {
            RestoreState();
            return false;
        }
        _pWindow = &_context.app().windowManager().getWindow(idx);
    } else {
        _pWindow = &_context.app().windowManager().getWindow(0u);
        _isMainWindow = true;
    }
    _pWindow->destroyCbk([this]() { onDestroyPlatformWindow();} );

    SetState();
    ImGuiIO& io = ImGui::GetIO();
    io.RenderDrawListsFn = nullptr;
    io.ImeWindowHandle = (void*)_pWindow->handle()._handle;
    RestoreState();

    _windowGUID = _pWindow->getGUID();

    _pWindow->addEventListener(WindowEvent::CLOSE_REQUESTED, [this](const DisplayWindow::WindowEventArgs& args) { ACKNOWLEDGE_UNUSED(args); OnClose();});
    _pWindow->addEventListener(WindowEvent::GAINED_FOCUS, [this](const DisplayWindow::WindowEventArgs& args) { OnFocus(args._flag);});
    _pWindow->addEventListener(WindowEvent::RESIZED_INTERNAL, [this](const DisplayWindow::WindowEventArgs& args) { OnSize(args.x, args.y);});
    _pWindow->addEventListener(WindowEvent::MOUSE_BUTTON, [this](const DisplayWindow::WindowEventArgs& args) { OnMouseButton(args.id, args._flag);});
    _pWindow->addEventListener(WindowEvent::MOUSE_MOVE, [this](const DisplayWindow::WindowEventArgs& args) { OnMouseMove(args.x, args.y);});
    _pWindow->addEventListener(WindowEvent::MOUSE_WHEEL, [this](const DisplayWindow::WindowEventArgs& args) { OnMouseWheel(args._mod);});
    _pWindow->addEventListener(WindowEvent::KEY_PRESS, [this](const DisplayWindow::WindowEventArgs& args) { OnKey(args._key, args._flag);});
    _pWindow->addEventListener(WindowEvent::TEXT, [this](const DisplayWindow::WindowEventArgs& args) { OnUTF8(args._text);});
    if (GetType() == ImWindow::E_PLATFORM_WINDOW_TYPE_DRAG_PREVIEW) {
        //_pWindow->opacity(128);
    }

    return true;
}

ImVec2 ImwWindowDivide::GetPosition() const
{
    if (_pWindow != nullptr) {
        return ImVec2(_pWindow->getPosition());
    }
    return ImVec2(1.0f, 1.0f);
}

ImVec2 ImwWindowDivide::GetSize() const
{
    return _size;
}

ImVec2 ImwWindowDivide::GetDrawableSize() const
{
    return _drawableSize;
}

bool ImwWindowDivide::IsWindowMaximized() const
{
    if (_pWindow != nullptr) {
        return _pWindow->maximized();
    }
    return false;
}

bool ImwWindowDivide::IsWindowMinimized() const {
    if (_pWindow != nullptr) {
        return _pWindow->minimized();
    } 

    return false;
}

void ImwWindowDivide::Show(bool bShow) {
    if (_pWindow != nullptr) {
        _pWindow->hidden(!bShow);
    }
}

void ImwWindowDivide::SetSize(int iWidth, int iHeight)
{
    if (_pWindow != nullptr) {
        _pWindow->setDimensions(to_U16(iWidth), to_U16(iHeight));
    }
}

void ImwWindowDivide::SetPosition(int iX, int iY)
{
    if (_pWindow != nullptr) {
        _pWindow->setPosition(iX, iY);
    }
}

void ImwWindowDivide::SetWindowMaximized(bool bMaximized)
{
    if (_pWindow != nullptr) {
        _pWindow->maximized(bMaximized);
    }
}

void ImwWindowDivide::SetWindowMinimized()
{
    if (_pWindow != nullptr) {
        _pWindow->minimized(true);
    }
}

void ImwWindowDivide::SetTitle(const char* pTitle)
{
    if (_pWindow != nullptr) {
        _pWindow->title(pTitle);
    }
}

void ImwWindowDivide::PreUpdate()
{

}

void ImwWindowDivide::Render()
{
    if (!m_bNeedRender) {
        return;
    }

    SetState();
    ImGuiIO& io = ImGui::GetIO();
    io.DisplaySize = GetSize();
    io.DisplayFramebufferScale = GetDrawableSize();
    ImGui::Render();
    _parent.renderDrawList(ImGui::GetDrawData(), _windowGUID);
    RestoreState();
}

bool ImwWindowDivide::OnClose() {
    ImwPlatformWindow::OnClose();
    return true;
}

void ImwWindowDivide::OnFocus(bool bHasFocus)
{
    if (!bHasFocus) {
        OnLoseFocus();
    }
}

void ImwWindowDivide::OnSize(int iWidth, int iHeight)
{
    ACKNOWLEDGE_UNUSED(iWidth);
    ACKNOWLEDGE_UNUSED(iHeight);
    if (_pWindow != nullptr) {
        _size = ImVec2(_pWindow->getDimensions());
        vec2<U16> display_size = _pWindow->getDrawableSize();
        _drawableSize = ImVec2(_size.x > 0 ? ((float)display_size.w / _size.x) : 0, _size.y > 0 ? ((float)display_size.h / _size.y) : 0);
    }
}

void ImwWindowDivide::OnMouseButton(int iButton, bool bDown)
{
    ((ImGuiContext*)m_pState)->IO.MouseDown[iButton] = bDown;
}

void ImwWindowDivide::OnMouseMove(int iX, int iY)
{
    ((ImGuiContext*)m_pState)->IO.MousePos = ImVec2((float)iX, (float)iY);
}

void ImwWindowDivide::OnMouseWheel(int iStep)
{
    ((ImGuiContext*)m_pState)->IO.MouseWheel += iStep;
}

void ImwWindowDivide::OnKey(Input::KeyCode eKey, bool bDown)
{
    ((ImGuiContext*)m_pState)->IO.KeysDown[eKey] = bDown;
}

void ImwWindowDivide::OnUTF8(const char* text)
{
    ((ImGuiContext*)m_pState)->IO.AddInputCharactersUTF8(text);
}

}; //namespace Divide

Commits for Divide-Framework/trunk/Source Code/Editor/Widgets/ImWindowDivide.cpp

Diff revisions: vs.
Revision Author Commited Message
970 Diff Diff IonutCava picture IonutCava Mon 13 Nov, 2017 17:16:44 +0000

[Ionut]
- ImWindow <-> DisplayWindow fixes

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

965 Diff Diff IonutCava picture IonutCava Sun 05 Nov, 2017 21:54:57 +0000

[Ionut]
- ImWindow updates

964 Diff Diff IonutCava picture IonutCava Sun 05 Nov, 2017 19:41:31 +0000

[Ionut]
- IMGUI rendering fixes

963 Diff Diff IonutCava picture IonutCava Sun 05 Nov, 2017 18:31:51 +0000

[Ionut]
- More multi-window fixes
- Profile guided performance improvements

962 Diff Diff IonutCava picture IonutCava Fri 03 Nov, 2017 17:17:55 +0000

[Ionut]
- Fix creation/destruction of multiple DisplayWindows
- Add an InputInterface per DisplayWindow
- More work on the ImWindow based Editor

961 Diff Diff IonutCava picture IonutCava Thu 02 Nov, 2017 23:24:10 +0000

[Ionut]
- IMGUI rendering work

960 Diff Diff IonutCava picture IonutCava Thu 02 Nov, 2017 17:39:53 +0000

[Ionut]
- Started porting ImWindow to our command buffer based rendering system.
- Also moved mouse positioning system to the window manager since mouse position is always relative to the active window

953 Diff Diff IonutCava picture IonutCava Sat 28 Oct, 2017 21:57:10 +0000

[Ionut]
- Fix blinking issue by caching and hashing pipelines to that we don’t overwrite pipelines used by other elements

951 IonutCava picture IonutCava Mon 23 Oct, 2017 23:25:49 +0000

[Ionut]
- Added a new project to the solution: Divide-Editor
— This project will be a Unity-style tool for the framework built using IMGUI and ImWindow
— Examples:

- Modified DisplayWindow class heavily to support new requirements