Selaa lähdekoodia

Internals: Tweak ItemSize calls. Added todo items.

omar 6 vuotta sitten
vanhempi
commit
b53630813e
2 muutettua tiedostoa jossa 7 lisäystä ja 5 poistoa
  1. 1 0
      docs/TODO.txt
  2. 6 5
      imgui_widgets.cpp

+ 1 - 0
docs/TODO.txt

@@ -34,6 +34,7 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i
  - scrolling/style: shadows on scrollable areas to denote that there is more contents
  - scrolling/style: shadows on scrollable areas to denote that there is more contents
 
 
  - drawdata: make it easy to clone (or swap?) a ImDrawData so user can easily save that data if they use threaded rendering.
  - drawdata: make it easy to clone (or swap?) a ImDrawData so user can easily save that data if they use threaded rendering.
+ - drawlist: add calctextsize func to facilitate consistent code from user pov
  - drawlist: end-user probably can't call Clear() directly because we expect a texture to be pushed in the stack.
  - drawlist: end-user probably can't call Clear() directly because we expect a texture to be pushed in the stack.
  - drawlist: maintaining bounding box per command would allow to merge draw command when clipping isn't relied on (typical non-scrolling window or non-overflowing column would merge with previous command).
  - drawlist: maintaining bounding box per command would allow to merge draw command when clipping isn't relied on (typical non-scrolling window or non-overflowing column would merge with previous command).
  - drawlist: primitives/helpers to manipulate vertices post submission, so e.g. a quad/rect can be resized to fit later submitted content, _without_ using the ChannelSplit api
  - drawlist: primitives/helpers to manipulate vertices post submission, so e.g. a quad/rect can be resized to fit later submitted content, _without_ using the ChannelSplit api

+ 6 - 5
imgui_widgets.cpp

@@ -642,7 +642,7 @@ bool ImGui::ArrowButtonEx(const char* str_id, ImGuiDir dir, ImVec2 size, ImGuiBu
     const ImGuiID id = window->GetID(str_id);
     const ImGuiID id = window->GetID(str_id);
     const ImRect bb(window->DC.CursorPos, window->DC.CursorPos + size);
     const ImRect bb(window->DC.CursorPos, window->DC.CursorPos + size);
     const float default_size = GetFrameHeight();
     const float default_size = GetFrameHeight();
-    ItemSize(bb, (size.y >= default_size) ? g.Style.FramePadding.y : 0.0f);
+    ItemSize(size, (size.y >= default_size) ? g.Style.FramePadding.y : 0.0f);
     if (!ItemAdd(bb, id))
     if (!ItemAdd(bb, id))
         return false;
         return false;
 
 
@@ -1040,8 +1040,9 @@ void ImGui::ProgressBar(float fraction, const ImVec2& size_arg, const char* over
     const ImGuiStyle& style = g.Style;
     const ImGuiStyle& style = g.Style;
 
 
     ImVec2 pos = window->DC.CursorPos;
     ImVec2 pos = window->DC.CursorPos;
-    ImRect bb(pos, pos + CalcItemSize(size_arg, CalcItemWidth(), g.FontSize + style.FramePadding.y*2.0f));
-    ItemSize(bb, style.FramePadding.y);
+    ImVec2 size = CalcItemSize(size_arg, CalcItemWidth(), g.FontSize + style.FramePadding.y*2.0f);
+    ImRect bb(pos, pos + size);
+    ItemSize(size, style.FramePadding.y);
     if (!ItemAdd(bb, 0))
     if (!ItemAdd(bb, 0))
         return;
         return;
 
 
@@ -1114,7 +1115,7 @@ void ImGui::Dummy(const ImVec2& size)
         return;
         return;
 
 
     const ImRect bb(window->DC.CursorPos, window->DC.CursorPos + size);
     const ImRect bb(window->DC.CursorPos, window->DC.CursorPos + size);
-    ItemSize(bb);
+    ItemSize(size);
     ItemAdd(bb, 0);
     ItemAdd(bb, 0);
 }
 }
 
 
@@ -5260,7 +5261,7 @@ bool ImGui::Selectable(const char* label, bool selected, ImGuiSelectableFlags fl
     ImVec2 pos = window->DC.CursorPos;
     ImVec2 pos = window->DC.CursorPos;
     pos.y += window->DC.CurrentLineTextBaseOffset;
     pos.y += window->DC.CurrentLineTextBaseOffset;
     ImRect bb_inner(pos, pos + size);
     ImRect bb_inner(pos, pos + size);
-    ItemSize(bb_inner);
+    ItemSize(size);
 
 
     // Fill horizontal space.
     // Fill horizontal space.
     ImVec2 window_padding = window->WindowPadding;
     ImVec2 window_padding = window->WindowPadding;