diff --git a/examples/allegro5_example/imgui_impl_a5.cpp b/examples/allegro5_example/imgui_impl_a5.cpp index b5dd7439..8faa332c 100644 --- a/examples/allegro5_example/imgui_impl_a5.cpp +++ b/examples/allegro5_example/imgui_impl_a5.cpp @@ -1,4 +1,7 @@ // ImGui Allegro 5 bindings +// You can copy and use unmodified imgui_impl_* files in your project. +// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown(). +// See main.cpp for an example of using this. // https://github.com/ocornut/imgui // by @birthggd diff --git a/examples/allegro5_example/imgui_impl_a5.h b/examples/allegro5_example/imgui_impl_a5.h index a6cda1c0..ec10fff1 100644 --- a/examples/allegro5_example/imgui_impl_a5.h +++ b/examples/allegro5_example/imgui_impl_a5.h @@ -1,4 +1,7 @@ // ImGui Allegro 5 bindings +// You can copy and use unmodified imgui_impl_* files in your project. +// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown(). +// See main.cpp for an example of using this. // https://github.com/ocornut/imgui // by @birthggd diff --git a/examples/directx11_example/imgui_impl_dx11.cpp b/examples/directx11_example/imgui_impl_dx11.cpp index 41684b33..6e7f1944 100644 --- a/examples/directx11_example/imgui_impl_dx11.cpp +++ b/examples/directx11_example/imgui_impl_dx11.cpp @@ -1,4 +1,7 @@ // ImGui Win32 + DirectX11 binding +// You can copy and use unmodified imgui_impl_* files in your project. +// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown(). +// See main.cpp for an example of using this. // https://github.com/ocornut/imgui #include @@ -328,9 +331,9 @@ bool ImGui_ImplDX11_CreateDeviceObjects() // Create the input layout D3D11_INPUT_ELEMENT_DESC localLayout[] = { - { "POSITION", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, (size_t)(&((ImDrawVert*)0)->pos), D3D11_INPUT_PER_VERTEX_DATA, 0 }, - { "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, (size_t)(&((ImDrawVert*)0)->uv), D3D11_INPUT_PER_VERTEX_DATA, 0 }, - { "COLOR", 0, DXGI_FORMAT_R8G8B8A8_UNORM, 0, (size_t)(&((ImDrawVert*)0)->col), D3D11_INPUT_PER_VERTEX_DATA, 0 }, + { "POSITION", 0, DXGI_FORMAT_R32G32_FLOAT, 0, (size_t)(&((ImDrawVert*)0)->pos), D3D11_INPUT_PER_VERTEX_DATA, 0 }, + { "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, (size_t)(&((ImDrawVert*)0)->uv), D3D11_INPUT_PER_VERTEX_DATA, 0 }, + { "COLOR", 0, DXGI_FORMAT_R8G8B8A8_UNORM, 0, (size_t)(&((ImDrawVert*)0)->col), D3D11_INPUT_PER_VERTEX_DATA, 0 }, }; if (g_pd3dDevice->CreateInputLayout(localLayout, 3, g_pVertexShaderBlob->GetBufferPointer(), g_pVertexShaderBlob->GetBufferSize(), &g_pInputLayout) != S_OK) diff --git a/examples/directx11_example/imgui_impl_dx11.h b/examples/directx11_example/imgui_impl_dx11.h index a36bfd68..e5d44600 100644 --- a/examples/directx11_example/imgui_impl_dx11.h +++ b/examples/directx11_example/imgui_impl_dx11.h @@ -1,4 +1,7 @@ // ImGui Win32 + DirectX11 binding +// You can copy and use unmodified imgui_impl_* files in your project. +// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown(). +// See main.cpp for an example of using this. // https://github.com/ocornut/imgui struct ID3D11Device; diff --git a/examples/directx9_example/imgui_impl_dx9.cpp b/examples/directx9_example/imgui_impl_dx9.cpp index b8186329..1e7c7900 100644 --- a/examples/directx9_example/imgui_impl_dx9.cpp +++ b/examples/directx9_example/imgui_impl_dx9.cpp @@ -1,4 +1,7 @@ // ImGui Win32 + DirectX9 binding +// You can copy and use unmodified imgui_impl_* files in your project. +// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown(). +// See main.cpp for an example of using this. // https://github.com/ocornut/imgui #include diff --git a/examples/directx9_example/imgui_impl_dx9.h b/examples/directx9_example/imgui_impl_dx9.h index 99075e53..608626fb 100644 --- a/examples/directx9_example/imgui_impl_dx9.h +++ b/examples/directx9_example/imgui_impl_dx9.h @@ -1,4 +1,7 @@ // ImGui Win32 + DirectX9 binding +// You can copy and use unmodified imgui_impl_* files in your project. +// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown(). +// See main.cpp for an example of using this. // https://github.com/ocornut/imgui struct IDirect3DDevice9; diff --git a/examples/ios_example/README.md b/examples/ios_example/README.md index 5b51b905..a2ada955 100644 --- a/examples/ios_example/README.md +++ b/examples/ios_example/README.md @@ -1,14 +1,14 @@ # iOS example ----- ## Introduction This example is the default XCode "OpenGL" example code, modified to support ImGui and [Synergy](http://synergy-project.org/). +It is a rather complex example because of all of the faff required to get an XCode/iOS application running. Refer to the regular OpenGL examples if you want to learn about integrating ImGui. + Synergy (remote keyboard/mouse) is not required, but it's pretty hard to use ImGui without it. Synergy includes a "uSynergy" library that allows embedding a synergy client, this is what is used here. ImGui supports "TouchPadding", and this is enabled when Synergy is not active. ## How to Use ----- 0. In Synergy, go to Preferences, and uncheck "Use SSL encryption" 0. Run the example app. @@ -16,7 +16,6 @@ Synergy (remote keyboard/mouse) is not required, but it's pretty hard to use ImG 0. Enter the name or the IP of your synergy host 0. If you had previously connected to a server, you may need to kill and re-start the app. ----- ## Notes and TODOs Things that would be nice but I didn't get around to doing: @@ -26,7 +25,6 @@ Things that would be nice but I didn't get around to doing: * Graceful disconnect/reconnect from uSynergy. * Copy/Paste not well-supported ----- ## C++ on iOS ImGui is a c++ library. If you want to include it directly, rename your Obj-C file to have the ".mm" extension. diff --git a/examples/marmalade_example/data/app.icf b/examples/marmalade_example/data/app.icf index a2783aea..fcd6585a 100644 --- a/examples/marmalade_example/data/app.icf +++ b/examples/marmalade_example/data/app.icf @@ -20,6 +20,8 @@ MemSize=6000000 MemSizeDebug=6000000 DispFixRot=FixedLandscape + +# emulate iphone 5 resolution, change these settings to emulate other display resolution WinWidth=1136 WinHeight=640 diff --git a/examples/marmalade_example/imgui_impl_marmalade.cpp b/examples/marmalade_example/imgui_impl_marmalade.cpp index 480ec01b..aaf08e3b 100644 --- a/examples/marmalade_example/imgui_impl_marmalade.cpp +++ b/examples/marmalade_example/imgui_impl_marmalade.cpp @@ -17,151 +17,160 @@ static double g_Time = 0.0f; static bool g_MousePressed[3] = { false, false, false }; static float g_MouseWheel = 0.0f; static CIwTexture* g_FontTexture = 0; -static int g_KeyboardGetCharAvailable = 0 ; +static char* g_ClipboardText = 0 ; +static bool g_osdKeyboardEnabled = false ; + +// use this setting to scale the interface - e.g. on device you could use 2 or 3 scale factor +static ImVec2 g_scale = ImVec2(1.0f,1.0f) ; // This is the main rendering function that you have to implement and provide to ImGui (via setting up 'RenderDrawListsFn' in the ImGuiIO structure) void ImGui_Marmalade_RenderDrawLists(ImDrawData* draw_data) { - // Handle cases of screen coordinates != from framebuffer coordinates (e.g. retina displays) - ImGuiIO& io = ImGui::GetIO(); - float fb_height = io.DisplaySize.y * io.DisplayFramebufferScale.y; - draw_data->ScaleClipRects(io.DisplayFramebufferScale); + // Handle cases of screen coordinates != from framebuffer coordinates (e.g. retina displays) + ImGuiIO& io = ImGui::GetIO(); + draw_data->ScaleClipRects(io.DisplayFramebufferScale); - // Render command lists - for(int n = 0; n < draw_data->CmdListsCount; n++) - { - const ImDrawList* cmd_list = draw_data->CmdLists[n]; - const unsigned char* vtx_buffer = (const unsigned char*)&cmd_list->VtxBuffer.front(); - const ImDrawIdx* idx_buffer = &cmd_list->IdxBuffer.front(); - int nVert = cmd_list->VtxBuffer.size() ; - CIwFVec2* pVertStream = IW_GX_ALLOC(CIwFVec2,nVert) ; - CIwFVec2* pUVStream = IW_GX_ALLOC(CIwFVec2,nVert) ; - CIwColour* pColStream = IW_GX_ALLOC(CIwColour,nVert) ; + // Render command lists + for(int n = 0; n < draw_data->CmdListsCount; n++) + { + const ImDrawList* cmd_list = draw_data->CmdLists[n]; + const unsigned char* vtx_buffer = (const unsigned char*)&cmd_list->VtxBuffer.front(); + const ImDrawIdx* idx_buffer = &cmd_list->IdxBuffer.front(); + int nVert = cmd_list->VtxBuffer.size() ; + CIwFVec2* pVertStream = IW_GX_ALLOC(CIwFVec2,nVert) ; + CIwFVec2* pUVStream = IW_GX_ALLOC(CIwFVec2,nVert) ; + CIwColour* pColStream = IW_GX_ALLOC(CIwColour,nVert) ; - for( int i=0; i < nVert; i++ ) { - pVertStream[i].x = cmd_list->VtxBuffer[i].pos.x ; - pVertStream[i].y = cmd_list->VtxBuffer[i].pos.y ; - pUVStream[i].x = cmd_list->VtxBuffer[i].uv.x ; - pUVStream[i].y = cmd_list->VtxBuffer[i].uv.y ; - pColStream[i] = cmd_list->VtxBuffer[i].col ; - } + for( int i=0; i < nVert; i++ ) { + // todo - optimize multiplication on gpu using vertex shader + pVertStream[i].x = cmd_list->VtxBuffer[i].pos.x * g_scale.x ; + pVertStream[i].y = cmd_list->VtxBuffer[i].pos.y * g_scale.y ; + pUVStream[i].x = cmd_list->VtxBuffer[i].uv.x ; + pUVStream[i].y = cmd_list->VtxBuffer[i].uv.y ; + pColStream[i] = cmd_list->VtxBuffer[i].col ; + } - IwGxSetVertStreamScreenSpace(pVertStream,nVert) ; - IwGxSetUVStream(pUVStream) ; - IwGxSetColStream(pColStream,nVert) ; - IwGxSetNormStream(0) ; + IwGxSetVertStreamScreenSpace(pVertStream,nVert) ; + IwGxSetUVStream(pUVStream) ; + IwGxSetColStream(pColStream,nVert) ; + IwGxSetNormStream(0) ; - for(int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.size(); cmd_i++) - { - const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i]; - if(pcmd->UserCallback) - { - pcmd->UserCallback(cmd_list,pcmd); - } - else - { - CIwMaterial* pCurrentMaterial = IW_GX_ALLOC_MATERIAL() ; - pCurrentMaterial->SetShadeMode(CIwMaterial::SHADE_FLAT) ; - pCurrentMaterial->SetCullMode(CIwMaterial::CULL_NONE) ; - pCurrentMaterial->SetFiltering(false) ; - pCurrentMaterial->SetAlphaMode(CIwMaterial::ALPHA_BLEND) ; - pCurrentMaterial->SetDepthWriteMode(CIwMaterial::DEPTH_WRITE_NORMAL); - pCurrentMaterial->SetAlphaTestMode(CIwMaterial::ALPHATEST_DISABLED); - pCurrentMaterial->SetTexture((CIwTexture*)pcmd->TextureId) ; - IwGxSetMaterial(pCurrentMaterial) ; + for(int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.size(); cmd_i++) + { + const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i]; + if(pcmd->UserCallback) + { + pcmd->UserCallback(cmd_list,pcmd); + } + else + { + CIwMaterial* pCurrentMaterial = IW_GX_ALLOC_MATERIAL() ; + pCurrentMaterial->SetShadeMode(CIwMaterial::SHADE_FLAT) ; + pCurrentMaterial->SetCullMode(CIwMaterial::CULL_NONE) ; + pCurrentMaterial->SetFiltering(false) ; + pCurrentMaterial->SetAlphaMode(CIwMaterial::ALPHA_BLEND) ; + pCurrentMaterial->SetDepthWriteMode(CIwMaterial::DEPTH_WRITE_NORMAL); + pCurrentMaterial->SetAlphaTestMode(CIwMaterial::ALPHATEST_DISABLED); + pCurrentMaterial->SetTexture((CIwTexture*)pcmd->TextureId) ; + IwGxSetMaterial(pCurrentMaterial) ; - IwGxDrawPrims(IW_GX_TRI_LIST,(uint16*)idx_buffer,pcmd->ElemCount) ; - } - idx_buffer += pcmd->ElemCount; - } - IwGxFlush() ; - } + IwGxDrawPrims(IW_GX_TRI_LIST,(uint16*)idx_buffer,pcmd->ElemCount) ; + } + idx_buffer += pcmd->ElemCount; + } + IwGxFlush() ; + } - // TODO restore modified state (i.e. mvp matrix) + // TODO restore modified state (i.e. mvp matrix) } static const char* ImGui_Marmalade_GetClipboardText() { - static char clipBuf[512] ; - if(s3eClipboardAvailable()) { - s3eClipboardGetText( clipBuf, 512 ); - } - else { - clipBuf[0] = '\0' ; - } + if(s3eClipboardAvailable()) { + int size = s3eClipboardGetText( NULL, 0 ); + if( size > 0 ) { + if(g_ClipboardText) { + delete[] g_ClipboardText ; + g_ClipboardText = 0 ; + } + g_ClipboardText = new char[size] ; + g_ClipboardText[0] = '\0' ; + s3eClipboardGetText(g_ClipboardText,size) ; + } + } - return clipBuf ; + return g_ClipboardText ; } static void ImGui_Marmalade_SetClipboardText(const char* text) { - if( s3eClipboardAvailable() ) { - s3eClipboardSetText(text); - } + if( s3eClipboardAvailable() ) { + s3eClipboardSetText(text); + } } int32 ImGui_Marmalade_PointerButtonEventCallback(void* SystemData,void* pUserData) { - // pEvent->m_Button is of type s3ePointerButton and indicates which mouse - // button was pressed. For touchscreens this should always have the value - // S3E_POINTER_BUTTON_SELECT - s3ePointerEvent* pEvent = (s3ePointerEvent*)SystemData ; + // pEvent->m_Button is of type s3ePointerButton and indicates which mouse + // button was pressed. For touchscreens this should always have the value + // S3E_POINTER_BUTTON_SELECT + s3ePointerEvent* pEvent = (s3ePointerEvent*)SystemData ; - if(pEvent->m_Pressed==1) { - if(pEvent->m_Button == S3E_POINTER_BUTTON_LEFTMOUSE) { - g_MousePressed[0] = true; - } - if(pEvent->m_Button == S3E_POINTER_BUTTON_RIGHTMOUSE) { - g_MousePressed[1] = true; - } - if(pEvent->m_Button == S3E_POINTER_BUTTON_MIDDLEMOUSE) { - g_MousePressed[2] = true; - } - if(pEvent->m_Button == S3E_POINTER_BUTTON_MOUSEWHEELUP) { - g_MouseWheel += pEvent->m_y ; - } - if(pEvent->m_Button == S3E_POINTER_BUTTON_MOUSEWHEELDOWN) { - g_MouseWheel += pEvent->m_y ; - } - } + if(pEvent->m_Pressed==1) { + if(pEvent->m_Button == S3E_POINTER_BUTTON_LEFTMOUSE) { + g_MousePressed[0] = true; + } + if(pEvent->m_Button == S3E_POINTER_BUTTON_RIGHTMOUSE) { + g_MousePressed[1] = true; + } + if(pEvent->m_Button == S3E_POINTER_BUTTON_MIDDLEMOUSE) { + g_MousePressed[2] = true; + } + if(pEvent->m_Button == S3E_POINTER_BUTTON_MOUSEWHEELUP) { + g_MouseWheel += pEvent->m_y ; + } + if(pEvent->m_Button == S3E_POINTER_BUTTON_MOUSEWHEELDOWN) { + g_MouseWheel += pEvent->m_y ; + } + } - return 0; + return 0; } -//void ImGui_Marmalade_ScrollCallback(GLFWwindow*,double /*xoffset*/,double yoffset) +//void ImGui_Marmalade_ScrollCallback(double /*xoffset*/,double yoffset) //{ -// g_MouseWheel += (float)yoffset; // Use fractional mouse wheel, 1.0 unit 5 lines. +// g_MouseWheel += (float)yoffset; // Use fractional mouse wheel, 1.0 unit 5 lines. //} int32 ImGui_Marmalade_KeyCallback(void* SystemData, void* userData) { - ImGuiIO& io = ImGui::GetIO(); - s3eKeyboardEvent* e = (s3eKeyboardEvent*)SystemData ; - if( e->m_Pressed == 1 ) { - io.KeysDown[e->m_Key] = true; - } - if(e->m_Pressed == 0) { - io.KeysDown[e->m_Key] = false; - } - - io.KeyCtrl = s3eKeyboardGetState(s3eKeyLeftControl) == S3E_KEY_STATE_DOWN || s3eKeyboardGetState(s3eKeyRightControl) == S3E_KEY_STATE_DOWN ; - io.KeyShift = s3eKeyboardGetState(s3eKeyLeftShift) == S3E_KEY_STATE_DOWN || s3eKeyboardGetState(s3eKeyRightShift) == S3E_KEY_STATE_DOWN ; - io.KeyAlt = s3eKeyboardGetState(s3eKeyLeftAlt) == S3E_KEY_STATE_DOWN || s3eKeyboardGetState(s3eKeyRightAlt) == S3E_KEY_STATE_DOWN ; + ImGuiIO& io = ImGui::GetIO(); + s3eKeyboardEvent* e = (s3eKeyboardEvent*)SystemData ; + if( e->m_Pressed == 1 ) { + io.KeysDown[e->m_Key] = true; + } + if(e->m_Pressed == 0) { + io.KeysDown[e->m_Key] = false; + } + + io.KeyCtrl = s3eKeyboardGetState(s3eKeyLeftControl) == S3E_KEY_STATE_DOWN || s3eKeyboardGetState(s3eKeyRightControl) == S3E_KEY_STATE_DOWN ; + io.KeyShift = s3eKeyboardGetState(s3eKeyLeftShift) == S3E_KEY_STATE_DOWN || s3eKeyboardGetState(s3eKeyRightShift) == S3E_KEY_STATE_DOWN ; + io.KeyAlt = s3eKeyboardGetState(s3eKeyLeftAlt) == S3E_KEY_STATE_DOWN || s3eKeyboardGetState(s3eKeyRightAlt) == S3E_KEY_STATE_DOWN ; - return 0 ; + return 0 ; } int32 ImGui_Marmalade_CharCallback(void* SystemData,void* userData) { - ImGuiIO& io = ImGui::GetIO(); + ImGuiIO& io = ImGui::GetIO(); - s3eKeyboardCharEvent* e = (s3eKeyboardCharEvent*)SystemData ; - if( (e->m_Char > 0 && e->m_Char < 0x10000) && io.WantTextInput ) { - io.AddInputCharacter((unsigned short)e->m_Char); - } + s3eKeyboardCharEvent* e = (s3eKeyboardCharEvent*)SystemData ; + if( (e->m_Char > 0 && e->m_Char < 0x10000) ) { + io.AddInputCharacter((unsigned short)e->m_Char); + } - return 0 ; + return 0 ; } bool ImGui_Marmalade_CreateDeviceObjects() @@ -174,17 +183,17 @@ bool ImGui_Marmalade_CreateDeviceObjects() io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height); // Create texture - g_FontTexture = new CIwTexture() ; - g_FontTexture->SetModifiable(true) ; - CIwImage& image = g_FontTexture->GetImage() ; - image.SetFormat(CIwImage::Format::ARGB_8888) ; - image.SetWidth(width) ; - image.SetHeight(height) ; - image.SetBuffers(); // allocates and own buffers - image.ReadTexels(pixels) ; - g_FontTexture->SetMipMapping(false) ; - g_FontTexture->SetFiltering(false) ; - g_FontTexture->Upload() ; + g_FontTexture = new CIwTexture() ; + g_FontTexture->SetModifiable(true) ; + CIwImage& image = g_FontTexture->GetImage() ; + image.SetFormat(CIwImage::ARGB_8888) ; + image.SetWidth(width) ; + image.SetHeight(height) ; + image.SetBuffers(); // allocates and own buffers + image.ReadTexels(pixels) ; + g_FontTexture->SetMipMapping(false) ; + g_FontTexture->SetFiltering(false) ; + g_FontTexture->Upload() ; // Store the pointer io.Fonts->TexID = (void *)g_FontTexture; @@ -198,6 +207,11 @@ bool ImGui_Marmalade_CreateDeviceObjects() void ImGui_Marmalade_InvalidateDeviceObjects() { + if(g_ClipboardText) { + delete[] g_ClipboardText ; + g_ClipboardText = 0 ; + } + if (g_FontTexture) { delete g_FontTexture ; @@ -208,7 +222,7 @@ void ImGui_Marmalade_InvalidateDeviceObjects() bool ImGui_Marmalade_Init( bool install_callbacks) { - IwGxInit() ; + IwGxInit() ; ImGuiIO& io = ImGui::GetIO(); io.KeyMap[ImGuiKey_Tab] = s3eKeyTab; // Keyboard mapping. ImGui will use those indices to peek into the io.KeyDown[] array. @@ -237,16 +251,10 @@ bool ImGui_Marmalade_Init( bool install_callbacks) if (install_callbacks) { - s3ePointerRegister(S3E_POINTER_BUTTON_EVENT,ImGui_Marmalade_PointerButtonEventCallback,0) ; - s3eKeyboardRegister(S3E_KEYBOARD_KEY_EVENT,ImGui_Marmalade_KeyCallback,0) ; - - // enable KEYBOARD_GET_CHAR - s3eKeyboardSetInt(S3E_KEYBOARD_GET_CHAR,1) ; - g_KeyboardGetCharAvailable = s3eKeyboardGetInt(S3E_KEYBOARD_GET_CHAR) ; - if( g_KeyboardGetCharAvailable ) { - s3eKeyboardRegister(S3E_KEYBOARD_CHAR_EVENT,ImGui_Marmalade_CharCallback,0) ; - } - } + s3ePointerRegister(S3E_POINTER_BUTTON_EVENT,ImGui_Marmalade_PointerButtonEventCallback,0) ; + s3eKeyboardRegister(S3E_KEYBOARD_KEY_EVENT,ImGui_Marmalade_KeyCallback,0) ; + s3eKeyboardRegister(S3E_KEYBOARD_CHAR_EVENT,ImGui_Marmalade_CharCallback,0) ; + } return true; } @@ -255,43 +263,34 @@ void ImGui_Marmalade_Shutdown() { ImGui_Marmalade_InvalidateDeviceObjects(); ImGui::Shutdown(); - IwGxTerminate(); + IwGxTerminate(); } void ImGui_Marmalade_NewFrame() { - if (!g_FontTexture) + if (!g_FontTexture) { ImGui_Marmalade_CreateDeviceObjects(); + } ImGuiIO& io = ImGui::GetIO(); // Setup display size (every frame to accommodate for window resizing) int w = IwGxGetScreenWidth(), h = IwGxGetScreenHeight() ; io.DisplaySize = ImVec2((float)w, (float)h); - // For retina display or other situations where window coordinates are different from framebuffer coordinates. User storage only, presently not used by ImGui. - io.DisplayFramebufferScale = ImVec2((float)1.0f, (float)1.0f); + // For retina display or other situations where window coordinates are different from framebuffer coordinates. User storage only, presently not used by ImGui. + io.DisplayFramebufferScale = g_scale; // Setup time step double current_time = s3eTimerGetUST() / 1000.0f ; io.DeltaTime = g_Time > 0.0 ? (float)(current_time - g_Time) : (float)(1.0f/60.0f); g_Time = current_time; - // Setup inputs - // (we already got mouse wheel, keyboard keys & characters from glfw callbacks polled in glfwPollEvents()) - //if ( gui_has_focus() ) - //{ - double mouse_x, mouse_y; - mouse_x = s3ePointerGetX(); - mouse_y = s3ePointerGetY(); - io.MousePos = ImVec2((float)mouse_x, (float)mouse_y); // Mouse position in screen coordinates (set to -1,-1 if no mouse / on another screen, etc.) - //} - //else - //{ - // io.MousePos = ImVec2(-1,-1); - //} + double mouse_x, mouse_y; + mouse_x = s3ePointerGetX(); + mouse_y = s3ePointerGetY(); + io.MousePos = ImVec2((float)mouse_x/g_scale.x, (float)mouse_y/g_scale.y); // Mouse position in screen coordinates (set to -1,-1 if no mouse / on another screen, etc.) - for (int i = 0; i < 3; i++) - { + for (int i = 0; i < 3; i++) { io.MouseDown[i] = g_MousePressed[i] || s3ePointerGetState((s3ePointerButton)i) != S3E_POINTER_STATE_UP; // If a mouse press event came, always pass it as "mouse held this frame", so we don't miss click-release events that are shorter than 1 frame. g_MousePressed[i] = false; } @@ -300,8 +299,22 @@ void ImGui_Marmalade_NewFrame() g_MouseWheel = 0.0f; // Hide OS mouse cursor if ImGui is drawing it -// s3ePointerSetInt(S3E_POINTER_HIDE_CURSOR,(io.MouseDrawCursor ? 0 : 1)); +// s3ePointerSetInt(S3E_POINTER_HIDE_CURSOR,(io.MouseDrawCursor ? 0 : 1)); // Start the frame ImGui::NewFrame(); + + // show/hide OSD keyboard + if( io.WantTextInput ) { // some text input widget is active? + if( !g_osdKeyboardEnabled ) { + g_osdKeyboardEnabled = true ; + s3eKeyboardSetInt(S3E_KEYBOARD_GET_CHAR,1) ; // show OSD keyboard + } + } + else { // no text input widget is active + if(g_osdKeyboardEnabled) { + g_osdKeyboardEnabled = false ; + s3eKeyboardSetInt(S3E_KEYBOARD_GET_CHAR,0) ; // hide OSD keyboard + } + } } diff --git a/examples/marmalade_example/imgui_impl_marmalade.h b/examples/marmalade_example/imgui_impl_marmalade.h index 2d7397da..17c5e96e 100644 --- a/examples/marmalade_example/imgui_impl_marmalade.h +++ b/examples/marmalade_example/imgui_impl_marmalade.h @@ -13,7 +13,7 @@ IMGUI_API bool ImGui_Marmalade_CreateDeviceObjects(); // callbacks (installed by default if you enable 'install_callbacks' during initialization) // You can also handle inputs yourself and use those as a reference. -IMGUI_API int32 ImGui_Marmalade_PointerButtonEventCallback(void* SystemData,void* pUserData); +IMGUI_API int32 ImGui_Marmalade_PointerButtonEventCallback(void* SystemData,void* pUserData); //IMGUI_API void ImGui_Marmalade_ScrollCallback(GLFWwindow* window, double xoffset, double yoffset); -IMGUI_API int32 ImGui_Marmalade_KeyCallback(void* SystemData,void* userData); -IMGUI_API int32 ImGui_Marmalade_CharCallback(void* SystemData,void* userData); +IMGUI_API int32 ImGui_Marmalade_KeyCallback(void* SystemData,void* userData); +IMGUI_API int32 ImGui_Marmalade_CharCallback(void* SystemData,void* userData); diff --git a/examples/marmalade_example/marmalade_example.mkb b/examples/marmalade_example/marmalade_example.mkb index 8be810bd..75cb2538 100644 --- a/examples/marmalade_example/marmalade_example.mkb +++ b/examples/marmalade_example/marmalade_example.mkb @@ -8,36 +8,38 @@ define IMGUI_DISABLE_INCLUDE_IMCONFIG_H define IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCS define IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCS +define _snprintf=snprintf options { - optimise-speed=1 + optimise-speed=1 + cxx11 } includepaths { - ../.. + ../.. } subprojects { - iwgx + iwgx } files { - (.) - ["imgui"] - ../../imgui.cpp - ../../imgui_demo.cpp - ../../imgui_draw.cpp - ../../imconfig.h - ../../imgui.h + (.) + ["imgui"] + ../../imgui.cpp + ../../imgui_demo.cpp + ../../imgui_draw.cpp + ../../imconfig.h + ../../imgui.h ../../imgui_internal.h - ["imgui","Marmalade binding"] - imgui_impl_marmalade.h - imgui_impl_marmalade.cpp - main.cpp + ["imgui","Marmalade binding"] + imgui_impl_marmalade.h + imgui_impl_marmalade.cpp + main.cpp } diff --git a/examples/opengl3_example/imgui_impl_glfw_gl3.cpp b/examples/opengl3_example/imgui_impl_glfw_gl3.cpp index d111b76a..0b5b658b 100644 --- a/examples/opengl3_example/imgui_impl_glfw_gl3.cpp +++ b/examples/opengl3_example/imgui_impl_glfw_gl3.cpp @@ -1,4 +1,7 @@ // ImGui GLFW binding with OpenGL3 + shaders +// You can copy and use unmodified imgui_impl_* files in your project. +// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown(). +// See main.cpp for an example of using this. // https://github.com/ocornut/imgui #include diff --git a/examples/opengl3_example/imgui_impl_glfw_gl3.h b/examples/opengl3_example/imgui_impl_glfw_gl3.h index edec71c3..33e01c30 100644 --- a/examples/opengl3_example/imgui_impl_glfw_gl3.h +++ b/examples/opengl3_example/imgui_impl_glfw_gl3.h @@ -1,4 +1,7 @@ // ImGui GLFW binding with OpenGL3 + shaders +// You can copy and use unmodified imgui_impl_* files in your project. +// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown(). +// See main.cpp for an example of using this. // https://github.com/ocornut/imgui struct GLFWwindow; diff --git a/examples/opengl_example/imgui_impl_glfw.cpp b/examples/opengl_example/imgui_impl_glfw.cpp index 27625e7e..3e06e4b9 100644 --- a/examples/opengl_example/imgui_impl_glfw.cpp +++ b/examples/opengl_example/imgui_impl_glfw.cpp @@ -1,4 +1,7 @@ // ImGui GLFW binding with OpenGL +// You can copy and use unmodified imgui_impl_* files in your project. +// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown(). +// See main.cpp for an example of using this. // https://github.com/ocornut/imgui #include diff --git a/examples/opengl_example/imgui_impl_glfw.h b/examples/opengl_example/imgui_impl_glfw.h index 35088f0e..05fe6b05 100644 --- a/examples/opengl_example/imgui_impl_glfw.h +++ b/examples/opengl_example/imgui_impl_glfw.h @@ -1,4 +1,7 @@ // ImGui GLFW binding with OpenGL +// You can copy and use unmodified imgui_impl_* files in your project. +// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown(). +// See main.cpp for an example of using this. // https://github.com/ocornut/imgui struct GLFWwindow; diff --git a/examples/sdl_opengl_example/imgui_impl_sdl.cpp b/examples/sdl_opengl_example/imgui_impl_sdl.cpp index 5d7c44a3..aed5881b 100644 --- a/examples/sdl_opengl_example/imgui_impl_sdl.cpp +++ b/examples/sdl_opengl_example/imgui_impl_sdl.cpp @@ -1,4 +1,7 @@ // ImGui SDL2 binding with OpenGL +// You can copy and use unmodified imgui_impl_* files in your project. +// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown(). +// See main.cpp for an example of using this. // https://github.com/ocornut/imgui #include diff --git a/examples/sdl_opengl_example/imgui_impl_sdl.h b/examples/sdl_opengl_example/imgui_impl_sdl.h index 1edd8980..cef9817c 100644 --- a/examples/sdl_opengl_example/imgui_impl_sdl.h +++ b/examples/sdl_opengl_example/imgui_impl_sdl.h @@ -1,4 +1,7 @@ // ImGui SDL2 binding with OpenGL +// You can copy and use unmodified imgui_impl_* files in your project. +// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown(). +// See main.cpp for an example of using this. // https://github.com/ocornut/imgui struct SDL_Window; diff --git a/extra_fonts/binary_to_compressed_c.cpp b/extra_fonts/binary_to_compressed_c.cpp index 34411a0d..a9b3b77f 100644 --- a/extra_fonts/binary_to_compressed_c.cpp +++ b/extra_fonts/binary_to_compressed_c.cpp @@ -18,21 +18,23 @@ typedef unsigned int stb_uint; typedef unsigned char stb_uchar; stb_uint stb_compress(stb_uchar *out,stb_uchar *in,stb_uint len); -static bool binary_to_compressed_c(const char* filename, const char* symbol, bool use_base85_encoding); +static bool binary_to_compressed_c(const char* filename, const char* symbol, bool use_base85_encoding, bool use_compression); int main(int argc, char** argv) { if (argc < 3) { - printf("Syntax: %s [-base85] \n", argv[0]); + printf("Syntax: %s [-base85] [-nocompress] \n", argv[0]); return 0; } int argn = 1; bool use_base85_encoding = false; + bool use_compression = true; if (argv[argn][0] == '-') { if (strcmp(argv[argn], "-base85") == 0) { use_base85_encoding = true; argn++; } + else if (strcmp(argv[argn], "-nocompress") == 0) { use_compression = false; argn++; } else { printf("Unknown argument: '%s'\n", argv[argn]); @@ -40,7 +42,7 @@ int main(int argc, char** argv) } } - binary_to_compressed_c(argv[argn], argv[argn+1], use_base85_encoding); + binary_to_compressed_c(argv[argn], argv[argn+1], use_base85_encoding, use_compression); return 1; } @@ -50,7 +52,7 @@ char Encode85Byte(unsigned int x) return (x>='\\') ? x+1 : x; } -bool binary_to_compressed_c(const char* filename, const char* symbol, bool use_base85_encoding) +bool binary_to_compressed_c(const char* filename, const char* symbol, bool use_base85_encoding, bool use_compression) { // Read file FILE* f = fopen(filename, "rb"); @@ -64,17 +66,19 @@ bool binary_to_compressed_c(const char* filename, const char* symbol, bool use_b // Compress int maxlen = data_sz + 512 + (data_sz >> 2) + sizeof(int); // total guess - char* compressed = new char[maxlen]; - int compressed_sz = stb_compress((stb_uchar*)compressed, (stb_uchar*)data, data_sz); - memset(compressed + compressed_sz, 0, maxlen - compressed_sz); + char* compressed = use_compression ? new char[maxlen] : data; + int compressed_sz = use_compression ? stb_compress((stb_uchar*)compressed, (stb_uchar*)data, data_sz) : data_sz; + if (use_compression) + memset(compressed + compressed_sz, 0, maxlen - compressed_sz); // Output as Base85 encoded FILE* out = stdout; fprintf(out, "// File: '%s' (%d bytes)\n", filename, (int)data_sz); fprintf(out, "// Exported using binary_to_compressed_c.cpp\n"); + const char* compressed_str = use_compression ? "compressed_" : ""; if (use_base85_encoding) { - fprintf(out, "static const char %s_compressed_data_base85[%d+1] =\n \"", symbol, (int)((compressed_sz+3)/4)*5); + fprintf(out, "static const char %s_%sdata_base85[%d+1] =\n \"", symbol, compressed_str, (int)((compressed_sz+3)/4)*5); int column = 0; for (int i = 0; i < compressed_sz; i += 4) { @@ -87,8 +91,8 @@ bool binary_to_compressed_c(const char* filename, const char* symbol, bool use_b } else { - fprintf(out, "static const unsigned int %s_compressed_size = %d;\n", symbol, (int)compressed_sz); - fprintf(out, "static const unsigned int %s_compressed_data[%d/4] =\n{", symbol, (int)((compressed_sz+3)/4)*4); + fprintf(out, "static const unsigned int %s_%ssize = %d;\n", symbol, compressed_str, (int)compressed_sz); + fprintf(out, "static const unsigned int %s_%sdata[%d/4] =\n{", symbol, compressed_str, (int)((compressed_sz+3)/4)*4); int column = 0; for (int i = 0; i < compressed_sz; i += 4) { @@ -103,7 +107,8 @@ bool binary_to_compressed_c(const char* filename, const char* symbol, bool use_b // Cleanup delete[] data; - delete[] compressed; + if (use_compression) + delete[] compressed; return true; } diff --git a/imgui.cpp b/imgui.cpp index 1f1aaedc..80f4b6ea 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -399,14 +399,19 @@ Issue numbers (#) refer to github issues. The list below consist mostly of notes of things to do before they are requested/discussed by users (at that point it usually happens on the github) - - window: autofit feedback loop when user relies on any dynamic layout (window width multiplier, column). maybe just clearly drop manual autofit? - - window: add a way for very transient windows (non-saved, temporary overlay over hundreds of objects) to "clean" up from the global window list. + - window: maximum window size settings (per-axis). for large popups in particular user may not want the popup to fill all space. + - window: add a way for very transient windows (non-saved, temporary overlay over hundreds of objects) to "clean" up from the global window list. perhaps a lightweight explicit cleanup pass. + - window: auto-fit feedback loop when user relies on any dynamic layout (window width multiplier, column). clarify. - window: allow resizing of child windows (possibly given min/max for each axis?) - window: background options for child windows, border option (disable rounding) + - window: add a way to clear an existing window instead of appending (e.g. for tooltip override using a consistent api rather than the deferred tooltip) - window: resizing from any sides? + mouse cursor directives for app. +!- window: begin with *p_opened == false should return false. - window: get size/pos helpers given names (see discussion in #249) - window: a collapsed window can be stuck behind the main menu bar? + - window: detect extra End() call that pop the "Debug" window out and assert at call site instead of later. !- scrolling: allow immediately effective change of scroll if we haven't appended items yet + - splitter: formalize the splitter idiom into an official api (we want to handle n-way split) - widgets: display mode: widget-label, label-widget (aligned on column or using fixed size), label-newline-tab-widget etc. - widgets: clean up widgets internal toward exposing everything. - widgets: add disabled and read-only modes (#211) @@ -421,6 +426,8 @@ - input number: use mouse wheel to step up/down - input number: applying arithmetics ops (+,-,*,/) messes up with text edit undo stack. - text: proper alignment options + - image/image button: misalignment on padded/bordered button? + - image/image button: parameters are confusing, image() has tint_col,border_col whereas imagebutton() has bg_col/tint_col. Even thou they are different parameters ordering could be more consistent. can we fix that? - layout: horizontal layout helper (#97) - layout: more generic alignment state (left/right/centered) for single items? - layout: clean up the InputFloatN/SliderFloatN/ColorEdit4 layout code. item width should include frame padding. @@ -436,19 +443,20 @@ - listbox: user may want to initial scroll to focus on the one selected value? - listbox: keyboard navigation. - listbox: scrolling should track modified selection. - ! menus/popups: clarify usage of popups id, how MenuItem/Selectable closing parent popups affects the ID, etc. this is quite fishy needs improvement! (#331) +-! menus/popups: clarify usage of popups id, how MenuItem/Selectable closing parent popups affects the ID, etc. this is quite fishy needs improvement! (#331) - menus: local shortcuts, global shortcuts (#126) - menus: icons - menus: menubars: some sort of priority / effect of main menu-bar on desktop size? + - statusbar: add a per-window status bar helper similar to what menubar does. - tabs - separator: separator on the initial position of a window is not visible (cursorpos.y <= clippos.y) - gauge: various forms of gauge/loading bars widgets - - color: add a better color picker (perhaps a popup). - - plot: plotlines should use the polygon-stroke facilities (currently issues with averaging normals) + - color: add a better color picker + - plot: PlotLines() should use the polygon-stroke facilities (currently issues with averaging normals) - plot: make it easier for user to draw extra stuff into the graph (e.g: draw basis, highlight certain points, 2d plots, multiple plots) - plot: "smooth" automatic scale over time, user give an input 0.0(full user scale) 1.0(full derived from value) - plot: add a helper e.g. Plot(char* label, float value, float time_span=2.0f) that stores values and Plot them for you - probably another function name. and/or automatically allow to plot ANY displayed value (more reliance on stable ID) - - file selection widget -> build the tool in our codebase to improve model-dialog idioms + - applet: file selection widget (as an example) - slider: allow using the [-]/[+] buttons used by InputFloat()/InputInt() - slider: initial absolute click is imprecise. change to relative movement slider (same as scrollbar). - slider: add dragging-based widgets to edit values with mouse (on 2 axises), saving screen real-estate. @@ -459,13 +467,15 @@ - text edit: centered text for slider as input text so it matches typical positioning. - text edit: flag to disable live update of the user buffer. - text edit: field resize behavior - field could stretch when being edited? hover tooltip shows more text? - - tree: add treenode/treepush int variants? because (void*) cast from int warns on some platforms/settings + - tree node / optimization: avoid formatting when clipped. + - tree node: tree-node/header right-most side doesn't take account of horizontal scrolling. + - tree node: add treenode/treepush int variants? because (void*) cast from int warns on some platforms/settings - textwrapped: figure out better way to use TextWrapped() in an always auto-resize context (tooltip, etc.) (git issue #249) - settings: write more decent code to allow saving/loading new fields - settings: api for per-tool simple persistent data (bool,int,float,columns sizes,etc.) in .ini file - style: store rounded corners in texture to use 1 quad per corner (filled and wireframe). so rounding have minor cost. - style: color-box not always square? - - style: a concept of "compact style" that the end-user can easily rely on (e.g. PushStyleCompact()?) that maps that other settings? + - style: a concept of "compact style" that the end-user can easily rely on (e.g. PushStyleCompact()?) that maps to other settings? avoid implementing duplicate helpers such as SmallCheckbox(), etc. - text: simple markup language for color change? - log: LogButtons() options for specifying depth and/or hiding depth slider - log: have more control over the log scope (e.g. stop logging when leaving current tree node scope) @@ -479,11 +489,12 @@ - focus: SetKeyboardFocusHere() on with >= 0 offset could be done on same frame (else latch and modulate on beginning of next frame) - input: rework IO to be able to pass actual events to fix temporal aliasing issues. - input: support track pad style scrolling & slider edit. - - memory: add a way to discard allocs of unused/transient windows. with the current architecture new windows (including popup, opened combos, listbox) perform at least 3 allocs. - misc: provide a way to compile out the entire implementation while providing a dummy API (e.g. #define IMGUI_DUMMY_IMPL) - misc: double-clicking on title bar to minimize isn't consistent, perhaps move to single-click on left-most collapse icon? - style editor: have a more global HSV setter (e.g. alter hue on all elements). consider replacing active/hovered by offset in HSV space? - style editor: color child window height expressed in multiple of line height. +!- examples: directx9/directx11: resizing window duplicate the font data :( + - optimization: use another hash function than crc32, e.g. FNV1a - optimization/render: merge command-lists with same clip-rect into one even if they aren't sequential? (as long as in-between clip rectangle don't overlap)? - optimization: turn some the various stack vectors into statically-sized arrays - optimization: better clipping for multi-component widgets @@ -908,7 +919,7 @@ int ImTextCharFromUtf8(unsigned int* out_char, const char* in_text, const char* if ((*str & 0xe0) == 0xc0) { *out_char = 0xFFFD; // will be invalid but not end of string - if (in_text_end && in_text_end - (const char*)str < 2) return 0; + if (in_text_end && in_text_end - (const char*)str < 2) return 1; if (*str < 0xc2) return 2; c = (unsigned int)((*str++ & 0x1f) << 6); if ((*str & 0xc0) != 0x80) return 2; @@ -919,7 +930,7 @@ int ImTextCharFromUtf8(unsigned int* out_char, const char* in_text, const char* if ((*str & 0xf0) == 0xe0) { *out_char = 0xFFFD; // will be invalid but not end of string - if (in_text_end && in_text_end - (const char*)str < 3) return 0; + if (in_text_end && in_text_end - (const char*)str < 3) return 1; if (*str == 0xe0 && (str[1] < 0xa0 || str[1] > 0xbf)) return 3; if (*str == 0xed && str[1] > 0x9f) return 3; // str[1] < 0x80 is checked below c = (unsigned int)((*str++ & 0x0f) << 12); @@ -933,7 +944,7 @@ int ImTextCharFromUtf8(unsigned int* out_char, const char* in_text, const char* if ((*str & 0xf8) == 0xf0) { *out_char = 0xFFFD; // will be invalid but not end of string - if (in_text_end && in_text_end - (const char*)str < 4) return 0; + if (in_text_end && in_text_end - (const char*)str < 4) return 1; if (*str > 0xf4) return 4; if (*str == 0xf0 && (str[1] < 0x90 || str[1] > 0xbf)) return 4; if (*str == 0xf4 && str[1] > 0x8f) return 4; // str[1] < 0x80 is checked below @@ -1761,6 +1772,17 @@ void ImGui::MemFree(void* ptr) return GImGui->IO.MemFreeFn(ptr); } +const char* ImGui::GetClipboardText() +{ + return GImGui->IO.GetClipboardTextFn ? GImGui->IO.GetClipboardTextFn() : ""; +} + +void ImGui::SetClipboardText(const char* text) +{ + if (GImGui->IO.SetClipboardTextFn) + GImGui->IO.SetClipboardTextFn(text); +} + const char* ImGui::GetVersion() { return IMGUI_VERSION; @@ -7217,7 +7239,8 @@ bool ImGui::InputTextEx(const char* label, char* buf, int buf_size, const ImVec2 if (g.IO.InputCharacters[0]) { // Process text input (before we check for Return because using some IME will effectively send a Return?) - if (!is_ctrl_down && is_editable) + // We ignore CTRL inputs, but need to allow CTRL+ALT as some keyboards (e.g. German) use AltGR - which is Alt+Ctrl - to input certain characters. + if (!(is_ctrl_down && !is_alt_down) && is_editable) { for (int n = 0; n < IM_ARRAYSIZE(g.IO.InputCharacters) && g.IO.InputCharacters[n]; n++) if (unsigned int c = (unsigned int)g.IO.InputCharacters[n]) diff --git a/imgui.h b/imgui.h index 361ba83e..29ad4756 100644 --- a/imgui.h +++ b/imgui.h @@ -416,9 +416,11 @@ namespace ImGui IMGUI_API void CaptureKeyboardFromApp(); // manually enforce imgui setting the io.WantCaptureKeyboard flag next frame (your application needs to handle it). e.g. capture keyboard when your widget is being hovered. IMGUI_API void CaptureMouseFromApp(); // manually enforce imgui setting the io.WantCaptureMouse flag next frame (your application needs to handle it). - // Helpers functions to access the MemAllocFn/MemFreeFn pointers in ImGui::GetIO() + // Helpers functions to access functions pointers in ImGui::GetIO() IMGUI_API void* MemAlloc(size_t sz); IMGUI_API void MemFree(void* ptr); + IMGUI_API const char* GetClipboardText(); + IMGUI_API void SetClipboardText(const char* text); // Internal state/context access - if you want to use multiple ImGui context, or share context between modules (e.g. DLL), or allocate the memory yourself IMGUI_API const char* GetVersion(); @@ -1113,7 +1115,7 @@ struct ImDrawList IMGUI_API void AddCircleFilled(const ImVec2& centre, float radius, ImU32 col, int num_segments = 12); IMGUI_API void AddText(const ImVec2& pos, ImU32 col, const char* text_begin, const char* text_end = NULL); IMGUI_API void AddText(const ImFont* font, float font_size, const ImVec2& pos, ImU32 col, const char* text_begin, const char* text_end = NULL, float wrap_width = 0.0f, const ImVec4* cpu_fine_clip_rect = NULL); - IMGUI_API void AddImage(ImTextureID user_texture_id, const ImVec2& a, const ImVec2& b, const ImVec2& uv0, const ImVec2& uv1, ImU32 col = 0xFFFFFFFF); + IMGUI_API void AddImage(ImTextureID user_texture_id, const ImVec2& a, const ImVec2& b, const ImVec2& uv0 = ImVec2(0,0), const ImVec2& uv1 = ImVec2(1,1), ImU32 col = 0xFFFFFFFF); IMGUI_API void AddPolyline(const ImVec2* points, const int num_points, ImU32 col, bool closed, float thickness, bool anti_aliased); IMGUI_API void AddConvexPolyFilled(const ImVec2* points, const int num_points, ImU32 col, bool anti_aliased); IMGUI_API void AddBezierCurve(const ImVec2& pos0, const ImVec2& cp0, const ImVec2& cp1, const ImVec2& pos1, ImU32 col, float thickness, int num_segments = 0); diff --git a/imgui_demo.cpp b/imgui_demo.cpp index 23de2a37..166bb30a 100644 --- a/imgui_demo.cpp +++ b/imgui_demo.cpp @@ -14,7 +14,7 @@ #include // sqrtf, fabsf, fmodf, powf, cosf, sinf, floorf, ceilf #include // vsnprintf, sscanf, printf -#if defined(_MSC_VER) && !defined(__S3E__) +#if defined(_MSC_VER) #pragma warning (disable: 4996) // 'This function or variable may be unsafe': strcpy, strdup, sprintf, vsnprintf, sscanf, fopen #define snprintf _snprintf #endif diff --git a/imgui_draw.cpp b/imgui_draw.cpp index c91bdcd3..1148ea99 100644 --- a/imgui_draw.cpp +++ b/imgui_draw.cpp @@ -26,7 +26,7 @@ #endif #endif -#if defined(_MSC_VER) && !defined(__S3E__) +#if defined(_MSC_VER) #pragma warning (disable: 4505) // unreferenced local function has been removed (stb stuff) #pragma warning (disable: 4996) // 'This function or variable may be unsafe': strcpy, strdup, sprintf, vsnprintf, sscanf, fopen #define snprintf _snprintf @@ -291,6 +291,7 @@ void ImDrawList::ChannelsMerge() void ImDrawList::ChannelsSetCurrent(int idx) { + IM_ASSERT(idx < _ChannelsCount); if (_ChannelsCurrent == idx) return; memcpy(&_Channels.Data[_ChannelsCurrent].CmdBuffer, &CmdBuffer, sizeof(CmdBuffer)); // copy 12 bytes, four times memcpy(&_Channels.Data[_ChannelsCurrent].IdxBuffer, &IdxBuffer, sizeof(IdxBuffer)); diff --git a/imgui_internal.h b/imgui_internal.h index a100fedd..ccd571fd 100644 --- a/imgui_internal.h +++ b/imgui_internal.h @@ -14,7 +14,7 @@ #include // FILE* #include // sqrtf() -#if defined(_MSC_VER) && !defined(__S3E__) +#if defined(_MSC_VER) #pragma warning (push) #pragma warning (disable: 4251) // class 'xxx' needs to have dll-interface to be used by clients of struct 'xxx' // when IMGUI_API is set to__declspec(dllexport) #endif @@ -698,6 +698,6 @@ namespace ImGui } // namespace ImGuiP -#if defined(_MSC_VER) && !defined(__S3E__) +#if defined(_MSC_VER) #pragma warning (pop) #endif