vertical panel resizing

This commit is contained in:
jacob 2025-12-21 19:51:17 -06:00
parent 0cf1dbebf9
commit de0e166de7
4 changed files with 37 additions and 13 deletions

View File

@ -1,7 +1,7 @@
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
//~ Tile types //~ Tile types
#define S_WorldSize 128 #define S_WorldSize 96
#define S_TilesXMacro(X) \ #define S_TilesXMacro(X) \
X(Empty) \ X(Empty) \

View File

@ -1077,10 +1077,17 @@ void V_TickForever(WaveLaneCtx *lane)
UI_SetNext(AxisSize, UI_PIX(3, 1), .axis = !panel->axis); UI_SetNext(AxisSize, UI_PIX(3, 1), .axis = !panel->axis);
UI_BuildBoxEx(divider_key); UI_BuildBoxEx(divider_key);
if (rep.is_hovered) if (rep.is_hovered || rep.is_m1_held)
{
if (panel->axis == Axis_X)
{
WND_PushCmd(window_frame, .kind = WND_CmdKind_SetCursor, WND_CursorKind_VerticalResize);
}
else
{ {
WND_PushCmd(window_frame, .kind = WND_CmdKind_SetCursor, WND_CursorKind_HorizontalResize); WND_PushCmd(window_frame, .kind = WND_CmdKind_SetCursor, WND_CursorKind_HorizontalResize);
} }
}
if (rep.is_m1_held) if (rep.is_m1_held)
{ {
@ -1088,10 +1095,21 @@ void V_TickForever(WaveLaneCtx *lane)
UI_Report parent_rep = UI_ReportFromKey(panel->parent->key); UI_Report parent_rep = UI_ReportFromKey(panel->parent->key);
/* FIXME: Height */ /* FIXME: Height */
f32 parent_width = DimsFromRng2(parent_rep.screen_rect).x; f32 parent_size = 0;
f32 new_size = 0;
if (panel->axis == Axis_X)
{
parent_size = DimsFromRng2(parent_rep.screen_rect).y;
new_size = frame->ui_cursor.y - panel_rep.screen_rect.p0.y;
}
else
{
parent_size = DimsFromRng2(parent_rep.screen_rect).x;
new_size = frame->ui_cursor.x - panel_rep.screen_rect.p0.x;
}
f32 old_ratio = panel->pref_ratio; f32 old_ratio = panel->pref_ratio;
f32 new_ratio = (frame->ui_cursor.x - panel_rep.screen_rect.p0.x) / parent_width; f32 new_ratio = new_size / parent_size;
f32 ratio_diff = new_ratio - old_ratio; f32 ratio_diff = new_ratio - old_ratio;
panel->pref_ratio_diff = ratio_diff; panel->pref_ratio_diff = ratio_diff;
} }

View File

@ -223,11 +223,11 @@ LRESULT CALLBACK WND_W32_WindowProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM l
{ {
if ((HWND)wparam == hwnd && LOWORD(lparam) == HTCLIENT) if ((HWND)wparam == hwnd && LOWORD(lparam) == HTCLIENT)
{ {
HCURSOR new_cursor = (HCURSOR)Atomic64Fetch(&window->new_cursor); HCURSOR desired_cursor = (HCURSOR)Atomic64Fetch(&window->desired_cursor);
if (new_cursor != window->active_cursor) if (desired_cursor != window->active_cursor)
{ {
SetCursor(new_cursor); SetCursor(desired_cursor);
window->active_cursor = new_cursor; window->active_cursor = desired_cursor;
} }
result = 1; result = 1;
} }
@ -573,7 +573,7 @@ void WND_EndFrame(WND_Frame frame, i32 vsync)
/* Process cmds */ /* Process cmds */
b32 was_restored = 0; b32 was_restored = 0;
WND_CursorKind new_cursor = (WND_CursorKind)Atomic64Fetch(&window->new_cursor); HCURSOR desired_cursor = (HCURSOR)Atomic64Fetch(&window->desired_cursor);
for (WND_W32_CmdNode *n = window->first_cmd; n; n = n->next) for (WND_W32_CmdNode *n = window->first_cmd; n; n = n->next)
{ {
WND_Cmd cmd = n->cmd; WND_Cmd cmd = n->cmd;
@ -646,7 +646,7 @@ void WND_EndFrame(WND_Frame frame, i32 vsync)
//- Cursor //- Cursor
case WND_CmdKind_SetCursor: case WND_CmdKind_SetCursor:
{ {
new_cursor = cmd.cursor; desired_cursor = g->cursors[cmd.cursor];
} break; } break;
//- Restore //- Restore
@ -710,7 +710,13 @@ void WND_EndFrame(WND_Frame frame, i32 vsync)
} }
/* Set cursor */ /* Set cursor */
Atomic64Set(&window->new_cursor, (u64)g->cursors[new_cursor]); {
HCURSOR old_desired_cursor = (HCURSOR)Atomic64FetchSet(&window->desired_cursor, (i64)desired_cursor);
if (old_desired_cursor != desired_cursor)
{
PostMessage(window->hwnd, WM_SETCURSOR, (WPARAM)window->hwnd, (LPARAM)HTCLIENT);
}
}
/* Commit backbuffer */ /* Commit backbuffer */
G_CommitBackbuffer(frame.backbuffer, vsync); G_CommitBackbuffer(frame.backbuffer, vsync);

View File

@ -26,7 +26,7 @@ Struct(WND_W32_Window)
Arena *w2u_events_arena; Arena *w2u_events_arena;
/* User -> Window proc */ /* User -> Window proc */
Atomic64 new_cursor; Atomic64 desired_cursor;
}; };
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////