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

Fixed a few zealous warnings.

This commit is contained in:
omar 2018-04-07 10:38:01 +02:00
parent c712f7275d
commit 82b7a39f31
3 changed files with 11 additions and 11 deletions

View File

@ -1381,8 +1381,8 @@ ImU32 ImGui::GetColorU32(ImU32 col)
float style_alpha = GImGui->Style.Alpha;
if (style_alpha >= 1.0f)
return col;
int a = (col & IM_COL32_A_MASK) >> IM_COL32_A_SHIFT;
a = (int)(a * style_alpha); // We don't need to clamp 0..255 because Style.Alpha is in 0..1 range.
ImU32 a = (col & IM_COL32_A_MASK) >> IM_COL32_A_SHIFT;
a = (ImU32)(a * style_alpha); // We don't need to clamp 0..255 because Style.Alpha is in 0..1 range.
return (col & ~IM_COL32_A_MASK) | (a << IM_COL32_A_SHIFT);
}
@ -1473,7 +1473,7 @@ void* ImFileLoadToMemory(const char* filename, const char* file_open_mode, int*
}
int file_size = (int)file_size_signed;
void* file_data = ImGui::MemAlloc(file_size + padding_bytes);
void* file_data = ImGui::MemAlloc((size_t)(file_size + padding_bytes));
if (file_data == NULL)
{
fclose(f);
@ -1486,7 +1486,7 @@ void* ImFileLoadToMemory(const char* filename, const char* file_open_mode, int*
return NULL;
}
if (padding_bytes > 0)
memset((void *)(((char*)file_data) + file_size), 0, padding_bytes);
memset((void *)(((char*)file_data) + file_size), 0, (size_t)padding_bytes);
fclose(f);
if (out_file_size)
@ -1773,7 +1773,7 @@ void ImGuiTextBuffer::appendfv(const char* fmt, va_list args)
}
Buf.resize(needed_sz);
ImFormatStringV(&Buf[write_off - 1], len + 1, fmt, args_copy);
ImFormatStringV(&Buf[write_off - 1], (size_t)len + 1, fmt, args_copy);
}
void ImGuiTextBuffer::appendf(const char* fmt, ...)
@ -8502,7 +8502,7 @@ static size_t GDataTypeSize[ImGuiDataType_COUNT] =
// NB: This is _not_ a full expression evaluator. We should probably add one though..
static bool DataTypeApplyOpFromText(const char* buf, const char* initial_value_buf, ImGuiDataType data_type, void* data_ptr, const char* scalar_format)
{
while (ImCharIsSpace(*buf))
while (ImCharIsSpace((unsigned int)*buf))
buf++;
// We don't support '-' op because it would conflict with inputing negative value.
@ -8511,7 +8511,7 @@ static bool DataTypeApplyOpFromText(const char* buf, const char* initial_value_b
if (op == '+' || op == '*' || op == '/')
{
buf++;
while (ImCharIsSpace(*buf))
while (ImCharIsSpace((unsigned int)*buf))
buf++;
}
else
@ -11748,7 +11748,7 @@ bool ImGui::ColorEdit4(const char* label, float col[4], ImGuiColorEditFlags flag
{
value_changed = true;
char* p = buf;
while (*p == '#' || ImCharIsSpace(*p))
while (*p == '#' || ImCharIsSpace((unsigned int)*p))
p++;
i[0] = i[1] = i[2] = i[3] = 0;
if (alpha)

View File

@ -2435,7 +2435,7 @@ ImVec2 ImFont::CalcTextSizeA(float size, float max_width, float wrap_width, cons
while (s < text_end)
{
const char c = *s;
if (ImCharIsSpace(c)) { s++; } else if (c == '\n') { s++; break; } else { break; }
if (ImCharIsSpace((unsigned int)c)) { s++; } else if (c == '\n') { s++; break; } else { break; }
}
continue;
}
@ -2560,7 +2560,7 @@ void ImFont::RenderText(ImDrawList* draw_list, float size, ImVec2 pos, ImU32 col
while (s < text_end)
{
const char c = *s;
if (ImCharIsSpace(c)) { s++; } else if (c == '\n') { s++; break; } else { break; }
if (ImCharIsSpace((unsigned int)c)) { s++; } else if (c == '\n') { s++; break; } else { break; }
}
continue;
}

View File

@ -98,7 +98,7 @@ IMGUI_API int ImTextCountUtf8BytesFromStr(const ImWchar* in_text, cons
IMGUI_API ImU32 ImHash(const void* data, int data_size, ImU32 seed = 0); // Pass data_size==0 for zero-terminated strings
IMGUI_API void* ImFileLoadToMemory(const char* filename, const char* file_open_mode, int* out_file_size = NULL, int padding_bytes = 0);
IMGUI_API FILE* ImFileOpen(const char* filename, const char* file_open_mode);
static inline bool ImCharIsSpace(int c) { return c == ' ' || c == '\t' || c == 0x3000; }
static inline bool ImCharIsSpace(unsigned int c) { return c == ' ' || c == '\t' || c == 0x3000; }
static inline bool ImIsPowerOfTwo(int v) { return v != 0 && (v & (v - 1)) == 0; }
static inline int ImUpperPowerOfTwo(int v) { v--; v |= v >> 1; v |= v >> 2; v |= v >> 4; v |= v >> 8; v |= v >> 16; v++; return v; }