mirror of
https://github.com/Drezil/imgui.git
synced 2024-12-18 14:16:36 +00:00
Merge branch 'master' into navigation
This commit is contained in:
commit
2b8224692e
@ -1,6 +1,6 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2014-2017 Omar Cornut and ImGui contributors
|
||||
Copyright (c) 2014-2018 Omar Cornut
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
21
imgui.cpp
21
imgui.cpp
@ -1736,7 +1736,7 @@ void ImGuiTextBuffer::appendf(const char* fmt, ...)
|
||||
// ImGuiSimpleColumns (internal use only)
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
ImGuiSimpleColumns::ImGuiSimpleColumns()
|
||||
ImGuiMenuColumns::ImGuiMenuColumns()
|
||||
{
|
||||
Count = 0;
|
||||
Spacing = Width = NextWidth = 0.0f;
|
||||
@ -1744,7 +1744,7 @@ ImGuiSimpleColumns::ImGuiSimpleColumns()
|
||||
memset(NextWidths, 0, sizeof(NextWidths));
|
||||
}
|
||||
|
||||
void ImGuiSimpleColumns::Update(int count, float spacing, bool clear)
|
||||
void ImGuiMenuColumns::Update(int count, float spacing, bool clear)
|
||||
{
|
||||
IM_ASSERT(Count <= IM_ARRAYSIZE(Pos));
|
||||
Count = count;
|
||||
@ -1761,7 +1761,7 @@ void ImGuiSimpleColumns::Update(int count, float spacing, bool clear)
|
||||
}
|
||||
}
|
||||
|
||||
float ImGuiSimpleColumns::DeclColumns(float w0, float w1, float w2) // not using va_arg because they promote float to double
|
||||
float ImGuiMenuColumns::DeclColumns(float w0, float w1, float w2) // not using va_arg because they promote float to double
|
||||
{
|
||||
NextWidth = 0.0f;
|
||||
NextWidths[0] = ImMax(NextWidths[0], w0);
|
||||
@ -1772,7 +1772,7 @@ float ImGuiSimpleColumns::DeclColumns(float w0, float w1, float w2) // not using
|
||||
return ImMax(Width, NextWidth);
|
||||
}
|
||||
|
||||
float ImGuiSimpleColumns::CalcExtraSpace(float avail_w)
|
||||
float ImGuiMenuColumns::CalcExtraSpace(float avail_w)
|
||||
{
|
||||
return ImMax(0.0f, avail_w - Width);
|
||||
}
|
||||
@ -12180,6 +12180,10 @@ void ImGui::BeginColumns(const char* str_id, int columns_count, ImGuiColumnsFlag
|
||||
window->DC.ColumnsOffsetX = 0.0f;
|
||||
window->DC.CursorPos.x = (float)(int)(window->Pos.x + window->DC.IndentX + window->DC.ColumnsOffsetX);
|
||||
|
||||
// Clear data if columns count changed
|
||||
if (columns->Columns.Size != 0 && columns->Columns.Size != columns_count + 1)
|
||||
columns->Columns.resize(0);
|
||||
|
||||
// Initialize defaults
|
||||
columns->IsFirstFrame = (columns->Columns.Size == 0);
|
||||
if (columns->Columns.Size == 0)
|
||||
@ -12192,7 +12196,6 @@ void ImGui::BeginColumns(const char* str_id, int columns_count, ImGuiColumnsFlag
|
||||
columns->Columns.push_back(column);
|
||||
}
|
||||
}
|
||||
IM_ASSERT(columns->Columns.Size == columns_count + 1);
|
||||
|
||||
for (int n = 0; n < columns_count + 1; n++)
|
||||
{
|
||||
@ -12641,12 +12644,6 @@ void ImGui::EndDragDropTarget()
|
||||
IM_ASSERT(g.DragDropActive);
|
||||
}
|
||||
|
||||
bool ImGui::IsDragDropActive()
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
return g.DragDropActive;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// PLATFORM DEPENDENT HELPERS
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -12764,7 +12761,7 @@ void ImGui::ShowMetricsWindow(bool* p_open)
|
||||
{
|
||||
if (ImGui::Begin("ImGui Metrics", p_open))
|
||||
{
|
||||
ImGui::Text("ImGui %s", ImGui::GetVersion());
|
||||
ImGui::Text("Dear ImGui %s", ImGui::GetVersion());
|
||||
ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate);
|
||||
ImGui::Text("%d vertices, %d indices (%d triangles)", ImGui::GetIO().MetricsRenderVertices, ImGui::GetIO().MetricsRenderIndices, ImGui::GetIO().MetricsRenderIndices / 3);
|
||||
ImGui::Text("%d allocations", ImGui::GetIO().MetricsAllocs);
|
||||
|
5
imgui.h
5
imgui.h
@ -379,8 +379,8 @@ namespace ImGui
|
||||
IMGUI_API bool CollapsingHeader(const char* label, bool* p_open, ImGuiTreeNodeFlags flags = 0); // when 'p_open' isn't NULL, display an additional small close button on upper right of the header
|
||||
|
||||
// Widgets: Selectable / Lists
|
||||
IMGUI_API bool Selectable(const char* label, bool selected = false, ImGuiSelectableFlags flags = 0, const ImVec2& size = ImVec2(0,0)); // size.x==0.0: use remaining width, size.x>0.0: specify width. size.y==0.0: use label height, size.y>0.0: specify height
|
||||
IMGUI_API bool Selectable(const char* label, bool* p_selected, ImGuiSelectableFlags flags = 0, const ImVec2& size = ImVec2(0,0));
|
||||
IMGUI_API bool Selectable(const char* label, bool selected = false, ImGuiSelectableFlags flags = 0, const ImVec2& size = ImVec2(0,0)); // "bool selected" carry the selection state (read-only). Selectable() is clicked is returns true so you can modify your selection state. size.x==0.0: use remaining width, size.x>0.0: specify width. size.y==0.0: use label height, size.y>0.0: specify height
|
||||
IMGUI_API bool Selectable(const char* label, bool* p_selected, ImGuiSelectableFlags flags = 0, const ImVec2& size = ImVec2(0,0)); // "bool* p_selected" point to the selection state (read-write), as a convenient helper.
|
||||
IMGUI_API bool ListBox(const char* label, int* current_item, const char* const items[], int items_count, int height_in_items = -1);
|
||||
IMGUI_API bool ListBox(const char* label, int* current_item, bool (*items_getter)(void* data, int idx, const char** out_text), void* data, int items_count, int height_in_items = -1);
|
||||
IMGUI_API bool ListBoxHeader(const char* label, const ImVec2& size = ImVec2(0,0)); // use if you want to reimplement ListBox() will custom data or interactions. make sure to call ListBoxFooter() afterwards.
|
||||
@ -437,7 +437,6 @@ namespace ImGui
|
||||
IMGUI_API bool BeginDragDropTarget(); // call after submitting an item that may receive an item. If this returns true, you can call AcceptDragDropPayload() + EndDragDropTarget()
|
||||
IMGUI_API const ImGuiPayload* AcceptDragDropPayload(const char* type, ImGuiDragDropFlags flags = 0); // accept contents of a given type. If ImGuiDragDropFlags_AcceptBeforeDelivery is set you can peek into the payload before the mouse button is released.
|
||||
IMGUI_API void EndDragDropTarget();
|
||||
IMGUI_API bool IsDragDropActive();
|
||||
|
||||
// Clipping
|
||||
IMGUI_API void PushClipRect(const ImVec2& clip_rect_min, const ImVec2& clip_rect_max, bool intersect_with_current_clip_rect);
|
||||
|
@ -160,7 +160,7 @@ void ImGui::ShowDemoWindow(bool* p_open)
|
||||
if (show_app_about)
|
||||
{
|
||||
ImGui::Begin("About Dear ImGui", &show_app_about, ImGuiWindowFlags_AlwaysAutoResize);
|
||||
ImGui::Text("dear imgui, %s", ImGui::GetVersion());
|
||||
ImGui::Text("Dear ImGui, %s", ImGui::GetVersion());
|
||||
ImGui::Separator();
|
||||
ImGui::Text("By Omar Cornut and all dear imgui contributors.");
|
||||
ImGui::Text("Dear ImGui is licensed under the MIT License, see LICENSE for more information.");
|
||||
@ -416,7 +416,7 @@ void ImGui::ShowDemoWindow(bool* p_open)
|
||||
{
|
||||
ImGui::Text("blah blah");
|
||||
ImGui::SameLine();
|
||||
if (ImGui::SmallButton("print")) printf("Child %d pressed", i);
|
||||
if (ImGui::SmallButton("button")) { };
|
||||
ImGui::TreePop();
|
||||
}
|
||||
ImGui::TreePop();
|
||||
@ -612,24 +612,58 @@ void ImGui::ShowDemoWindow(bool* p_open)
|
||||
|
||||
if (ImGui::TreeNode("Selectables"))
|
||||
{
|
||||
// Selectable() has 2 overloads:
|
||||
// - The one taking "bool selected" as a read-only selection information. When Selectable() has been clicked is returns true and you can alter selection state accordingly.
|
||||
// - The one taking "bool* p_selected" as a read-write selection information (convenient in some cases)
|
||||
// The earlier is more flexible, as in real application your selection may be stored in a different manner (in flags within objects, as an external list, etc).
|
||||
if (ImGui::TreeNode("Basic"))
|
||||
{
|
||||
static bool selected[4] = { false, true, false, false };
|
||||
ImGui::Selectable("1. I am selectable", &selected[0]);
|
||||
ImGui::Selectable("2. I am selectable", &selected[1]);
|
||||
static bool selection[5] = { false, true, false, false, false };
|
||||
ImGui::Selectable("1. I am selectable", &selection[0]);
|
||||
ImGui::Selectable("2. I am selectable", &selection[1]);
|
||||
ImGui::Text("3. I am not selectable");
|
||||
ImGui::Selectable("4. I am selectable", &selected[2]);
|
||||
if (ImGui::Selectable("5. I am double clickable", selected[3], ImGuiSelectableFlags_AllowDoubleClick))
|
||||
ImGui::Selectable("4. I am selectable", &selection[3]);
|
||||
if (ImGui::Selectable("5. I am double clickable", selection[4], ImGuiSelectableFlags_AllowDoubleClick))
|
||||
if (ImGui::IsMouseDoubleClicked(0))
|
||||
selected[3] = !selected[3];
|
||||
selection[4] = !selection[4];
|
||||
ImGui::TreePop();
|
||||
}
|
||||
if (ImGui::TreeNode("Rendering more text into the same block"))
|
||||
if (ImGui::TreeNode("Selection State: Single Selection"))
|
||||
{
|
||||
static int selected = -1;
|
||||
for (int n = 0; n < 5; n++)
|
||||
{
|
||||
char buf[32];
|
||||
sprintf(buf, "Object %d", n);
|
||||
if (ImGui::Selectable(buf, selected == n))
|
||||
selected = n;
|
||||
}
|
||||
ImGui::TreePop();
|
||||
}
|
||||
if (ImGui::TreeNode("Selection State: Multiple Selection"))
|
||||
{
|
||||
ShowHelpMarker("Hold CTRL and click to select multiple items.");
|
||||
static bool selection[5] = { false, false, false, false, false };
|
||||
for (int n = 0; n < 5; n++)
|
||||
{
|
||||
char buf[32];
|
||||
sprintf(buf, "Object %d", n);
|
||||
if (ImGui::Selectable(buf, selection[n]))
|
||||
{
|
||||
if (!ImGui::GetIO().KeyCtrl) // Clear selection when CTRL is not held
|
||||
memset(selection, 0, sizeof(selection));
|
||||
selection[n] ^= 1;
|
||||
}
|
||||
}
|
||||
ImGui::TreePop();
|
||||
}
|
||||
if (ImGui::TreeNode("Rendering more text into the same line"))
|
||||
{
|
||||
// Using the Selectable() override that takes "bool* p_selected" parameter and toggle your booleans automatically.
|
||||
static bool selected[3] = { false, false, false };
|
||||
ImGui::Selectable("main.c", &selected[0]); ImGui::SameLine(300); ImGui::Text(" 2,345 bytes");
|
||||
ImGui::Selectable("main.c", &selected[0]); ImGui::SameLine(300); ImGui::Text(" 2,345 bytes");
|
||||
ImGui::Selectable("Hello.cpp", &selected[1]); ImGui::SameLine(300); ImGui::Text("12,345 bytes");
|
||||
ImGui::Selectable("Hello.h", &selected[2]); ImGui::SameLine(300); ImGui::Text(" 2,345 bytes");
|
||||
ImGui::Selectable("Hello.h", &selected[2]); ImGui::SameLine(300); ImGui::Text(" 2,345 bytes");
|
||||
ImGui::TreePop();
|
||||
}
|
||||
if (ImGui::TreeNode("In columns"))
|
||||
@ -776,14 +810,14 @@ void ImGui::ShowDemoWindow(bool* p_open)
|
||||
{
|
||||
static ImVec4 color = ImColor(114, 144, 154, 200);
|
||||
|
||||
static bool hdr = false;
|
||||
static bool alpha_preview = true;
|
||||
static bool alpha_half_preview = false;
|
||||
static bool options_menu = true;
|
||||
ImGui::Checkbox("With HDR", &hdr); ImGui::SameLine(); ShowHelpMarker("Currently all this does is to lift the 0..1 limits on dragging widgets.");
|
||||
static bool hdr = false;
|
||||
ImGui::Checkbox("With Alpha Preview", &alpha_preview);
|
||||
ImGui::Checkbox("With Half Alpha Preview", &alpha_half_preview);
|
||||
ImGui::Checkbox("With Options Menu", &options_menu); ImGui::SameLine(); ShowHelpMarker("Right-click on the individual color widget to show options.");
|
||||
ImGui::Checkbox("With HDR", &hdr); ImGui::SameLine(); ShowHelpMarker("Currently all this does is to lift the 0..1 limits on dragging widgets.");
|
||||
int misc_flags = (hdr ? ImGuiColorEditFlags_HDR : 0) | (alpha_half_preview ? ImGuiColorEditFlags_AlphaPreviewHalf : (alpha_preview ? ImGuiColorEditFlags_AlphaPreview : 0)) | (options_menu ? 0 : ImGuiColorEditFlags_NoOptions);
|
||||
|
||||
ImGui::Text("Color widget:");
|
||||
|
@ -36,7 +36,7 @@ struct ImRect;
|
||||
struct ImGuiColMod;
|
||||
struct ImGuiStyleMod;
|
||||
struct ImGuiGroupData;
|
||||
struct ImGuiSimpleColumns;
|
||||
struct ImGuiMenuColumns;
|
||||
struct ImGuiDrawContext;
|
||||
struct ImGuiTextEditState;
|
||||
struct ImGuiMouseCursorData;
|
||||
@ -341,14 +341,14 @@ struct ImGuiGroupData
|
||||
};
|
||||
|
||||
// Simple column measurement currently used for MenuItem() only. This is very short-sighted/throw-away code and NOT a generic helper.
|
||||
struct IMGUI_API ImGuiSimpleColumns
|
||||
struct IMGUI_API ImGuiMenuColumns
|
||||
{
|
||||
int Count;
|
||||
float Spacing;
|
||||
float Width, NextWidth;
|
||||
float Pos[8], NextWidths[8];
|
||||
float Pos[4], NextWidths[4];
|
||||
|
||||
ImGuiSimpleColumns();
|
||||
ImGuiMenuColumns();
|
||||
void Update(int count, float spacing, bool clear);
|
||||
float DeclColumns(float w0, float w1, float w2);
|
||||
float CalcExtraSpace(float avail_w);
|
||||
@ -898,7 +898,7 @@ struct IMGUI_API ImGuiWindow
|
||||
ImRect InnerRect;
|
||||
int LastFrameActive;
|
||||
float ItemWidthDefault;
|
||||
ImGuiSimpleColumns MenuColumns; // Simplified columns storage for menu items
|
||||
ImGuiMenuColumns MenuColumns; // Simplified columns storage for menu items
|
||||
ImGuiStorage StateStorage;
|
||||
ImVector<ImGuiColumnsSet> ColumnsStorage;
|
||||
float FontWindowScale; // Scale multiplier per-window
|
||||
|
Loading…
Reference in New Issue
Block a user