We omit the ImGui:: prefix in this function, as we don't expect user to be copy and pasting this code.
| 8447 | |
| 8448 | // We omit the ImGui:: prefix in this function, as we don't expect user to be copy and pasting this code. |
| 8449 | void ImGui::ShowStyleEditor(ImGuiStyle* ref) |
| 8450 | { |
| 8451 | IMGUI_DEMO_MARKER("Tools/Style Editor"); |
| 8452 | // You can pass in a reference ImGuiStyle structure to compare to, revert to and save to |
| 8453 | // (without a reference style pointer, we will use one compared locally as a reference) |
| 8454 | ImGuiStyle& style = GetStyle(); |
| 8455 | static ImGuiStyle ref_saved_style; |
| 8456 | |
| 8457 | // Default to using internal storage as reference |
| 8458 | static bool init = true; |
| 8459 | if (init && ref == NULL) |
| 8460 | ref_saved_style = style; |
| 8461 | init = false; |
| 8462 | if (ref == NULL) |
| 8463 | ref = &ref_saved_style; |
| 8464 | |
| 8465 | // The logic behind dynamically changing 'max_border_size' is to not encourage people to increase border size too much: it'll likely reveal lots of subtle rendering artifacts and this isn't a priority right now. |
| 8466 | // Note that _MainScale is currently internal PLEASE DO NOT USE IN YOUR CODE. |
| 8467 | const float default_border_size = (float)(int)style._MainScale; |
| 8468 | const float max_border_size = IM_MAX(default_border_size, 2.0f); |
| 8469 | |
| 8470 | PushItemWidth(GetWindowWidth() * 0.50f); |
| 8471 | |
| 8472 | { |
| 8473 | // General |
| 8474 | SeparatorText("General"); |
| 8475 | if ((GetIO().BackendFlags & ImGuiBackendFlags_RendererHasTextures) == 0) |
| 8476 | { |
| 8477 | BulletText("Warning: Font scaling will NOT be smooth, because\nImGuiBackendFlags_RendererHasTextures is not set!"); |
| 8478 | BulletText("For instructions, see:"); |
| 8479 | SameLine(); |
| 8480 | TextLinkOpenURL("docs/BACKENDS.md", "https://github.com/ocornut/imgui/blob/master/docs/BACKENDS.md"); |
| 8481 | } |
| 8482 | |
| 8483 | if (ShowStyleSelector("Colors##Selector")) |
| 8484 | ref_saved_style = style; |
| 8485 | ShowFontSelector("Fonts##Selector"); |
| 8486 | if (DragFloat("FontSizeBase", &style.FontSizeBase, 0.20f, 5.0f, 100.0f, "%.0f")) |
| 8487 | style._NextFrameFontSizeBase = style.FontSizeBase; // FIXME: Temporary hack until we finish remaining work. |
| 8488 | SameLine(0.0f, 0.0f); Text(" (out %.2f)", GetFontSize()); |
| 8489 | DragFloat("FontScaleMain", &style.FontScaleMain, 0.02f, 0.5f, 4.0f); |
| 8490 | //BeginDisabled(GetIO().ConfigDpiScaleFonts); |
| 8491 | DragFloat("FontScaleDpi", &style.FontScaleDpi, 0.02f, 0.5f, 4.0f); |
| 8492 | //SetItemTooltip("When io.ConfigDpiScaleFonts is set, this value is automatically overwritten."); |
| 8493 | //EndDisabled(); |
| 8494 | |
| 8495 | // Simplified Settings (expose floating-pointer border sizes as boolean representing 0.0f or 1.0f) |
| 8496 | if (SliderFloat("FrameRounding", &style.FrameRounding, 0.0f, 12.0f, "%.0f")) |
| 8497 | style.GrabRounding = style.FrameRounding; // Make GrabRounding always the same value as FrameRounding |
| 8498 | { bool border = (style.WindowBorderSize > 0.0f); if (Checkbox("WindowBorder", &border)) { style.WindowBorderSize = border ? default_border_size : 0.0f; } } |
| 8499 | SameLine(); |
| 8500 | { bool border = (style.FrameBorderSize > 0.0f); if (Checkbox("FrameBorder", &border)) { style.FrameBorderSize = border ? default_border_size : 0.0f; } } |
| 8501 | SameLine(); |
| 8502 | { bool border = (style.PopupBorderSize > 0.0f); if (Checkbox("PopupBorder", &border)) { style.PopupBorderSize = border ? default_border_size : 0.0f; } } |
| 8503 | } |
| 8504 | |
| 8505 | // Save/Revert button |
| 8506 | if (Button("Save Ref")) |
nothing calls this directly
no test coverage detected