diff options
author | 2018-12-05 19:45:08 +0100 | |
---|---|---|
committer | 2018-12-05 19:45:08 +0100 | |
commit | 0bd02131b644b61088789f52f31b750c9aecaa6d (patch) | |
tree | 811c679a1bba8b24fc7967cdfe73640254d64156 /3rdparty/bgfx/examples/common/entry/entry_sdl.cpp | |
parent | 9a81ec7eaf00d73a23db5c003dc45b55d4b76c4a (diff) |
3rdparty: Updated bgfx, bimg, and bx to latest upstream. [Ryan Holtz]
Diffstat (limited to '3rdparty/bgfx/examples/common/entry/entry_sdl.cpp')
-rw-r--r-- | 3rdparty/bgfx/examples/common/entry/entry_sdl.cpp | 60 |
1 files changed, 49 insertions, 11 deletions
diff --git a/3rdparty/bgfx/examples/common/entry/entry_sdl.cpp b/3rdparty/bgfx/examples/common/entry/entry_sdl.cpp index 62a59b5bc04..d582b034e5e 100644 --- a/3rdparty/bgfx/examples/common/entry/entry_sdl.cpp +++ b/3rdparty/bgfx/examples/common/entry/entry_sdl.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2011-2017 Branimir Karadzic. All rights reserved. + * Copyright 2011-2018 Branimir Karadzic. All rights reserved. * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause */ @@ -281,6 +281,7 @@ namespace entry , m_width(0) , m_height(0) , m_flags(0) + , m_flagsEnabled(false) { } @@ -290,6 +291,7 @@ namespace entry uint32_t m_height; uint32_t m_flags; tinystl::string m_title; + bool m_flagsEnabled; }; static uint32_t s_userEventStart; @@ -299,6 +301,7 @@ namespace entry SDL_USER_WINDOW_CREATE, SDL_USER_WINDOW_DESTROY, SDL_USER_WINDOW_SET_TITLE, + SDL_USER_WINDOW_SET_FLAGS, SDL_USER_WINDOW_SET_POS, SDL_USER_WINDOW_SET_SIZE, SDL_USER_WINDOW_TOGGLE_FRAME, @@ -485,6 +488,8 @@ namespace entry WindowHandle defaultWindow = { 0 }; setWindowSize(defaultWindow, m_width, m_height, true); + SDL_EventState(SDL_DROPFILE, SDL_ENABLE); + bx::FileReaderI* reader = NULL; while (NULL == reader) { @@ -556,7 +561,7 @@ namespace entry m_eventQueue.postMouseEvent(handle , mev.x , mev.y - , 0 + , m_mz , button , mev.type == SDL_MOUSEBUTTONDOWN ); @@ -803,6 +808,18 @@ namespace entry } break; + case SDL_DROPFILE: + { + const SDL_DropEvent& dev = event.drop; + WindowHandle handle = defaultWindow; //findHandle(dev.windowID); + if (isValid(handle) ) + { + m_eventQueue.postDropFileEvent(handle, dev.file); + SDL_free(dev.file); + } + } + break; + default: { const SDL_UserEvent& uev = event.user; @@ -814,13 +831,13 @@ namespace entry Msg* msg = (Msg*)uev.data2; m_window[handle.idx] = SDL_CreateWindow(msg->m_title.c_str() - , msg->m_x - , msg->m_y - , msg->m_width - , msg->m_height - , SDL_WINDOW_SHOWN - | SDL_WINDOW_RESIZABLE - ); + , msg->m_x + , msg->m_y + , msg->m_width + , msg->m_height + , SDL_WINDOW_SHOWN + | SDL_WINDOW_RESIZABLE + ); m_flags[handle.idx] = msg->m_flags; @@ -859,6 +876,24 @@ namespace entry } break; + case SDL_USER_WINDOW_SET_FLAGS: + { + WindowHandle handle = getWindowHandle(uev); + Msg* msg = (Msg*)uev.data2; + + if (msg->m_flagsEnabled) + { + m_flags[handle.idx] |= msg->m_flags; + } + else + { + m_flags[handle.idx] &= ~msg->m_flags; + } + + delete msg; + } + break; + case SDL_USER_WINDOW_SET_POS: { WindowHandle handle = getWindowHandle(uev); @@ -1075,9 +1110,12 @@ namespace entry sdlPostEvent(SDL_USER_WINDOW_SET_TITLE, _handle, msg); } - void toggleWindowFrame(WindowHandle _handle) + void setWindowFlags(WindowHandle _handle, uint32_t _flags, bool _enabled) { - sdlPostEvent(SDL_USER_WINDOW_TOGGLE_FRAME, _handle); + Msg* msg = new Msg; + msg->m_flags = _flags; + msg->m_flagsEnabled = _enabled; + sdlPostEvent(SDL_USER_WINDOW_SET_FLAGS, _handle, msg); } void toggleFullscreen(WindowHandle _handle) |