file drop support

This commit is contained in:
Ryan Fleury
2024-08-27 14:49:57 -07:00
parent 32fcc6d34c
commit 59360f770c
3 changed files with 47 additions and 3 deletions
+23 -2
View File
@@ -540,7 +540,27 @@ os_w32_wnd_proc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
F32 new_dpi = (F32)(wParam & 0xffff);
window->dpi = new_dpi;
}break;
//- rjf: [file drop]
case WM_DROPFILES:
{
HDROP drop = (HDROP)wParam;
POINT drop_pt = {0};
DragQueryPoint(drop, &drop_pt);
ScreenToClient(window->hwnd, &drop_pt);
U64 num_files_dropped = DragQueryFile(drop, 0xffffffff, 0, 0);
OS_Event *event = os_w32_push_event(OS_EventKind_FileDrop, window);
event->pos = v2f32((F32)drop_pt.x, (F32)drop_pt.y);
for(U64 idx = 0; idx < num_files_dropped; idx += 1)
{
U64 name_size = DragQueryFile(drop, idx, 0, 0) + 1;
U8 *name_ptr = push_array(os_w32_event_arena, U8, name_size);
DragQueryFile(drop, idx, name_ptr, name_size);
str8_list_push(os_w32_event_arena, &event->strings, str8(name_ptr, name_size));
}
DragFinish(drop);
}break;
//- rjf: [custom border]
case WM_NCPAINT:
{
@@ -1014,7 +1034,8 @@ os_window_open(Vec2F32 resolution, OS_WindowFlags flags, String8 title)
(int)resolution.y,
0, 0,
os_w32_gfx_state->hInstance,
0);
0);
DragAcceptFiles(hwnd, 1);
scratch_end(scratch);
}