|
|
@@ -52,6 +52,7 @@
|
|
|
static void ShowExampleAppConsole(bool* opened);
|
|
|
static void ShowExampleAppLog(bool* opened);
|
|
|
static void ShowExampleAppLayout(bool* opened);
|
|
|
+static void ShowExampleAppPropertyEditor(bool* opened);
|
|
|
static void ShowExampleAppLongText(bool* opened);
|
|
|
static void ShowExampleAppAutoResize(bool* opened);
|
|
|
static void ShowExampleAppFixedOverlay(bool* opened);
|
|
|
@@ -90,7 +91,7 @@ void ImGui::ShowUserGuide()
|
|
|
}
|
|
|
|
|
|
// Demonstrate most ImGui features (big function!)
|
|
|
-void ImGui::ShowTestWindow(bool* opened)
|
|
|
+void ImGui::ShowTestWindow(bool* p_opened)
|
|
|
{
|
|
|
// Examples apps
|
|
|
static bool show_app_metrics = false;
|
|
|
@@ -98,6 +99,7 @@ void ImGui::ShowTestWindow(bool* opened)
|
|
|
static bool show_app_console = false;
|
|
|
static bool show_app_log = false;
|
|
|
static bool show_app_layout = false;
|
|
|
+ static bool show_app_property_editor = false;
|
|
|
static bool show_app_long_text = false;
|
|
|
static bool show_app_auto_resize = false;
|
|
|
static bool show_app_fixed_overlay = false;
|
|
|
@@ -109,6 +111,7 @@ void ImGui::ShowTestWindow(bool* opened)
|
|
|
if (show_app_console) ShowExampleAppConsole(&show_app_console);
|
|
|
if (show_app_log) ShowExampleAppLog(&show_app_log);
|
|
|
if (show_app_layout) ShowExampleAppLayout(&show_app_layout);
|
|
|
+ if (show_app_property_editor) ShowExampleAppPropertyEditor(&show_app_property_editor);
|
|
|
if (show_app_long_text) ShowExampleAppLongText(&show_app_long_text);
|
|
|
if (show_app_auto_resize) ShowExampleAppAutoResize(&show_app_auto_resize);
|
|
|
if (show_app_fixed_overlay) ShowExampleAppFixedOverlay(&show_app_fixed_overlay);
|
|
|
@@ -142,7 +145,7 @@ void ImGui::ShowTestWindow(bool* opened)
|
|
|
if (no_scrollbar) window_flags |= ImGuiWindowFlags_NoScrollbar;
|
|
|
if (no_collapse) window_flags |= ImGuiWindowFlags_NoCollapse;
|
|
|
if (!no_menu) window_flags |= ImGuiWindowFlags_MenuBar;
|
|
|
- if (!ImGui::Begin("ImGui Demo", opened, ImVec2(550,680), bg_alpha, window_flags))
|
|
|
+ if (!ImGui::Begin("ImGui Demo", p_opened, ImVec2(550,680), bg_alpha, window_flags))
|
|
|
{
|
|
|
// Early out if the window is collapsed, as an optimization.
|
|
|
ImGui::End();
|
|
|
@@ -168,6 +171,7 @@ void ImGui::ShowTestWindow(bool* opened)
|
|
|
ImGui::MenuItem("Console", NULL, &show_app_console);
|
|
|
ImGui::MenuItem("Log", NULL, &show_app_log);
|
|
|
ImGui::MenuItem("Simple layout", NULL, &show_app_layout);
|
|
|
+ ImGui::MenuItem("Property editor", NULL, &show_app_property_editor);
|
|
|
ImGui::MenuItem("Long text display", NULL, &show_app_long_text);
|
|
|
ImGui::MenuItem("Auto-resizing window", NULL, &show_app_auto_resize);
|
|
|
ImGui::MenuItem("Simple overlay", NULL, &show_app_fixed_overlay);
|
|
|
@@ -1205,142 +1209,135 @@ void ImGui::ShowTestWindow(bool* opened)
|
|
|
if (ImGui::CollapsingHeader("Columns"))
|
|
|
{
|
|
|
// Basic columns
|
|
|
- ImGui::Text("Basic:");
|
|
|
- ImGui::Columns(4, "mycolumns");
|
|
|
- ImGui::Separator();
|
|
|
- ImGui::Text("ID"); ImGui::NextColumn();
|
|
|
- ImGui::Text("Name"); ImGui::NextColumn();
|
|
|
- ImGui::Text("Path"); ImGui::NextColumn();
|
|
|
- ImGui::Text("Flags"); ImGui::NextColumn();
|
|
|
- ImGui::Separator();
|
|
|
- const char* names[3] = { "One", "Two", "Three" };
|
|
|
- const char* paths[3] = { "/path/one", "/path/two", "/path/three" };
|
|
|
- static int selected = -1;
|
|
|
- for (int i = 0; i < 3; i++)
|
|
|
- {
|
|
|
- char label[32];
|
|
|
- sprintf(label, "%04d", i);
|
|
|
- if (ImGui::Selectable(label, selected == i, ImGuiSelectableFlags_SpanAllColumns))
|
|
|
- selected = i;
|
|
|
- ImGui::NextColumn();
|
|
|
- ImGui::Text(names[i]); ImGui::NextColumn();
|
|
|
- ImGui::Text(paths[i]); ImGui::NextColumn();
|
|
|
- ImGui::Text("...."); ImGui::NextColumn();
|
|
|
+ if (ImGui::TreeNode("Basic"))
|
|
|
+ {
|
|
|
+ ImGui::Columns(4, "mycolumns");
|
|
|
+ ImGui::Separator();
|
|
|
+ ImGui::Text("ID"); ImGui::NextColumn();
|
|
|
+ ImGui::Text("Name"); ImGui::NextColumn();
|
|
|
+ ImGui::Text("Path"); ImGui::NextColumn();
|
|
|
+ ImGui::Text("Flags"); ImGui::NextColumn();
|
|
|
+ ImGui::Separator();
|
|
|
+ const char* names[3] = { "One", "Two", "Three" };
|
|
|
+ const char* paths[3] = { "/path/one", "/path/two", "/path/three" };
|
|
|
+ static int selected = -1;
|
|
|
+ for (int i = 0; i < 3; i++)
|
|
|
+ {
|
|
|
+ char label[32];
|
|
|
+ sprintf(label, "%04d", i);
|
|
|
+ if (ImGui::Selectable(label, selected == i, ImGuiSelectableFlags_SpanAllColumns))
|
|
|
+ selected = i;
|
|
|
+ ImGui::NextColumn();
|
|
|
+ ImGui::Text(names[i]); ImGui::NextColumn();
|
|
|
+ ImGui::Text(paths[i]); ImGui::NextColumn();
|
|
|
+ ImGui::Text("...."); ImGui::NextColumn();
|
|
|
+ }
|
|
|
+ ImGui::Columns(1);
|
|
|
+ ImGui::Separator();
|
|
|
+ ImGui::TreePop();
|
|
|
}
|
|
|
- ImGui::Columns(1);
|
|
|
-
|
|
|
- ImGui::Separator();
|
|
|
- ImGui::Spacing();
|
|
|
|
|
|
// Scrolling columns
|
|
|
/*
|
|
|
- ImGui::Text("Scrolling:");
|
|
|
- ImGui::BeginChild("##header", ImVec2(0, ImGui::GetTextLineHeightWithSpacing()+ImGui::GetStyle().ItemSpacing.y));
|
|
|
- ImGui::Columns(3);
|
|
|
- ImGui::Text("ID"); ImGui::NextColumn();
|
|
|
- ImGui::Text("Name"); ImGui::NextColumn();
|
|
|
- ImGui::Text("Path"); ImGui::NextColumn();
|
|
|
- ImGui::Columns(1);
|
|
|
- ImGui::Separator();
|
|
|
- ImGui::EndChild();
|
|
|
- ImGui::BeginChild("##scrollingregion", ImVec2(0, 60));
|
|
|
- ImGui::Columns(3);
|
|
|
- for (int i = 0; i < 10; i++)
|
|
|
+ if (ImGui::TreeNode("Scrolling"))
|
|
|
{
|
|
|
- ImGui::Text("%04d", i); ImGui::NextColumn();
|
|
|
- ImGui::Text("Foobar"); ImGui::NextColumn();
|
|
|
- ImGui::Text("/path/foobar/%04d/", i); ImGui::NextColumn();
|
|
|
+ ImGui::BeginChild("##header", ImVec2(0, ImGui::GetTextLineHeightWithSpacing()+ImGui::GetStyle().ItemSpacing.y));
|
|
|
+ ImGui::Columns(3);
|
|
|
+ ImGui::Text("ID"); ImGui::NextColumn();
|
|
|
+ ImGui::Text("Name"); ImGui::NextColumn();
|
|
|
+ ImGui::Text("Path"); ImGui::NextColumn();
|
|
|
+ ImGui::Columns(1);
|
|
|
+ ImGui::Separator();
|
|
|
+ ImGui::EndChild();
|
|
|
+ ImGui::BeginChild("##scrollingregion", ImVec2(0, 60));
|
|
|
+ ImGui::Columns(3);
|
|
|
+ for (int i = 0; i < 10; i++)
|
|
|
+ {
|
|
|
+ ImGui::Text("%04d", i); ImGui::NextColumn();
|
|
|
+ ImGui::Text("Foobar"); ImGui::NextColumn();
|
|
|
+ ImGui::Text("/path/foobar/%04d/", i); ImGui::NextColumn();
|
|
|
+ }
|
|
|
+ ImGui::Columns(1);
|
|
|
+ ImGui::EndChild();
|
|
|
+ ImGui::TreePop();
|
|
|
}
|
|
|
- ImGui::Columns(1);
|
|
|
- ImGui::EndChild();
|
|
|
-
|
|
|
- ImGui::Separator();
|
|
|
- ImGui::Spacing();
|
|
|
*/
|
|
|
|
|
|
// Create multiple items in a same cell before switching to next column
|
|
|
- ImGui::Text("Mixed items:");
|
|
|
- ImGui::Columns(3, "mixed");
|
|
|
- ImGui::Separator();
|
|
|
-
|
|
|
- static int e = 0;
|
|
|
- ImGui::Text("Hello");
|
|
|
- ImGui::Button("Banana");
|
|
|
- ImGui::RadioButton("radio a", &e, 0);
|
|
|
- ImGui::NextColumn();
|
|
|
-
|
|
|
- ImGui::Text("ImGui");
|
|
|
- ImGui::Button("Apple");
|
|
|
- ImGui::RadioButton("radio b", &e, 1);
|
|
|
- static float foo = 1.0f;
|
|
|
- ImGui::InputFloat("red", &foo, 0.05f, 0, 3);
|
|
|
- ImGui::Text("An extra line here.");
|
|
|
- ImGui::NextColumn();
|
|
|
-
|
|
|
- ImGui::Text("Sailor");
|
|
|
- ImGui::Button("Corniflower");
|
|
|
- ImGui::RadioButton("radio c", &e, 2);
|
|
|
- static float bar = 1.0f;
|
|
|
- ImGui::InputFloat("blue", &bar, 0.05f, 0, 3);
|
|
|
- ImGui::NextColumn();
|
|
|
+ if (ImGui::TreeNode("Mixed items"))
|
|
|
+ {
|
|
|
+ ImGui::Columns(3, "mixed");
|
|
|
+ ImGui::Separator();
|
|
|
|
|
|
- if (ImGui::CollapsingHeader("Category A")) ImGui::Text("Blah blah blah"); ImGui::NextColumn();
|
|
|
- if (ImGui::CollapsingHeader("Category B")) ImGui::Text("Blah blah blah"); ImGui::NextColumn();
|
|
|
- if (ImGui::CollapsingHeader("Category C")) ImGui::Text("Blah blah blah"); ImGui::NextColumn();
|
|
|
- ImGui::Columns(1);
|
|
|
+ ImGui::Text("Hello");
|
|
|
+ ImGui::Button("Banana");
|
|
|
+ ImGui::NextColumn();
|
|
|
|
|
|
- ImGui::Separator();
|
|
|
- ImGui::Spacing();
|
|
|
+ ImGui::Text("ImGui");
|
|
|
+ ImGui::Button("Apple");
|
|
|
+ static float foo = 1.0f;
|
|
|
+ ImGui::InputFloat("red", &foo, 0.05f, 0, 3);
|
|
|
+ ImGui::Text("An extra line here.");
|
|
|
+ ImGui::NextColumn();
|
|
|
|
|
|
- // Tree items
|
|
|
- ImGui::Text("Tree items:");
|
|
|
- ImGui::Columns(2, "tree items");
|
|
|
- ImGui::Separator();
|
|
|
- if (ImGui::TreeNode("Hello")) { ImGui::BulletText("Sailor"); ImGui::TreePop(); } ImGui::NextColumn();
|
|
|
- if (ImGui::TreeNode("Bonjour")) { ImGui::BulletText("Marin"); ImGui::TreePop(); } ImGui::NextColumn();
|
|
|
- ImGui::Columns(1);
|
|
|
+ ImGui::Text("Sailor");
|
|
|
+ ImGui::Button("Corniflower");
|
|
|
+ static float bar = 1.0f;
|
|
|
+ ImGui::InputFloat("blue", &bar, 0.05f, 0, 3);
|
|
|
+ ImGui::NextColumn();
|
|
|
|
|
|
- ImGui::Separator();
|
|
|
- ImGui::Spacing();
|
|
|
+ if (ImGui::CollapsingHeader("Category A")) ImGui::Text("Blah blah blah"); ImGui::NextColumn();
|
|
|
+ if (ImGui::CollapsingHeader("Category B")) ImGui::Text("Blah blah blah"); ImGui::NextColumn();
|
|
|
+ if (ImGui::CollapsingHeader("Category C")) ImGui::Text("Blah blah blah"); ImGui::NextColumn();
|
|
|
+ ImGui::Columns(1);
|
|
|
+ ImGui::Separator();
|
|
|
+ ImGui::TreePop();
|
|
|
+ }
|
|
|
|
|
|
// Word wrapping
|
|
|
- ImGui::Text("Word-wrapping:");
|
|
|
- ImGui::Columns(2, "word-wrapping");
|
|
|
- ImGui::Separator();
|
|
|
- ImGui::TextWrapped("The quick brown fox jumps over the lazy dog.");
|
|
|
- ImGui::Text("Hello Left");
|
|
|
- ImGui::NextColumn();
|
|
|
- ImGui::TextWrapped("The quick brown fox jumps over the lazy dog.");
|
|
|
- ImGui::Text("Hello Right");
|
|
|
- ImGui::Columns(1);
|
|
|
-
|
|
|
- ImGui::Separator();
|
|
|
- ImGui::Spacing();
|
|
|
+ if (ImGui::TreeNode("Word-wrapping"))
|
|
|
+ {
|
|
|
+ ImGui::Columns(2, "word-wrapping");
|
|
|
+ ImGui::Separator();
|
|
|
+ ImGui::TextWrapped("The quick brown fox jumps over the lazy dog.");
|
|
|
+ ImGui::TextWrapped("Hello Left");
|
|
|
+ ImGui::NextColumn();
|
|
|
+ ImGui::TextWrapped("The quick brown fox jumps over the lazy dog.");
|
|
|
+ ImGui::TextWrapped("Hello Right");
|
|
|
+ ImGui::Columns(1);
|
|
|
+ ImGui::Separator();
|
|
|
+ ImGui::TreePop();
|
|
|
+ }
|
|
|
|
|
|
- if (ImGui::TreeNode("Inside a tree.."))
|
|
|
+ if (ImGui::TreeNode("Borders"))
|
|
|
{
|
|
|
- if (ImGui::TreeNode("node 1 (with borders)"))
|
|
|
- {
|
|
|
- ImGui::Columns(4);
|
|
|
- for (int i = 0; i < 8; i++)
|
|
|
- {
|
|
|
- ImGui::Text("%c%c%c", 'a'+i, 'a'+i, 'a'+i);
|
|
|
- ImGui::NextColumn();
|
|
|
- }
|
|
|
- ImGui::Columns(1);
|
|
|
- ImGui::TreePop();
|
|
|
- }
|
|
|
- if (ImGui::TreeNode("node 2 (without borders)"))
|
|
|
+ static bool h_borders = true;
|
|
|
+ static bool v_borders = true;
|
|
|
+ ImGui::Checkbox("horizontal", &h_borders);
|
|
|
+ ImGui::SameLine();
|
|
|
+ ImGui::Checkbox("vertical", &v_borders);
|
|
|
+ ImGui::Columns(4, NULL, v_borders);
|
|
|
+ if (h_borders) ImGui::Separator();
|
|
|
+ for (int i = 0; i < 8; i++)
|
|
|
{
|
|
|
- ImGui::Columns(4, NULL, false);
|
|
|
- for (int i = 0; i < 8; i++)
|
|
|
- {
|
|
|
- ImGui::Text("%c%c%c", 'a'+i, 'a'+i, 'a'+i);
|
|
|
- ImGui::NextColumn();
|
|
|
- }
|
|
|
- ImGui::Columns(1);
|
|
|
- ImGui::TreePop();
|
|
|
+ ImGui::Text("%c%c%c", 'a'+i, 'a'+i, 'a'+i);
|
|
|
+ ImGui::NextColumn();
|
|
|
}
|
|
|
+ ImGui::Columns(1);
|
|
|
+ if (h_borders) ImGui::Separator();
|
|
|
+ ImGui::TreePop();
|
|
|
+ }
|
|
|
+
|
|
|
+ bool opened = ImGui::TreeNode("Tree within single cell");
|
|
|
+ ImGui::SameLine(); ShowHelpMarker("NB: Tree node must be poped before ending the cell.\nThere's no storage of state per-cell.");
|
|
|
+ if (opened)
|
|
|
+ {
|
|
|
+ ImGui::Columns(2, "tree items");
|
|
|
+ ImGui::Separator();
|
|
|
+ if (ImGui::TreeNode("Hello")) { ImGui::BulletText("Sailor"); ImGui::TreePop(); } ImGui::NextColumn();
|
|
|
+ if (ImGui::TreeNode("Bonjour")) { ImGui::BulletText("Marin"); ImGui::TreePop(); } ImGui::NextColumn();
|
|
|
+ ImGui::Columns(1);
|
|
|
+ ImGui::Separator();
|
|
|
ImGui::TreePop();
|
|
|
}
|
|
|
}
|
|
|
@@ -2179,6 +2176,78 @@ static void ShowExampleAppLayout(bool* opened)
|
|
|
ImGui::End();
|
|
|
}
|
|
|
|
|
|
+static void ShowExampleAppPropertyEditor(bool* opened)
|
|
|
+{
|
|
|
+ ImGui::SetNextWindowSize(ImVec2(430,450), ImGuiSetCond_FirstUseEver);
|
|
|
+ if (!ImGui::Begin("Example: Property editor", opened))
|
|
|
+ {
|
|
|
+ ImGui::End();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ ShowHelpMarker("This example shows how you may implement a property editor using two columns.\nAll objects/fields data are dummies here.\nRemember that in many simple cases, you can use ImGui::SameLine(xxx) to position\nyour cursor horizontally instead of using the Columns() API.");
|
|
|
+
|
|
|
+ ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(2,2));
|
|
|
+ ImGui::Columns(2);
|
|
|
+ ImGui::Separator();
|
|
|
+
|
|
|
+ ImGui::Text("Item1"); ImGui::NextColumn();
|
|
|
+ ImGui::Text("value1"); ImGui::NextColumn();
|
|
|
+
|
|
|
+ struct funcs
|
|
|
+ {
|
|
|
+ static void ShowDummyObject(const char* prefix, ImU32 uid)
|
|
|
+ {
|
|
|
+ ImGui::PushID(uid); // Use object uid as identifier. Most commonly you could also use the object pointer as a base ID.
|
|
|
+ bool opened = ImGui::TreeNode("Object", "%s_%u", prefix, uid);
|
|
|
+ ImGui::NextColumn();
|
|
|
+ ImGui::Text("my sailor is rich");
|
|
|
+ ImGui::NextColumn();
|
|
|
+ if (opened)
|
|
|
+ {
|
|
|
+ static float dummy_members[8] = { 0.0f,0.0f,1.0f,3.1416f,100.0f,999.0f };
|
|
|
+ for (int i = 0; i < 8; i++)
|
|
|
+ {
|
|
|
+ ImGui::PushID(i); // Use field index as identifier.
|
|
|
+ if (i < 2)
|
|
|
+ {
|
|
|
+ ShowDummyObject("Child", ImGui::GetID("foo"));
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ ImGui::AlignFirstTextHeightToWidgets();
|
|
|
+ // Here we use a Selectable (instead of Text) to highlight on hover
|
|
|
+ //ImGui::Text("Field_%d", i);
|
|
|
+ char label[32];
|
|
|
+ sprintf(label, "Field_%d", i);
|
|
|
+ ImGui::Selectable(label);
|
|
|
+ ImGui::NextColumn();
|
|
|
+ ImGui::PushItemWidth(-1);
|
|
|
+ if (i >= 5)
|
|
|
+ ImGui::InputFloat("##value", &dummy_members[i], 1.0f);
|
|
|
+ else
|
|
|
+ ImGui::DragFloat("##value", &dummy_members[i], 0.01f);
|
|
|
+ ImGui::PopItemWidth();
|
|
|
+ ImGui::NextColumn();
|
|
|
+ }
|
|
|
+ ImGui::PopID();
|
|
|
+ }
|
|
|
+ ImGui::TreePop();
|
|
|
+ }
|
|
|
+ ImGui::PopID();
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ // Iterate dummy objects with dummy members (all the same data)
|
|
|
+ for (int obj_i = 0; obj_i < 3; obj_i++)
|
|
|
+ funcs::ShowDummyObject("Object", obj_i);
|
|
|
+
|
|
|
+ ImGui::Columns(1);
|
|
|
+ ImGui::Separator();
|
|
|
+ ImGui::PopStyleVar();
|
|
|
+ ImGui::End();
|
|
|
+}
|
|
|
+
|
|
|
static void ShowExampleAppLongText(bool* opened)
|
|
|
{
|
|
|
ImGui::SetNextWindowSize(ImVec2(520,600), ImGuiSetCond_FirstUseEver);
|