| 125 | } |
| 126 | |
| 127 | void ImageLoader::renderUI(Gui::Widgets& widget) |
| 128 | { |
| 129 | // When output size requirements change, we'll trigger a graph recompile to update the render pass I/O sizes. |
| 130 | if (widget.dropdown("Output size", mOutputSizeSelection)) |
| 131 | requestRecompile(); |
| 132 | widget.tooltip( |
| 133 | "Specifies the pass output size.\n" |
| 134 | "'Default' means that the output is sized based on requirements of connected passes.\n" |
| 135 | "'Fixed' means the output is always at the image's native size.\n" |
| 136 | "If the output is of a different size than the native image resolution, the image will be rescaled bilinearly.", |
| 137 | true |
| 138 | ); |
| 139 | |
| 140 | widget.text("Image File: " + mImagePath.string()); |
| 141 | bool reloadImage = false; |
| 142 | reloadImage |= widget.checkbox("Load As SRGB", mLoadSRGB); |
| 143 | reloadImage |= widget.checkbox("Generate Mipmaps", mGenerateMips); |
| 144 | |
| 145 | if (widget.button("Load File")) |
| 146 | { |
| 147 | reloadImage |= openFileDialog({}, mImagePath); |
| 148 | } |
| 149 | |
| 150 | if (mpTex) |
| 151 | { |
| 152 | if (mpTex->getMipCount() > 1) |
| 153 | widget.slider("Mip Level", mMipLevel, 0u, mpTex->getMipCount() - 1); |
| 154 | if (mpTex->getArraySize() > 1) |
| 155 | widget.slider("Array Slice", mArraySlice, 0u, mpTex->getArraySize() - 1); |
| 156 | |
| 157 | widget.image(mImagePath.string().c_str(), mpTex.get(), {320, 320}); |
| 158 | widget.text("Image format: " + to_string(mpTex->getFormat())); |
| 159 | widget.text("Image size: (" + std::to_string(mpTex->getWidth()) + ", " + std::to_string(mpTex->getHeight()) + ")"); |
| 160 | widget.text("Output format: " + to_string(mOutputFormat)); |
| 161 | widget.text("Output size: (" + std::to_string(mOutputSize.x) + ", " + std::to_string(mOutputSize.y) + ")"); |
| 162 | } |
| 163 | |
| 164 | if (reloadImage && !mImagePath.empty()) |
| 165 | { |
| 166 | uint2 prevSize = {}; |
| 167 | if (mpTex) |
| 168 | prevSize = {mpTex->getWidth(), mpTex->getHeight()}; |
| 169 | |
| 170 | if (!loadImage(mImagePath)) |
| 171 | { |
| 172 | msgBox("Error", fmt::format("Failed to load image from '{}'", mImagePath), MsgBoxType::Ok, MsgBoxIcon::Warning); |
| 173 | } |
| 174 | |
| 175 | // If output is set to native size and image dimensions have changed, |
| 176 | // we'll trigger a graph recompile to update the render pass I/O sizes. |
| 177 | if (mOutputSizeSelection == RenderPassHelpers::IOSize::Fixed && mpTex != nullptr && |
| 178 | (mpTex->getWidth() != prevSize.x || mpTex->getHeight() != prevSize.y)) |
| 179 | { |
| 180 | requestRecompile(); |
| 181 | } |
| 182 | } |
| 183 | } |
| 184 |
nothing calls this directly
no test coverage detected