Added captions to windows.

This commit is contained in:
Justin Marshall
2026-05-14 19:58:13 -07:00
parent d5f59f06e1
commit 3cad87be0a
2 changed files with 561 additions and 117 deletions
+64 -7
View File
@@ -1003,7 +1003,9 @@ static const char* CAMWND_PROP_REBUILD_MODE = "QER_CamWnd_RebuildMode";
static const char* CAMWND_PROP_ENTITY_MODE = "QER_CamWnd_EntityMode";
static const char* CAMWND_PROP_FILTER_MASK = "QER_CamWnd_FilterMask";
#define CAMWND_CAPTION_HEIGHT 30
#define CAMWND_MENU_HEIGHT 22
#define CAMWND_TOPBAR_HEIGHT (CAMWND_CAPTION_HEIGHT + CAMWND_MENU_HEIGHT)
#define CAMWND_MENU_CHILD_ID 62000
#define CAMWND_MENU_CMD_REALTIME_LIGHTING 62100
#define CAMWND_MENU_CMD_SHOW_WORLD 62101
@@ -1026,7 +1028,7 @@ static const char* CAMWND_PROP_FILTER_MASK = "QER_CamWnd_FilterMask";
static LRESULT CALLBACK CamWnd_MenuBarProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
static int CamWnd_GetMenuHeight() {
return CAMWND_MENU_HEIGHT;
return CAMWND_TOPBAR_HEIGHT;
}
static int CamWnd_GetIntProp(HWND hWnd, const char* name, int defaultValue = 0) {
@@ -1092,8 +1094,8 @@ static void CamWnd_RequestRedraw(CCamWnd* cam) {
static void CamWnd_GetMenuItemRect(HWND hWnd, int item, RECT& rect) {
GetClientRect(hWnd, &rect);
rect.top = 1;
rect.bottom = CAMWND_MENU_HEIGHT - 1;
rect.top = CAMWND_CAPTION_HEIGHT + 1;
rect.bottom = CAMWND_TOPBAR_HEIGHT - 1;
if (item == 0) {
rect.left = 4;
@@ -1317,7 +1319,7 @@ static HWND CamWnd_EnsureMenuBar(CCamWnd* cam) {
0,
0,
rect.Width(),
CAMWND_MENU_HEIGHT,
CAMWND_TOPBAR_HEIGHT,
cam->GetSafeHwnd(),
(HMENU)CAMWND_MENU_CHILD_ID,
AfxGetInstanceHandle(),
@@ -1343,7 +1345,7 @@ static void CamWnd_LayoutMenuBar(CCamWnd* cam) {
CRect rect;
cam->GetClientRect(rect);
MoveWindow(hBar, 0, 0, rect.Width(), CAMWND_MENU_HEIGHT, TRUE);
MoveWindow(hBar, 0, 0, rect.Width(), CAMWND_TOPBAR_HEIGHT, TRUE);
}
static void CamWnd_DestroyMenuBar(CCamWnd* cam) {
@@ -1581,6 +1583,39 @@ static bool CamWnd_MenuFilterBrush(CCamWnd* cam, brush_t* brush) {
return false;
}
static COLORREF CamWnd_LerpColor(COLORREF a, COLORREF b, float t) {
const int ar = GetRValue(a);
const int ag = GetGValue(a);
const int ab = GetBValue(a);
const int br = GetRValue(b);
const int bg = GetGValue(b);
const int bb = GetBValue(b);
const int r = ar + (int)((br - ar) * t);
const int g = ag + (int)((bg - ag) * t);
const int bl = ab + (int)((bb - ab) * t);
return RGB(r, g, bl);
}
static void CamWnd_FillHorizontalGradient(HDC hDC, const RECT& rect, COLORREF leftColor, COLORREF rightColor) {
const int width = rect.right - rect.left;
if (width <= 0) {
return;
}
for (int x = 0; x < width; x++) {
const float t = (width > 1) ? ((float)x / (float)(width - 1)) : 0.0f;
const COLORREF color = CamWnd_LerpColor(leftColor, rightColor, t);
HPEN pen = CreatePen(PS_SOLID, 1, color);
HPEN oldPen = (HPEN)SelectObject(hDC, pen);
MoveToEx(hDC, rect.left + x, rect.top, NULL);
LineTo(hDC, rect.left + x, rect.bottom);
SelectObject(hDC, oldPen);
DeleteObject(pen);
}
}
static LRESULT CALLBACK CamWnd_MenuBarProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
switch (uMsg) {
case WM_ERASEBKGND:
@@ -1615,10 +1650,25 @@ static LRESULT CALLBACK CamWnd_MenuBarProc(HWND hWnd, UINT uMsg, WPARAM wParam,
RECT rect;
GetClientRect(hWnd, &rect);
FillRect(hDC, &rect, (HBRUSH)(COLOR_BTNFACE + 1));
RECT captionRect = rect;
captionRect.top = 0;
captionRect.bottom = CAMWND_CAPTION_HEIGHT;
RECT menuRect = rect;
menuRect.top = CAMWND_CAPTION_HEIGHT;
menuRect.bottom = CAMWND_TOPBAR_HEIGHT;
CamWnd_FillHorizontalGradient(hDC, captionRect, RGB(24, 82, 150), RGB(92, 96, 104));
FillRect(hDC, &menuRect, (HBRUSH)(COLOR_BTNFACE + 1));
RECT dividerRect = rect;
dividerRect.top = CAMWND_CAPTION_HEIGHT - 1;
dividerRect.bottom = CAMWND_CAPTION_HEIGHT;
FillRect(hDC, &dividerRect, (HBRUSH)(COLOR_3DSHADOW + 1));
RECT lineRect = rect;
lineRect.top = CAMWND_MENU_HEIGHT - 1;
lineRect.top = CAMWND_TOPBAR_HEIGHT - 1;
lineRect.bottom = CAMWND_TOPBAR_HEIGHT;
FillRect(hDC, &lineRect, (HBRUSH)(COLOR_3DSHADOW + 1));
HFONT font = (HFONT)SendMessage(hWnd, WM_GETFONT, 0, 0);
@@ -1628,6 +1678,13 @@ static LRESULT CALLBACK CamWnd_MenuBarProc(HWND hWnd, UINT uMsg, WPARAM wParam,
}
SetBkMode(hDC, TRANSPARENT);
RECT captionTextRect = captionRect;
captionTextRect.left += 8;
captionTextRect.right -= 8;
SetTextColor(hDC, RGB(235, 242, 255));
DrawText(hDC, "Viewport", -1, &captionTextRect, DT_SINGLELINE | DT_LEFT | DT_VCENTER | DT_END_ELLIPSIS);
SetTextColor(hDC, GetSysColor(COLOR_BTNTEXT));
RECT itemRect;