mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-15 01:17:00 +00:00
Added GetContentRegionAvailWidth() helper. Demo tweaks.
This commit is contained in:
parent
fc13ae2aa5
commit
d88b73a8b7
@ -4550,6 +4550,11 @@ ImVec2 ImGui::GetContentRegionAvail()
|
|||||||
return GetContentRegionMax() - (window->DC.CursorPos - window->Pos);
|
return GetContentRegionMax() - (window->DC.CursorPos - window->Pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float ImGui::GetContentRegionAvailWidth()
|
||||||
|
{
|
||||||
|
return GetContentRegionAvail().x;
|
||||||
|
}
|
||||||
|
|
||||||
// In window space (not screen space!)
|
// In window space (not screen space!)
|
||||||
ImVec2 ImGui::GetWindowContentRegionMin()
|
ImVec2 ImGui::GetWindowContentRegionMin()
|
||||||
{
|
{
|
||||||
|
1
imgui.h
1
imgui.h
@ -124,6 +124,7 @@ namespace ImGui
|
|||||||
IMGUI_API ImVec2 GetContentRegionAvail(); // == GetContentRegionMax() - GetCursorPos()
|
IMGUI_API ImVec2 GetContentRegionAvail(); // == GetContentRegionMax() - GetCursorPos()
|
||||||
IMGUI_API ImVec2 GetWindowContentRegionMin(); // window boundaries, in windows coordinates
|
IMGUI_API ImVec2 GetWindowContentRegionMin(); // window boundaries, in windows coordinates
|
||||||
IMGUI_API ImVec2 GetWindowContentRegionMax();
|
IMGUI_API ImVec2 GetWindowContentRegionMax();
|
||||||
|
IMGUI_API float GetContentRegionAvailWidth(); //
|
||||||
IMGUI_API ImDrawList* GetWindowDrawList(); // get rendering command-list if you want to append your own draw primitives
|
IMGUI_API ImDrawList* GetWindowDrawList(); // get rendering command-list if you want to append your own draw primitives
|
||||||
IMGUI_API ImFont* GetWindowFont();
|
IMGUI_API ImFont* GetWindowFont();
|
||||||
IMGUI_API float GetWindowFontSize(); // size (also height in pixels) of current font with current scale applied
|
IMGUI_API float GetWindowFontSize(); // size (also height in pixels) of current font with current scale applied
|
||||||
|
@ -735,21 +735,26 @@ void ImGui::ShowTestWindow(bool* opened)
|
|||||||
if (ImGui::TreeNode("Widgets Alignment"))
|
if (ImGui::TreeNode("Widgets Alignment"))
|
||||||
{
|
{
|
||||||
static float f = 0.0f;
|
static float f = 0.0f;
|
||||||
ImGui::Text("Fixed: 100 pixels");
|
ImGui::Text("PushItemWidth(100)");
|
||||||
ImGui::PushItemWidth(100);
|
ImGui::PushItemWidth(100);
|
||||||
ImGui::InputFloat("float##1", &f);
|
ImGui::InputFloat("float##1", &f);
|
||||||
ImGui::PopItemWidth();
|
ImGui::PopItemWidth();
|
||||||
|
|
||||||
ImGui::Text("Proportional: 50%% of window width");
|
ImGui::Text("PushItemWidth(GetWindowWidth() * 0.5f);");
|
||||||
ImGui::PushItemWidth(ImGui::GetWindowWidth() * 0.5f);
|
ImGui::PushItemWidth(ImGui::GetWindowWidth() * 0.5f);
|
||||||
ImGui::InputFloat("float##2", &f);
|
ImGui::InputFloat("float##2", &f);
|
||||||
ImGui::PopItemWidth();
|
ImGui::PopItemWidth();
|
||||||
|
|
||||||
ImGui::Text("Right-aligned: Leave 100 pixels for label");
|
ImGui::Text("PushItemWidth(GetContentRegionAvailWidth() * 0.5f);");
|
||||||
ImGui::PushItemWidth(-100);
|
ImGui::PushItemWidth(ImGui::GetContentRegionAvailWidth() * 0.5f);
|
||||||
ImGui::InputFloat("float##3", &f);
|
ImGui::InputFloat("float##3", &f);
|
||||||
ImGui::PopItemWidth();
|
ImGui::PopItemWidth();
|
||||||
|
|
||||||
|
ImGui::Text("PushItemWidth(-100);");
|
||||||
|
ImGui::PushItemWidth(-100);
|
||||||
|
ImGui::InputFloat("float##4", &f);
|
||||||
|
ImGui::PopItemWidth();
|
||||||
|
|
||||||
ImGui::TreePop();
|
ImGui::TreePop();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1205,7 +1210,7 @@ void ImGui::ShowTestWindow(bool* opened)
|
|||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
ImGui::Spacing();
|
ImGui::Spacing();
|
||||||
|
|
||||||
// Word-wrapping
|
// Word wrapping
|
||||||
ImGui::Text("Word-wrapping:");
|
ImGui::Text("Word-wrapping:");
|
||||||
ImGui::Columns(2, "word-wrapping");
|
ImGui::Columns(2, "word-wrapping");
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
|
Loading…
Reference in New Issue
Block a user