texturev: Added support for drop file.

This commit is contained in:
Branimir Karadžić 2018-01-04 13:05:36 -08:00
parent 37949c91f1
commit 0093775508
3 changed files with 21 additions and 17 deletions

View File

@ -787,6 +787,7 @@ restart:
WindowHandle handle = { UINT16_MAX };
bool mouseLock = inputIsMouseLocked();
bool clearDropFile = true;
const Event* ev;
do
@ -910,7 +911,8 @@ restart:
case Event::DropFile:
{
const DropFileEvent* drop = static_cast<const DropFileEvent*>(ev);
DBG("%s", drop->m_filePath.get() );
win.m_dropFile = drop->m_filePath;
clearDropFile = false;
}
break;
@ -925,7 +927,12 @@ restart:
if (isValid(handle) )
{
const WindowState& win = s_window[handle.idx];
WindowState& win = s_window[handle.idx];
if (clearDropFile)
{
win.m_dropFile.clear();
}
_state = win;
if (handle.idx == 0)

View File

@ -8,6 +8,7 @@
#include "dbg.h"
#include <bx/bx.h>
#include <bx/filepath.h>
#include <bx/string.h>
namespace bx { struct FileReaderI; struct FileWriterI; struct AllocatorI; }
@ -272,6 +273,7 @@ namespace entry
uint32_t m_height;
MouseState m_mouse;
void* m_nwh;
bx::FilePath m_dropFile;
};
bool processWindowEvents(WindowState& _state, uint32_t& _debug, uint32_t& _reset);

View File

@ -1257,27 +1257,22 @@ int _main_(int _argc, char** _argv)
int exitcode = bx::kExitSuccess;
bgfx::TextureHandle texture = BGFX_INVALID_HANDLE;
if (view.m_fileList.empty() )
{
exitcode = bx::kExitFailure;
if (2 > _argc)
{
help("File path is not specified.");
}
else
{
fprintf(stderr, "Unable to load '%s' texture.\n", filePath);
}
}
else
{
uint32_t fileIndex = 0;
bool dragging = false;
entry::WindowState windowState;
entry::MouseState mouseStatePrev;
entry::MouseState mouseState;
while (!entry::processEvents(width, height, debug, reset, &mouseState) )
while (!entry::processWindowEvents(windowState, debug, reset) )
{
const entry::MouseState& mouseState = windowState.m_mouse;
if (!windowState.m_dropFile.isEmpty() )
{
view.updateFileList(windowState.m_dropFile);
windowState.m_dropFile.clear();
}
imguiBeginFrame(mouseState.m_mx
, mouseState.m_my
, (mouseState.m_buttons[entry::MouseButton::Left ] ? IMGUI_MBUT_LEFT : 0)