1
0
mirror of https://github.com/ocornut/imgui.git synced 2024-11-28 09:30:56 +01:00

Merge remote-tracking branch 'origin' into 2015-04-indexed-rendering

Conflicts:
	imgui.cpp
This commit is contained in:
ocornut 2015-04-17 08:42:36 +01:00
commit 4f1acf0d4a
4 changed files with 32 additions and 26 deletions

View File

@ -1,6 +1,6 @@
The MIT License (MIT) The MIT License (MIT)
Copyright (c) 2014 Omar Cornut Copyright (c) 2014-2015 Omar Cornut and ImGui contributors
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal

View File

@ -35,6 +35,9 @@ static void ImGui_ImplGlfwGL3_RenderDrawLists(ImDrawList** const cmd_lists, int
return; return;
// Setup render state: alpha-blending enabled, no face culling, no depth testing, scissor enabled // Setup render state: alpha-blending enabled, no face culling, no depth testing, scissor enabled
GLint last_program, last_texture;
glGetIntegerv(GL_CURRENT_PROGRAM, &last_program);
glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture);
glEnable(GL_BLEND); glEnable(GL_BLEND);
glBlendEquation(GL_FUNC_ADD); glBlendEquation(GL_FUNC_ADD);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
@ -109,9 +112,9 @@ static void ImGui_ImplGlfwGL3_RenderDrawLists(ImDrawList** const cmd_lists, int
// Restore modified state // Restore modified state
glBindVertexArray(0); glBindVertexArray(0);
glUseProgram(0); glUseProgram(last_program);
glDisable(GL_SCISSOR_TEST); glDisable(GL_SCISSOR_TEST);
glBindTexture(GL_TEXTURE_2D, 0); glBindTexture(GL_TEXTURE_2D, last_texture);
} }
static const char* ImGui_ImplGlfwGL3_GetClipboardText() static const char* ImGui_ImplGlfwGL3_GetClipboardText()
@ -135,7 +138,7 @@ void ImGui_ImplGlfwGL3_ScrollCallback(GLFWwindow*, double /*xoffset*/, double yo
g_MouseWheel += (float)yoffset; // Use fractional mouse wheel, 1.0 unit 5 lines. g_MouseWheel += (float)yoffset; // Use fractional mouse wheel, 1.0 unit 5 lines.
} }
void ImGui_ImplGlfwGL3_KeyCallback(GLFWwindow* window, int key, int, int action, int mods) void ImGui_ImplGlfwGL3_KeyCallback(GLFWwindow*, int key, int, int action, int mods)
{ {
ImGuiIO& io = ImGui::GetIO(); ImGuiIO& io = ImGui::GetIO();
if (action == GLFW_PRESS) if (action == GLFW_PRESS)
@ -144,9 +147,9 @@ void ImGui_ImplGlfwGL3_KeyCallback(GLFWwindow* window, int key, int, int action,
io.KeysDown[key] = false; io.KeysDown[key] = false;
(void)mods; // Modifiers are not reliable across systems (void)mods; // Modifiers are not reliable across systems
io.KeyCtrl = glfwGetKey(window, GLFW_KEY_LEFT_CONTROL) == GLFW_PRESS || glfwGetKey(window, GLFW_KEY_RIGHT_CONTROL) == GLFW_PRESS; io.KeyCtrl = io.KeysDown[GLFW_KEY_LEFT_CONTROL] || io.KeysDown[GLFW_KEY_RIGHT_CONTROL];
io.KeyShift = glfwGetKey(window, GLFW_KEY_LEFT_SHIFT) == GLFW_PRESS || glfwGetKey(window, GLFW_KEY_RIGHT_SHIFT) == GLFW_PRESS; io.KeyShift = io.KeysDown[GLFW_KEY_LEFT_SHIFT] || io.KeysDown[GLFW_KEY_RIGHT_SHIFT];
io.KeyAlt = glfwGetKey(window, GLFW_KEY_LEFT_ALT) == GLFW_PRESS || glfwGetKey(window, GLFW_KEY_RIGHT_ALT) == GLFW_PRESS; io.KeyAlt = io.KeysDown[GLFW_KEY_LEFT_ALT] || io.KeysDown[GLFW_KEY_RIGHT_ALT];
} }
void ImGui_ImplGlfwGL3_CharCallback(GLFWwindow*, unsigned int c) void ImGui_ImplGlfwGL3_CharCallback(GLFWwindow*, unsigned int c)

View File

@ -116,7 +116,7 @@ void ImGui_ImplGlfw_ScrollCallback(GLFWwindow*, double /*xoffset*/, double yoffs
g_MouseWheel += (float)yoffset; // Use fractional mouse wheel, 1.0 unit 5 lines. g_MouseWheel += (float)yoffset; // Use fractional mouse wheel, 1.0 unit 5 lines.
} }
void ImGui_ImplGlFw_KeyCallback(GLFWwindow* window, int key, int, int action, int mods) void ImGui_ImplGlFw_KeyCallback(GLFWwindow*, int key, int, int action, int mods)
{ {
ImGuiIO& io = ImGui::GetIO(); ImGuiIO& io = ImGui::GetIO();
if (action == GLFW_PRESS) if (action == GLFW_PRESS)
@ -125,9 +125,9 @@ void ImGui_ImplGlFw_KeyCallback(GLFWwindow* window, int key, int, int action, in
io.KeysDown[key] = false; io.KeysDown[key] = false;
(void)mods; // Modifiers are not reliable across systems (void)mods; // Modifiers are not reliable across systems
io.KeyCtrl = glfwGetKey(window, GLFW_KEY_LEFT_CONTROL) == GLFW_PRESS || glfwGetKey(window, GLFW_KEY_RIGHT_CONTROL) == GLFW_PRESS; io.KeyCtrl = io.KeysDown[GLFW_KEY_LEFT_CONTROL] || io.KeysDown[GLFW_KEY_RIGHT_CONTROL];
io.KeyShift = glfwGetKey(window, GLFW_KEY_LEFT_SHIFT) == GLFW_PRESS || glfwGetKey(window, GLFW_KEY_RIGHT_SHIFT) == GLFW_PRESS; io.KeyShift = io.KeysDown[GLFW_KEY_LEFT_SHIFT] || io.KeysDown[GLFW_KEY_RIGHT_SHIFT];
io.KeyAlt = glfwGetKey(window, GLFW_KEY_LEFT_ALT) == GLFW_PRESS || glfwGetKey(window, GLFW_KEY_RIGHT_ALT) == GLFW_PRESS; io.KeyAlt = io.KeysDown[GLFW_KEY_LEFT_ALT] || io.KeysDown[GLFW_KEY_RIGHT_ALT];
} }
void ImGui_ImplGlfw_CharCallback(GLFWwindow*, unsigned int c) void ImGui_ImplGlfw_CharCallback(GLFWwindow*, unsigned int c)

View File

@ -2,7 +2,7 @@
// See ImGui::ShowTestWindow() for sample code. // See ImGui::ShowTestWindow() for sample code.
// Read 'Programmer guide' below for notes on how to setup ImGui in your codebase. // Read 'Programmer guide' below for notes on how to setup ImGui in your codebase.
// Get latest version at https://github.com/ocornut/imgui // Get latest version at https://github.com/ocornut/imgui
// Developed by Omar Cornut and contributors. // Developed by Omar Cornut and ImGui contributors.
/* /*
@ -327,16 +327,16 @@
- layout: horizontal layout helper (github issue #97) - layout: horizontal layout helper (github issue #97)
- layout: more generic alignment state (left/right/centered) for single items? - layout: more generic alignment state (left/right/centered) for single items?
- layout: clean up the InputFloatN/SliderFloatN/ColorEdit4 layout code. item width should include frame padding. - layout: clean up the InputFloatN/SliderFloatN/ColorEdit4 layout code. item width should include frame padding.
- columns: separator function or parameter that works within the column (currently Separator() bypass all columns) - columns: separator function or parameter that works within the column (currently Separator() bypass all columns) (github issue #125)
- columns: declare column set (each column: fixed size, %, fill, distribute default size among fills) - columns: declare column set (each column: fixed size, %, fill, distribute default size among fills) (github issue #125)
- columns: columns header to act as button (~sort op) and allow resize/reorder - columns: columns header to act as button (~sort op) and allow resize/reorder (github issue #125)
- columns: user specify columns size - columns: user specify columns size (github issue #125)
- columns: tree node example, removing the last NextColumn() makes a padding difference (it should not) - popup: border options. richer api like BeginChild() perhaps? (github issue #197)
- combo: turn child handling code into pop up helper - combo: turn child handling code into pop up helper
- combo: contents should extends to fit label if combo widget is small - combo: contents should extends to fit label if combo widget is small
- listbox: multiple selection - listbox: multiple selection
- listbox: user may want to initial scroll to focus on the one selected value? - listbox: user may want to initial scroll to focus on the one selected value?
! menubar, menus ! menubar, menus (github issue #126)
- tabs - tabs
- gauge: various forms of gauge/loading bars widgets - gauge: various forms of gauge/loading bars widgets
- color: better color editor. - color: better color editor.
@ -4357,9 +4357,11 @@ static inline bool IsWindowContentHoverable(ImGuiWindow* window)
{ {
ImGuiState& g = *GImGui; ImGuiState& g = *GImGui;
ImGuiWindow* focused_window = g.FocusedWindow; // An active popup disable hovering on other windows (apart from its own children)
if (focused_window && (focused_window->Flags & ImGuiWindowFlags_Popup) != 0 && focused_window->WasVisible && focused_window != window) if (ImGuiWindow* focused_window = g.FocusedWindow)
return false; if (ImGuiWindow* focused_root_window = focused_window->RootWindow)
if ((focused_root_window->Flags & ImGuiWindowFlags_Popup) != 0 && focused_root_window->WasVisible && focused_root_window != window->RootWindow)
return false;
return true; return true;
} }
@ -8233,7 +8235,7 @@ ImFont* ImFontAtlas::AddFontFromFileTTF(const char* filename, float size_pixels,
return NULL; return NULL;
} }
ImFont* font = AddFontFromMemoryTTF(data, data_size, size_pixels, glyph_ranges, font_no); ImFont* font = AddFontFromMemoryTTF(data, (unsigned int)data_size, size_pixels, glyph_ranges, font_no);
return font; return font;
} }
@ -8270,7 +8272,7 @@ ImFont* ImFontAtlas::AddFontFromMemoryCompressedTTF(const void* in_compressed_tt
stb_decompress(buf_decompressed, (unsigned char*)in_compressed_ttf_data, in_compressed_ttf_data_size); stb_decompress(buf_decompressed, (unsigned char*)in_compressed_ttf_data, in_compressed_ttf_data_size);
// Add // Add
ImFont* font = AddFontFromMemoryTTF(buf_decompressed, buf_decompressed_size, size_pixels, glyph_ranges, font_no); ImFont* font = AddFontFromMemoryTTF(buf_decompressed, (unsigned int)buf_decompressed_size, size_pixels, glyph_ranges, font_no);
return font; return font;
} }
@ -8486,7 +8488,8 @@ void ImFontAtlas::RenderCustomTexData(int pass, void* p_rects)
ImVector<stbrp_rect>& rects = *(ImVector<stbrp_rect>*)p_rects; ImVector<stbrp_rect>& rects = *(ImVector<stbrp_rect>*)p_rects;
if (pass == 0) if (pass == 0)
{ {
stbrp_rect r = { 0 }; stbrp_rect r;
memset(&r, 0, sizeof(r));
r.w = (TEX_DATA_W*2)+1; r.w = (TEX_DATA_W*2)+1;
r.h = TEX_DATA_H+1; r.h = TEX_DATA_H+1;
rects.push_back(r); rects.push_back(r);
@ -10532,13 +10535,13 @@ void ImGui::ShowMetricsWindow(bool* opened)
{ {
static void NodeDrawList(ImDrawList* draw_list, const char* label) static void NodeDrawList(ImDrawList* draw_list, const char* label)
{ {
bool opened = ImGui::TreeNode(draw_list, "%s: %d vtx, %d indices, %d cmds", label, draw_list->vtx_buffer.size(), draw_list->idx_buffer.size(), draw_list->commands.size()); bool node_opened = ImGui::TreeNode(draw_list, "%s: %d vtx, %d indices, %d cmds", label, draw_list->vtx_buffer.size(), draw_list->idx_buffer.size(), draw_list->commands.size());
if (draw_list == ImGui::GetWindowDrawList()) if (draw_list == ImGui::GetWindowDrawList())
{ {
ImGui::SameLine(); ImGui::SameLine();
ImGui::TextColored(ImColor(255,100,100), "CURRENTLY APPENDING"); // Can't display stats for active draw list! (we don't have the data double-buffered) ImGui::TextColored(ImColor(255,100,100), "CURRENTLY APPENDING"); // Can't display stats for active draw list! (we don't have the data double-buffered)
} }
if (!opened) if (!node_opened)
return; return;
for (const ImDrawCmd* pcmd = draw_list->commands.begin(); pcmd < draw_list->commands.end(); pcmd++) for (const ImDrawCmd* pcmd = draw_list->commands.begin(); pcmd < draw_list->commands.end(); pcmd++)
if (pcmd->user_callback) if (pcmd->user_callback)