diff --git a/3rdparty/ocornut-imgui/imgui.cpp b/3rdparty/ocornut-imgui/imgui.cpp index 54d015f81..54dc79972 100644 --- a/3rdparty/ocornut-imgui/imgui.cpp +++ b/3rdparty/ocornut-imgui/imgui.cpp @@ -3131,7 +3131,7 @@ static void ClosePopup(ImGuiID id) if (!IsPopupOpen(id)) return; ImGuiState& g = *GImGui; - ClosePopupToLevel(g.OpenedPopupStack.size() - 1); + ClosePopupToLevel( int(g.OpenedPopupStack.size() - 1) ); } // Close the popup we have begin-ed into. diff --git a/examples/common/imgui/ocornut_imgui.cpp b/examples/common/imgui/ocornut_imgui.cpp index 99bd0da73..7fe96f225 100644 --- a/examples/common/imgui/ocornut_imgui.cpp +++ b/examples/common/imgui/ocornut_imgui.cpp @@ -41,7 +41,7 @@ struct OcornutImguiContext const ImDrawList* cmd_list = _lists[ii]; const ImDrawVert* vtx_buffer = cmd_list->vtx_buffer.begin(); - uint32_t vtx_size = (uint32_t)cmd_list->vtx_buffer.size(); + uint32_t vtx_size = (uint32_t)cmd_list->vtx_buffer.size(); if (!bgfx::checkAvailTransientVertexBuffer(vtx_size, m_decl)) { @@ -55,16 +55,16 @@ struct OcornutImguiContext memcpy(verts, vtx_buffer, vtx_size * sizeof(ImDrawVert)); uint32_t vtx_offset = 0; - const ImDrawCmd* pcmd_begin = cmd_list->commands.begin(); - const ImDrawCmd* pcmd_end = cmd_list->commands.end(); + const ImDrawCmd* pcmd_begin = cmd_list->commands.begin(); + const ImDrawCmd* pcmd_end = cmd_list->commands.end(); for (const ImDrawCmd* pcmd = pcmd_begin; pcmd != pcmd_end; pcmd++) { - if (pcmd->user_callback) - { - pcmd->user_callback(cmd_list, pcmd); - vtx_offset += pcmd->vtx_count; - continue; - } + if (pcmd->user_callback) + { + pcmd->user_callback(cmd_list, pcmd); + vtx_offset += pcmd->vtx_count; + continue; + } if (0 == pcmd->vtx_count) { continue; @@ -77,11 +77,11 @@ struct OcornutImguiContext | BGFX_STATE_MSAA ); bgfx::setScissor(uint16_t(bx::fmax(pcmd->clip_rect.x, 0.0f)) - , uint16_t(bx::fmax(pcmd->clip_rect.y, 0.0f)) - , uint16_t(bx::fmin(pcmd->clip_rect.z, 65535.0f)-bx::fmax(pcmd->clip_rect.x, 0.0f)) - , uint16_t(bx::fmin(pcmd->clip_rect.w, 65535.0f)-bx::fmax(pcmd->clip_rect.y, 0.0f)) - ); - union { void* ptr; bgfx::TextureHandle handle; } texture = { pcmd->texture_id }; + , uint16_t(bx::fmax(pcmd->clip_rect.y, 0.0f)) + , uint16_t(bx::fmin(pcmd->clip_rect.z, 65535.0f)-bx::fmax(pcmd->clip_rect.x, 0.0f)) + , uint16_t(bx::fmin(pcmd->clip_rect.w, 65535.0f)-bx::fmax(pcmd->clip_rect.y, 0.0f)) + ); + union { void* ptr; bgfx::TextureHandle handle; } texture ={ pcmd->texture_id }; bgfx::setTexture(0, s_tex, 0 != texture.handle.idx ? texture.handle @@ -101,7 +101,7 @@ struct OcornutImguiContext { m_viewId = 255; m_allocator = _allocator; - m_lastScroll = 0; + m_lastScroll = 0; ImGuiIO& io = ImGui::GetIO(); io.RenderDrawListsFn = renderDrawLists; @@ -179,7 +179,7 @@ struct OcornutImguiContext io.Fonts->GetTexDataAsRGBA32(&data, &width, &height); - m_texture = bgfx::createTexture2D( (uint16_t)width + m_texture = bgfx::createTexture2D((uint16_t)width , (uint16_t)height , 1 , bgfx::TextureFormat::BGRA8 @@ -206,9 +206,9 @@ struct OcornutImguiContext { m_viewId = _viewId; ImGuiIO& io = ImGui::GetIO(); - if (_inputChar < 0x7f) + if (_inputChar < 0x7f) { - io.AddInputCharacter(_inputChar); // ASCII or GTFO! :( + io.AddInputCharacter(_inputChar); // ASCII or GTFO! :( } io.DisplaySize = ImVec2((float)_width, (float)_height); @@ -246,7 +246,7 @@ struct OcornutImguiContext bgfx::TextureHandle m_texture; bgfx::UniformHandle s_tex; uint8_t m_viewId; - int32_t m_lastScroll; + int32_t m_lastScroll; }; static OcornutImguiContext s_ctx; diff --git a/examples/common/imgui/scintilla.cpp b/examples/common/imgui/scintilla.cpp index 3e39ab82e..a19962a0a 100644 --- a/examples/common/imgui/scintilla.cpp +++ b/examples/common/imgui/scintilla.cpp @@ -80,8 +80,8 @@ static inline uint32_t makeRgba(uint32_t r, uint32_t g, uint32_t b, uint32_t a = struct FontInt { - ImFont* m_font; - float m_scale; + ImFont* m_font; + float m_scale; float m_fontSize; }; @@ -236,7 +236,7 @@ public: virtual Scintilla::XYPOSITION WidthChar(Scintilla::Font& _font, char ch) BX_OVERRIDE { FontInt* fi = (FontInt*)_font.GetID(); - return fi->m_font->GetCharAdvance((unsigned int)ch) * fi->m_scale; + return fi->m_font->GetCharAdvance((unsigned int)ch) * fi->m_scale; } virtual Scintilla::XYPOSITION Ascent(Scintilla::Font& _font) BX_OVERRIDE @@ -251,14 +251,14 @@ public: return -fi->m_font->Descent * fi->m_scale; } - virtual Scintilla::XYPOSITION InternalLeading(Scintilla::Font& /*_font*/) BX_OVERRIDE + virtual Scintilla::XYPOSITION InternalLeading(Scintilla::Font& /*_font*/) BX_OVERRIDE { return 0; } virtual Scintilla::XYPOSITION ExternalLeading(Scintilla::Font& /*_font*/) BX_OVERRIDE { - return 0; + return 0; } virtual Scintilla::XYPOSITION Height(Scintilla::Font& _font) BX_OVERRIDE @@ -633,7 +633,7 @@ public: return 0; } - intptr_t command(unsigned int _msg, uintptr_t _p0 = 0, intptr_t _p1 = 0) + intptr_t command(unsigned int _msg, uintptr_t _p0 = 0, intptr_t _p1 = 0) { return WndProc(_msg, _p0, _p1); } @@ -854,7 +854,7 @@ namespace Scintilla } void Font::Create(const FontParameters& fp) - { + { FontInt* newFont = (FontInt*)ImGui::MemAlloc(sizeof(FontInt) ); fid = newFont; newFont->m_font = ImGui::GetIO().Fonts->Fonts[0]; @@ -1063,4 +1063,28 @@ namespace Scintilla } // namespace Scintilla +ScintillaEditor* ImGuiScintilla(const char* _name, bool* _opened, const ImVec2& _size) +{ + ScintillaEditor* sci = NULL; + + if (ImGui::Begin(_name, _opened, _size) ) + { + ImGuiStorage* storage = ImGui::GetStateStorage(); + + ImGuiID id = ImGui::GetID(_name); + sci = (ScintillaEditor*)storage->GetVoidPtr(id); + if (NULL == sci) + { + ImVec2 size = ImGui::GetWindowSize(); + sci = ScintillaEditor::create(size.x, size.y); + storage->SetVoidPtr(id, (void*)sci); + } + + sci->draw(); + } + + ImGui::End(); + return sci; +} + #endif // defined(SCI_NAMESPACE) diff --git a/examples/common/imgui/scintilla.h b/examples/common/imgui/scintilla.h index 50d3c07c1..d57362e94 100644 --- a/examples/common/imgui/scintilla.h +++ b/examples/common/imgui/scintilla.h @@ -15,10 +15,12 @@ struct ScintillaEditor static ScintillaEditor* create(int _width, int _height); static void destroy(ScintillaEditor* _scintilla); - intptr_t command(unsigned int _message, uintptr_t _p0 = 0, intptr_t _p1 = 0); + intptr_t command(unsigned int _message, uintptr_t _p0 = 0, intptr_t _p1 = 0); void draw(); }; +ScintillaEditor* ImGuiScintilla(const char* _name, bool* _opened, const ImVec2& _size); + #endif // defined(SCI_NAMESPACE) #endif // SCINTILLA_H_HEADER_GUARD