Refactor: Tweaked and improved the sectioning to facilitate grepping/moving around and applied to all files. (#2036)

This commit is contained in:
omar
2018-09-06 11:35:13 +02:00
parent 0b18c11440
commit e58bc3d5b7
5 changed files with 186 additions and 129 deletions

View File

@ -4,16 +4,19 @@
/*
Index of this file:
- Cruft for stb_truetype/stb_rectpack implementation
- Style functions (default style)
- ImDrawList
- ImDrawData
- ShadeVertsXXX helpers functions
- ImFontConfig
- ImFontAtlas
- ImFont
- Internal Render Helpers
- Default font data
// [SECTION] STB libraries implementation
// [SECTION] Style functions
// [SECTION] ImDrawList
// [SECTION] ImDrawData
// [SECTION] Helpers ShadeVertsXXX functions
// [SECTION] ImFontConfig
// [SECTION] ImFontAtlas
// [SECTION] ImFontAtlas glyph ranges helpers + GlyphRangesBuilder
// [SECTION] ImFont
// [SECTION] Internal Render Helpers
// [SECTION] Decompression code
// [SECTION] Default font data (ProggyClean.ttf)
*/
@ -72,7 +75,7 @@ Index of this file:
#endif
//-------------------------------------------------------------------------
// STB libraries implementation
// [SECTION] STB libraries implementation
//-------------------------------------------------------------------------
// Compile time options:
@ -161,7 +164,7 @@ using namespace IMGUI_STB_NAMESPACE;
#endif
//-----------------------------------------------------------------------------
// Style functions
// [SECTION] Style functions
//-----------------------------------------------------------------------------
void ImGui::StyleColorsDark(ImGuiStyle* dst)
@ -316,7 +319,7 @@ void ImGui::StyleColorsLight(ImGuiStyle* dst)
}
//-----------------------------------------------------------------------------
// ImDrawListData
// ImDrawList
//-----------------------------------------------------------------------------
ImDrawListSharedData::ImDrawListSharedData()
@ -334,10 +337,6 @@ ImDrawListSharedData::ImDrawListSharedData()
}
}
//-----------------------------------------------------------------------------
// ImDrawList
//-----------------------------------------------------------------------------
void ImDrawList::Clear()
{
CmdBuffer.resize(0);
@ -1227,7 +1226,7 @@ void ImDrawList::AddImageRounded(ImTextureID user_texture_id, const ImVec2& a, c
}
//-----------------------------------------------------------------------------
// ImDrawData
// [SECTION] ImDrawData
//-----------------------------------------------------------------------------
// For backward compatibility: convert all buffers from indexed to de-indexed, in case you cannot render indexed. Note: this is slow and most likely a waste of resources. Always prefer indexed rendering!
@ -1264,7 +1263,7 @@ void ImDrawData::ScaleClipRects(const ImVec2& scale)
}
//-----------------------------------------------------------------------------
// Shade functions
// [SECTION] Helpers ShadeVertsXXX functions
//-----------------------------------------------------------------------------
// Generic linear color gradient, write to RGB fields, leave A untouched.
@ -1311,7 +1310,7 @@ void ImGui::ShadeVertsLinearUV(ImDrawList* draw_list, int vert_start_idx, int ve
}
//-----------------------------------------------------------------------------
// ImFontConfig
// [SECTION] ImFontConfig
//-----------------------------------------------------------------------------
ImFontConfig::ImFontConfig()
@ -1337,7 +1336,7 @@ ImFontConfig::ImFontConfig()
}
//-----------------------------------------------------------------------------
// ImFontAtlas
// [SECTION] ImFontAtlas
//-----------------------------------------------------------------------------
// A work of art lies ahead! (. = white layer, X = black layer, others are blank)
@ -2074,6 +2073,10 @@ static void UnpackAccumulativeOffsetsIntoRanges(int base_codepoint, const short*
out_ranges[0] = 0;
}
//-------------------------------------------------------------------------
// [SECTION] ImFontAtlas glyph ranges helpers + GlyphRangesBuilder
//-------------------------------------------------------------------------
const ImWchar* ImFontAtlas::GetGlyphRangesChineseSimplifiedCommon()
{
// Store 2500 regularly used characters for Simplified Chinese.
@ -2223,10 +2226,6 @@ const ImWchar* ImFontAtlas::GetGlyphRangesThai()
return &ranges[0];
}
//-----------------------------------------------------------------------------
// ImFontAtlas::GlyphRangesBuilder
//-----------------------------------------------------------------------------
void ImFontAtlas::GlyphRangesBuilder::AddText(const char* text, const char* text_end)
{
while (text_end ? (text < text_end) : *text)
@ -2262,7 +2261,7 @@ void ImFontAtlas::GlyphRangesBuilder::BuildRanges(ImVector<ImWchar>* out_ranges)
}
//-----------------------------------------------------------------------------
// ImFont
// [SECTION] ImFont
//-----------------------------------------------------------------------------
ImFont::ImFont()
@ -2813,12 +2812,12 @@ void ImFont::RenderText(ImDrawList* draw_list, float size, ImVec2 pos, ImU32 col
}
//-----------------------------------------------------------------------------
// Internals Render Helpers
// [SECTION] Internal Render Helpers
// (progressively moved from imgui.cpp to here when they are redesigned to stop accessing ImGui global state)
//-----------------------------------------------------------------------------
// RenderMouseCursor()
// RenderArrowPointingAt()
// RenderRectFilledRangeH()
// - RenderMouseCursor()
// - RenderArrowPointingAt()
// - RenderRectFilledRangeH()
//-----------------------------------------------------------------------------
void ImGui::RenderMouseCursor(ImDrawList* draw_list, ImVec2 pos, float scale, ImGuiMouseCursor mouse_cursor)
@ -2927,8 +2926,9 @@ void ImGui::RenderRectFilledRangeH(ImDrawList* draw_list, const ImRect& rect, Im
draw_list->PathFillConvex(col);
}
//-----------------------------------------------------------------------------
// DEFAULT FONT DATA
// [SECTION] Decompression code
//-----------------------------------------------------------------------------
// Compressed with stb_compress() then converted to a C array and encoded as base85.
// Use the program in misc/fonts/binary_to_compressed_c.cpp to create the array from a TTF file.
@ -3047,6 +3047,8 @@ static unsigned int stb_decompress(unsigned char *output, const unsigned char *i
}
}
//-----------------------------------------------------------------------------
// [SECTION] Default font data (ProggyClean.ttf)
//-----------------------------------------------------------------------------
// ProggyClean.ttf
// Copyright (c) 2004, 2005 Tristan Grimmer