mirror of
https://github.com/ocornut/imgui.git
synced 2024-11-23 21:09:01 +08:00
ShowFontAtlas, Demo: optionally use style text color for tint. (#6129)
This commit is contained in:
parent
5a3f82e2f4
commit
2efebe3315
@ -13168,10 +13168,13 @@ void ImGui::ShowFontAtlas(ImFontAtlas* atlas)
|
||||
DebugNodeFont(font);
|
||||
PopID();
|
||||
}
|
||||
if (TreeNode("Atlas texture", "Atlas texture (%dx%d pixels)", atlas->TexWidth, atlas->TexHeight))
|
||||
if (TreeNode("Font Atlas", "Font Atlas (%dx%d pixels)", atlas->TexWidth, atlas->TexHeight))
|
||||
{
|
||||
ImVec4 tint_col = ImVec4(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
ImVec4 border_col = ImVec4(1.0f, 1.0f, 1.0f, 0.5f);
|
||||
ImGuiContext& g = *GImGui;
|
||||
ImGuiMetricsConfig* cfg = &g.DebugMetricsConfig;
|
||||
Checkbox("Tint with Text Color", &cfg->ShowAtlasTintedWithTextColor); // Using text color ensure visibility of core atlas data, but will alter custom colored icons
|
||||
ImVec4 tint_col = cfg->ShowAtlasTintedWithTextColor ? GetStyleColorVec4(ImGuiCol_Text) : ImVec4(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
ImVec4 border_col = GetStyleColorVec4(ImGuiCol_Border);
|
||||
Image(atlas->TexID, ImVec2((float)atlas->TexWidth, (float)atlas->TexHeight), ImVec2(0.0f, 0.0f), ImVec2(1.0f, 1.0f), tint_col, border_col);
|
||||
TreePop();
|
||||
}
|
||||
|
@ -1024,12 +1024,14 @@ static void ShowDemoWindowWidgets()
|
||||
float my_tex_w = (float)io.Fonts->TexWidth;
|
||||
float my_tex_h = (float)io.Fonts->TexHeight;
|
||||
{
|
||||
static bool use_text_color_for_tint = false;
|
||||
ImGui::Checkbox("Use Text Color for Tint", &use_text_color_for_tint);
|
||||
ImGui::Text("%.0fx%.0f", my_tex_w, my_tex_h);
|
||||
ImVec2 pos = ImGui::GetCursorScreenPos();
|
||||
ImVec2 uv_min = ImVec2(0.0f, 0.0f); // Top-left
|
||||
ImVec2 uv_max = ImVec2(1.0f, 1.0f); // Lower-right
|
||||
ImVec4 tint_col = ImVec4(1.0f, 1.0f, 1.0f, 1.0f); // No tint
|
||||
ImVec4 border_col = ImVec4(1.0f, 1.0f, 1.0f, 0.5f); // 50% opaque white
|
||||
ImVec4 tint_col = use_text_color_for_tint ? ImGui::GetStyleColorVec4(ImGuiCol_Text) : ImVec4(1.0f, 1.0f, 1.0f, 1.0f); // No tint
|
||||
ImVec4 border_col = ImGui::GetStyleColorVec4(ImGuiCol_Border);
|
||||
ImGui::Image(my_tex_id, ImVec2(my_tex_w, my_tex_h), uv_min, uv_max, tint_col, border_col);
|
||||
if (ImGui::IsItemHovered())
|
||||
{
|
||||
|
@ -1671,23 +1671,16 @@ enum ImGuiDebugLogFlags_
|
||||
|
||||
struct ImGuiMetricsConfig
|
||||
{
|
||||
bool ShowDebugLog;
|
||||
bool ShowStackTool;
|
||||
bool ShowWindowsRects;
|
||||
bool ShowWindowsBeginOrder;
|
||||
bool ShowTablesRects;
|
||||
bool ShowDrawCmdMesh;
|
||||
bool ShowDrawCmdBoundingBoxes;
|
||||
int ShowWindowsRectsType;
|
||||
int ShowTablesRectsType;
|
||||
|
||||
ImGuiMetricsConfig()
|
||||
{
|
||||
ShowDebugLog = ShowStackTool = ShowWindowsRects = ShowWindowsBeginOrder = ShowTablesRects = false;
|
||||
ShowDrawCmdMesh = true;
|
||||
ShowDrawCmdBoundingBoxes = true;
|
||||
ShowWindowsRectsType = ShowTablesRectsType = -1;
|
||||
}
|
||||
bool ShowDebugLog = false;
|
||||
bool ShowStackTool = false;
|
||||
bool ShowWindowsRects = false;
|
||||
bool ShowWindowsBeginOrder = false;
|
||||
bool ShowTablesRects = false;
|
||||
bool ShowDrawCmdMesh = true;
|
||||
bool ShowDrawCmdBoundingBoxes = true;
|
||||
bool ShowAtlasTintedWithTextColor = false;
|
||||
int ShowWindowsRectsType = -1;
|
||||
int ShowTablesRectsType = -1;
|
||||
};
|
||||
|
||||
struct ImGuiStackLevelInfo
|
||||
|
Loading…
Reference in New Issue
Block a user