Merge pull request #1756 from cloudwu/unicodeimgui

unicode inputChar support for imguiBeginFrame
This commit is contained in:
Бранимир Караџић 2019-05-06 08:40:52 -07:00 committed by GitHub
commit 3266469823
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 3 deletions

View File

@ -9,6 +9,7 @@
#include <bx/math.h>
#include <bx/timer.h>
#include <dear-imgui/imgui.h>
#include <dear-imgui/imgui_internal.h>
#include "imgui.h"
#include "../bgfx_utils.h"
@ -340,7 +341,7 @@ struct OcornutImguiContext
, int32_t _scroll
, int _width
, int _height
, char _inputChar
, int _inputChar
, bgfx::ViewId _viewId
)
{
@ -350,6 +351,12 @@ struct OcornutImguiContext
if (_inputChar < 0x7f)
{
io.AddInputCharacter(_inputChar); // ASCII or GTFO! :(
} else
{
char tmpstr[6];
ImWchar unicode[2] = { (ImWchar)_inputChar, 0 };
ImTextStrToUtf8(tmpstr, sizeof(tmpstr), unicode, unicode+1);
io.AddInputCharactersUTF8(tmpstr);
}
io.DisplaySize = ImVec2( (float)_width, (float)_height);
@ -427,7 +434,7 @@ void imguiDestroy()
s_ctx.destroy();
}
void imguiBeginFrame(int32_t _mx, int32_t _my, uint8_t _button, int32_t _scroll, uint16_t _width, uint16_t _height, char _inputChar, bgfx::ViewId _viewId)
void imguiBeginFrame(int32_t _mx, int32_t _my, uint8_t _button, int32_t _scroll, uint16_t _width, uint16_t _height, int _inputChar, bgfx::ViewId _viewId)
{
s_ctx.beginFrame(_mx, _my, _button, _scroll, _width, _height, _inputChar, _viewId);
}

View File

@ -30,7 +30,7 @@ namespace bx { struct AllocatorI; }
void imguiCreate(float _fontSize = 18.0f, bx::AllocatorI* _allocator = NULL);
void imguiDestroy();
void imguiBeginFrame(int32_t _mx, int32_t _my, uint8_t _button, int32_t _scroll, uint16_t _width, uint16_t _height, char _inputChar = 0, bgfx::ViewId _view = 255);
void imguiBeginFrame(int32_t _mx, int32_t _my, uint8_t _button, int32_t _scroll, uint16_t _width, uint16_t _height, int _inputChar = 0, bgfx::ViewId _view = 255);
void imguiEndFrame();
namespace entry { class AppI; }