[BUG_FIXED] Fix Tab close button too small issue with a very high resolution display.

This commit is contained in:
Don Ho 2015-05-01 19:51:59 +02:00
parent ac61c43d15
commit 6bf823d3f8
4 changed files with 43 additions and 33 deletions

View File

@ -347,8 +347,9 @@ LRESULT Notepad_plus::init(HWND hwnd)
::SendMessage(_subDocTab.getHSelf(), WM_SETFONT, (WPARAM)hf, MAKELPARAM(TRUE, 0));
}
int tabDpiDynamicalHeight = NppParameters::getInstance()->_dpiManager.scaleY(20);
TabCtrl_SetItemSize(_mainDocTab.getHSelf(), 45, tabDpiDynamicalHeight);
TabCtrl_SetItemSize(_subDocTab.getHSelf(), 45, tabDpiDynamicalHeight);
int tabDpiDynamicalWidth = NppParameters::getInstance()->_dpiManager.scaleX(45);
TabCtrl_SetItemSize(_mainDocTab.getHSelf(), tabDpiDynamicalWidth, tabDpiDynamicalHeight);
TabCtrl_SetItemSize(_subDocTab.getHSelf(), tabDpiDynamicalWidth, tabDpiDynamicalHeight);
}
_mainDocTab.display();

View File

@ -1269,9 +1269,10 @@ void Notepad_plus::command(int id)
int iconDpiDynamicalSize = NppParameters::getInstance()->_dpiManager.scaleY(_toReduceTabBar?12:18);
//Resize the tab height
int tabDpiDynamicalWidth = NppParameters::getInstance()->_dpiManager.scaleX(45);
int tabDpiDynamicalHeight = NppParameters::getInstance()->_dpiManager.scaleY(_toReduceTabBar?20:25);
TabCtrl_SetItemSize(_mainDocTab.getHSelf(), 45, tabDpiDynamicalHeight);
TabCtrl_SetItemSize(_subDocTab.getHSelf(), 45, tabDpiDynamicalHeight);
TabCtrl_SetItemSize(_mainDocTab.getHSelf(), tabDpiDynamicalWidth, tabDpiDynamicalHeight);
TabCtrl_SetItemSize(_subDocTab.getHSelf(), tabDpiDynamicalWidth, tabDpiDynamicalHeight);
_docTabIconList.setIconSize(iconDpiDynamicalSize);
//change the font
@ -1297,7 +1298,6 @@ void Notepad_plus::command(int id)
{
bool isDrag = TabBarPlus::doDragNDropOrNot();
TabBarPlus::doDragNDrop(!isDrag);
//checkMenuItem(IDM_VIEW_LOCKTABBAR, isDrag);
break;
}
@ -1305,7 +1305,6 @@ void Notepad_plus::command(int id)
case IDM_VIEW_DRAWTABBAR_INACIVETAB:
{
TabBarPlus::setDrawInactiveTab(!TabBarPlus::drawInactiveTab());
//TabBarPlus::setDrawInactiveTab(!TabBarPlus::drawInactiveTab(), _subDocTab.getHSelf());
break;
}
case IDM_VIEW_DRAWTABBAR_TOPBAR:
@ -1321,8 +1320,9 @@ void Notepad_plus::command(int id)
// This part is just for updating (redraw) the tabs
{
int tabDpiDynamicalHeight = NppParameters::getInstance()->_dpiManager.scaleY(TabBarPlus::drawTabCloseButton()?21:20);
TabCtrl_SetItemSize(_mainDocTab.getHSelf(), 45, tabDpiDynamicalHeight);
TabCtrl_SetItemSize(_subDocTab.getHSelf(), 45, tabDpiDynamicalHeight);
int tabDpiDynamicalWidth = NppParameters::getInstance()->_dpiManager.scaleX(TabBarPlus::drawTabCloseButton() ? 60:45);
TabCtrl_SetItemSize(_mainDocTab.getHSelf(), tabDpiDynamicalWidth, tabDpiDynamicalHeight);
TabCtrl_SetItemSize(_subDocTab.getHSelf(), tabDpiDynamicalWidth, tabDpiDynamicalHeight);
}
::SendMessage(_pPublicInterface->getHSelf(), WM_SIZE, 0, 0);
break;

