MCPcopy Create free account
hub / github.com/BohemiaInteractive/CWR / renderPreviewPanel

Method renderPreviewPanel

apps/tools/Studio/StudioApp.cpp:2196–2601  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2194}
2195
2196void StudioApp::renderPreviewPanel(float, float, float w, float h)
2197{
2198 ImGui::BeginChild("PreviewPanel", ImVec2(w, h), ImGuiChildFlags_Borders);
2199 ImGui::Text("Preview");
2200 if (currentPreview == PreviewType::Image && !selectedFile.empty())
2201 {
2202 ImGui::SameLine();
2203 ImGui::Text("Zoom: %.0f%%", textureZoom * 100.0f);
2204 ImGui::SameLine();
2205 if (ImGui::SmallButton("-##zoom"))
2206 textureZoom = std::max(0.1f, textureZoom * 0.8f);
2207 ImGui::SameLine();
2208 if (ImGui::SmallButton("+##zoom"))
2209 textureZoom = std::min(8.0f, textureZoom * 1.25f);
2210 ImGui::SameLine();
2211 if (ImGui::SmallButton("1:1##zoom"))
2212 textureZoom = 1.0f;
2213 ImGui::SameLine();
2214 if (ImGui::SmallButton("Fit##zoom"))
2215 {
2216 if (previewTexW > 0 && previewTexH > 0)
2217 {
2218 ImVec2 avail = ImGui::GetContentRegionAvail();
2219 textureZoom = std::min(avail.x / (float)previewTexW, avail.y / (float)previewTexH);
2220 }
2221 }
2222 if (textureMipCount > 1)
2223 {
2224 ImGui::SameLine();
2225 ImGui::Text("Mip:");
2226 ImGui::SameLine();
2227 ImGui::SetNextItemWidth(200.0f);
2228
2229 auto mipLabel = [&](int m) -> std::string
2230 {
2231 int mw = std::max(1, textureOrigW >> m);
2232 int mh = std::max(1, textureOrigH >> m);
2233 std::string s = std::to_string(mw) + "x" + std::to_string(mh);
2234 if (m == 0)
2235 s += " (100%)";
2236 else
2237 {
2238 float pct = 100.0f / (1 << m);
2239 char buf[32];
2240 snprintf(buf, sizeof(buf), " (%.4g%%)", pct);
2241 s += buf;
2242 }
2243 return s;
2244 };
2245
2246 if (ImGui::BeginCombo("##mip", mipLabel(textureMipLevel).c_str()))
2247 {
2248 for (int m = 0; m < textureMipCount; m++)
2249 {
2250 bool selected = (textureMipLevel == m);
2251 if (ImGui::Selectable(mipLabel(m).c_str(), selected))
2252 {
2253 textureMipLevel = m;

Callers

nothing calls this directly

Calls 15

minFunction · 0.85
ImageClass · 0.85
InspectPboFunction · 0.85
FormatSizeFunction · 0.85
logFunction · 0.85
ParseFXYFunction · 0.85
PreviewFontFromDataFunction · 0.85
PreviewFontFunction · 0.85
clearMethod · 0.80
sizeMethod · 0.80
durationMethod · 0.80
isVirtualMethod · 0.80

Tested by

no test coverage detected