Two-line accent row (bCompact = single-line, de-emphasized); returns true on left-click. OutCloseClicked set when the trailing close button is hit (if bShowClose).
| 180 | constexpr ImVec4 kProjDialogTextMuted = ImVec4(0.42f, 0.42f, 0.47f, 1.00f); |
| 181 | constexpr ImVec4 kProjDialogTextSection = ImVec4(0.50f, 0.58f, 0.72f, 1.00f); |
| 182 | constexpr ImVec4 kProjDialogAccentBlue = ImVec4(0.36f, 0.66f, 1.00f, 1.00f); |
| 183 | constexpr ImVec4 kProjDialogAccentGold = ImVec4(1.00f, 0.78f, 0.40f, 1.00f); |
| 184 | constexpr ImVec4 kProjDialogAccentSoft = ImVec4(0.45f, 0.48f, 0.55f, 1.00f); |
| 185 | constexpr ImVec4 kProjDialogDanger = ImVec4(0.96f, 0.36f, 0.38f, 1.00f); |
| 186 | |
| 187 | // Small uppercase section label in the section-text color. |
| 188 | void DrawSectionHeader(const char* Label) |
| 189 | { |
| 190 | ImGui::Spacing(); |
| 191 | ImGuiX::Font::PushFont(ImGuiX::Font::EFont::TinyBold); |
| 192 | ImGui::PushStyleColor(ImGuiCol_Text, kProjDialogTextSection); |
| 193 | ImGui::SetCursorPosX(ImGui::GetCursorPosX() + 4.0f); |
| 194 | ImGui::TextUnformatted(Label); |
| 195 | ImGui::PopStyleColor(); |
| 196 | ImGuiX::Font::PopFont(); |
| 197 | ImGui::Spacing(); |
| 198 | } |
| 199 | |
| 200 | // Returns true on left-click, and sets OutCloseClicked when the trailing close button is hit. |
| 201 | bool DrawProjectRow( |
| 202 | const char* Icon, |
| 203 | const char* Title, |
| 204 | const char* Subtitle, |
| 205 | const ImVec4& Accent, |
| 206 | bool bCompact = false, |
| 207 | bool bShowClose = false, |
| 208 | bool* OutCloseClicked = nullptr) |
| 209 | { |
| 210 | if (OutCloseClicked) |
| 211 | { |
| 212 | *OutCloseClicked = false; |
| 213 | } |
| 214 | |
| 215 | const float Avail = ImGui::GetContentRegionAvail().x; |
| 216 | const float Height = bCompact ? 30.0f : 50.0f; |
| 217 | const float CloseW = bShowClose ? 28.0f : 0.0f; |
| 218 | const ImVec2 P0 = ImGui::GetCursorScreenPos(); |
| 219 | const ImVec2 P1 = ImVec2(P0.x + Avail, P0.y + Height); |
| 220 | |
| 221 | // Two rows can share a title, so seed the ID scope from the subtitle path as well. |
| 222 | ImGui::PushID(Title); |
| 223 | ImGui::PushID(Subtitle ? Subtitle : ""); |
| 224 | |
| 225 | // Invisible button covers the full row area (minus the close column). |
| 226 | ImGui::SetCursorScreenPos(P0); |
| 227 | const bool bRowClicked = ImGui::InvisibleButton( |
| 228 | "##row", |
| 229 | ImVec2(Math::Max(Avail - CloseW, 1.0f), Height)); // floor, InvisibleButton asserts on zero width |
| 230 | const bool bHovered = ImGui::IsItemHovered(); |
| 231 | const bool bActive = ImGui::IsItemActive(); |
| 232 | |
| 233 | ImDrawList* DL = ImGui::GetWindowDrawList(); |
| 234 | const ImU32 BgCol = ImGui::ColorConvertFloat4ToU32( |
| 235 | bActive ? kProjDialogRowBgActive : (bHovered ? kProjDialogRowBgHover : kProjDialogRowBg)); |
| 236 | DL->AddRectFilled(P0, P1, BgCol, 4.0f); |
| 237 | DL->AddRectFilled(P0, ImVec2(P0.x + 3.0f, P1.y), |
| 238 | ImGui::ColorConvertFloat4ToU32(Accent), 4.0f); |
| 239 |
no test coverage detected