Minor comments + renaming internal fields

This commit is contained in:
omar 2017-09-06 17:20:54 +02:00
parent 8971d70149
commit 790605e359
2 changed files with 10 additions and 11 deletions

View File

@ -2286,14 +2286,14 @@ void ImGui::NewFrame()
mouse_earliest_button_down = i; mouse_earliest_button_down = i;
} }
bool mouse_avail_to_imgui = (mouse_earliest_button_down == -1) || g.IO.MouseDownOwned[mouse_earliest_button_down]; bool mouse_avail_to_imgui = (mouse_earliest_button_down == -1) || g.IO.MouseDownOwned[mouse_earliest_button_down];
if (g.CaptureMouseNextFrame != -1) if (g.WantCaptureMouseNextFrame != -1)
g.IO.WantCaptureMouse = (g.CaptureMouseNextFrame != 0); g.IO.WantCaptureMouse = (g.WantCaptureMouseNextFrame != 0);
else else
g.IO.WantCaptureMouse = (mouse_avail_to_imgui && (g.HoveredWindow != NULL || mouse_any_down)) || (g.ActiveId != 0) || (!g.OpenPopupStack.empty()); g.IO.WantCaptureMouse = (mouse_avail_to_imgui && (g.HoveredWindow != NULL || mouse_any_down)) || (g.ActiveId != 0) || (!g.OpenPopupStack.empty());
g.IO.WantCaptureKeyboard = (g.CaptureKeyboardNextFrame != -1) ? (g.CaptureKeyboardNextFrame != 0) : (g.ActiveId != 0); g.IO.WantCaptureKeyboard = (g.WantCaptureKeyboardNextFrame != -1) ? (g.WantCaptureKeyboardNextFrame != 0) : (g.ActiveId != 0);
g.IO.WantTextInput = (g.ActiveId != 0 && g.InputTextState.Id == g.ActiveId); g.IO.WantTextInput = (g.ActiveId != 0 && g.InputTextState.Id == g.ActiveId);
g.MouseCursor = ImGuiMouseCursor_Arrow; g.MouseCursor = ImGuiMouseCursor_Arrow;
g.CaptureMouseNextFrame = g.CaptureKeyboardNextFrame = -1; g.WantCaptureMouseNextFrame = g.WantCaptureKeyboardNextFrame = -1;
g.OsImePosRequest = ImVec2(1.0f, 1.0f); // OS Input Method Editor showing on top-left of our window by default g.OsImePosRequest = ImVec2(1.0f, 1.0f); // OS Input Method Editor showing on top-left of our window by default
// If mouse was first clicked outside of ImGui bounds we also cancel out hovering. // If mouse was first clicked outside of ImGui bounds we also cancel out hovering.
@ -3306,12 +3306,12 @@ void ImGui::SetMouseCursor(ImGuiMouseCursor cursor_type)
void ImGui::CaptureKeyboardFromApp(bool capture) void ImGui::CaptureKeyboardFromApp(bool capture)
{ {
GImGui->CaptureKeyboardNextFrame = capture ? 1 : 0; GImGui->WantCaptureKeyboardNextFrame = capture ? 1 : 0;
} }
void ImGui::CaptureMouseFromApp(bool capture) void ImGui::CaptureMouseFromApp(bool capture)
{ {
GImGui->CaptureMouseNextFrame = capture ? 1 : 0; GImGui->WantCaptureMouseNextFrame = capture ? 1 : 0;
} }
bool ImGui::IsItemHovered() bool ImGui::IsItemHovered()
@ -6478,6 +6478,7 @@ bool ImGui::InputScalarAsWidgetReplacement(const ImRect& aabb, const char* label
ImGuiWindow* window = GetCurrentWindow(); ImGuiWindow* window = GetCurrentWindow();
// Our replacement widget will override the focus ID (registered previously to allow for a TAB focus to happen) // Our replacement widget will override the focus ID (registered previously to allow for a TAB focus to happen)
// On the first frame, g.ScalarAsInputTextId == 0, then on subsequent frames it becomes == id
SetActiveID(g.ScalarAsInputTextId, window); SetActiveID(g.ScalarAsInputTextId, window);
SetHoveredID(0); SetHoveredID(0);
FocusableItemUnregister(window); FocusableItemUnregister(window);
@ -6723,7 +6724,6 @@ bool ImGui::SliderFloat(const char* label, float* v, float v_min, float v_max, c
{ {
SetActiveID(id, window); SetActiveID(id, window);
FocusWindow(window); FocusWindow(window);
if (tab_focus_requested || g.IO.KeyCtrl) if (tab_focus_requested || g.IO.KeyCtrl)
{ {
start_text_input = true; start_text_input = true;
@ -7024,7 +7024,6 @@ bool ImGui::DragFloat(const char* label, float* v, float v_speed, float v_min, f
{ {
SetActiveID(id, window); SetActiveID(id, window);
FocusWindow(window); FocusWindow(window);
if (tab_focus_requested || g.IO.KeyCtrl || g.IO.MouseDoubleClicked[0]) if (tab_focus_requested || g.IO.KeyCtrl || g.IO.MouseDoubleClicked[0])
{ {
start_text_input = true; start_text_input = true;

View File

@ -486,8 +486,8 @@ struct ImGuiContext
float FramerateSecPerFrame[120]; // calculate estimate of framerate for user float FramerateSecPerFrame[120]; // calculate estimate of framerate for user
int FramerateSecPerFrameIdx; int FramerateSecPerFrameIdx;
float FramerateSecPerFrameAccum; float FramerateSecPerFrameAccum;
int CaptureMouseNextFrame; // explicit capture via CaptureInputs() sets those flags int WantCaptureMouseNextFrame; // explicit capture via CaptureInputs() sets those flags
int CaptureKeyboardNextFrame; int WantCaptureKeyboardNextFrame;
char TempBuffer[1024*3+1]; // temporary text buffer char TempBuffer[1024*3+1]; // temporary text buffer
ImGuiContext() ImGuiContext()
@ -558,7 +558,7 @@ struct ImGuiContext
memset(FramerateSecPerFrame, 0, sizeof(FramerateSecPerFrame)); memset(FramerateSecPerFrame, 0, sizeof(FramerateSecPerFrame));
FramerateSecPerFrameIdx = 0; FramerateSecPerFrameIdx = 0;
FramerateSecPerFrameAccum = 0.0f; FramerateSecPerFrameAccum = 0.0f;
CaptureMouseNextFrame = CaptureKeyboardNextFrame = -1; WantCaptureMouseNextFrame = WantCaptureKeyboardNextFrame = -1;
memset(TempBuffer, 0, sizeof(TempBuffer)); memset(TempBuffer, 0, sizeof(TempBuffer));
} }
}; };