Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve code style, add missing const qualifiers #8279

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions imgui.h
Original file line number Diff line number Diff line change
Expand Up @@ -3461,9 +3461,9 @@ struct ImFont
// Methods
IMGUI_API ImFont();
IMGUI_API ~ImFont();
IMGUI_API const ImFontGlyph*FindGlyph(ImWchar c);
IMGUI_API const ImFontGlyph*FindGlyphNoFallback(ImWchar c);
float GetCharAdvance(ImWchar c) { return ((int)c < IndexAdvanceX.Size) ? IndexAdvanceX[(int)c] : FallbackAdvanceX; }
IMGUI_API const ImFontGlyph*FindGlyph(ImWchar c) const;
IMGUI_API const ImFontGlyph*FindGlyphNoFallback(ImWchar c) const;
float GetCharAdvance(ImWchar c) const { return ((int)c < IndexAdvanceX.Size) ? IndexAdvanceX[(int)c] : FallbackAdvanceX; }
bool IsLoaded() const { return ContainerAtlas != NULL; }
const char* GetDebugName() const { return ConfigData ? ConfigData->Name : "<unknown>"; }

Expand All @@ -3481,7 +3481,7 @@ struct ImFont
IMGUI_API void AddGlyph(const ImFontConfig* src_cfg, ImWchar c, float x0, float y0, float x1, float y1, float u0, float v0, float u1, float v1, float advance_x);
IMGUI_API void AddRemapChar(ImWchar dst, ImWchar src, bool overwrite_dst = true); // Makes 'dst' character/glyph points to 'src' character/glyph. Currently needs to be called AFTER fonts have been built.
IMGUI_API void SetGlyphVisible(ImWchar c, bool visible);
IMGUI_API bool IsGlyphRangeUnused(unsigned int c_begin, unsigned int c_last);
IMGUI_API bool IsGlyphRangeUnused(unsigned int c_begin, unsigned int c_last) const;
};

//-----------------------------------------------------------------------------
Expand Down
6 changes: 3 additions & 3 deletions imgui_draw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3806,7 +3806,7 @@ void ImFont::BuildLookupTable()

// API is designed this way to avoid exposing the 4K page size
// e.g. use with IsGlyphRangeUnused(0, 255)
bool ImFont::IsGlyphRangeUnused(unsigned int c_begin, unsigned int c_last)
bool ImFont::IsGlyphRangeUnused(unsigned int c_begin, unsigned int c_last) const
{
unsigned int page_begin = (c_begin / 4096);
unsigned int page_last = (c_last / 4096);
Expand Down Expand Up @@ -3896,7 +3896,7 @@ void ImFont::AddRemapChar(ImWchar dst, ImWchar src, bool overwrite_dst)
}

// Find glyph, return fallback if missing
const ImFontGlyph* ImFont::FindGlyph(ImWchar c)
const ImFontGlyph* ImFont::FindGlyph(ImWchar c) const
{
if (c >= (size_t)IndexLookup.Size)
return FallbackGlyph;
Expand All @@ -3906,7 +3906,7 @@ const ImFontGlyph* ImFont::FindGlyph(ImWchar c)
return &Glyphs.Data[i];
}

const ImFontGlyph* ImFont::FindGlyphNoFallback(ImWchar c)
const ImFontGlyph* ImFont::FindGlyphNoFallback(ImWchar c) const
{
if (c >= (size_t)IndexLookup.Size)
return NULL;
Expand Down