| 40 | |
| 41 | |
| 42 | void Viewer::DoResizeWidthHeightInterface(int srcW, int srcH, int& dstW, int& dstH) |
| 43 | { |
| 44 | float aspect = float(srcW) / float(srcH); |
| 45 | static bool lockAspect = true; |
| 46 | |
| 47 | float dimWidth = Gutil::GetUIParamScaled(90.0f, 2.5f); |
| 48 | float dimOffset = Gutil::GetUIParamScaled(140.0f, 2.5f); |
| 49 | float powButtonWidth = Gutil::GetUIParamScaled(44.0f, 2.5f); |
| 50 | |
| 51 | static char lo[32]; |
| 52 | static char hi[32]; |
| 53 | |
| 54 | ImGui::SetNextItemWidth(dimWidth); |
| 55 | if (ImGui::InputInt("Width", &dstW) && lockAspect) |
| 56 | dstH = int( float(dstW) / aspect ); |
| 57 | tiClamp(dstW, 4, Viewer::Image::MaxDim); tiClamp(dstH, 4, Viewer::Image::MaxDim); |
| 58 | int loP2W = tNextLowerPower2(dstW); tiClampMin(loP2W, 4); tsPrintf(lo, "%d##Wlo", loP2W); |
| 59 | int hiP2W = tNextHigherPower2(dstW); tsPrintf(hi, "%d##Whi", hiP2W); |
| 60 | ImGui::SetCursorPosX(dimOffset); |
| 61 | ImGui::SameLine(); |
| 62 | ImGui::SetCursorPosX(dimOffset); |
| 63 | if (ImGui::Button(lo, tVector2(powButtonWidth, 0.0f))) { dstW = loP2W; if (lockAspect) dstH = int( float(dstW) / aspect ); } |
| 64 | ImGui::SameLine(); |
| 65 | if (ImGui::Button(hi, tVector2(powButtonWidth, 0.0f))) { dstW = hiP2W; if (lockAspect) dstH = int( float(dstW) / aspect ); } |
| 66 | ImGui::SameLine(); |
| 67 | Gutil::HelpMark("Final output width in pixels.\nIf dimensions match current no scaling."); |
| 68 | |
| 69 | if (ImGui::Checkbox("Lock Aspect", &lockAspect) && lockAspect) |
| 70 | { |
| 71 | dstW = srcW; |
| 72 | dstH = srcH; |
| 73 | } |
| 74 | |
| 75 | ImGui::SetNextItemWidth(dimWidth); |
| 76 | if (ImGui::InputInt("Height", &dstH) && lockAspect) |
| 77 | dstW = int( float(dstH) * aspect ); |
| 78 | tiClamp(dstW, 4, Viewer::Image::MaxDim); tiClamp(dstH, 4, Viewer::Image::MaxDim); |
| 79 | ImGui::SetCursorPosX(dimOffset); |
| 80 | int loP2H = tNextLowerPower2(dstH); tiClampMin(loP2H, 4); tsPrintf(lo, "%d##Hlo", loP2H); |
| 81 | int hiP2H = tNextHigherPower2(dstH); tsPrintf(hi, "%d##Hhi", hiP2H); |
| 82 | ImGui::SameLine(); |
| 83 | ImGui::SetCursorPosX(dimOffset); |
| 84 | if (ImGui::Button(lo, tVector2(powButtonWidth, 0.0f))) { dstH = loP2H; if (lockAspect) dstW = int( float(dstH) * aspect ); } |
| 85 | ImGui::SameLine(); |
| 86 | if (ImGui::Button(hi, tVector2(powButtonWidth, 0.0f))) { dstH = hiP2H; if (lockAspect) dstW = int( float(dstH) * aspect ); } |
| 87 | |
| 88 | ImGui::SameLine(); |
| 89 | Gutil::HelpMark("Final output height in pixels.\nIf dimensions match current no scaling."); |
| 90 | } |
| 91 | |
| 92 | |
| 93 | void Viewer::DoResizeFilterInterface(int srcW, int srcH, int dstW, int dstH) |
nothing calls this directly
no outgoing calls
no test coverage detected