mirror of
https://github.com/shadps4-emu/ext-imgui.git
synced 2024-11-23 18:29:42 +00:00
Comments in demo and opengl code + Internals: Added HoveredIdNotActiveTimer tracking hovering time unless the item is active, which is a commonly useful pattern.
This commit is contained in:
parent
e610afeea3
commit
ac9aaf4b6e
@ -306,7 +306,7 @@ void ImGui_ImplOpenGL3_DestroyFontsTexture()
|
||||
}
|
||||
}
|
||||
|
||||
// If you get an error please report on github. You may try different GL context version or GLSL version.
|
||||
// If you get an error please report on github. You may try different GL context version or GLSL version. See GL<>GLSL version table at the top of this file.
|
||||
static bool CheckShader(GLuint handle, const char* desc)
|
||||
{
|
||||
GLint status = 0, log_length = 0;
|
||||
@ -324,14 +324,14 @@ static bool CheckShader(GLuint handle, const char* desc)
|
||||
return (GLboolean)status == GL_TRUE;
|
||||
}
|
||||
|
||||
// If you get an error please report on github. You may try different GL context version or GLSL version.
|
||||
// If you get an error please report on GitHub. You may try different GL context version or GLSL version.
|
||||
static bool CheckProgram(GLuint handle, const char* desc)
|
||||
{
|
||||
GLint status = 0, log_length = 0;
|
||||
glGetProgramiv(handle, GL_LINK_STATUS, &status);
|
||||
glGetProgramiv(handle, GL_INFO_LOG_LENGTH, &log_length);
|
||||
if ((GLboolean)status == GL_FALSE)
|
||||
fprintf(stderr, "ERROR: ImGui_ImplOpenGL3_CreateDeviceObjects: failed to link %s!\n", desc);
|
||||
fprintf(stderr, "ERROR: ImGui_ImplOpenGL3_CreateDeviceObjects: failed to link %s! (with GLSL '%s')\n", desc, g_GlslVersionString);
|
||||
if (log_length > 0)
|
||||
{
|
||||
ImVector<char> buf;
|
||||
|
@ -2511,7 +2511,7 @@ void ImGui::SetHoveredID(ImGuiID id)
|
||||
g.HoveredId = id;
|
||||
g.HoveredIdAllowOverlap = false;
|
||||
if (id != 0 && g.HoveredIdPreviousFrame != id)
|
||||
g.HoveredIdTimer = 0.0f;
|
||||
g.HoveredIdTimer = g.HoveredIdNotActiveTimer = 0.0f;
|
||||
}
|
||||
|
||||
ImGuiID ImGui::GetHoveredID()
|
||||
@ -3191,8 +3191,12 @@ void ImGui::NewFrame()
|
||||
// Clear reference to active widget if the widget isn't alive anymore
|
||||
if (!g.HoveredIdPreviousFrame)
|
||||
g.HoveredIdTimer = 0.0f;
|
||||
if (!g.HoveredIdPreviousFrame || (g.HoveredId && g.ActiveId == g.HoveredId))
|
||||
g.HoveredIdNotActiveTimer = 0.0f;
|
||||
if (g.HoveredId)
|
||||
g.HoveredIdTimer += g.IO.DeltaTime;
|
||||
if (g.HoveredId && g.ActiveId != g.HoveredId)
|
||||
g.HoveredIdNotActiveTimer += g.IO.DeltaTime;
|
||||
g.HoveredIdPreviousFrame = g.HoveredId;
|
||||
g.HoveredId = 0;
|
||||
g.HoveredIdAllowOverlap = false;
|
||||
|
@ -1,22 +1,25 @@
|
||||
// dear imgui, v1.66 WIP
|
||||
// (demo code)
|
||||
|
||||
// Message to the person tempted to delete this file when integrating ImGui into their code base:
|
||||
// Don't do it! Do NOT remove this file from your project! It is useful reference code that you and other users will want to refer to.
|
||||
// Message to the person tempted to delete this file when integrating Dear ImGui into their code base:
|
||||
// Do NOT remove this file from your project! Think again! It is the most useful reference code that you and other coders
|
||||
// will want to refer to and call. Have the ImGui::ShowDemoWindow() function wired in an always-available debug menu of
|
||||
// your game/app! Removing this file from your project is hindering access to documentation for everyone in your team,
|
||||
// likely leading you to poorer usage of the library.
|
||||
// Everything in this file will be stripped out by the linker if you don't call ImGui::ShowDemoWindow().
|
||||
// During development, you can call ImGui::ShowDemoWindow() in your code to learn about various features of ImGui. Have it wired in a debug menu!
|
||||
// Removing this file from your project is hindering access to documentation for everyone in your team, likely leading you to poorer usage of the library.
|
||||
// Note that you can #define IMGUI_DISABLE_DEMO_WINDOWS in imconfig.h for the same effect.
|
||||
// If you want to link core ImGui in your final builds but not those demo windows, #define IMGUI_DISABLE_DEMO_WINDOWS in imconfig.h and those functions will be empty.
|
||||
// In other situation, when you have ImGui available you probably want this to be available for reference and execution.
|
||||
// If you want to link core Dear ImGui in your shipped builds but want an easy guarantee that the demo will not be linked,
|
||||
// you can setup your imconfig.h with #define IMGUI_DISABLE_DEMO_WINDOWS and those functions will be empty.
|
||||
// In other situation, whenever you have Dear ImGui available you probably want this to be available for reference.
|
||||
// Thank you,
|
||||
// -Your beloved friend, imgui_demo.cpp (that you won't delete)
|
||||
|
||||
// Message to beginner C/C++ programmers about the meaning of the 'static' keyword: in this demo code, we frequently we use 'static' variables inside functions.
|
||||
// A static variable persist across calls, so it is essentially like a global variable but declared inside the scope of the function.
|
||||
// We do this as a way to gather code and data in the same place, just to make the demo code faster to read, faster to write, and use less code.
|
||||
// It also happens to be a convenient way of storing simple UI related information as long as your function doesn't need to be reentrant or used in threads.
|
||||
// This might be a pattern you occasionally want to use in your code, but most of the real data you would be editing is likely to be stored outside your functions.
|
||||
// Message to beginner C/C++ programmers about the meaning of the 'static' keyword:
|
||||
// In this demo code, we frequently we use 'static' variables inside functions. A static variable persist across calls, so it is
|
||||
// essentially like a global variable but declared inside the scope of the function. We do this as a way to gather code and data
|
||||
// in the same place, to make the demo source code faster to read, faster to write, and smaller in size.
|
||||
// It also happens to be a convenient way of storing simple UI related information as long as your function doesn't need to be reentrant
|
||||
// or used in threads. This might be a pattern you will want to use in your code, but most of the real data you would be editing is
|
||||
// likely going to be stored outside your functions.
|
||||
|
||||
/*
|
||||
|
||||
|
@ -662,7 +662,8 @@ struct ImGuiContext
|
||||
ImGuiID HoveredId; // Hovered widget
|
||||
bool HoveredIdAllowOverlap;
|
||||
ImGuiID HoveredIdPreviousFrame;
|
||||
float HoveredIdTimer;
|
||||
float HoveredIdTimer; // Measure contiguous hovering time
|
||||
float HoveredIdNotActiveTimer; // Measure contiguous hovering time where the item has not been active
|
||||
ImGuiID ActiveId; // Active widget
|
||||
ImGuiID ActiveIdPreviousFrame;
|
||||
ImGuiID ActiveIdIsAlive; // Active widget has been seen this frame (we can't use a bool as the ActiveId may change within the frame)
|
||||
@ -809,7 +810,7 @@ struct ImGuiContext
|
||||
HoveredId = 0;
|
||||
HoveredIdAllowOverlap = false;
|
||||
HoveredIdPreviousFrame = 0;
|
||||
HoveredIdTimer = 0.0f;
|
||||
HoveredIdTimer = HoveredIdNotActiveTimer = 0.0f;
|
||||
ActiveId = 0;
|
||||
ActiveIdPreviousFrame = 0;
|
||||
ActiveIdIsAlive = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user