Browse Source

Removed dependency on limits.h

ocornut 11 years ago
parent
commit
080eb69e68
1 changed files with 12 additions and 7 deletions
  1. 12 7
      imgui.cpp

+ 12 - 7
imgui.cpp

@@ -158,7 +158,6 @@
 
 
 #include "imgui.h"
 #include "imgui.h"
 #include <ctype.h>		// toupper
 #include <ctype.h>		// toupper
-#include <limits.h>		// INT_MAX
 #include <math.h>		// sqrt
 #include <math.h>		// sqrt
 #include <stdint.h>		// intptr_t
 #include <stdint.h>		// intptr_t
 #include <stdio.h>		// vsnprintf
 #include <stdio.h>		// vsnprintf
@@ -292,6 +291,12 @@ void ImGuiIO::AddInputCharacter(char c)
 #undef PI
 #undef PI
 const float PI = 3.14159265358979323846f;
 const float PI = 3.14159265358979323846f;
 
 
+#ifdef INT_MAX
+#define IM_INT_MAX INT_MAX
+#else
+#define IM_INT_MAX 2147483647
+#endif
+
 // Math bits
 // Math bits
 // We are keeping those static in the .cpp file so as not to leak them outside, in the case the user has implicit cast operators between ImVec2 and its own types.
 // We are keeping those static in the .cpp file so as not to leak them outside, in the case the user has implicit cast operators between ImVec2 and its own types.
 static inline ImVec2 operator*(const ImVec2& lhs, const float rhs)				{ return ImVec2(lhs.x*rhs, lhs.y*rhs); }
 static inline ImVec2 operator*(const ImVec2& lhs, const float rhs)				{ return ImVec2(lhs.x*rhs, lhs.y*rhs); }
@@ -907,8 +912,8 @@ ImGuiWindow::ImGuiWindow(const char* name, ImVec2 default_pos, ImVec2 default_si
 		AutoFitFrames = 3;
 		AutoFitFrames = 3;
 
 
 	FocusIdxCounter = -1;
 	FocusIdxCounter = -1;
-	FocusIdxRequestCurrent = INT_MAX;
-	FocusIdxRequestNext = INT_MAX;
+	FocusIdxRequestCurrent = IM_INT_MAX;
+	FocusIdxRequestNext = IM_INT_MAX;
 
 
 	DrawList = new ImDrawList();
 	DrawList = new ImDrawList();
 }
 }
@@ -949,7 +954,7 @@ bool ImGuiWindow::FocusItemRegister(bool is_active, int* out_idx)
 		return false;
 		return false;
 
 
 	// Process input at this point: TAB, Shift-TAB switch focus
 	// Process input at this point: TAB, Shift-TAB switch focus
-	if (FocusIdxRequestNext == INT_MAX && is_active && ImGui::IsKeyPressedMap(ImGuiKey_Tab))
+	if (FocusIdxRequestNext == IM_INT_MAX && is_active && ImGui::IsKeyPressedMap(ImGuiKey_Tab))
 	{
 	{
 		// Modulo on index will be applied at the end of frame once we've got the total counter of items.
 		// Modulo on index will be applied at the end of frame once we've got the total counter of items.
 		FocusIdxRequestNext = FocusIdxCounter + (g.IO.KeyShift ? -1 : +1);
 		FocusIdxRequestNext = FocusIdxCounter + (g.IO.KeyShift ? -1 : +1);
@@ -1826,9 +1831,9 @@ bool Begin(const char* name, bool* open, ImVec2 size, float fill_alpha, ImGuiWin
 		window->ItemWidthDefault = (float)(int)(window->Size.x > 0.0f ? window->Size.x * 0.65f : 250.0f);
 		window->ItemWidthDefault = (float)(int)(window->Size.x > 0.0f ? window->Size.x * 0.65f : 250.0f);
 
 
 		// Prepare for focus requests
 		// Prepare for focus requests
-		if (window->FocusIdxRequestNext == INT_MAX || window->FocusIdxCounter == -1)
+		if (window->FocusIdxRequestNext == IM_INT_MAX || window->FocusIdxCounter == -1)
 		{
 		{
-			window->FocusIdxRequestCurrent = INT_MAX;
+			window->FocusIdxRequestCurrent = IM_INT_MAX;
 		}
 		}
 		else
 		else
 		{
 		{
@@ -1836,7 +1841,7 @@ bool Begin(const char* name, bool* open, ImVec2 size, float fill_alpha, ImGuiWin
 			window->FocusIdxRequestCurrent = (window->FocusIdxRequestNext + mod) % mod;
 			window->FocusIdxRequestCurrent = (window->FocusIdxRequestNext + mod) % mod;
 		}
 		}
 		window->FocusIdxCounter = -1;
 		window->FocusIdxCounter = -1;
-		window->FocusIdxRequestNext = INT_MAX;
+		window->FocusIdxRequestNext = IM_INT_MAX;
 
 
 		ImGuiAabb title_bar_aabb = window->TitleBarAabb();
 		ImGuiAabb title_bar_aabb = window->TitleBarAabb();