| 157 | } |
| 158 | |
| 159 | void EditorInterface::DrawTitlebar(float& outHeight) |
| 160 | { |
| 161 | const bool isMaximized = Window::Get()->IsMaximized(); |
| 162 | const float titlebarHeight = isMaximized ? 68.0f : 58.0f; |
| 163 | float titlebarVerticalOffset = isMaximized ? 0.0f : 0.0f; |
| 164 | const ImVec2 windowPadding = ImGui::GetCurrentWindow()->WindowPadding; |
| 165 | |
| 166 | ImGui::SetCursorPos(ImVec2(windowPadding.x, windowPadding.y + titlebarVerticalOffset)); |
| 167 | const ImVec2 titlebarMin = ImGui::GetCursorScreenPos(); |
| 168 | const ImVec2 titlebarMax = { ImGui::GetCursorScreenPos().x + ImGui::GetWindowWidth() - windowPadding.y * 2.0f, |
| 169 | ImGui::GetCursorScreenPos().y + titlebarHeight }; |
| 170 | auto* bgDrawList = ImGui::GetBackgroundDrawList(); |
| 171 | auto* fgDrawList = ImGui::GetForegroundDrawList(); |
| 172 | |
| 173 | // Logo |
| 174 | { |
| 175 | const int logoWidth = NuakeTexture->GetSize().x; |
| 176 | const int logoHeight = NuakeTexture->GetSize().y; |
| 177 | const ImVec2 logoOffset(2.0f + windowPadding.x, 5.0f + windowPadding.y + titlebarVerticalOffset); |
| 178 | const ImVec2 logoRectStart = { ImGui::GetItemRectMin().x + logoOffset.x, ImGui::GetItemRectMin().y + logoOffset.y }; |
| 179 | const ImVec2 logoRectMax = { logoRectStart.x + logoWidth, logoRectStart.y + logoHeight }; |
| 180 | |
| 181 | ImGui::SetCursorPosX(ImGui::GetCursorPosX() + 2.0f + windowPadding.x); |
| 182 | ImGui::SetCursorPosY(ImGui::GetCursorPosY() + (5.0f + windowPadding.y + titlebarVerticalOffset) / 2.0); |
| 183 | ImGui::Image((ImTextureID)NuakeTexture->GetImGuiDescriptorSet(), ImVec2(logoWidth, logoHeight)); |
| 184 | } |
| 185 | |
| 186 | const float w = ImGui::GetContentRegionAvail().x; |
| 187 | const float buttonsAreaWidth = 94; |
| 188 | |
| 189 | // Title bar drag area |
| 190 | // On Windows we hook into the GLFW win32 window internals |
| 191 | ImGui::SetCursorPos(ImVec2(windowPadding.x, windowPadding.y + titlebarVerticalOffset)); // Reset cursor pos |
| 192 | |
| 193 | const auto titleBarDragSize = ImVec2(w - buttonsAreaWidth, titlebarHeight); |
| 194 | |
| 195 | if (Window::Get()->IsMaximized()) |
| 196 | { |
| 197 | float windowMousePosY = ImGui::GetMousePos().y - ImGui::GetCursorScreenPos().y; |
| 198 | if (windowMousePosY >= 0.0f && windowMousePosY <= 5.0f) |
| 199 | m_TitleBarHovered = true; // Account for the top-most pixels which don't register |
| 200 | } |
| 201 | |
| 202 | auto curPos = ImGui::GetCursorPos(); |
| 203 | bool isOnMenu = false; |
| 204 | { |
| 205 | const float logoHorizontalOffset = 5.0f * 2.0f + 48.0f + windowPadding.x; |
| 206 | ImGui::SetCursorPos(ImVec2(logoHorizontalOffset, 6.0f + titlebarVerticalOffset)); |
| 207 | DrawMenuBar(); |
| 208 | if (ImGui::IsItemHovered()) |
| 209 | { |
| 210 | isOnMenu = true; |
| 211 | } |
| 212 | |
| 213 | } |
| 214 | |
| 215 | |
| 216 | { |
nothing calls this directly
no test coverage detected