View File

@ -348,8 +348,9 @@ void TabBarPlus::doOwnerDrawTab()
::SetWindowLongPtr(_hwndArray[i], GWL_STYLE, style);
::InvalidateRect(_hwndArray[i], NULL, TRUE);
const int base = 6;
::SendMessage(_hwndArray[i], TCM_SETPADDING, 0, MAKELPARAM(_drawTabCloseButton?base+3:base, 0));
const int paddingSizeDynamicW = NppParameters::getInstance()->_dpiManager.scaleX(6);
const int paddingSizePlusClosebuttonDynamicW = NppParameters::getInstance()->_dpiManager.scaleX(9);
::SendMessage(_hwndArray[i], TCM_SETPADDING, 0, MAKELPARAM(_drawTabCloseButton ? paddingSizePlusClosebuttonDynamicW : paddingSizeDynamicW, 0));
}
}
}
@ -665,7 +666,6 @@ void TabBarPlus::drawItem(DRAWITEMSTRUCT *pDrawItemStruct)
if (!::SendMessage(_hSelf, TCM_GETITEM, nTab, reinterpret_cast<LPARAM>(&tci)))
{
::MessageBox(NULL, TEXT("! TCM_GETITEM"), TEXT(""), MB_OK);
//return ::CallWindowProc(_tabBarDefaultProc, hwnd, Message, wParam, lParam);
}
HDC hDC = pDrawItemStruct->hDC;
@ -681,16 +681,17 @@ void TabBarPlus::drawItem(DRAWITEMSTRUCT *pDrawItemStruct)
if (_drawTopBar)
{
RECT barRect = rect;
int paddingDynamicSix = NppParameters::getInstance()->_dpiManager.scaleX(6);
int paddingDynamicTwo = NppParameters::getInstance()->_dpiManager.scaleX(2);
if (_isVertical)
{
barRect.right = barRect.left + 6;
rect.left += 2;
barRect.right = barRect.left + paddingDynamicSix;
rect.left += paddingDynamicTwo;
}
else
{
barRect.bottom = barRect.top + 6;
rect.top += 2;
barRect.bottom = barRect.top + paddingDynamicSix;
rect.top += paddingDynamicTwo;
}
if (::SendMessage(_hParent, NPPM_INTERNAL_ISFOCUSEDTAB, 0, (LPARAM)_hSelf))
@ -721,7 +722,6 @@ void TabBarPlus::drawItem(DRAWITEMSTRUCT *pDrawItemStruct)
{
if (!_isVertical)
{
//closeButtonRect.top += 2;
closeButtonRect.left -= 2;
}
}
@ -729,6 +729,8 @@ void TabBarPlus::drawItem(DRAWITEMSTRUCT *pDrawItemStruct)
{
if (_isVertical)
closeButtonRect.left += 2;
else
closeButtonRect.left += NppParameters::getInstance()->_dpiManager.scaleX(2);
}
@ -750,15 +752,17 @@ void TabBarPlus::drawItem(DRAWITEMSTRUCT *pDrawItemStruct)
BITMAP bmp;
::GetObject(hBmp, sizeof(bmp), &bmp);
int bmDpiDynamicalWidth = NppParameters::getInstance()->_dpiManager.scaleX(bmp.bmWidth);
int bmDpiDynamicalHeight = NppParameters::getInstance()->_dpiManager.scaleY(bmp.bmHeight);
if (_isVertical)
rect.top = closeButtonRect.top + bmp.bmHeight;
rect.top = closeButtonRect.top + bmDpiDynamicalHeight;
else
rect.right = closeButtonRect.left;
int bmDpiDynamicalWidth = NppParameters::getInstance()->_dpiManager.scaleX(bmp.bmWidth);
int bmDpiDynamicalHeight = NppParameters::getInstance()->_dpiManager.scaleY(bmp.bmHeight);
::SelectObject(hdcMemory, hBmp);
::BitBlt(hDC, closeButtonRect.left, closeButtonRect.top, bmDpiDynamicalWidth, bmDpiDynamicalHeight, hdcMemory, 0, 0, SRCCOPY);
::StretchBlt(hDC, closeButtonRect.left, closeButtonRect.top, bmDpiDynamicalWidth, bmDpiDynamicalHeight, hdcMemory, 0, 0, bmp.bmWidth, bmp.bmHeight, SRCCOPY);
::DeleteDC(hdcMemory);
::DeleteObject(hBmp);
}
@ -781,13 +785,10 @@ void TabBarPlus::drawItem(DRAWITEMSTRUCT *pDrawItemStruct)
RECT & imageRect = info.rcImage;
if (_isVertical)
xPos = (rect.left + (rect.right - rect.left)/2 + 2) - (imageRect.right - imageRect.left)/2;
xPos = (rect.left + (rect.right - rect.left) / 2 + NppParameters::getInstance()->_dpiManager.scaleX(2)) - (imageRect.right - imageRect.left) / 2;
else
yPos = (rect.top + (rect.bottom - rect.top)/2 + (isSelected?0:2)) - (imageRect.bottom - imageRect.top)/2;
yPos = (rect.top + (rect.bottom - rect.top) / 2 + (isSelected ? 0 : NppParameters::getInstance()->_dpiManager.scaleX(2))) - (imageRect.bottom - imageRect.top) / 2;
if (isSelected)
marge = spaceUnit*2;
else
marge = spaceUnit;
if (_isVertical)
@ -861,8 +862,8 @@ void TabBarPlus::drawItem(DRAWITEMSTRUCT *pDrawItemStruct)
if (_isVertical)
{
rect.bottom -= 2;
rect.left += ::GetSystemMetrics(SM_CXEDGE) + 4;
rect.bottom -= NppParameters::getInstance()->_dpiManager.scaleY(2);
rect.left += ::GetSystemMetrics(SM_CXEDGE) + NppParameters::getInstance()->_dpiManager.scaleX(4);
rect.top += (_drawTabCloseButton)?spaceUnit:0;
Flags |= DT_BOTTOM;
@ -870,7 +871,7 @@ void TabBarPlus::drawItem(DRAWITEMSTRUCT *pDrawItemStruct)
else
{
rect.top -= ::GetSystemMetrics(SM_CYEDGE);
rect.top += 3;
rect.top += NppParameters::getInstance()->_dpiManager.scaleY(3);
rect.left += _drawTabCloseButton?spaceUnit:0;
Flags |= DT_VCENTER;
@ -881,9 +882,9 @@ void TabBarPlus::drawItem(DRAWITEMSTRUCT *pDrawItemStruct)
::SetTextColor(hDC, _inactiveTextColour);
if (_isVertical)
{
rect.top += 2;
rect.bottom += 4;
rect.left += ::GetSystemMetrics(SM_CXEDGE) + 2;
rect.top += NppParameters::getInstance()->_dpiManager.scaleY(2);
rect.bottom += NppParameters::getInstance()->_dpiManager.scaleY(4);
rect.left += ::GetSystemMetrics(SM_CXEDGE) + NppParameters::getInstance()->_dpiManager.scaleX(2);
}
else
{
@ -984,6 +985,14 @@ void TabBarPlus::exchangeItemData(POINT point)
}
CloseButtonZone::CloseButtonZone()
{
_width = NppParameters::getInstance()->_dpiManager.scaleX(11);
_hight = NppParameters::getInstance()->_dpiManager.scaleY(11);
_fromTop = NppParameters::getInstance()->_dpiManager.scaleY(5);
_fromRight = NppParameters::getInstance()->_dpiManager.scaleX(3);
}
bool CloseButtonZone::isHit(int x, int y, const RECT & testZone) const
{
if (((x + _width + _fromRight) < testZone.right) || (x > (testZone.right - _fromRight)))

View File

@ -129,7 +129,7 @@ protected:
struct CloseButtonZone {
CloseButtonZone(): _width(11), _hight(11), _fromTop(5), _fromRight(3){};
CloseButtonZone();
bool isHit(int x, int y, const RECT & testZone) const;
RECT getButtonRectFrom(const RECT & tabItemRect) const;