Skip to content

Commit 0bcc4fd

Browse files
committed
Add details/icon/preview buttons + zoom slider
* They are presented at the bottom of the window (to the left of Ok/Cancel) * The size of the widget is unchanged * Compatible with small window sizes Note: preview now starts at zoom=3 instead of 5
1 parent 500c906 commit 0bcc4fd

File tree

1 file changed

+27
-2
lines changed

1 file changed

+27
-2
lines changed

ImFileDialog.cpp

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -840,7 +840,7 @@ namespace ifd {
840840
}
841841
void FileDialog::m_refreshIconPreview()
842842
{
843-
if (m_zoom >= 5.0f) {
843+
if (m_zoom >= 3.0f) {
844844
if (m_previewLoader == nullptr) {
845845
m_previewLoaderRunning = true;
846846
m_previewLoader = new std::thread(&FileDialog::m_loadPreview, this);
@@ -1386,7 +1386,32 @@ namespace ifd {
13861386
}
13871387
}
13881388

1389-
// buttons
1389+
// zoom
1390+
{
1391+
int zoom_int = (int)m_zoom;
1392+
ImGui::SetNextItemWidth(150.f);
1393+
bool changed = false;
1394+
changed |= ImGui::RadioButton("Details", & zoom_int, 1);
1395+
ImGui::SameLine();
1396+
changed |= ImGui::RadioButton("Icons", & zoom_int, 2);
1397+
ImGui::SameLine();
1398+
changed |= ImGui::RadioButton("Preview", & zoom_int, 3);
1399+
ImGui::SameLine();
1400+
if (zoom_int >= 3)
1401+
{
1402+
ImGui::SameLine();
1403+
ImGui::SetNextItemWidth(75.f);
1404+
changed |= ImGui::SliderInt("##Zoom", &zoom_int, 3, 30, "");
1405+
}
1406+
if (changed)
1407+
{
1408+
m_zoom = (float) zoom_int;
1409+
m_refreshIconPreview();
1410+
}
1411+
ImGui::SameLine();
1412+
}
1413+
1414+
// buttons
13901415
float ok_cancel_width = GUI_ELEMENT_SIZE * 7;
13911416
ImGui::SetCursorPosX(ImGui::GetWindowWidth() - ok_cancel_width);
13921417
if (ImGui::Button(m_type == IFD_DIALOG_SAVE ? "Save" : "Open", ImVec2(ok_cancel_width / 2 - ImGui::GetStyle().ItemSpacing.x, 0.0f))) {

0 commit comments

Comments
 (0)