mirror of
https://github.com/bsnes-emu/bsnes.git
synced 2025-08-20 05:21:26 +02:00
Update to v106r41 release.
byuu says: Changelog: - hiro: added Label::set(Background,Foreground)Color (not implemented on Cocoa backend) - hiro: added (Horizontal,Vertical)Layout::setPadding() - setMargin(m) is now an alias to setPadding({m, m, m, m}) - hiro/Windows: update Label rendering to draw to an offscreen canvas to prevent flickering - sfc: reverted back to 224/240-line height (from 223/239-line height in earlier v106 WIPs) - bsnes: new multi-segment status bar added - bsnes: exiting fullscreen mode will resize and recenter window - this is required; the window geometry gets all scrambled when toggling fullscreen mode - bsnes: updated to a new logo [Ange Albertini] Errata: - hiro/Windows: try to paint Label backgroundColor quicker to avoid startup flicker - `WM_ERASEBKGND` fallthrough to `WM_PAINT` seems to work - hiro/Qt: use Window backgroundColor for Label when no Label backgroundColor set - bsnes: update size multipliers in presentation.cpp to 224/240 (main window size is off in this WIP)
This commit is contained in:
@@ -8,7 +8,6 @@ auto pLabel::construct() -> void {
|
||||
0, 0, 0, 0, _parentHandle(), nullptr, GetModuleHandle(0), 0);
|
||||
SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)&reference);
|
||||
pWidget::_setState();
|
||||
setAlignment(state().alignment);
|
||||
setText(state().text);
|
||||
}
|
||||
|
||||
@@ -25,6 +24,14 @@ auto pLabel::setAlignment(Alignment alignment) -> void {
|
||||
InvalidateRect(hwnd, 0, false);
|
||||
}
|
||||
|
||||
auto pLabel::setBackgroundColor(Color color) -> void {
|
||||
InvalidateRect(hwnd, 0, false);
|
||||
}
|
||||
|
||||
auto pLabel::setForegroundColor(Color color) -> void {
|
||||
InvalidateRect(hwnd, 0, false);
|
||||
}
|
||||
|
||||
auto pLabel::setText(const string& text) -> void {
|
||||
SetWindowText(hwnd, utf16_t(text));
|
||||
InvalidateRect(hwnd, 0, false);
|
||||
@@ -44,20 +51,32 @@ static auto CALLBACK Label_windowProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM
|
||||
BeginPaint(hwnd, &ps);
|
||||
RECT rc;
|
||||
GetClientRect(hwnd, &rc);
|
||||
//todo: use DrawThemeParentBackground if Label is inside TabFrame
|
||||
if(auto brush = window->self()->hbrush) {
|
||||
FillRect(ps.hdc, &rc, brush);
|
||||
} else {
|
||||
DrawThemeParentBackground(hwnd, ps.hdc, &rc);
|
||||
}
|
||||
SetBkMode(ps.hdc, TRANSPARENT);
|
||||
SelectObject(ps.hdc, label->self()->hfont);
|
||||
|
||||
auto hdcMemory = CreateCompatibleDC(ps.hdc);
|
||||
auto hbmMemory = CreateCompatibleBitmap(ps.hdc, rc.right - rc.left, rc.bottom - rc.top);
|
||||
SelectObject(hdcMemory, hbmMemory);
|
||||
|
||||
uint length = GetWindowTextLength(hwnd);
|
||||
wchar_t text[length + 1];
|
||||
GetWindowText(hwnd, text, length + 1);
|
||||
text[length] = 0;
|
||||
DrawText(ps.hdc, text, -1, &rc, DT_CALCRECT | DT_END_ELLIPSIS);
|
||||
|
||||
//todo: use DrawThemeParentBackground if Label is inside TabFrame
|
||||
if(auto color = label->backgroundColor()) {
|
||||
auto brush = CreateSolidBrush(CreateRGB(color));
|
||||
FillRect(hdcMemory, &rc, brush);
|
||||
DeleteObject(brush);
|
||||
} else if(auto brush = window->self()->hbrush) {
|
||||
FillRect(hdcMemory, &rc, brush);
|
||||
} else {
|
||||
DrawThemeParentBackground(hwnd, hdcMemory, &rc);
|
||||
}
|
||||
|
||||
SetBkMode(hdcMemory, TRANSPARENT);
|
||||
SelectObject(hdcMemory, label->self()->hfont);
|
||||
DrawText(hdcMemory, text, -1, &rc, DT_CALCRECT | DT_END_ELLIPSIS);
|
||||
uint height = rc.bottom;
|
||||
|
||||
GetClientRect(hwnd, &rc);
|
||||
rc.top = (rc.bottom - height) / 2;
|
||||
rc.bottom = rc.top + height;
|
||||
@@ -67,7 +86,15 @@ static auto CALLBACK Label_windowProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM
|
||||
uint verticalAlignment = DT_VCENTER;
|
||||
if(label->alignment().vertical() < 0.333) verticalAlignment = DT_TOP;
|
||||
if(label->alignment().vertical() > 0.666) verticalAlignment = DT_BOTTOM;
|
||||
DrawText(ps.hdc, text, -1, &rc, DT_END_ELLIPSIS | horizontalAlignment | verticalAlignment);
|
||||
if(auto color = label->foregroundColor()) {
|
||||
SetTextColor(hdcMemory, CreateRGB(color));
|
||||
}
|
||||
DrawText(hdcMemory, text, -1, &rc, DT_END_ELLIPSIS | horizontalAlignment | verticalAlignment);
|
||||
|
||||
GetClientRect(hwnd, &rc);
|
||||
BitBlt(ps.hdc, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, hdcMemory, 0, 0, SRCCOPY);
|
||||
DeleteObject(hbmMemory);
|
||||
DeleteObject(hdcMemory);
|
||||
EndPaint(hwnd, &ps);
|
||||
return false;
|
||||
}
|
||||
|
@@ -7,6 +7,8 @@ struct pLabel : pWidget {
|
||||
|
||||
auto minimumSize() const -> Size override;
|
||||
auto setAlignment(Alignment alignment) -> void;
|
||||
auto setBackgroundColor(Color color) -> void;
|
||||
auto setForegroundColor(Color color) -> void;
|
||||
auto setText(const string& text) -> void;
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user