Fixed Clang -Weverything warnings + TODO list entries

This commit is contained in:
ocornut 2014-11-30 12:21:50 +00:00
parent e9aead09cb
commit a31e44b99a
3 changed files with 30 additions and 27 deletions

View File

@ -198,6 +198,7 @@
- text edit: add multi-line text edit - text edit: add multi-line text edit
- settings: write more decent code to allow saving/loading new fields - settings: write more decent code to allow saving/loading new fields
- settings: api for per-tool simple persistent data (bool,int,float) in .ini file - settings: api for per-tool simple persistent data (bool,int,float) in .ini file
- log: have more control over the log scope (e.g. stop logging when leaving current tree node scope)
- log: be able to right-click and log a window or tree-node into tty/file/clipboard? - log: be able to right-click and log a window or tree-node into tty/file/clipboard?
- filters: set a current filter that tree node can automatically query to hide themselves - filters: set a current filter that tree node can automatically query to hide themselves
- filters: handle wildcards (with implicit leading/trailing *), regexps - filters: handle wildcards (with implicit leading/trailing *), regexps
@ -212,6 +213,7 @@
- misc: provide a way to compile out the entire implementation while providing a dummy API (e.g. #define IMGUI_DUMMY_IMPL - misc: provide a way to compile out the entire implementation while providing a dummy API (e.g. #define IMGUI_DUMMY_IMPL
- misc: not thread-safe - misc: not thread-safe
- misc: double-clicking on title bar to minimize isn't consistent, perhaps move to single-click on left-most collapse icon? - misc: double-clicking on title bar to minimize isn't consistent, perhaps move to single-click on left-most collapse icon?
- misc: CalcTextSize() could benefit from having 'hide_text_after_double_hash' false by default for external use?
- style editor: add a button to output C code. - style editor: add a button to output C code.
- examples: integrate dx11 example. - examples: integrate dx11 example.
- examples: integrate opengl 3/4 programmable pipeline example. - examples: integrate opengl 3/4 programmable pipeline example.
@ -438,7 +440,7 @@ static int ImStricmp(const char* str1, const char* str2)
static int ImStrnicmp(const char* str1, const char* str2, int count) static int ImStrnicmp(const char* str1, const char* str2, int count)
{ {
int d; int d = 0;
while (count > 0 && (d = toupper(*str2) - toupper(*str1)) == 0 && *str1) { str1++; str2++; count--; } while (count > 0 && (d = toupper(*str2) - toupper(*str1)) == 0 && *str1) { str1++; str2++; count--; }
return (count == 0) ? 0 : d; return (count == 0) ? 0 : d;
} }
@ -725,7 +727,7 @@ struct ImGuiState
bool Initialized; bool Initialized;
ImGuiIO IO; ImGuiIO IO;
ImGuiStyle Style; ImGuiStyle Style;
float FontSize; // == IO.FontGlobalScale * IO.Font->Scale * IO.Font->GetFontSize(). Vertical distance between two lines of text, aka == CalcTextSize(" ").y float FontSize; // == IO.FontGlobalScale * IO.Font->Scale * IO.Font->Info->FontSize. Vertical distance between two lines of text, aka == CalcTextSize(" ").y
ImVec2 FontTexUvForWhite; // == IO.Font->FontTexUvForWhite (cached copy) ImVec2 FontTexUvForWhite; // == IO.Font->FontTexUvForWhite (cached copy)
float Time; float Time;
@ -1369,7 +1371,7 @@ void ImGui::NewFrame()
IM_ASSERT(g.IO.Font && g.IO.Font->IsLoaded()); // Font not loaded IM_ASSERT(g.IO.Font && g.IO.Font->IsLoaded()); // Font not loaded
IM_ASSERT(g.IO.Font->Scale > 0.0f); IM_ASSERT(g.IO.Font->Scale > 0.0f);
g.FontSize = g.IO.FontGlobalScale * g.IO.Font->GetFontSize() * g.IO.Font->Scale; g.FontSize = g.IO.FontGlobalScale * (float)g.IO.Font->Info->FontSize * g.IO.Font->Scale;
g.FontTexUvForWhite = g.IO.Font->TexUvForWhite; g.FontTexUvForWhite = g.IO.Font->TexUvForWhite;
g.IO.Font->FallbackGlyph = g.IO.Font->FindGlyph(g.IO.Font->FallbackChar); g.IO.Font->FallbackGlyph = g.IO.Font->FindGlyph(g.IO.Font->FallbackChar);
@ -1803,12 +1805,12 @@ static void RenderCollapseTriangle(ImVec2 p_min, bool open, float scale, bool sh
// Calculate text size. Text can be multi-line. Optionally ignore text after a ## marker. // Calculate text size. Text can be multi-line. Optionally ignore text after a ## marker.
// CalcTextSize("") should return ImVec2(0.0f, GImGui.FontSize) // CalcTextSize("") should return ImVec2(0.0f, GImGui.FontSize)
ImVec2 ImGui::CalcTextSize(const char* text, const char* text_end, bool hide_text_after_hash, float wrap_width) ImVec2 ImGui::CalcTextSize(const char* text, const char* text_end, bool hide_text_after_double_hash, float wrap_width)
{ {
ImGuiWindow* window = GetCurrentWindow(); ImGuiWindow* window = GetCurrentWindow();
const char* text_display_end; const char* text_display_end;
if (hide_text_after_hash) if (hide_text_after_double_hash)
text_display_end = FindTextDisplayEnd(text, text_end); // Hide anything after a '##' string text_display_end = FindTextDisplayEnd(text, text_end); // Hide anything after a '##' string
else else
text_display_end = text_end; text_display_end = text_end;
@ -4128,10 +4130,10 @@ static void STB_TEXTEDIT_DELETECHARS(STB_TEXTEDIT_STRING* obj, int pos, int n)
static bool STB_TEXTEDIT_INSERTCHARS(STB_TEXTEDIT_STRING* obj, int pos, const ImWchar* new_text, int new_text_len) static bool STB_TEXTEDIT_INSERTCHARS(STB_TEXTEDIT_STRING* obj, int pos, const ImWchar* new_text, int new_text_len)
{ {
const size_t text_len = ImStrlenW(obj->Text); const size_t text_len = ImStrlenW(obj->Text);
if (new_text_len + text_len + 1 >= obj->BufSize) if ((size_t)new_text_len + text_len + 1 >= obj->BufSize)
return false; return false;
if (pos != text_len) if (pos != (int)text_len)
memmove(obj->Text + (size_t)pos + new_text_len, obj->Text + (size_t)pos, (text_len - (size_t)pos) * sizeof(ImWchar)); memmove(obj->Text + (size_t)pos + new_text_len, obj->Text + (size_t)pos, (text_len - (size_t)pos) * sizeof(ImWchar));
memcpy(obj->Text + (size_t)pos, new_text, (size_t)new_text_len * sizeof(ImWchar)); memcpy(obj->Text + (size_t)pos, new_text, (size_t)new_text_len * sizeof(ImWchar));
obj->Text[text_len + (size_t)new_text_len] = '\0'; obj->Text[text_len + (size_t)new_text_len] = '\0';
@ -4304,7 +4306,7 @@ bool ImGui::InputInt(const char* label, int *v, int step, int step_fast, ImGuiIn
// Public API to manipulate UTF-8 text // Public API to manipulate UTF-8 text
// We expose UTF-8 to the user (unlike the STB_TEXTEDIT_* functions which are manipulating wchar) // We expose UTF-8 to the user (unlike the STB_TEXTEDIT_* functions which are manipulating wchar)
void ImGuiTextEditCallbackData::DeleteChars(size_t pos, size_t bytes_count) void ImGuiTextEditCallbackData::DeleteChars(int pos, int bytes_count)
{ {
char* dst = Buf + pos; char* dst = Buf + pos;
const char* src = Buf + pos + bytes_count; const char* src = Buf + pos + bytes_count;
@ -4313,31 +4315,32 @@ void ImGuiTextEditCallbackData::DeleteChars(size_t pos, size_t bytes_count)
*dst = '\0'; *dst = '\0';
BufDirty = true; BufDirty = true;
if ((size_t)CursorPos + bytes_count >= pos) if (CursorPos + bytes_count >= pos)
CursorPos -= bytes_count; CursorPos -= bytes_count;
else if ((size_t)CursorPos >= pos) else if (CursorPos >= pos)
CursorPos = pos; CursorPos = pos;
SelectionStart = SelectionEnd = CursorPos; SelectionStart = SelectionEnd = CursorPos;
} }
void ImGuiTextEditCallbackData::InsertChars(size_t pos, const char* new_text, const char* new_text_end) void ImGuiTextEditCallbackData::InsertChars(int pos, const char* new_text, const char* new_text_end)
{ {
const size_t text_len = strlen(Buf); const size_t text_len = strlen(Buf);
if (!new_text_end) if (!new_text_end)
new_text_end = new_text + strlen(new_text); new_text_end = new_text + strlen(new_text);
const size_t new_text_len = new_text_end - new_text; const size_t new_text_len = (size_t)(new_text_end - new_text);
if (new_text_len + text_len + 1 >= BufSize) if (new_text_len + text_len + 1 >= BufSize)
return; return;
if (text_len != pos) size_t upos = (size_t)pos;
memmove(Buf + pos + new_text_len, Buf + pos, text_len - pos); if (text_len != upos)
memcpy(Buf + pos, new_text, new_text_len * sizeof(char)); memmove(Buf + upos + new_text_len, Buf + upos, text_len - upos);
memcpy(Buf + upos, new_text, new_text_len * sizeof(char));
Buf[text_len + new_text_len] = '\0'; Buf[text_len + new_text_len] = '\0';
BufDirty = true; BufDirty = true;
if ((size_t)CursorPos >= pos) if (CursorPos >= pos)
CursorPos += new_text_len; CursorPos += (int)new_text_len;
SelectionStart = SelectionEnd = CursorPos; SelectionStart = SelectionEnd = CursorPos;
} }
@ -5796,6 +5799,7 @@ bool ImFont::LoadFromMemory(const void* data, size_t data_size)
IM_ASSERT(Kerning == NULL && KerningCount == 0); IM_ASSERT(Kerning == NULL && KerningCount == 0);
Kerning = (FntKerning*)p; Kerning = (FntKerning*)p;
KerningCount = block_size / sizeof(FntKerning); KerningCount = block_size / sizeof(FntKerning);
break;
default: default:
break; break;
} }
@ -7152,7 +7156,7 @@ struct ExampleAppConsole
else if (candidates.size() == 1) else if (candidates.size() == 1)
{ {
// Single match. Delete the beginning of the word and replace it entirely so we've got nice casing // Single match. Delete the beginning of the word and replace it entirely so we've got nice casing
data->DeleteChars(word_start - data->Buf, word_end-word_start); data->DeleteChars(word_start-data->Buf, word_end-word_start);
data->InsertChars(data->CursorPos, candidates[0]); data->InsertChars(data->CursorPos, candidates[0]);
data->InsertChars(data->CursorPos, " "); data->InsertChars(data->CursorPos, " ");
} }
@ -7162,7 +7166,7 @@ struct ExampleAppConsole
int match_len = word_end - word_start; int match_len = word_end - word_start;
while (true) while (true)
{ {
char c; int c = 0;
bool all_candidates_matches = true; bool all_candidates_matches = true;
for (size_t i = 0; i < candidates.size() && all_candidates_matches; i++) for (size_t i = 0; i < candidates.size() && all_candidates_matches; i++)
{ {

View File

@ -295,7 +295,7 @@ namespace ImGui
IMGUI_API int GetFrameCount(); IMGUI_API int GetFrameCount();
IMGUI_API const char* GetStyleColorName(ImGuiCol idx); IMGUI_API const char* GetStyleColorName(ImGuiCol idx);
IMGUI_API void GetDefaultFontData(const void** fnt_data, unsigned int* fnt_size, const void** png_data, unsigned int* png_size); IMGUI_API void GetDefaultFontData(const void** fnt_data, unsigned int* fnt_size, const void** png_data, unsigned int* png_size);
IMGUI_API ImVec2 CalcTextSize(const char* text, const char* text_end = NULL, bool hide_text_after_hash = true, float wrap_width = -1.0f); IMGUI_API ImVec2 CalcTextSize(const char* text, const char* text_end = NULL, bool hide_text_after_double_hash = false, float wrap_width = -1.0f);
} // namespace ImGui } // namespace ImGui
@ -619,8 +619,8 @@ struct ImGuiTextEditCallbackData
void* UserData; // What user passed to InputText() void* UserData; // What user passed to InputText()
// NB: calling those function loses selection. // NB: calling those function loses selection.
void DeleteChars(size_t pos, size_t bytes_count); void DeleteChars(int pos, int bytes_count);
void InsertChars(size_t pos, const char* text, const char* text_end = NULL); void InsertChars(int pos, const char* text, const char* text_end = NULL);
}; };
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -727,7 +727,6 @@ struct ImFont
IMGUI_API void Clear(); IMGUI_API void Clear();
IMGUI_API void BuildLookupTable(); IMGUI_API void BuildLookupTable();
IMGUI_API const FntGlyph* FindGlyph(unsigned short c) const; IMGUI_API const FntGlyph* FindGlyph(unsigned short c) const;
IMGUI_API float GetFontSize() const { return (float)Info->FontSize; } // before scale!
IMGUI_API bool IsLoaded() const { return Info != NULL && Common != NULL && Glyphs != NULL; } IMGUI_API bool IsLoaded() const { return Info != NULL && Common != NULL && Glyphs != NULL; }
// 'max_width' stops rendering after a certain width (could be turned into a 2d size). FLT_MAX to disable. // 'max_width' stops rendering after a certain width (could be turned into a 2d size). FLT_MAX to disable.

View File

@ -1008,13 +1008,13 @@ static void stb_textedit_discard_undo(StbUndoState *state)
int n = state->undo_rec[0].insert_length, i; int n = state->undo_rec[0].insert_length, i;
// delete n characters from all other records // delete n characters from all other records
state->undo_char_point = state->undo_char_point - (short) n; // vsnet05 state->undo_char_point = state->undo_char_point - (short) n; // vsnet05
memmove(state->undo_char, state->undo_char + n, (size_t) (state->undo_char_point*sizeof(STB_TEXTEDIT_CHARTYPE))); memmove(state->undo_char, state->undo_char + n, (size_t) ((size_t)state->undo_char_point*sizeof(STB_TEXTEDIT_CHARTYPE)));
for (i=0; i < state->undo_point; ++i) for (i=0; i < state->undo_point; ++i)
if (state->undo_rec[i].char_storage >= 0) if (state->undo_rec[i].char_storage >= 0)
state->undo_rec[i].char_storage = state->undo_rec[i].char_storage - (short) n; // vsnet05 // @OPTIMIZE: get rid of char_storage and infer it state->undo_rec[i].char_storage = state->undo_rec[i].char_storage - (short) n; // vsnet05 // @OPTIMIZE: get rid of char_storage and infer it
} }
--state->undo_point; --state->undo_point;
memmove(state->undo_rec, state->undo_rec+1, (size_t) (state->undo_point*sizeof(state->undo_rec[0]))); memmove(state->undo_rec, state->undo_rec+1, (size_t) ((size_t)state->undo_point*sizeof(state->undo_rec[0])));
} }
} }
@ -1032,13 +1032,13 @@ static void stb_textedit_discard_redo(StbUndoState *state)
int n = state->undo_rec[k].insert_length, i; int n = state->undo_rec[k].insert_length, i;
// delete n characters from all other records // delete n characters from all other records
state->redo_char_point = state->redo_char_point + (short) n; // vsnet05 state->redo_char_point = state->redo_char_point + (short) n; // vsnet05
memmove(state->undo_char + state->redo_char_point, state->undo_char + state->redo_char_point-n, (size_t) ((STB_TEXTEDIT_UNDOSTATECOUNT - state->redo_char_point)*sizeof(STB_TEXTEDIT_CHARTYPE))); memmove(state->undo_char + state->redo_char_point, state->undo_char + state->redo_char_point-n, (size_t) ((size_t)(STB_TEXTEDIT_UNDOSTATECOUNT - state->redo_char_point)*sizeof(STB_TEXTEDIT_CHARTYPE)));
for (i=state->redo_point; i < k; ++i) for (i=state->redo_point; i < k; ++i)
if (state->undo_rec[i].char_storage >= 0) if (state->undo_rec[i].char_storage >= 0)
state->undo_rec[i].char_storage = state->undo_rec[i].char_storage + (short) n; // vsnet05 state->undo_rec[i].char_storage = state->undo_rec[i].char_storage + (short) n; // vsnet05
} }
++state->redo_point; ++state->redo_point;
memmove(state->undo_rec + state->redo_point-1, state->undo_rec + state->redo_point, (size_t) ((STB_TEXTEDIT_UNDOSTATECOUNT - state->redo_point)*sizeof(state->undo_rec[0]))); memmove(state->undo_rec + state->redo_point-1, state->undo_rec + state->redo_point, (size_t) ((size_t)(STB_TEXTEDIT_UNDOSTATECOUNT - state->redo_point)*sizeof(state->undo_rec[0])));
} }
} }