mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-10 20:42:21 +02:00
Add support for file drag drop
This commit is contained in:
parent
73376d2f75
commit
6d2803dbb1
7 changed files with 94 additions and 18 deletions
|
@ -153,7 +153,8 @@ BFWindow::BFWindow()
|
|||
mMouseUpFunc = NULL;
|
||||
mMouseWheelFunc = NULL;
|
||||
mMouseLeaveFunc = NULL;
|
||||
mMenuItemSelectedFunc = NULL;
|
||||
mMenuItemSelectedFunc = NULL;
|
||||
mDragDropFileFunc = NULL;
|
||||
mHitTestFunc = NULL;
|
||||
mFlags = 0;
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@ typedef void (*BFWindow_MouseUp)(BFWindow* window, int x, int y, int btn);
|
|||
typedef void (*BFWindow_MouseWheel)(BFWindow* window, int x, int y, float deltaX, float deltaY);
|
||||
typedef void (*BFWindow_MouseLeave)(BFWindow* window);
|
||||
typedef void (*BFWindow_MenuItemSelectedFunc)(BFWindow* window, BFMenu* menu);
|
||||
typedef void (*BFWindow_DragDropFileFunc)(BFWindow* window, const char* filePath);
|
||||
|
||||
enum
|
||||
{
|
||||
|
@ -53,7 +54,8 @@ enum
|
|||
BFWINDOW_FAKEFOCUS = 0x1000000,
|
||||
BFWINDOW_SHOWMINIMIZED = 0x2000000,
|
||||
BFWINDOW_SHOWMAXIMIZED = 0x4000000,
|
||||
BFWINDOW_ALLOW_FULLSCREEN = 0x8000000
|
||||
BFWINDOW_ALLOW_FULLSCREEN = 0x8000000,
|
||||
BFWINDOW_ACCEPTFILES = 0x10000000
|
||||
|
||||
};
|
||||
|
||||
|
@ -103,7 +105,7 @@ public:
|
|||
uint32 mMouseDownTicks[MOUSEBUTTON_MAX];
|
||||
|
||||
BFMenu* mMenu;
|
||||
RenderWindow* mRenderWindow;
|
||||
RenderWindow* mRenderWindow;
|
||||
bool mNonExclusiveMouseCapture;
|
||||
BFWindow_MovedFunc mMovedFunc;
|
||||
BFWindow_CloseQueryFunc mCloseQueryFunc;
|
||||
|
@ -120,7 +122,8 @@ public:
|
|||
BFWindow_MouseUp mMouseUpFunc;
|
||||
BFWindow_MouseWheel mMouseWheelFunc;
|
||||
BFWindow_MouseLeave mMouseLeaveFunc;
|
||||
BFWindow_MenuItemSelectedFunc mMenuItemSelectedFunc;
|
||||
BFWindow_MenuItemSelectedFunc mMenuItemSelectedFunc;
|
||||
BFWindow_DragDropFileFunc mDragDropFileFunc;
|
||||
|
||||
public:
|
||||
BFWindow();
|
||||
|
|
|
@ -283,7 +283,7 @@ BF_EXPORT void BF_CALLTYPE BFWindow_SetCallbacks(BFWindow* window, BFWindow_Move
|
|||
BFWindow_KeyCharFunc keyCharFunc, BFWindow_KeyDownFunc keyDownFunc, BFWindow_KeyUpFunc keyUpFunc, BFWindow_HitTestFunc hitTestFunc,
|
||||
BFWindow_MouseMove mouseMoveFunc, BFWindow_MouseProxyMove mouseProxyMoveFunc,
|
||||
BFWindow_MouseDown mouseDownFunc, BFWindow_MouseUp mouseUpFunc, BFWindow_MouseWheel mouseWheelFunc, BFWindow_MouseLeave mouseLeaveFunc,
|
||||
BFWindow_MenuItemSelectedFunc menuItemSelectedFunc)
|
||||
BFWindow_MenuItemSelectedFunc menuItemSelectedFunc, BFWindow_DragDropFileFunc dragDropFileFunc)
|
||||
{
|
||||
window->mMovedFunc = movedFunc;
|
||||
window->mCloseQueryFunc = closeQueryFunc;
|
||||
|
@ -300,7 +300,8 @@ BF_EXPORT void BF_CALLTYPE BFWindow_SetCallbacks(BFWindow* window, BFWindow_Move
|
|||
window->mMouseUpFunc = mouseUpFunc;
|
||||
window->mMouseWheelFunc = mouseWheelFunc;
|
||||
window->mMouseLeaveFunc = mouseLeaveFunc;
|
||||
window->mMenuItemSelectedFunc = menuItemSelectedFunc;
|
||||
window->mMenuItemSelectedFunc = menuItemSelectedFunc;
|
||||
window->mDragDropFileFunc = dragDropFileFunc;
|
||||
}
|
||||
|
||||
BF_EXPORT void* BFWindow_GetNativeUnderlying(BFWindow* window)
|
||||
|
|
|
@ -162,7 +162,10 @@ WinBFWindow::WinBFWindow(BFWindow* parent, const StringImpl& title, int x, int y
|
|||
if (windowFlags & BFWINDOW_MAXIMIZE)
|
||||
aWindowFlags |= WS_MAXIMIZEBOX;
|
||||
if ((windowFlags & BFWINDOW_TOPMOST) && (parent == NULL))
|
||||
windowFlagsEx |= WS_EX_TOPMOST;
|
||||
windowFlagsEx |= WS_EX_TOPMOST;
|
||||
if ((windowFlags & BFWINDOW_ACCEPTFILES))
|
||||
windowFlagsEx |= WS_EX_ACCEPTFILES;
|
||||
|
||||
if (windowFlags & BFWINDOW_CLIENT_SIZED)
|
||||
{
|
||||
RECT rect = {0, 0, width, height};
|
||||
|
@ -1123,6 +1126,18 @@ LRESULT WinBFWindow::WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPar
|
|||
case WM_INPUTLANGCHANGE:
|
||||
mKeyLayoutHasAltGr = (KeyboardLayoutHasAltGr((HKL)lParam) == TRUE);
|
||||
break;
|
||||
|
||||
case WM_DROPFILES:
|
||||
{
|
||||
HDROP hDropInfo = (HDROP)wParam;
|
||||
char sItem[MAX_PATH];
|
||||
|
||||
for(int i = 0; DragQueryFileA(hDropInfo, i, (LPSTR)sItem, sizeof(sItem)); i++)
|
||||
mDragDropFileFunc(this, sItem);
|
||||
|
||||
DragFinish(hDropInfo);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
app->mInMsgProc = false;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue