mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-02 01:48:05 +00:00
Bug 508734 - <menuitem> checkbox ugliness with high DPI. r=jmathies,neil
This commit is contained in:
parent
6dc97c3352
commit
b85bd0a5fa
@ -149,21 +149,23 @@ static PRBool IsTopLevelMenu(nsIFrame *aFrame)
|
||||
return isTopLevel;
|
||||
}
|
||||
|
||||
|
||||
static SIZE GetCheckboxSize(HANDLE theme, HDC hdc)
|
||||
static MARGINS GetCheckboxMargins(HANDLE theme, HDC hdc)
|
||||
{
|
||||
MARGINS checkboxContent = {0};
|
||||
nsUXThemeData::getThemeMargins(theme, hdc, MENU_POPUPCHECK, MCB_NORMAL, TMT_CONTENTMARGINS, NULL, &checkboxContent);
|
||||
return checkboxContent;
|
||||
}
|
||||
static SIZE GetCheckboxBGSize(HANDLE theme, HDC hdc)
|
||||
{
|
||||
SIZE checkboxSize;
|
||||
nsUXThemeData::getThemePartSize(theme, hdc, MENU_POPUPCHECK, MC_CHECKMARKNORMAL, NULL, TS_TRUE, &checkboxSize);
|
||||
|
||||
MARGINS checkboxSizing;
|
||||
MARGINS checkboxContent;
|
||||
nsUXThemeData::getThemeMargins(theme, hdc, MENU_POPUPCHECKBACKGROUND, MCB_NORMAL, TMT_SIZINGMARGINS, NULL, &checkboxSizing);
|
||||
nsUXThemeData::getThemeMargins(theme, hdc, MENU_POPUPCHECKBACKGROUND, MCB_NORMAL, TMT_CONTENTMARGINS, NULL, &checkboxContent);
|
||||
MARGINS checkboxMargins = GetCheckboxMargins(theme, hdc);
|
||||
|
||||
int leftMargin = checkboxSizing.cxLeftWidth;
|
||||
int rightMargin = checkboxSizing.cxRightWidth;
|
||||
int topMargin = checkboxSizing.cyTopHeight;
|
||||
int bottomMargin = checkboxSizing.cyBottomHeight;
|
||||
int leftMargin = checkboxMargins.cxLeftWidth;
|
||||
int rightMargin = checkboxMargins.cxRightWidth;
|
||||
int topMargin = checkboxMargins.cyTopHeight;
|
||||
int bottomMargin = checkboxMargins.cyBottomHeight;
|
||||
|
||||
int width = leftMargin + checkboxSize.cx + rightMargin;
|
||||
int height = topMargin + checkboxSize.cy + bottomMargin;
|
||||
@ -172,21 +174,21 @@ static SIZE GetCheckboxSize(HANDLE theme, HDC hdc)
|
||||
ret.cy = height;
|
||||
return ret;
|
||||
}
|
||||
static SIZE GetCheckboxBounds(HANDLE theme, HDC hdc)
|
||||
static SIZE GetCheckboxBGBounds(HANDLE theme, HDC hdc)
|
||||
{
|
||||
MARGINS checkboxSizing;
|
||||
MARGINS checkboxContent;
|
||||
nsUXThemeData::getThemeMargins(theme, hdc, MENU_POPUPCHECKBACKGROUND, MCB_NORMAL, TMT_SIZINGMARGINS, NULL, &checkboxSizing);
|
||||
nsUXThemeData::getThemeMargins(theme, hdc, MENU_POPUPCHECKBACKGROUND, MCB_NORMAL, TMT_CONTENTMARGINS, NULL, &checkboxContent);
|
||||
MARGINS checkboxBGSizing = {0};
|
||||
MARGINS checkboxBGContent = {0};
|
||||
nsUXThemeData::getThemeMargins(theme, hdc, MENU_POPUPCHECKBACKGROUND, MCB_NORMAL, TMT_SIZINGMARGINS, NULL, &checkboxBGSizing);
|
||||
nsUXThemeData::getThemeMargins(theme, hdc, MENU_POPUPCHECKBACKGROUND, MCB_NORMAL, TMT_CONTENTMARGINS, NULL, &checkboxBGContent);
|
||||
|
||||
#define posdx(d) ((d) > 0 ? d : 0)
|
||||
|
||||
int dx = posdx(checkboxContent.cxRightWidth - checkboxSizing.cxRightWidth) + posdx(checkboxContent.cxLeftWidth - checkboxSizing.cxLeftWidth);
|
||||
int dy = posdx(checkboxContent.cyTopHeight - checkboxSizing.cyTopHeight) + posdx(checkboxContent.cyBottomHeight - checkboxSizing.cyBottomHeight);
|
||||
int dx = posdx(checkboxBGContent.cxRightWidth - checkboxBGSizing.cxRightWidth) + posdx(checkboxBGContent.cxLeftWidth - checkboxBGSizing.cxLeftWidth);
|
||||
int dy = posdx(checkboxBGContent.cyTopHeight - checkboxBGSizing.cyTopHeight) + posdx(checkboxBGContent.cyBottomHeight - checkboxBGSizing.cyBottomHeight);
|
||||
|
||||
#undef posdx
|
||||
|
||||
SIZE ret(GetCheckboxSize(theme,hdc));
|
||||
SIZE ret(GetCheckboxBGSize(theme, hdc));
|
||||
ret.cx += dx;
|
||||
ret.cy += dy;
|
||||
return ret;
|
||||
@ -196,13 +198,13 @@ static SIZE GetGutterSize(HANDLE theme, HDC hdc)
|
||||
SIZE gutterSize;
|
||||
nsUXThemeData::getThemePartSize(theme, hdc, MENU_POPUPGUTTER, 0, NULL, TS_TRUE, &gutterSize);
|
||||
|
||||
SIZE checkboxSize(GetCheckboxBounds(theme, hdc));
|
||||
SIZE checkboxBGSize(GetCheckboxBGBounds(theme, hdc));
|
||||
|
||||
SIZE itemSize;
|
||||
nsUXThemeData::getThemePartSize(theme, hdc, MENU_POPUPITEM, MPI_NORMAL, NULL, TS_TRUE, &itemSize);
|
||||
|
||||
int width = PR_MAX(itemSize.cx, checkboxSize.cx + gutterSize.cx);
|
||||
int height = PR_MAX(itemSize.cy, checkboxSize.cy);
|
||||
int width = PR_MAX(itemSize.cx, checkboxBGSize.cx + gutterSize.cx);
|
||||
int height = PR_MAX(itemSize.cy, checkboxBGSize.cy);
|
||||
SIZE ret;
|
||||
ret.cx = width;
|
||||
ret.cy = height;
|
||||
@ -1103,20 +1105,27 @@ RENDER_AGAIN:
|
||||
if (isDisabled)
|
||||
bgState += 1;
|
||||
|
||||
SIZE checkboxSize(GetCheckboxSize(theme,hdc));
|
||||
SIZE checkboxBGSize(GetCheckboxBGSize(theme, hdc));
|
||||
|
||||
RECT checkRect = widgetRect;
|
||||
RECT checkBGRect = widgetRect;
|
||||
if (IsFrameRTL(aFrame)) {
|
||||
checkRect.left = checkRect.right-checkboxSize.cx;
|
||||
checkBGRect.left = checkBGRect.right-checkboxBGSize.cx;
|
||||
} else {
|
||||
checkRect.right = checkRect.left+checkboxSize.cx;
|
||||
checkBGRect.right = checkBGRect.left+checkboxBGSize.cx;
|
||||
}
|
||||
|
||||
// Center the checkbox vertically in the menuitem
|
||||
checkRect.top += (checkRect.bottom - checkRect.top)/2 - checkboxSize.cy/2;
|
||||
checkRect.bottom = checkRect.top + checkboxSize.cy;
|
||||
// Center the checkbox background vertically in the menuitem
|
||||
checkBGRect.top += (checkBGRect.bottom - checkBGRect.top)/2 - checkboxBGSize.cy/2;
|
||||
checkBGRect.bottom = checkBGRect.top + checkboxBGSize.cy;
|
||||
|
||||
nsUXThemeData::drawThemeBG(theme, hdc, MENU_POPUPCHECKBACKGROUND, bgState, &checkRect, &clipRect);
|
||||
nsUXThemeData::drawThemeBG(theme, hdc, MENU_POPUPCHECKBACKGROUND, bgState, &checkBGRect, &clipRect);
|
||||
|
||||
MARGINS checkMargins = GetCheckboxMargins(theme, hdc);
|
||||
RECT checkRect = checkBGRect;
|
||||
checkRect.left += checkMargins.cxLeftWidth;
|
||||
checkRect.right -= checkMargins.cxRightWidth;
|
||||
checkRect.top += checkMargins.cyTopHeight;
|
||||
checkRect.bottom -= checkMargins.cyBottomHeight;
|
||||
nsUXThemeData::drawThemeBG(theme, hdc, MENU_POPUPCHECK, state, &checkRect, &clipRect);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user