| 190 | |
| 191 | |
| 192 | void Viewer::DoDeleteFileNoRecycleModal(bool deleteFileNoRecycPressed) |
| 193 | { |
| 194 | if (deleteFileNoRecycPressed) |
| 195 | ImGui::OpenPopup("Delete File Permanently"); |
| 196 | |
| 197 | // The unused isOpenPerm bool is just so we get a close button in ImGui. |
| 198 | bool isOpenPerm = true; |
| 199 | if (!ImGui::BeginPopupModal("Delete File Permanently", &isOpenPerm, ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoScrollbar)) |
| 200 | return; |
| 201 | |
| 202 | float buttonWidth = Gutil::GetUIParamScaled(76.0f, 2.5f); |
| 203 | |
| 204 | tString fullname = CurrImage->Filename; |
| 205 | tString file = tSystem::tGetFileName(fullname); |
| 206 | tString dir = tSystem::tGetDir(fullname); |
| 207 | |
| 208 | // The overall width is based on the larger of the filename and directory. We clamp |
| 209 | // the width of these two by calling CropStringToWidth. |
| 210 | float maxPathWidth = Gutil::GetUIParamScaled(380.0f, 2.5f); |
| 211 | float minPathWidth = Gutil::GetUIParamScaled(296.0f, 2.5f); |
| 212 | float fileWidth = 0.0f; |
| 213 | tString croppedFile = Gutil::CropStringToWidth(file, maxPathWidth, true, &fileWidth); |
| 214 | float dirWidth = 0.0f; |
| 215 | tString croppedDir = Gutil::CropStringToWidth(dir, maxPathWidth, true, &dirWidth); |
| 216 | float pathWidth = tMax(fileWidth, dirWidth, minPathWidth); |
| 217 | |
| 218 | ImGui::Text("Delete File"); |
| 219 | ImGui::Indent(); |
| 220 | ImGui::Text("%s", croppedFile.Chr()); |
| 221 | ImGui::Unindent(); |
| 222 | if (croppedFile != file) |
| 223 | Gutil::ToolTip(file.Chr()); |
| 224 | |
| 225 | ImGui::Text("In Folder"); |
| 226 | ImGui::Indent(); |
| 227 | ImGui::Text("%s", croppedDir.Chr()); |
| 228 | ImGui::Unindent(); |
| 229 | if (croppedDir != dir) |
| 230 | Gutil::ToolTip(dir.Chr()); |
| 231 | |
| 232 | ImGuiStyle& style = ImGui::GetStyle(); |
| 233 | ImGui::SetCursorPosY(ImGui::GetCursorPosY() + style.ItemSpacing.y); |
| 234 | ImGui::Separator(); |
| 235 | |
| 236 | ImGui::SetCursorPosY(ImGui::GetCursorPosY() + style.ItemSpacing.y); |
| 237 | ImGui::Text("This cannot be undone. File deletion will be permanent."); |
| 238 | ImGui::SetCursorPosY(ImGui::GetCursorPosY() + style.ItemSpacing.y); |
| 239 | |
| 240 | if (Gutil::Button("Cancel", tVector2(buttonWidth, 0.0f))) |
| 241 | ImGui::CloseCurrentPopup(); |
| 242 | |
| 243 | ImGui::SameLine(); |
| 244 | float okOffset = ImGui::GetStyle().IndentSpacing + pathWidth - buttonWidth + ImGui::GetStyle().ItemSpacing.x; |
| 245 | ImGui::SetCursorPosX(okOffset); |
| 246 | |
| 247 | ImGui::SetItemDefaultFocus(); |
| 248 | if (ImGui::IsWindowAppearing()) |
| 249 | ImGui::SetKeyboardFocusHere(); |
nothing calls this directly
no outgoing calls
no test coverage detected