Fix #20631: IME window not positioned correctly

This commit is contained in:
wstagg 2024-01-30 22:44:58 +00:00 committed by GitHub
parent ceafb68481
commit 4a51e7f362
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 6 additions and 16 deletions

View File

@ -12,6 +12,7 @@
- Fix: [#20255] Images from the last hovered-over coaster in the object selection are not freed.
- Fix: [#20616] Confirmation button in the track designers quit prompt has the wrong text.
- Fix: [#20628] Moving caret using Ctrl+left can move too far when using a multibyte grapheme.
- Fix: [#20631] IME window not positioned correctly.
- Fix: [#20845] Trying to save under a folder with no write permissions causes a crash.
- Fix: [#21054] “No entrance” style is selected by default in the track designer.
- Fix: [#21145] [Plugin] setInterval/setTimeout handle conflict.

View File

@ -38,11 +38,7 @@ bool TextComposition::IsActive()
TextInputSession* TextComposition::Start(u8string& buffer, size_t maxLength)
{
// TODO This doesn't work, and position could be improved to where text entry is
SDL_Rect rect = { 10, 10, 100, 100 };
SDL_SetTextInputRect(&rect);
SDL_StartTextInput();
_session.Buffer = &buffer;
_session.MaxLength = maxLength;
_session.SelectionStart = buffer.size();

View File

@ -7,6 +7,7 @@
* OpenRCT2 is licensed under the GNU General Public License version 3.
*****************************************************************************/
#include <SDL.h>
#include <SDL_keycode.h>
#include <algorithm>
#include <iterator>
@ -291,7 +292,7 @@ public:
// IME composition
if (!String::IsNullOrEmpty(gTextInput->ImeBuffer))
{
DrawIMEComposition(dpi, cursorX, cursorY);
IMEComposition(cursorX, cursorY);
}
}
@ -316,18 +317,10 @@ public:
}
private:
static void DrawIMEComposition(DrawPixelInfo& dpi, int32_t cursorX, int32_t cursorY)
static void IMEComposition(int32_t cursorX, int32_t cursorY)
{
int compositionWidth = GfxGetStringWidth(gTextInput->ImeBuffer, FontStyle::Medium);
ScreenCoordsXY screenCoords(cursorX - (compositionWidth / 2), cursorY + 13);
int width = compositionWidth;
int height = 10;
GfxFillRect(
dpi, { screenCoords - ScreenCoordsXY{ 1, 1 }, screenCoords + ScreenCoordsXY{ width + 1, height + 1 } },
PALETTE_INDEX_12);
GfxFillRect(dpi, { screenCoords, screenCoords + ScreenCoordsXY{ width, height } }, PALETTE_INDEX_0);
GfxDrawString(dpi, screenCoords, static_cast<const char*>(gTextInput->ImeBuffer), { COLOUR_DARK_GREEN });
SDL_Rect rect = { cursorX, cursorY, 100, 100 };
SDL_SetTextInputRect(&rect);
}
void ExecuteCallback(bool hasValue)