The open source OpenXR runtime

ext/imgui: Add function to draw image with background color

+45
+5
src/external/imgui/imgui_monado/cimgui_monado.h
··· 22 22 23 23 void igToggleButton(const char *str_id, bool *v); 24 24 25 + void igImageBg(ImTextureID user_texture_id, 26 + const ImVec2 size, 27 + const ImVec2 uv0, const ImVec2 uv1, 28 + const ImVec4 tint_col, const ImVec4 border_col, const ImVec4 bg_col); 29 + 25 30 #ifdef __cplusplus 26 31 } 27 32 #endif
+40
src/external/imgui/imgui_monado/imgui_monado.cpp
··· 280 280 ImVec2(p.x + radius + t * (width - radius * 2.0f), p.y + radius), 281 281 radius - 1.5f, IM_COL32(255, 255, 255, 255)); 282 282 } 283 + 284 + extern "C" 285 + void igImageBg(ImTextureID user_texture_id, 286 + const ImVec2 size, 287 + const ImVec2 uv0, const ImVec2 uv1, 288 + const ImVec4 tint_col, const ImVec4 border_col, const ImVec4 bg_col) 289 + { 290 + ImGuiWindow* window = GetCurrentWindow(); 291 + if (window->SkipItems) { 292 + return; 293 + } 294 + 295 + ImRect bb(window->DC.CursorPos, window->DC.CursorPos + size); 296 + auto bbImg = bb; 297 + if (border_col.w > 0.0f) { 298 + bb.Max += ImVec2(2, 2); 299 + 300 + // Move the image pixel down and right, to be inside of the frame. 301 + bbImg.Min += ImVec2(1, 1); 302 + bbImg.Max += ImVec2(1, 1); 303 + } 304 + 305 + ItemSize(bb); 306 + if (!ItemAdd(bb, 0)) { 307 + return; 308 + } 309 + 310 + // Do we have a border? 311 + if (border_col.w > 0.0f) { 312 + window->DrawList->AddRect(bb.Min, bb.Max, GetColorU32(border_col), 0.0f); 313 + } 314 + 315 + // Should we clear the background? 316 + if (bg_col.w > 0.0f) { 317 + window->DrawList->AddRectFilled(bbImg.Min, bbImg.Max, GetColorU32(bg_col)); 318 + } 319 + 320 + // Finally the image. 321 + window->DrawList->AddImage(user_texture_id, bbImg.Min, bbImg.Max, uv0, uv1, GetColorU32(tint_col)); 322 + }