move from imgui to CLAY
This commit is contained in:
@@ -22,11 +22,17 @@ struct PlatformMenu {
|
||||
int32_t item_count;
|
||||
};
|
||||
|
||||
// Called by the platform layer when the window needs a frame rendered
|
||||
// (e.g., during a live resize). user_data is the pointer passed to
|
||||
// platform_set_frame_callback.
|
||||
typedef void (*PlatformFrameCallback)(void *user_data);
|
||||
|
||||
PlatformWindow *platform_create_window(PlatformWindowDesc *desc);
|
||||
void platform_destroy_window(PlatformWindow *window);
|
||||
bool platform_poll_events(PlatformWindow *window);
|
||||
void platform_get_size(PlatformWindow *window, int32_t *w, int32_t *h);
|
||||
void *platform_get_native_handle(PlatformWindow *window);
|
||||
|
||||
void platform_set_frame_callback(PlatformWindow *window, PlatformFrameCallback cb, void *user_data);
|
||||
void platform_set_menu(PlatformWindow *window, PlatformMenu *menus, int32_t menu_count);
|
||||
int32_t platform_poll_menu_command(PlatformWindow *window);
|
||||
|
||||
@@ -6,29 +6,29 @@
|
||||
#include <windows.h>
|
||||
#include <malloc.h>
|
||||
|
||||
#include "imgui_impl_win32.h"
|
||||
|
||||
extern IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
|
||||
|
||||
struct PlatformWindow {
|
||||
HWND hwnd;
|
||||
bool should_close;
|
||||
int32_t width;
|
||||
int32_t height;
|
||||
int32_t pending_menu_cmd;
|
||||
PlatformFrameCallback frame_callback;
|
||||
void *frame_callback_user_data;
|
||||
};
|
||||
|
||||
static PlatformWindow *g_current_window = nullptr;
|
||||
|
||||
static LRESULT CALLBACK win32_wndproc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) {
|
||||
if (ImGui_ImplWin32_WndProcHandler(hwnd, msg, wparam, lparam))
|
||||
return true;
|
||||
|
||||
switch (msg) {
|
||||
case WM_SIZE:
|
||||
if (g_current_window && wparam != SIZE_MINIMIZED) {
|
||||
g_current_window->width = (int32_t)LOWORD(lparam);
|
||||
g_current_window->height = (int32_t)HIWORD(lparam);
|
||||
// Render a frame during the modal resize loop so the UI
|
||||
// stays responsive instead of showing a stretched image.
|
||||
if (g_current_window->frame_callback) {
|
||||
g_current_window->frame_callback(g_current_window->frame_callback_user_data);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
case WM_COMMAND:
|
||||
@@ -133,6 +133,11 @@ void *platform_get_native_handle(PlatformWindow *window) {
|
||||
return (void *)window->hwnd;
|
||||
}
|
||||
|
||||
void platform_set_frame_callback(PlatformWindow *window, PlatformFrameCallback cb, void *user_data) {
|
||||
window->frame_callback = cb;
|
||||
window->frame_callback_user_data = user_data;
|
||||
}
|
||||
|
||||
void platform_set_menu(PlatformWindow *window, PlatformMenu *menus, int32_t menu_count) {
|
||||
HMENU menu_bar = CreateMenu();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user