[CHARMAP] Updates to behaviour and UI (#2543)

Purpose
~=~=~=~

This pull request updates charmap to look a bit better (removes gap at bottom of the window), removes the blank space character (0x0020) from the charmap, and also modifies the behaviour of when a larger glyph is rendered (allowing the user to select a new glyph by holding down the mouse button). This better mimics the charmap.exe that is bundled by Microsoft.

Proposed changes
~=~=~=~=~=~=~=~=

- Remove gap where the advanced button is normally rendered when compiled with REMOVE_ADVANCED (which is the default behaviour).
- Skip over the blank space character.
- Change behaviour of rendering large glyphs to allow mouse move, and to hide on double click.
- Optimize search for glyph under the mouse by using the cellSize instead of PtInRect.


* [CHARMAP] Resize the window slightly when compiled with REMOVE_ADVANCED to avoid deadspace at the bottom of the window

* [CHARMAP] Skip over the non-printable characters by starting with character ' ' + 1

* [CHARMAP] Instead of iterating over every cell, simply compute the cell x and y using the CellSize

Modify behaviour of charmap to allow large character render on mouse move, only hiding the larger character on double click.
This commit is contained in:
Charles Ambrye 2020-04-15 14:31:16 -07:00 committed by GitHub
parent ea298746db
commit d90e1061e1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 54 additions and 50 deletions

View file

@ -276,6 +276,8 @@ ChangeView(HWND hWnd)
RECT rcCharmap; RECT rcCharmap;
#ifndef REMOVE_ADVANCED #ifndef REMOVE_ADVANCED
RECT rcAdvanced; RECT rcAdvanced;
#else
RECT rcCopy;
#endif #endif
RECT rcPanelExt; RECT rcPanelExt;
RECT rcPanelInt; RECT rcPanelInt;
@ -284,10 +286,16 @@ ChangeView(HWND hWnd)
UINT xPos, yPos; UINT xPos, yPos;
UINT Width, Height; UINT Width, Height;
UINT DeskTopWidth, DeskTopHeight; UINT DeskTopWidth, DeskTopHeight;
#ifdef REMOVE_ADVANCED
HWND hCopy;
#endif
GetClientRect(hCharmapDlg, &rcCharmap); GetClientRect(hCharmapDlg, &rcCharmap);
#ifndef REMOVE_ADVANCED #ifndef REMOVE_ADVANCED
GetClientRect(hAdvancedDlg, &rcAdvanced); GetClientRect(hAdvancedDlg, &rcAdvanced);
#else
hCopy = GetDlgItem(hCharmapDlg, IDC_COPY);
GetClientRect(hCopy, &rcCopy);
#endif #endif
GetWindowRect(hWnd, &rcPanelExt); GetWindowRect(hWnd, &rcPanelExt);
GetClientRect(hWnd, &rcPanelInt); GetClientRect(hWnd, &rcPanelInt);
@ -312,6 +320,10 @@ ChangeView(HWND hWnd)
#ifndef REMOVE_ADVANCED #ifndef REMOVE_ADVANCED
if (Settings.IsAdvancedView) if (Settings.IsAdvancedView)
Height += rcAdvanced.bottom; Height += rcAdvanced.bottom;
#else
/* The lack of advanced button leaves an empty gap at the bottom of the window.
Shrink the window height a bit here to accomodate for that lost control. */
Height = rcCharmap.bottom + rcCopy.bottom + 10;
#endif #endif
if ((xPos + Width) > DeskTopWidth) if ((xPos + Width) > DeskTopWidth)
xPos += DeskTopWidth - (xPos + Width); xPos += DeskTopWidth - (xPos + Width);

View file

@ -256,7 +256,7 @@ SetFont(PMAP infoPtr,
GGI_MARK_NONEXISTING_GLYPHS) != GDI_ERROR) GGI_MARK_NONEXISTING_GLYPHS) != GDI_ERROR)
{ {
j = 0; j = 0;
for (i = 0; i < MAX_GLYPHS; i++) for (i = ' ' + 1; i < MAX_GLYPHS; i++)
{ {
if (out[i] != 0xffff) if (out[i] != 0xffff)
{ {
@ -312,18 +312,11 @@ OnClick(PMAP infoPtr,
WORD ptx, WORD ptx,
WORD pty) WORD pty)
{ {
POINT pt;
INT x, y; INT x, y;
pt.x = ptx; x = ptx / max(1, infoPtr->CellSize.cx);
pt.y = pty; y = pty / max(1, infoPtr->CellSize.cy);
for (x = 0; x < XCELLS; x++)
for (y = 0; y < YCELLS; y++)
{
if (PtInRect(&infoPtr->Cells[y][x].CellInt,
pt))
{
/* if the cell is not already active */ /* if the cell is not already active */
if (!infoPtr->Cells[y][x].bActive) if (!infoPtr->Cells[y][x].bActive)
{ {
@ -352,25 +345,6 @@ OnClick(PMAP infoPtr,
else else
CreateLargeCell(infoPtr); CreateLargeCell(infoPtr);
} }
else
{
/* flick between large and small */
if (infoPtr->pActiveCell->bLarge)
{
DestroyWindow(infoPtr->hLrgWnd);
infoPtr->hLrgWnd = NULL;
}
else
{
CreateLargeCell(infoPtr);
}
infoPtr->pActiveCell->bLarge = (infoPtr->pActiveCell->bLarge) ? FALSE : TRUE;
}
break;
}
}
} }
@ -577,12 +551,30 @@ MapWndProc(HWND hwnd,
break; break;
} }
case WM_MOUSEMOVE:
{
if (wParam & MK_LBUTTON)
{
OnClick(infoPtr,
LOWORD(lParam),
HIWORD(lParam));
}
break;
}
case WM_LBUTTONDBLCLK: case WM_LBUTTONDBLCLK:
{ {
NotifyParentOfSelection(infoPtr, NotifyParentOfSelection(infoPtr,
FM_SETCHAR, FM_SETCHAR,
infoPtr->pActiveCell->ch); infoPtr->pActiveCell->ch);
if (infoPtr->pActiveCell->bLarge)
{
DestroyWindow(infoPtr->hLrgWnd);
infoPtr->hLrgWnd = NULL;
}
infoPtr->pActiveCell->bLarge = FALSE;
break; break;
} }