Răsfoiți Sursa

BeginChildFrame() / EndChildFrame() helpers.

ocornut 10 ani în urmă
părinte
comite
e7f51172c1
2 a modificat fișierele cu 20 adăugiri și 0 ștergeri
  1. 17 0
      imgui.cpp
  2. 3 0
      imgui.h

+ 17 - 0
imgui.cpp

@@ -2530,6 +2530,23 @@ void ImGui::EndChild()
     }
     }
 }
 }
 
 
+// Helper to create a child window / scrolling region that looks like a normal widget frame.
+void ImGui::BeginChildFrame(ImGuiID id, const ImVec2& size)
+{
+    ImGuiState& g = *GImGui;
+    const ImGuiStyle& style = g.Style;
+    ImGui::PushStyleColor(ImGuiCol_ChildWindowBg, style.Colors[ImGuiCol_FrameBg]);
+    ImGui::PushStyleVar(ImGuiStyleVar_ChildWindowRounding, style.FrameRounding);
+    ImGui::BeginChild(id, size);
+}
+
+void ImGui::EndChildFrame()
+{
+    ImGui::EndChild();
+    ImGui::PopStyleVar();
+    ImGui::PopStyleColor();
+}
+
 static ImGuiWindow* FindWindowByName(const char* name)
 static ImGuiWindow* FindWindowByName(const char* name)
 {
 {
     // FIXME-OPT: Consider optimizing this (e.g. sorted hashes to window pointers)
     // FIXME-OPT: Consider optimizing this (e.g. sorted hashes to window pointers)

+ 3 - 0
imgui.h

@@ -336,6 +336,9 @@ namespace ImGui
     IMGUI_API ImVec2        CalcTextSize(const char* text, const char* text_end = NULL, bool hide_text_after_double_hash = false, float wrap_width = -1.0f);
     IMGUI_API ImVec2        CalcTextSize(const char* text, const char* text_end = NULL, bool hide_text_after_double_hash = false, float wrap_width = -1.0f);
     IMGUI_API void          CalcListClipping(int items_count, float items_height, int* out_items_display_start, int* out_items_display_end);    // helper to manually clip large list of items. see comments in implementation.
     IMGUI_API void          CalcListClipping(int items_count, float items_height, int* out_items_display_start, int* out_items_display_end);    // helper to manually clip large list of items. see comments in implementation.
 
 
+    IMGUI_API void          BeginChildFrame(ImGuiID id, const ImVec2& size);                    // helper to create a child window / scrolling region that looks like a normal widget frame.
+    IMGUI_API void          EndChildFrame();
+
     IMGUI_API ImU32         ColorConvertFloat4ToU32(const ImVec4& in);
     IMGUI_API ImU32         ColorConvertFloat4ToU32(const ImVec4& in);
     IMGUI_API void          ColorConvertRGBtoHSV(float r, float g, float b, float& out_h, float& out_s, float& out_v);
     IMGUI_API void          ColorConvertRGBtoHSV(float r, float g, float b, float& out_h, float& out_s, float& out_v);
     IMGUI_API void          ColorConvertHSVtoRGB(float h, float s, float v, float& out_r, float& out_g, float& out_b);
     IMGUI_API void          ColorConvertHSVtoRGB(float h, float s, float v, float& out_r, float& out_g, float& out_b);