MCPcopy Create free account
hub / github.com/WinDurango/WinDurango / XBNotif

Method XBNotif

projects/WinDurango.Common/src/GUI.cpp:78–144  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

76 }
77
78 void GUI::XBNotif(const char* notif_text, const char* icon, const char* bottom_tip)
79 {
80 ImVec4 tipColor = ImVec4(64.0f/255.0f, 158.0f/255.0f, 254.0f/255.0f, 1.0f);
81 ImVec4 color = ImVec4(38/255.0f, 145/255.0f, 253/255.0f, 1.0f);
82 ImGuiWindowFlags flags = ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoScrollWithMouse | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoBringToFrontOnFocus | ImGuiWindowFlags_NoNavFocus | ImGuiWindowFlags_NoDecoration;
83
84 ImGuiViewport* vp = ImGui::GetMainViewport();
85
86 ImVec2 windowPos;
87 windowPos.x = ImGui::GetIO().DisplaySize.x * 0.5f;
88 windowPos.y = ImGui::GetIO().DisplaySize.y * 0.95f;
89
90 ImGui::SetNextWindowPos(windowPos, ImGuiCond_Always, ImVec2(0.5f, 1.0f));
91
92 ImGui::PushStyleColor(ImGuiCol_WindowBg, tipColor);
93 ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 3.0f);
94 ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, 0.0f);
95 ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(12, 12));
96 ImGui::SetNextWindowSize(ImVec2(370, 60));
97
98 ImGui::Begin("NotificationTip", nullptr, flags);
99
100 ImVec2 pos = ImGui::GetWindowPos();
101
102 ImVec2 p = ImGui::GetCursorScreenPos();
103 float size = 38.0f;
104
105 ImDrawList* draw_list = ImGui::GetWindowDrawList();
106 draw_list->AddRectFilled(p, ImVec2(p.x + size, p.y + size), IM_COL32(31, 73, 117, 255));
107
108 const char* text = icon;
109 ImVec2 text_size = ImGui::CalcTextSize(text);
110 ImVec2 text_pos = ImVec2(
111 p.x + (size - text_size.x) / 2,
112 p.y + (size - text_size.y) / 2
113 );
114 draw_list->AddText(text_pos, IM_COL32(255, 255, 255, 255), text);
115
116 ImVec2 notif_pos = ImVec2(
117 text_pos.x + 40,
118 text_pos.y
119 );
120 draw_list->AddText(notif_pos, IM_COL32(255, 255, 255, 255), notif_text);
121
122 ImGui::End();
123
124 ImGui::PopStyleColor();
125 ImGui::PopStyleVar(3);
126
127 float windowEndY = pos.y + 50;
128
129 ImGui::SetNextWindowPos({pos.x, windowEndY});
130 ImGui::PushStyleColor(ImGuiCol_WindowBg, color);
131 ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 3.0f);
132 ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, 0.0f);
133 ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(15, 15));
134 ImGui::SetNextWindowSize(ImVec2(370, 40));
135

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected