MCPcopy Create free account
hub / github.com/brenocq/implot3d / ShowStyleEditor

Function ShowStyleEditor

implot3d_demo.cpp:2001–2275  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1999}
2000
2001void ShowStyleEditor(ImPlot3DStyle* ref) {
2002 ImPlot3DContext& gp = *GImPlot3D;
2003
2004 // Handle style internal storage
2005 ImPlot3DStyle& style = GetStyle();
2006 static ImPlot3DStyle ref_saved_style;
2007 static bool init = true;
2008 if (init && ref == nullptr)
2009 ref_saved_style = style;
2010 init = false;
2011 if (ref == nullptr)
2012 ref = &ref_saved_style;
2013
2014 // Handle flash style color
2015 static float flash_color_time = 0.5f;
2016 static ImPlot3DCol flash_color_idx = ImPlot3DCol_COUNT;
2017 static ImVec4 flash_color_backup = ImVec4(0, 0, 0, 0);
2018 if (flash_color_idx != ImPlot3DCol_COUNT) {
2019 // Flash color
2020 ImVec4& color = style.Colors[flash_color_idx];
2021 ImGui::ColorConvertHSVtoRGB(ImCos(flash_color_time * 6.0f) * 0.5f + 0.5f, 0.5f, 0.5f, color.x, color.y, color.z);
2022 color.w = 1.0f;
2023
2024 // Decrease timer until zero
2025 if ((flash_color_time -= ImGui::GetIO().DeltaTime) <= 0.0f) {
2026 // When timer reaches zero, restore the backup color
2027 style.Colors[flash_color_idx] = flash_color_backup;
2028 flash_color_idx = ImPlot3DCol_COUNT;
2029 flash_color_time = 0.5f;
2030 }
2031 }
2032
2033 // Style selector
2034 if (ImPlot3D::ShowStyleSelector("Colors##Selector"))
2035 ref_saved_style = style;
2036
2037 // Save/Revert button
2038 if (ImGui::Button("Save Ref"))
2039 *ref = ref_saved_style = style;
2040 ImGui::SameLine();
2041 if (ImGui::Button("Revert Ref"))
2042 style = *ref;
2043 ImGui::SameLine();
2044 HelpMarker("Save/Revert in local non-persistent storage. Default Colors definition are not affected. "
2045 "Use \"Export\" below to save them somewhere.");
2046
2047 ImGui::Separator();
2048
2049 if (ImGui::BeginTabBar("##Tabs", ImGuiTabBarFlags_None)) {
2050 if (ImGui::BeginTabItem("Variables")) {
2051 ImGui::Text("Item Styling");
2052 ImGui::SliderFloat("LineWeight", &style.LineWeight, 0.0f, 5.0f, "%.1f");
2053 ImGui::SliderFloat("MarkerSize", &style.MarkerSize, 2.0f, 10.0f, "%.1f");
2054 ImGui::SliderFloat("FillAlpha", &style.FillAlpha, 0.0f, 1.0f, "%.2f");
2055 ImGui::Text("Plot Styling");
2056 ImGui::SliderFloat2("PlotDefaultSize", (float*)&style.PlotDefaultSize, 0.0f, 1000, "%.0f");
2057 ImGui::SliderFloat2("PlotMinSize", (float*)&style.PlotMinSize, 0.0f, 300, "%.0f");
2058 ImGui::SliderFloat2("PlotPadding", (float*)&style.PlotPadding, 0.0f, 20.0f, "%.0f");

Callers 1

ShowDemoWindowFunction · 0.85

Calls 15

ShowStyleSelectorFunction · 0.85
HelpMarkerFunction · 0.85
GetStyleColorNameFunction · 0.85
IsColorAutoFunction · 0.85
GetColormapSizeFunction · 0.85
GetColormapNameFunction · 0.85
GetColormapColorU32Function · 0.85
PushStyleVarFunction · 0.85
BustItemCacheFunction · 0.85
PopStyleVarFunction · 0.85
ColormapButtonFunction · 0.85
AddColormapFunction · 0.85

Tested by

no test coverage detected