1
0
Fork 0
mirror of https://github.com/gwm17/implot.git synced 2024-11-22 18:28:53 -05:00

Fix for allowing core imgui to use typed ImGuiCol / ImGuiStyleVar enums. (#405)

This commit is contained in:
omar 2022-09-24 02:30:19 +02:00 committed by GitHub
parent 6978a3e177
commit 8879c99aef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -4235,7 +4235,7 @@ ImPlotStyle& GetStyle() {
void PushStyleColor(ImPlotCol idx, ImU32 col) { void PushStyleColor(ImPlotCol idx, ImU32 col) {
ImPlotContext& gp = *GImPlot; ImPlotContext& gp = *GImPlot;
ImGuiColorMod backup; ImGuiColorMod backup;
backup.Col = idx; backup.Col = (ImGuiCol)idx;
backup.BackupValue = gp.Style.Colors[idx]; backup.BackupValue = gp.Style.Colors[idx];
gp.ColorModifiers.push_back(backup); gp.ColorModifiers.push_back(backup);
gp.Style.Colors[idx] = ImGui::ColorConvertU32ToFloat4(col); gp.Style.Colors[idx] = ImGui::ColorConvertU32ToFloat4(col);
@ -4244,7 +4244,7 @@ void PushStyleColor(ImPlotCol idx, ImU32 col) {
void PushStyleColor(ImPlotCol idx, const ImVec4& col) { void PushStyleColor(ImPlotCol idx, const ImVec4& col) {
ImPlotContext& gp = *GImPlot; ImPlotContext& gp = *GImPlot;
ImGuiColorMod backup; ImGuiColorMod backup;
backup.Col = idx; backup.Col = (ImGuiCol)idx;
backup.BackupValue = gp.Style.Colors[idx]; backup.BackupValue = gp.Style.Colors[idx];
gp.ColorModifiers.push_back(backup); gp.ColorModifiers.push_back(backup);
gp.Style.Colors[idx] = col; gp.Style.Colors[idx] = col;
@ -4267,7 +4267,7 @@ void PushStyleVar(ImPlotStyleVar idx, float val) {
const ImPlotStyleVarInfo* var_info = GetPlotStyleVarInfo(idx); const ImPlotStyleVarInfo* var_info = GetPlotStyleVarInfo(idx);
if (var_info->Type == ImGuiDataType_Float && var_info->Count == 1) { if (var_info->Type == ImGuiDataType_Float && var_info->Count == 1) {
float* pvar = (float*)var_info->GetVarPtr(&gp.Style); float* pvar = (float*)var_info->GetVarPtr(&gp.Style);
gp.StyleModifiers.push_back(ImGuiStyleMod(idx, *pvar)); gp.StyleModifiers.push_back(ImGuiStyleMod((ImGuiStyleVar)idx, *pvar));
*pvar = val; *pvar = val;
return; return;
} }
@ -4279,27 +4279,27 @@ void PushStyleVar(ImPlotStyleVar idx, int val) {
const ImPlotStyleVarInfo* var_info = GetPlotStyleVarInfo(idx); const ImPlotStyleVarInfo* var_info = GetPlotStyleVarInfo(idx);
if (var_info->Type == ImGuiDataType_S32 && var_info->Count == 1) { if (var_info->Type == ImGuiDataType_S32 && var_info->Count == 1) {
int* pvar = (int*)var_info->GetVarPtr(&gp.Style); int* pvar = (int*)var_info->GetVarPtr(&gp.Style);
gp.StyleModifiers.push_back(ImGuiStyleMod(idx, *pvar)); gp.StyleModifiers.push_back(ImGuiStyleMod((ImGuiStyleVar)idx, *pvar));
*pvar = val; *pvar = val;
return; return;
} }
else if (var_info->Type == ImGuiDataType_Float && var_info->Count == 1) { else if (var_info->Type == ImGuiDataType_Float && var_info->Count == 1) {
float* pvar = (float*)var_info->GetVarPtr(&gp.Style); float* pvar = (float*)var_info->GetVarPtr(&gp.Style);
gp.StyleModifiers.push_back(ImGuiStyleMod(idx, *pvar)); gp.StyleModifiers.push_back(ImGuiStyleMod((ImGuiStyleVar)idx, *pvar));
*pvar = (float)val; *pvar = (float)val;
return; return;
} }
IM_ASSERT(0 && "Called PushStyleVar() int variant but variable is not a int!"); IM_ASSERT(0 && "Called PushStyleVar() int variant but variable is not a int!");
} }
void PushStyleVar(ImGuiStyleVar idx, const ImVec2& val) void PushStyleVar(ImPlotStyleVar idx, const ImVec2& val)
{ {
ImPlotContext& gp = *GImPlot; ImPlotContext& gp = *GImPlot;
const ImPlotStyleVarInfo* var_info = GetPlotStyleVarInfo(idx); const ImPlotStyleVarInfo* var_info = GetPlotStyleVarInfo(idx);
if (var_info->Type == ImGuiDataType_Float && var_info->Count == 2) if (var_info->Type == ImGuiDataType_Float && var_info->Count == 2)
{ {
ImVec2* pvar = (ImVec2*)var_info->GetVarPtr(&gp.Style); ImVec2* pvar = (ImVec2*)var_info->GetVarPtr(&gp.Style);
gp.StyleModifiers.push_back(ImGuiStyleMod(idx, *pvar)); gp.StyleModifiers.push_back(ImGuiStyleMod((ImGuiStyleVar)idx, *pvar));
*pvar = val; *pvar = val;
return; return;
} }