ImGui-imgui实例解析之ShowStyleEditor-Colors
ImGui-imgui实例解析之ShowStyleEditor-Colors
没有明白是什么意思:
LogBegin(ImGuiLogType_TTY, auto_open_depth);
ImGui::LogText("ImVec4* colors = ImGui::GetStyle().Colors;" IM_NEWLINE);
ImGui::LogFinish();
颜色提取:
for (int i = 0; i < ImGuiCol_COUNT; i++)
{
const ImVec4& col = style.Colors[i];
const char* name = ImGui::GetStyleColorName(i);
if (!output_only_modified || memcmp(&col, &ref->Colors[i], sizeof(ImVec4)) != 0)
ImGui::LogText("colors[ImGuiCol_%s]%*s= ImVec4(%.2ff, %.2ff, %.2ff, %.2ff);" IM_NEWLINE,
name, 23 - (int)strlen(name), "", col.x, col.y, col.z, col.w);
}
文件过虑器:
static ImGuiTextFilter filter;
filter.Draw("Filter colors", ImGui::GetFontSize() * 16);
单选组:TMD还是没有明白,为什么这就是选中的,艹。
if (ImGui::RadioButton("Opaque", alpha_flags == ImGuiColorEditFlags_None))
{
alpha_flags = ImGuiColorEditFlags_None;
}
if (ImGui::RadioButton("Alpha", alpha_flags == ImGuiColorEditFlags_AlphaPreview))
{
alpha_flags = ImGuiColorEditFlags_AlphaPreview;
}
if (ImGui::RadioButton("Both", alpha_flags == ImGuiColorEditFlags_AlphaPreviewHalf))
{
alpha_flags = ImGuiColorEditFlags_AlphaPreviewHalf;
}
增加一个区域:真TMD的长呀。
ImGui::BeginChild("##colors", ImVec2(0, 0), true,
ImGuiWindowFlags_AlwaysVerticalScrollbar |
ImGuiWindowFlags_AlwaysHorizontalScrollbar |
ImGuiWindowFlags_NavFlattened);
结束区域:
ImGui::EndChild();// 需要和ImGui::BeginChild成对出现。
以颜色的名字,过虑颜色:
for (int i = 0; i < ImGuiCol_COUNT; i++)
{
const char* name = ImGui::GetStyleColorName(i);
if (!filter.PassFilter(name))
continue;
ImGui::PushID(i);
ImGui::ColorEdit4("##color", (float*)&style.Colors[i], ImGuiColorEditFlags_AlphaBar | alpha_flags);
if (memcmp(&style.Colors[i], &ref->Colors[i], sizeof(ImVec4)) != 0)
{
// Tips: in a real user application, you may want to merge and use an icon font into the main font,
// so instead of "Save"/"Revert" you'd use icons!
// Read the FAQ and docs/FONTS.md about using icon fonts. It's really easy and super convenient!
ImGui::SameLine(0.0f, style.ItemInnerSpacing.x); if (ImGui::Button("Save")) { ref->Colors[i] = style.Colors[i]; }
ImGui::SameLine(0.0f, style.ItemInnerSpacing.x); if (ImGui::Button("Revert")) { style.Colors[i] = ref->Colors[i]; }
}
ImGui::SameLine(0.0f, style.ItemInnerSpacing.x);
ImGui::TextUnformatted(name);// 没明白是什么意思,也没去试。
ImGui::PopID();
}
颜色编辑器:
ImGui::ColorEdit4("##color", (float*)&style.Colors[i], ImGuiColorEditFlags_AlphaBar | alpha_flags);
欢迎关注我,一起进步!扫描下方二维码即可加我
![](https://images.cnblogs.com/cnblogs_com/FKdelphi/1101510/o_200417075318%E5%8A%A0%E6%88%91QQ.jpg)
![](https://images.cnblogs.com/cnblogs_com/FKdelphi/1101510/o_200417080925%E5%8A%A0%E6%88%91%E5%BE%AE%E4%BF%A1.jpg)