Unravel Engine C++ Reference
Loading...
Searching...
No Matches
imgui_context_menu_style.cpp
Go to the documentation of this file.
2
3#include <imgui/imgui_internal.h>
4
5namespace ImGui
6{
7namespace
8{
9
10constexpr int k_context_menu_style_var_count = 5;
11constexpr int k_context_menu_style_color_count = 4;
12
13} // namespace
14
16{
17 PushStyleVar(ImGuiStyleVar_PopupRounding, 6.0f);
18 PushStyleVar(ImGuiStyleVar_PopupBorderSize, 1.0f);
19 PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(12.0f, 10.0f));
20 PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(10.0f, 6.0f));
21 PushStyleVar(ImGuiStyleVar_ItemInnerSpacing, ImVec2(8.0f, 6.0f));
22
23 ImVec4 popup_bg = GetStyleColorVec4(ImGuiCol_PopupBg);
24 popup_bg.x = std::min(popup_bg.x + 0.02f, 1.0f);
25 popup_bg.y = std::min(popup_bg.y + 0.02f, 1.0f);
26 popup_bg.z = std::min(popup_bg.z + 0.02f, 1.0f);
27 PushStyleColor(ImGuiCol_PopupBg, popup_bg);
28
29 ImVec4 header_hovered = GetStyleColorVec4(ImGuiCol_HeaderHovered);
30 header_hovered.w = std::min(header_hovered.w + 0.08f, 1.0f);
31 PushStyleColor(ImGuiCol_HeaderHovered, header_hovered);
32
33 ImVec4 header_active = GetStyleColorVec4(ImGuiCol_HeaderActive);
34 header_active.w = std::min(header_active.w + 0.12f, 1.0f);
35 PushStyleColor(ImGuiCol_HeaderActive, header_active);
36
37 ImVec4 separator = GetStyleColorVec4(ImGuiCol_Separator);
38 separator.w = std::min(separator.w + 0.35f, 1.0f);
39 PushStyleColor(ImGuiCol_Separator, separator);
40}
41
43{
44 PopStyleColor(k_context_menu_style_color_count);
45 PopStyleVar(k_context_menu_style_var_count);
46}
47
48auto MenuItemIcon(const char* icon, const char* label, const char* shortcut, bool enabled) -> bool
49{
50 if(icon == nullptr || icon[0] == '\0')
51 {
52 return MenuItem(label, shortcut, false, enabled);
53 }
54
55 char buffer[256];
56 ImFormatString(buffer, IM_ARRAYSIZE(buffer), "%s %s", icon, label);
57 return MenuItem(buffer, shortcut, false, enabled);
58}
59
60auto BeginMenuIcon(const char* icon, const char* label, bool enabled) -> bool
61{
62 if(icon == nullptr || icon[0] == '\0')
63 {
64 return BeginMenu(label, enabled);
65 }
66
67 char buffer[256];
68 ImFormatString(buffer, IM_ARRAYSIZE(buffer), "%s %s", icon, label);
69 return BeginMenu(buffer, enabled);
70}
71
72} // namespace ImGui
const char * icon
auto BeginMenuIcon(const char *icon, const char *label, bool enabled) -> bool
auto MenuItemIcon(const char *icon, const char *label, const char *shortcut, bool enabled) -> bool
bool enabled