-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
incorporate r-lyeh's table variant from ocornut/imgui#513
- Loading branch information
Showing
7 changed files
with
193 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,65 @@ | ||
[Debug] | ||
Pos=131,11 | ||
Pos=192,219 | ||
Size=582,388 | ||
Collapsed=0 | ||
|
||
[ImGui Demo] | ||
Pos=824,220 | ||
Size=550,680 | ||
Collapsed=0 | ||
|
||
[Example: Console] | ||
Pos=73,62 | ||
Size=520,600 | ||
Collapsed=0 | ||
|
||
[Example: Log] | ||
Pos=60,60 | ||
Size=500,400 | ||
Collapsed=0 | ||
|
||
[Example: Layout] | ||
Pos=60,60 | ||
Size=500,440 | ||
Collapsed=0 | ||
|
||
[Example: Long text display] | ||
Pos=60,60 | ||
Size=520,600 | ||
Collapsed=0 | ||
|
||
[Same title as another window##1] | ||
Pos=100,100 | ||
Size=441,61 | ||
Collapsed=0 | ||
|
||
[Same title as another window##2] | ||
Pos=100,200 | ||
Size=441,61 | ||
Collapsed=0 | ||
|
||
[###AnimatedTitle] | ||
Pos=195,298 | ||
Size=238,48 | ||
Collapsed=0 | ||
|
||
[Example: Custom rendering] | ||
Pos=60,60 | ||
Size=350,560 | ||
Collapsed=0 | ||
|
||
[ImGui Metrics] | ||
Pos=60,60 | ||
Size=380,194 | ||
Collapsed=0 | ||
|
||
[About ImGui] | ||
Pos=60,60 | ||
Size=525,86 | ||
Collapsed=0 | ||
|
||
[Example: Constrained Resize] | ||
Pos=60,60 | ||
Size=200,200 | ||
Collapsed=0 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,15 @@ | ||
#pragma once | ||
|
||
#include "imgui.h" | ||
|
||
struct SDL_Window; | ||
typedef union SDL_Event SDL_Event; | ||
|
||
extern bool ImGui_ImplSdlGL3_Init(SDL_Window* window); | ||
extern void ImGui_ImplSdlGL3_Shutdown(); | ||
extern void ImGui_ImplSdlGL3_NewFrame(SDL_Window* window); | ||
extern bool ImGui_ImplSdlGL3_ProcessEvent(SDL_Event* event); | ||
IMGUI_API bool ImGui_ImplSdlGL3_Init(SDL_Window* window); | ||
IMGUI_API void ImGui_ImplSdlGL3_Shutdown(); | ||
IMGUI_API void ImGui_ImplSdlGL3_NewFrame(SDL_Window* window); | ||
IMGUI_API bool ImGui_ImplSdlGL3_ProcessEvent(SDL_Event* event); | ||
|
||
// Use if you want to reset your rendering device without losing ImGui state. | ||
extern void ImGui_ImplSdlGL3_InvalidateDeviceObjects(); | ||
extern bool ImGui_ImplSdlGL3_CreateDeviceObjects(); | ||
IMGUI_API void ImGui_ImplSdlGL3_InvalidateDeviceObjects(); | ||
IMGUI_API bool ImGui_ImplSdlGL3_CreateDeviceObjects(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
#pragma once | ||
|
||
#include "imgui.h" | ||
|
||
/* // [src] https://github.com/ocornut/imgui/issues/513 | ||
// Usage: | ||
static const char *headers[] = { | ||
"Index", "Color", "Flip?", "Filename" | ||
}; | ||
static float widths[ IM_ARRAYSIZE(headers) ] = {}; | ||
if( ImGui::BeginTable("WinTextureContent", headers, widths, IM_ARRAYSIZE(headers)) ) { | ||
// Draw as many rows as needed | ||
for( int i = 0; i < 10; ++i ) { | ||
ImGui::Text("%d", i); ImGui::NextColumn(); | ||
ImGui::ColorButton( ImVec4(0.5f,0.2f,i*0.3f,1.f)); ImGui::NextColumn(); | ||
ImGui::Text("%s", i % 2 ? "yes" : "no"); ImGui::NextColumn(); | ||
ImGui::Text(__FILE__); ImGui::NextColumn(); | ||
} | ||
ImGui::EndTable(); | ||
} | ||
*/ | ||
|
||
// .h | ||
namespace ImGui { | ||
IMGUI_API int BeginTable(const char* columnsId, const char** headers, float *widths, int count, bool border = true); | ||
IMGUI_API void EndTable(); | ||
} | ||
|
||
// .cpp | ||
namespace ImGui { | ||
static inline IMGUI_API | ||
int BeginTable(const char* columnsId, const char** headers, float* widths, int count, bool draw_border) { | ||
if (count <= 0) | ||
return 0; | ||
|
||
// Draw column headers | ||
ImGuiStyle & style = ImGui::GetStyle(); | ||
const ImVec2 firstTextSize = ImGui::CalcTextSize(headers[0], NULL, true); | ||
|
||
ImGui::BeginChild(columnsId, ImVec2(0, firstTextSize.y + 2 * style.ItemSpacing.y), true); | ||
|
||
char str_id[256]; | ||
sprintf(str_id, "tbl0_%s", columnsId); | ||
ImGui::Columns(count, str_id, draw_border); | ||
|
||
float offset = 0.0f; | ||
for (int i = 0; i < count; i++) { | ||
ImGui::SetColumnOffset(i, offset); | ||
|
||
if (widths[i] <= 0) { | ||
const ImVec2 textsize = ImGui::CalcTextSize(headers[i], NULL, true); | ||
const float colSizeX = (textsize.x + 2 * style.ItemSpacing.x); | ||
widths[i] = colSizeX + 1; | ||
} | ||
|
||
if (i < (count - 1)) { | ||
float curOffset = offset; | ||
offset = ImGui::GetColumnOffset(i + 1); | ||
widths[i] = offset - curOffset + 1; | ||
} | ||
|
||
ImGui::Text(headers[i]); | ||
ImGui::NextColumn(); | ||
} | ||
|
||
ImGui::Columns(1); | ||
ImGui::EndChild(); | ||
|
||
// Draw body | ||
str_id[3] = '1'; | ||
columnsId = str_id; | ||
|
||
ImGui::BeginChild(columnsId, ImVec2(0, 0), true); | ||
ImGui::Columns(count, columnsId, draw_border); | ||
|
||
offset = 0.0f; | ||
for (int i = 0; i < count; i++) { | ||
ImGui::SetColumnOffset(i, offset); | ||
offset += widths[i] - 1; | ||
} | ||
|
||
return 1; | ||
} | ||
|
||
static inline IMGUI_API | ||
void EndTable() { | ||
ImGui::Columns(1); | ||
ImGui::EndChild(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters