| 284 | |
| 285 | |
| 286 | void Viewer::DoResizeImageModal(bool resizeImagePressed) |
| 287 | { |
| 288 | if (resizeImagePressed) |
| 289 | ImGui::OpenPopup("Resize Image"); |
| 290 | |
| 291 | bool isOpenResizeImage = true; |
| 292 | if (!ImGui::BeginPopupModal("Resize Image", &isOpenResizeImage, ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoScrollbar)) |
| 293 | return; |
| 294 | |
| 295 | Config::ProfileData& profile = Config::GetProfileData(); |
| 296 | float buttonWidth = Gutil::GetUIParamScaled(78.0f, 2.5f); |
| 297 | |
| 298 | tAssert(CurrImage); tPicture* picture = CurrImage->GetCurrentPic(); tAssert(picture); |
| 299 | int srcW = picture->GetWidth(); |
| 300 | int srcH = picture->GetHeight(); |
| 301 | static int dstW = 512; |
| 302 | static int dstH = 512; |
| 303 | if (resizeImagePressed) { dstW = srcW; dstH = srcH; } |
| 304 | |
| 305 | DoResizeWidthHeightInterface(srcW, srcH, dstW, dstH); |
| 306 | DoResizeFilterInterface(srcW, srcH, dstW, dstH); |
| 307 | |
| 308 | ImGui::NewLine(); |
| 309 | ImGui::Separator(); |
| 310 | ImGui::NewLine(); |
| 311 | |
| 312 | if (Gutil::Button("Reset", tVector2(buttonWidth, 0.0f))) |
| 313 | { |
| 314 | dstW = srcW; |
| 315 | dstH = srcH; |
| 316 | } |
| 317 | |
| 318 | ImGui::SameLine(); |
| 319 | if (Gutil::Button("Cancel", tVector2(buttonWidth, 0.0f))) |
| 320 | ImGui::CloseCurrentPopup(); |
| 321 | |
| 322 | ImGui::SameLine(); |
| 323 | if (ImGui::IsWindowAppearing()) |
| 324 | ImGui::SetKeyboardFocusHere(); |
| 325 | if (Gutil::Button("Resize", tVector2(buttonWidth, 0.0f))) |
| 326 | { |
| 327 | if ((dstW != srcW) || (dstH != srcH)) |
| 328 | { |
| 329 | CurrImage->Unbind(); |
| 330 | CurrImage->Resample(dstW, dstH, tImage::tResampleFilter(profile.ResampleFilter), tImage::tResampleEdgeMode(profile.ResampleEdgeMode)); |
| 331 | CurrImage->Bind(); |
| 332 | Gutil::SetWindowTitle(); |
| 333 | Viewer::ZoomDownscaleOnly(); |
| 334 | } |
| 335 | ImGui::CloseCurrentPopup(); |
| 336 | } |
| 337 | ImGui::EndPopup(); |
| 338 | } |
| 339 | |
| 340 | |
| 341 | void Viewer::DoResizeCanvasModal(bool resizeCanvasPressed) |