diff --git a/Src/ColourDialogs.cpp b/Src/ColourDialogs.cpp index 4ae01fcd..2e01aeec 100644 --- a/Src/ColourDialogs.cpp +++ b/Src/ColourDialogs.cpp @@ -46,10 +46,14 @@ void Viewer::ShowPixelEditorOverlay(bool* popen) { tVector2 windowPos = GetDialogOrigin(DialogID::PixelEditor); ImGui::SetNextWindowPos(windowPos, ImGuiCond_FirstUseEver); + + // I imagine NoResize is implied by AlwaysAutoResize. However I have seen cases where + // a scrollbar width gets reserved even with AutoResize is on. This is why we're using + // NoScrollBar every time we use AutoResize. ImGuiWindowFlags flags = ImGuiWindowFlags_NoResize | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoFocusOnAppearing | - ImGuiWindowFlags_NoNav; + ImGuiWindowFlags_NoNav | ImGuiWindowFlags_NoScrollbar; static bool live = true; static tColourf floatCol = tColourf::black; @@ -141,7 +145,7 @@ void Viewer::ShowChannelFilterOverlay(bool* popen) ImGui::SetNextWindowPos(windowPos, ImGuiCond_FirstUseEver); ImGuiWindowFlags flags = ImGuiWindowFlags_NoResize | ImGuiWindowFlags_AlwaysAutoResize | - ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoNav; + ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoNav | ImGuiWindowFlags_NoScrollbar; if (ImGui::Begin("Channel Filter", popen, flags)) { @@ -330,7 +334,7 @@ void Viewer::DoLevelsModal(bool levelsPressed) } bool isOpenLevels = true; - if (!ImGui::BeginPopupModal("Adjust Levels", &isOpenLevels, ImGuiWindowFlags_AlwaysAutoResize)) + if (!ImGui::BeginPopupModal("Adjust Levels", &isOpenLevels, ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoScrollbar)) { if (popupOpen) { @@ -630,10 +634,10 @@ void Viewer::DoLevelsModal(bool levelsPressed) Viewer::SetWindowTitle(); ImGui::CloseCurrentPopup(); } - ImGui::SameLine(); - - ImGui::SetCursorPosX(ImGui::GetWindowContentRegionMax().x - buttonWidth); + + float okOffset = Viewer::GetUIParamScaled(264.0f, 2.5f); + ImGui::SetCursorPosX(okOffset); if (ImGui::IsWindowAppearing()) ImGui::SetKeyboardFocusHere(); if (Viewer::Button("OK", tVector2(buttonWidth, 0.0f))) diff --git a/Src/ContactSheet.cpp b/Src/ContactSheet.cpp index c24d8c0e..a229a67e 100644 --- a/Src/ContactSheet.cpp +++ b/Src/ContactSheet.cpp @@ -66,9 +66,10 @@ void Viewer::DoSaveContactSheetModal(bool saveContactSheetPressed) // The unused isOpenContactSheet bool is just so we get a close button in ImGui. Returns false if popup not open. bool isOpenContactSheet = true; - if (!ImGui::BeginPopupModal("Contact Sheet", &isOpenContactSheet, ImGuiWindowFlags_AlwaysAutoResize)) + if (!ImGui::BeginPopupModal("Contact Sheet", &isOpenContactSheet, ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoScrollbar)) return; + const ImGuiStyle& style = ImGui::GetStyle(); static int frameWidth = 256; static int frameHeight = 256; static bool anyImageNeedsResize = false; @@ -143,7 +144,8 @@ void Viewer::DoSaveContactSheetModal(bool saveContactSheetPressed) ImGui::SameLine(); if (ImGui::Button(hi, powSize)) frameHeight = hiP2H; - ImGui::SameLine(); ShowHelpMark("Single frame height in pixels."); + ImGui::SameLine(); + ShowHelpMark("Single frame height in pixels."); ImGui::SetNextItemWidth(itemWidth); ImGui::InputInt("Columns", &numCols); @@ -267,10 +269,12 @@ void Viewer::DoSaveContactSheetModal(bool saveContactSheetPressed) ImGui::CloseCurrentPopup(); ImGui::SameLine(); - ImGui::SetCursorPosX(ImGui::GetWindowContentRegionMax().x - buttonWidth); - tString outFile = destDir + tString(filename) + extensionWithDot; bool closeThisModal = false; + + float genButOffset = Viewer::GetUIParamScaled(324.0f, 2.5f); + ImGui::SetCursorPosX(genButOffset); + if (ImGui::IsWindowAppearing()) ImGui::SetKeyboardFocusHere(); if (Viewer::Button("Generate", tVector2(buttonWidth, 0.0f)) && (numImg >= 2)) @@ -298,7 +302,7 @@ void Viewer::DoSaveContactSheetModal(bool saveContactSheetPressed) // The unused isOpen bool is just so we get a close button in ImGui. bool isOpen = true; - if (ImGui::BeginPopupModal("Overwrite Contact Sheet File", &isOpen, ImGuiWindowFlags_AlwaysAutoResize)) + if (ImGui::BeginPopupModal("Overwrite Contact Sheet File", &isOpen, ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoScrollbar)) { bool pressedOK = false, pressedCancel = false; DoOverwriteFileModal(outFile, pressedOK, pressedCancel); diff --git a/Src/Crop.cpp b/Src/Crop.cpp index 0ee49848..ce2310f2 100644 --- a/Src/Crop.cpp +++ b/Src/Crop.cpp @@ -870,7 +870,7 @@ void Viewer::ShowCropPopup(const tVector4& lrtb, const tVector2& uvoffset) ImGuiWindowFlags flags = ImGuiWindowFlags_NoResize | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoFocusOnAppearing | - ImGuiWindowFlags_NoNav; + ImGuiWindowFlags_NoNav | ImGuiWindowFlags_NoScrollbar; if (ImGui::Begin("Crop", &CropMode, flags)) { diff --git a/Src/Details.cpp b/Src/Details.cpp index 0bdc14c7..daa994a3 100644 --- a/Src/Details.cpp +++ b/Src/Details.cpp @@ -206,8 +206,8 @@ void Viewer::ShowImageMetaDataOverlay(bool* popen) ImGui::SetNextWindowPos(windowPos, ImGuiCond_Appearing); ImGuiWindowFlags flags = - ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoSavedSettings | - ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoNav; + ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoScrollbar | + ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoNav; if (ImGui::Begin("Meta Data", popen, flags)) { diff --git a/Src/Dialogs.cpp b/Src/Dialogs.cpp index db011f8d..1c385952 100644 --- a/Src/Dialogs.cpp +++ b/Src/Dialogs.cpp @@ -113,29 +113,52 @@ void Viewer::DoDeleteFileModal(bool deleteFilePressed) // The unused isOpenDeleteFile bool is just so we get a close button in ImGui. bool isOpenDeleteFile = true; - if (!ImGui::BeginPopupModal("Delete File", &isOpenDeleteFile, ImGuiWindowFlags_AlwaysAutoResize)) + if (!ImGui::BeginPopupModal("Delete File", &isOpenDeleteFile, ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoScrollbar)) return; float buttonWidth = Viewer::GetUIParamScaled(76.0f, 2.5f); tString fullname = CurrImage->Filename; tString file = tSystem::tGetFileName(fullname); tString dir = tSystem::tGetDir(fullname); + + // @wip + // Create a function based on the stuff in CalcTextSize that crops a string + // to a particular size based on the current font/scale. Something like + // tString CropStringToWidth(const tString& src, int width, bool ellipsis = true, bool keepStart = true) + // If ellipsis is true the returned string may strt or end with "...". The total width of the + // returned string (including the ellipsis) fits in width. If ellipsis is false it may fit a few more + // characters. If keepStart is true, the start of src will always be kept and the ellipsis, if requested + // and required, will be at the end. If keepStart is false, the end of src will always be kept, and the + // ellipsis, if requested and required, will be at the start of src. Could also support middle ellipsis. + // + // float maxPathWidth = Viewer::GetUIParamScaled(327.0f, 2.5f); + // float fileWidth = ImGui::CalcTextSize(file.Chr()).x; + // if (fileWidth > maxPathWidth) + ImGui::Text("Delete File"); - ImGui::Indent(); ImGui::Text("%s", file.Chr()); ImGui::Unindent(); + ImGui::Indent(); + ImGui::Text("%s", file.Chr()); + ImGui::Unindent(); + ImGui::Text("In Folder"); - ImGui::Indent(); ImGui::Text("%s", dir.Chr()); ImGui::Unindent(); - ImGui::NewLine(); + ImGui::Indent(); + ImGui::Text("%s", dir.Chr()); + ImGui::Unindent(); + + ImGuiStyle& style = ImGui::GetStyle(); + ImGui::SetCursorPosY(ImGui::GetCursorPosY() + style.ItemSpacing.y); ImGui::Separator(); - ImGui::NewLine(); + ImGui::SetCursorPosY(ImGui::GetCursorPosY() + style.ItemSpacing.y); ImGui::Checkbox("Confirm file deletions in the future?", &profile.ConfirmDeletes); - ImGui::NewLine(); + ImGui::SetCursorPosY(ImGui::GetCursorPosY() + style.ItemSpacing.y); if (Viewer::Button("Cancel", tVector2(buttonWidth, 0.0f))) ImGui::CloseCurrentPopup(); ImGui::SameLine(); - ImGui::SetCursorPosX(ImGui::GetWindowContentRegionMax().x - buttonWidth); + float okOffset = Viewer::GetUIParamScaled(300.0f, 2.5f); + ImGui::SetCursorPosX(okOffset); if (ImGui::IsWindowAppearing()) ImGui::SetKeyboardFocusHere(); @@ -156,7 +179,7 @@ void Viewer::DoDeleteFileNoRecycleModal(bool deleteFileNoRecycPressed) // The unused isOpenPerm bool is just so we get a close button in ImGui. bool isOpenPerm = true; - if (!ImGui::BeginPopupModal("Delete File Permanently", &isOpenPerm, ImGuiWindowFlags_AlwaysAutoResize)) + if (!ImGui::BeginPopupModal("Delete File Permanently", &isOpenPerm, ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoScrollbar)) return; float buttonWidth = Viewer::GetUIParamScaled(76.0f, 2.5f); @@ -165,22 +188,31 @@ void Viewer::DoDeleteFileNoRecycleModal(bool deleteFileNoRecycPressed) tString file = tSystem::tGetFileName(fullname); tString dir = tSystem::tGetDir(fullname); ImGui::Text("Delete File"); - ImGui::Indent(); ImGui::Text("%s", file.Chr()); ImGui::Unindent(); + ImGui::Indent(); + ImGui::Text("%s", file.Chr()); + ImGui::Unindent(); + ImGui::Text("In Folder"); - ImGui::Indent(); ImGui::Text("%s", dir.Chr()); ImGui::Unindent(); - ImGui::NewLine(); + ImGui::Indent(); + ImGui::Text("%s", dir.Chr()); + ImGui::Unindent(); + + ImGuiStyle& style = ImGui::GetStyle(); + ImGui::SetCursorPosY(ImGui::GetCursorPosY() + style.ItemSpacing.y); ImGui::Separator(); - ImGui::NewLine(); + ImGui::SetCursorPosY(ImGui::GetCursorPosY() + style.ItemSpacing.y); - ImGui::Text("This operation cannot be undone. The file\nwill be deleted permanently."); - ImGui::NewLine(); + ImGui::Text("This cannot be undone. File deletion will be permanent."); + ImGui::SetCursorPosY(ImGui::GetCursorPosY() + 2.0f*style.ItemSpacing.y); if (Viewer::Button("Cancel", tVector2(buttonWidth, 0.0f))) ImGui::CloseCurrentPopup(); ImGui::SetItemDefaultFocus(); ImGui::SameLine(); - ImGui::SetCursorPosX(ImGui::GetWindowContentRegionMax().x - buttonWidth); + + float okOffset = Viewer::GetUIParamScaled(300.0f, 2.5f); + ImGui::SetCursorPosX(okOffset); if (ImGui::IsWindowAppearing()) ImGui::SetKeyboardFocusHere(); @@ -197,7 +229,7 @@ void Viewer::DoDeleteFileNoRecycleModal(bool deleteFileNoRecycPressed) void Viewer::DoSnapMessageNoFileBrowseModal(bool justPressed) { if (justPressed) - ImGui::OpenPopup("Message_NoFileBrowse"); + ImGui::OpenPopup("Snap Message##NoFileBrowse"); // The unused isMessage bool is just so we get a close button in ImGui. Returns false if popup not open. bool isMessage = true; @@ -205,8 +237,8 @@ void Viewer::DoSnapMessageNoFileBrowseModal(bool justPressed) ( !ImGui::BeginPopupModal ( - "Message_NoFileBrowse", &isMessage, - ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove + "Snap Message##NoFileBrowse", &isMessage, + ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_AlwaysAutoResize ) ) { @@ -218,11 +250,14 @@ void Viewer::DoSnapMessageNoFileBrowseModal(bool justPressed) ( "The Snap version of Tacent View does not\n" "support opening Nautilus or Dolphin.\n\n" - "Please use the deb install or compile if\n" - "you need the feature on Linux." + "Please use the deb install or build from\n" + "source if you need this feature on Linux." ); ImGui::NewLine(); - ImGui::SetCursorPosX(ImGui::GetWindowContentRegionMax().x - buttonWidth); + + float okOffset = Viewer::GetUIParamScaled(170.0f, 2.5f); + ImGui::SetCursorPosX(okOffset); + if (ImGui::Button("OK", tVector2(buttonWidth, 0.0f))) ImGui::CloseCurrentPopup(); @@ -233,7 +268,7 @@ void Viewer::DoSnapMessageNoFileBrowseModal(bool justPressed) void Viewer::DoSnapMessageNoFrameTransModal(bool justPressed) { if (justPressed) - ImGui::OpenPopup("Message_NoFrameTrans"); + ImGui::OpenPopup("Snap Message##NoTransparentWorkArea"); // The unused isMessage bool is just so we get a close button in ImGui. Returns false if popup not open. bool isMessage = true; @@ -241,8 +276,8 @@ void Viewer::DoSnapMessageNoFrameTransModal(bool justPressed) ( !ImGui::BeginPopupModal ( - "Message_NoFrameTrans", &isMessage, - ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove + "Snap Message##NoTransparentWorkArea", &isMessage, + ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_AlwaysAutoResize ) ) { @@ -254,11 +289,13 @@ void Viewer::DoSnapMessageNoFrameTransModal(bool justPressed) ( "The Snap version of Tacent View does not\n" "support transparent work area.\n\n" - "Please use the deb install or compile if\n" - "you need the feature on Linux." + "Please use the deb install or build from\n" + "source if you need this feature on Linux." ); ImGui::NewLine(); - ImGui::SetCursorPosX(ImGui::GetWindowContentRegionMax().x - buttonWidth); + + float okOffset = Viewer::GetUIParamScaled(170.0f, 2.5f); + ImGui::SetCursorPosX(okOffset); if (ImGui::Button("OK", tVector2(buttonWidth, 0.0f))) ImGui::CloseCurrentPopup(); @@ -273,7 +310,7 @@ void Viewer::DoRenameModal(bool renamePressed) // The unused isOpenRen bool is just so we get a close button in ImGui. bool isOpenRen = true; - if (!ImGui::BeginPopupModal("Rename File", &isOpenRen, ImGuiWindowFlags_AlwaysAutoResize)) + if (!ImGui::BeginPopupModal("Rename File", &isOpenRen, ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoScrollbar)) return; float buttonWidth = Viewer::GetUIParamScaled(76.0f, 2.5f); @@ -293,7 +330,9 @@ void Viewer::DoRenameModal(bool renamePressed) ImGui::CloseCurrentPopup(); ImGui::SameLine(); - ImGui::SetCursorPosX(ImGui::GetWindowContentRegionMax().x - buttonWidth); + + float okOffset = Viewer::GetUIParamScaled(165.0f, 2.5f); + ImGui::SetCursorPosX(okOffset); if (ImGui::IsWindowAppearing()) ImGui::SetKeyboardFocusHere(); diff --git a/Src/FileDialog.cpp b/Src/FileDialog.cpp index 8aa850cf..350a0109 100644 --- a/Src/FileDialog.cpp +++ b/Src/FileDialog.cpp @@ -629,6 +629,7 @@ ContentItem::ContentItem(const tSystem::tFileInfo& fileInfo) : // File type field. FileType = tSystem::tGetFileType(Name); FileTypeString.Set(tSystem::tGetFileTypeName(FileType)); + FileTypeString.ToUpper(); // File size field. FileSize = fileInfo.FileSize; @@ -1225,8 +1226,7 @@ FileDialog::DialogState FileDialog::DoPopup() case DialogMode::SaveFile: label = "Save File"; configPath = &ConfigSaveFilePath; break; } - ImGuiContext& ctx = *GImGui; - const ImGuiStyle& style = ctx.Style; + const ImGuiStyle& style = ImGui::GetStyle(); tVector2 nextWinSize = Viewer::GetUIParamScaled(tVector2(660.0f, 400.0f), 2.5f); ImGui::SetNextWindowSize(nextWinSize, ImGuiCond_Appearing); @@ -1245,11 +1245,10 @@ FileDialog::DialogState FileDialog::DoPopup() setYScrollToSel = true; } - ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, tVector2::zero); ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 0.0f); if (!ImGui::BeginPopupModal(label, &isOpen, ImGuiWindowFlags_MenuBar)) { - ImGui::PopStyleVar(2); + ImGui::PopStyleVar(); return DialogState::Closed; } @@ -1259,14 +1258,12 @@ FileDialog::DialogState FileDialog::DoPopup() tVector2 toolImageSize = Viewer::GetUIParamExtent(tVector2(24.0f, 24.0f), tVector2(62.0f, 62.0f)); float menuBarHeight = toolImageSize.y + style.ItemSpacing.y*2.0f; - float bottomBarRowA = Viewer::GetUIParamScaled(20.0, 2.5f); - float bottomBarRowB = Viewer::GetUIParamScaled(28.0, 2.5f); float colWidthIcon = Viewer::GetUIParamScaled(24.0, 2.5f); float colWidthName = Viewer::GetUIParamScaled(190.0, 2.5f); float colWidthTime = Viewer::GetUIParamScaled(120.0, 2.5f); - float colWidthType = Viewer::GetUIParamScaled(36.0, 2.5f); + float colWidthType = Viewer::GetUIParamScaled(39.0, 2.5f); float colWidthSize = Viewer::GetUIParamScaled(60.0, 2.5f); - float bottomBarHeight = bottomBarRowA + bottomBarRowB; + float bottomBarHeight = Viewer::GetUIParamExtent(52.0f, 140.0f); // // Begin MenuBar @@ -1275,7 +1272,7 @@ FileDialog::DialogState FileDialog::DoPopup() { ImGuiWindow* window = ImGui::GetCurrentWindow(); if (window) - window->MenuBarImageButtonHeight = toolImageSize.y + style.ItemSpacing.y*2.0f; + window->MenuBarImageButtonHeight = toolImageSize.y;// + style.ItemSpacing.y*1.0f; // Up directory. uint64 upImgID = Viewer::Image_UpFolder.Bind(); @@ -1353,7 +1350,6 @@ FileDialog::DialogState FileDialog::DoPopup() } ShowToolTip("Refresh"); - ImGui::SetCursorPosY(ImGui::GetCursorPosY() + style.ItemSpacing.y); if (ImGui::BeginMenu("View##FileDialog")) { ImGui::MenuItem("Show Hidden", "", &ConfigShowHidden); @@ -1364,8 +1360,8 @@ FileDialog::DialogState FileDialog::DoPopup() ImGui::EndMenuBar(); } - ImGui::PopStyleVar(); - ImGui::SetCursorPosY(ImGui::GetCursorPosY() - 3.0f*style.ItemSpacing.y); + + ImGui::SetCursorPosY(ImGui::GetCursorPosY() - 4.0f*style.ItemSpacing.y); // // End of menubar. // @@ -1569,6 +1565,7 @@ FileDialog::DialogState FileDialog::DoPopup() bool resultAvail = false; ContentItem* selItem = SelectedNode ? SelectedNode->FindSelectedItem() : nullptr; float actionButtonWidth = Viewer::GetUIParamScaled(70.0f, 2.5f); + ImGui::SetCursorPosY(ImGui::GetCursorPosY() + style.ItemSpacing.y); switch (Mode) { case DialogMode::OpenFile: @@ -1584,12 +1581,17 @@ FileDialog::DialogState FileDialog::DoPopup() if (!resultAvail) ImGui::PopStyleColor(); - DoFileTypesDropdown(true); + if (!FileTypes.IsEmpty()) + { + ImGui::SameLine(); + DoFileTypesDropdown(true); + } // Open button and set final Result to be picked up. - ImGui::SetCursorPosY(ImGui::GetWindowContentRegionMax().y - bottomBarRowA); + ImGui::SetCursorPosY(ImGui::GetCursorPosY() + style.ItemSpacing.y ); if (resultAvail) { + // The GetWindowContentRegionMax is OK here since width was fixed to a specific size before the Begin call. ImGui::SetCursorPosX(ImGui::GetWindowContentRegionMax().x - 2.0f*actionButtonWidth - style.ItemSpacing.x); // X2 because of the cancel button to right. if (Viewer::Button("Open", tVector2(actionButtonWidth, 0.0f))) { @@ -1610,13 +1612,18 @@ FileDialog::DialogState FileDialog::DoPopup() ImGui::SetNextItemWidth( ImGui::GetWindowContentRegionMax().x / 2.0f ); ImGui::InputTextWithHint("##File Name", "File Name Sans Extension", &SaveFileResult); - DoFileTypesDropdown(false); + if (!FileTypes.IsEmpty()) + { + ImGui::SameLine(); + DoFileTypesDropdown(false); + } tFileType fileType = FileTypes.GetFirstSelectedType(); // Save button and set final Result to be picked up. - ImGui::SetCursorPosY(ImGui::GetWindowContentRegionMax().y - bottomBarRowA); + ImGui::SetCursorPosY(ImGui::GetCursorPosY() + style.ItemSpacing.y ); if ((fileType != tFileType::Invalid) && (SaveFileResult.length() > 0)) { + // The GetWindowContentRegionMax is OK here since width was fixed to a specific size before the Begin call. ImGui::SetCursorPosX(ImGui::GetWindowContentRegionMax().x - 2.0f*actionButtonWidth - style.ItemSpacing.x); // X2 because of the cancel button to right. if (Viewer::Button("Save", tVector2(actionButtonWidth, 0.0f))) { @@ -1648,9 +1655,10 @@ FileDialog::DialogState FileDialog::DoPopup() ImGui::PopStyleColor(); // Open button and set final Result to be picked up. - ImGui::SetCursorPosY(ImGui::GetWindowContentRegionMax().y - bottomBarRowA); + ImGui::SetCursorPosY(ImGui::GetCursorPosY() + style.ItemSpacing.y ); if (resultAvail) { + // The GetWindowContentRegionMax is OK here since width was fixed to a specific size before the Begin call. ImGui::SetCursorPosX(ImGui::GetWindowContentRegionMax().x - 2.0f*actionButtonWidth - style.ItemSpacing.x); // X2 because of the cancel button to right. if (Viewer::Button("Open", tVector2(actionButtonWidth, 0.0f))) { @@ -1664,6 +1672,7 @@ FileDialog::DialogState FileDialog::DoPopup() } // The cancel button is the same for all modes. + // The GetWindowContentRegionMax is OK here since width was fixed to a specific size before the Begin call. ImGui::SetCursorPosX(ImGui::GetWindowContentRegionMax().x - actionButtonWidth); if (ImGui::IsWindowAppearing()) @@ -1682,16 +1691,13 @@ FileDialog::DialogState FileDialog::DoPopup() void FileDialog::DoFileTypesDropdown(bool supportMultipleTypes) { - if (FileTypes.IsEmpty()) - return; - - ImGuiContext& ctx = *GImGui; - const ImGuiStyle& style = ctx.Style; + const ImGuiStyle& style = ImGui::GetStyle(); float dropdownWidth = Viewer::GetUIParamScaled(140.0f, 2.5f); dropdownWidth += style.ItemSpacing.x; - ImGui::SameLine(); ImGui::SetNextItemWidth(dropdownWidth); + + // The GetWindowContentRegionMax is OK here since width was fixed to a specific size before the Begin call. ImGui::SetCursorPosX(ImGui::GetWindowContentRegionMax().x - dropdownWidth); // Nothing selected means all types used. @@ -1712,7 +1718,7 @@ void FileDialog::DoFileTypesDropdown(bool supportMultipleTypes) currChosen = FileTypes.GetSelectedString(tSystem::tFileTypes::Separator::CommaSpace, 4); } - if (ImGui::BeginCombo("##TypeFilter", currChosen.Chr())) + if (ImGui::BeginCombo("##TypeFilter", currChosen.Chr(), ImGuiComboFlags_HeightLarge)) { if (supportMultipleTypes && ImGui::Selectable("All Types", allTypes)) { diff --git a/Src/InputBindings.cpp b/Src/InputBindings.cpp index bda4912c..511887f2 100644 --- a/Src/InputBindings.cpp +++ b/Src/InputBindings.cpp @@ -499,7 +499,7 @@ void Bindings::ShowBindingsWindow(bool* popen, bool justOpened) tVector2 windowPos = GetDialogOrigin(DialogID::Bindings); ImGui::SetNextWindowPos(windowPos, ImGuiCond_FirstUseEver); - ImGuiWindowFlags flags = ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoNav | ImGuiWindowFlags_NoResize; + ImGuiWindowFlags flags = ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoNav | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoScrollbar; if (ImGui::Begin("Keyboard Bindings", popen, flags)) { static int profileIdx = 0; @@ -559,8 +559,11 @@ void Bindings::ShowBindingsWindow(bool* popen, bool justOpened) ImGui::SetCursorPosY(ImGui::GetCursorPosY() + 8); uint32 tableFlags = ImGuiTableFlags_ScrollY | ImGuiTableFlags_BordersInner | ImGuiTableFlags_BordersOuter; - const float rowHeight = 25.0f; - const int maxRowsToDisplay = 16; + + float rowHeight = Viewer::GetUIParamExtent(24.85f, 61.0f); + int maxRowsToDisplay = Viewer::GetUIParamExtent(16, 11); + float keyTextOffsetY = Viewer::GetUIParamScaled(3.0f, 2.5f); + int totalAssigned = prof->InputBindings.GetTotalAssigned(); const int numRowsToDisplay = tMin(maxRowsToDisplay, totalAssigned); tVector2 outerSize = ImVec2(0.0f, rowHeight + rowHeight * float(numRowsToDisplay)); @@ -605,6 +608,7 @@ void Bindings::ShowBindingsWindow(bool* popen, bool justOpened) // Key/mods column. ImGui::TableSetColumnIndex(0); + ImGui::SetCursorPosY(ImGui::GetCursorPosY() + keyTextOffsetY); ImGui::Text( GetModKeyText(k, m).Chr() ); // The operation column. @@ -683,7 +687,7 @@ void Bindings::ShowAddBindingSection(Config::ProfileData& settings, float keyWid tVector2 outerSize = ImVec2(0.0f, rowHeight); float removeColSize = Viewer::GetUIParamScaled(20.0f, 2.5f); - float buttonSize = Viewer::GetUIParamScaled(100.0f, 2.5f); + float buttonSize = Viewer::GetUIParamScaled(80.0f, 2.5f); if (ImGui::BeginTable("KeyAssignTable", 3, tableFlags, outerSize)) { @@ -786,7 +790,7 @@ void Bindings::ShowAddBindingSection(Config::ProfileData& settings, float keyWid ShowToolTip("Adds the new keybinding. Warns if already assigned to something else."); bool isOpen = true; - if (ImGui::BeginPopupModal("Key Assignment Warning", &isOpen, ImGuiWindowFlags_AlwaysAutoResize)) + if (ImGui::BeginPopupModal("Key Assignment Warning", &isOpen, ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoScrollbar)) { tString msg; if (permanent) @@ -818,7 +822,9 @@ void Bindings::ShowAddBindingSection(Config::ProfileData& settings, float keyWid if (!permanent) { ImGui::SameLine(); - ImGui::SetCursorPosX(ImGui::GetWindowContentRegionMax().x - buttonSize); + + float buttonOffset = Viewer::GetUIParamScaled(236.0f, 2.5f); + ImGui::SetCursorPosX(buttonOffset); if (ImGui::Button("Replace##AssignWarn", tVector2(buttonSize, 0.0f))) { settings.InputBindings.AssignKey(addKey, addMods, Operation(addOp)); @@ -847,7 +853,7 @@ void Bindings::ShowCheatSheetWindow(bool* popen) ImGui::SetNextWindowSize(windowSize, ImGuiCond_Always); ImGui::SetNextWindowPos(windowPos, ImGuiCond_FirstUseEver); - ImGuiWindowFlags flags = ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoNav; + ImGuiWindowFlags flags = ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoNav | ImGuiWindowFlags_NoScrollbar; ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, tVector2(0.0f, 1.0f)); tString title; diff --git a/Src/MultiFrame.cpp b/Src/MultiFrame.cpp index e015802c..e11bb5af 100644 --- a/Src/MultiFrame.cpp +++ b/Src/MultiFrame.cpp @@ -90,7 +90,7 @@ void Viewer::DoSaveMultiFrameModal(bool saveMultiFramePressed) // The unused isOpenMultiFrame bool is just so we get a close button in ImGui. Returns false if popup not open. bool isOpenMultiFrame = true; - if (!ImGui::BeginPopupModal("Multi Frame", &isOpenMultiFrame, ImGuiWindowFlags_AlwaysAutoResize)) + if (!ImGui::BeginPopupModal("Multi Frame", &isOpenMultiFrame, ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoScrollbar)) return; static int outWidth = 256; @@ -187,7 +187,8 @@ void Viewer::DoSaveMultiFrameModal(bool saveMultiFramePressed) ImGui::CloseCurrentPopup(); ImGui::SameLine(); - ImGui::SetCursorPosX(ImGui::GetWindowContentRegionMax().x - buttonWidth); + float genOffset = Viewer::GetUIParamScaled(294.0f, 2.5f); + ImGui::SetCursorPosX(genOffset); tString outFile = destDir + tString(filename) + "." + extension; bool closeThisModal = false; if (ImGui::IsWindowAppearing()) @@ -217,7 +218,7 @@ void Viewer::DoSaveMultiFrameModal(bool saveMultiFramePressed) // The unused isOpen bool is just so we get a close button in ImGui. bool isOpen = true; - if (ImGui::BeginPopupModal("Overwrite image File", &isOpen, ImGuiWindowFlags_AlwaysAutoResize)) + if (ImGui::BeginPopupModal("Overwrite image File", &isOpen, ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoScrollbar)) { bool pressedOK = false, pressedCancel = false; DoOverwriteFileModal(outFile, pressedOK, pressedCancel); @@ -350,7 +351,7 @@ void Viewer::DoSaveExtractFramesModal(bool saveExtractFramesPressed) // The unused isOpenExtractFrames bool is just so we get a close button in ImGui. Returns false if popup not open. bool isOpenExtractFrames = true; - if (!ImGui::BeginPopupModal("Extract Frames", &isOpenExtractFrames, ImGuiWindowFlags_AlwaysAutoResize)) + if (!ImGui::BeginPopupModal("Extract Frames", &isOpenExtractFrames, ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoScrollbar)) return; float inputWidth = Viewer::GetUIParamScaled(160.0f, 2.5f); @@ -447,9 +448,10 @@ void Viewer::DoSaveExtractFramesModal(bool saveExtractFramesPressed) ImGui::CloseCurrentPopup(); ImGui::SameLine(); - ImGui::SetCursorPosX(ImGui::GetWindowContentRegionMax().x - buttonWidth); + float extOffset = Viewer::GetUIParamScaled(230.0f, 2.5f); + ImGui::SetCursorPosX(extOffset); - // This needs to be static since DoSaveModal is called for every frame the modal is open. + // This needs to be static since this function is called for every frame the modal is open. static tList overwriteFiles(tListMode::Static); bool closeThisModal = false; @@ -507,7 +509,7 @@ void Viewer::DoSaveExtractFramesModal(bool saveExtractFramesPressed) // The unused isOpen bool is just so we get a close button in ImGui. bool isOpen = true; - if (ImGui::BeginPopupModal("Extract Overwrite Popup", &isOpen, ImGuiWindowFlags_AlwaysAutoResize)) + if (ImGui::BeginPopupModal("Extract Overwrite Popup", &isOpen, ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoScrollbar)) { bool pressedOK = false, pressedCancel = false; Viewer::DoOverwriteMultipleFilesModal(overwriteFiles, pressedOK, pressedCancel); diff --git a/Src/OpenSaveDialogs.cpp b/Src/OpenSaveDialogs.cpp index 6f3048ec..d3fe5020 100644 --- a/Src/OpenSaveDialogs.cpp +++ b/Src/OpenSaveDialogs.cpp @@ -86,7 +86,7 @@ void Viewer::DoOpenDirModal(bool openDirPressed) } -void Viewer::DoSaveModal(bool savePressed) +void Viewer::DoSaveCurrentModal(bool savePressed) { static tString label; if (!CurrImage) @@ -106,7 +106,7 @@ void Viewer::DoSaveModal(bool savePressed) // The unused isOpenSaveOptions bool is just so we get a close button in ImGui. Returns false if popup not open. bool isOpenSaveOptions = true; ImGui::SetNextWindowSize(tVector2(nextWinWidth, 0.0f)); - if (!ImGui::BeginPopupModal(label.Chr(), &isOpenSaveOptions, ImGuiWindowFlags_AlwaysAutoResize)) + if (!ImGui::BeginPopupModal(label.Chr(), &isOpenSaveOptions, ImGuiWindowFlags_NoScrollbar)) return; tFileType saveType = tGetFileType(SaveAsFile); @@ -146,7 +146,7 @@ void Viewer::DoSaveAsModal(bool saveAsPressed) // The unused isOpenSaveOptions bool is just so we get a close button in ImGui. Returns false if popup not open. bool isOpenSaveOptions = true; ImGui::SetNextWindowSize(tVector2(nextWinWidth, 0.0f)); - if (!ImGui::BeginPopupModal(label.Chr(), &isOpenSaveOptions, ImGuiWindowFlags_AlwaysAutoResize)) + if (!ImGui::BeginPopupModal(label.Chr(), &isOpenSaveOptions, ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoScrollbar)) return; DoSavePopup(); @@ -171,7 +171,8 @@ void Viewer::DoSavePopup() if (Viewer::Button("Cancel", tVector2(buttonWidth, 0.0f))) ImGui::CloseCurrentPopup(); ImGui::SameLine(); - + + // The GetWindowContentRegionMax is OK here since width was fixed to a specific size before the Begin call. ImGui::SetCursorPosX(ImGui::GetWindowContentRegionMax().x - buttonWidth); bool closeThisModal = false; @@ -209,7 +210,7 @@ void Viewer::DoSavePopup() // The unused isOpen bool is just so we get a close button in ImGui. bool isOpen = true; - if (ImGui::BeginPopupModal("Overwrite File", &isOpen, ImGuiWindowFlags_AlwaysAutoResize)) + if (ImGui::BeginPopupModal("Overwrite File", &isOpen, ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoScrollbar)) { bool pressedOK = false, pressedCancel = false; DoOverwriteFileModal(SaveAsFile, pressedOK, pressedCancel); @@ -264,6 +265,7 @@ void Viewer::DoSaveUnsupportedTypePopup() float buttonWidth = Viewer::GetUIParamScaled(76.0f, 2.5f); + // The GetWindowContentRegionMax is OK here since width was fixed to a specific size before the Begin call. ImGui::SetCursorPosX(ImGui::GetWindowContentRegionMax().x - buttonWidth); bool closeThisModal = false; @@ -730,7 +732,7 @@ void Viewer::DoSaveAllModal(bool saveAllPressed) // The unused isOpenSaveAll bool is just so we get a close button in ImGui. Returns false if popup not open. bool isOpenSaveAll = true; - if (!ImGui::BeginPopupModal("Save All", &isOpenSaveAll, ImGuiWindowFlags_AlwaysAutoResize)) + if (!ImGui::BeginPopupModal("Save All", &isOpenSaveAll, ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoScrollbar)) return; ImGui::Text("Save all %d images to the image type you select.", Images.GetNumItems()); @@ -809,14 +811,17 @@ void Viewer::DoSaveAllModal(bool saveAllPressed) ImGui::Separator(); tString destDir = DoSubFolder(); + ImGui::Separator(); + ImGui::NewLine(); if (Viewer::Button("Cancel", tVector2(buttonWidth, 0.0f))) ImGui::CloseCurrentPopup(); ImGui::SameLine(); - ImGui::SetCursorPosX(ImGui::GetWindowContentRegionMax().x - buttonWidth); + float saveAllOffset = Viewer::GetUIParamScaled(200.0f, 2.5f); + ImGui::SetCursorPosX(saveAllOffset); - // This needs to be static since DoSaveModal is called for every frame the modal is open. + // This needs to be static since this function is called for every frame the modal is open. static tList overwriteFiles(tListMode::Static); bool closeThisModal = false; @@ -849,7 +854,7 @@ void Viewer::DoSaveAllModal(bool saveAllPressed) // The unused isOpen bool is just so we get a close button in ImGui. bool isOpen = true; - if (ImGui::BeginPopupModal("Overwrite Multiple Files", &isOpen, ImGuiWindowFlags_AlwaysAutoResize)) + if (ImGui::BeginPopupModal("Overwrite Multiple Files", &isOpen, ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoScrollbar)) { bool pressedOK = false, pressedCancel = false; DoOverwriteMultipleFilesModal(overwriteFiles, pressedOK, pressedCancel); @@ -890,6 +895,8 @@ void Viewer::DoOverwriteMultipleFilesModal(const tList& overwriteFi Config::ProfileData& profile = Config::GetProfileData(); float buttonWidth = Viewer::GetUIParamScaled(76.0f, 2.5f); + // @wip For both filename and folder we need to restrict the string width using that function I haven't written + // yet to crop a string to a specific width and optionally add an ellisis. tString dir = tSystem::tGetDir(*overwriteFiles.First()); ImGui::Text("The Following Files"); ImGui::Indent(); @@ -923,8 +930,9 @@ void Viewer::DoOverwriteMultipleFilesModal(const tList& overwriteFi } ImGui::SameLine(); - ImGui::SetCursorPosX(ImGui::GetWindowContentRegionMax().x - buttonWidth); + float overwriteOffset = Viewer::GetUIParamScaled(280.0f, 2.5f); + ImGui::SetCursorPosX(overwriteOffset); if (Viewer::Button("Overwrite", tVector2(buttonWidth, 0.0f))) { pressedOK = true; @@ -993,6 +1001,8 @@ void Viewer::DoOverwriteFileModal(const tString& outFile, bool& pressedOK, bool& Config::ProfileData& profile = Config::GetProfileData(); float buttonWidth = Viewer::GetUIParamScaled(76.0f, 2.5f); + // @wip For both filename and folder we need to restrict the string width using that function I haven't written + // yet to crop a string to a specific width and optionally add an ellisis. tString file = tSystem::tGetFileName(outFile); tString dir = tSystem::tGetDir(outFile); ImGui::Text("Overwrite file"); @@ -1013,8 +1023,9 @@ void Viewer::DoOverwriteFileModal(const tString& outFile, bool& pressedOK, bool& } ImGui::SameLine(); - ImGui::SetCursorPosX(ImGui::GetWindowContentRegionMax().x - buttonWidth); + float okOffset = Viewer::GetUIParamScaled(280.0f, 2.5f); + ImGui::SetCursorPosX(okOffset); if (ImGui::IsWindowAppearing()) ImGui::SetKeyboardFocusHere(); if (Viewer::Button("OK", tVector2(buttonWidth, 0.0f))) diff --git a/Src/OpenSaveDialogs.h b/Src/OpenSaveDialogs.h index bf0d6a0d..6d7d0ae0 100644 --- a/Src/OpenSaveDialogs.h +++ b/Src/OpenSaveDialogs.h @@ -25,7 +25,7 @@ namespace Viewer void DoOpenFileModal(bool openFilePressed); void DoOpenDirModal(bool openDirPressed); - void DoSaveModal(bool savePressed); + void DoSaveCurrentModal(bool savePressed); void DoSaveAsModal(bool savePressed); void DoSaveAllModal(bool saveAllPressed); diff --git a/Src/Properties.cpp b/Src/Properties.cpp index fc05e89a..9c17928c 100644 --- a/Src/Properties.cpp +++ b/Src/Properties.cpp @@ -105,7 +105,7 @@ bool Viewer::DoChooseDisplayImage(tString& texTypeName, float itemWidth) void Viewer::ShowPropertiesWindow(bool* popen) { - ImGuiWindowFlags windowFlags = ImGuiWindowFlags_AlwaysAutoResize; // | ImGuiWindowFlags_NoFocusOnAppearing; + ImGuiWindowFlags windowFlags = ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoScrollbar; // We specify a default position/size in case there's no data in the .ini file. Typically this isn't required! We only // do it to make the Demo applications a little more welcoming. @@ -242,6 +242,8 @@ void Viewer::ShowPropertiesWindow(bool* popen) { if (scrubberDisplayed) ImGui::SameLine(); + + // The GetWindowContentRegionMax is OK here since width was fixed to a specific size before the Begin call. ImGui::SetCursorPosX(ImGui::GetWindowContentRegionMax().x - itemWidth); if (ImGui::Button("Reset", tVector2(itemWidth, 0.0f))) { @@ -377,6 +379,8 @@ void Viewer::ShowPropertiesWindow(bool* popen) { if (scrubberDisplayed) ImGui::SameLine(); + + // The GetWindowContentRegionMax is OK here since width was fixed to a specific size before the Begin call. ImGui::SetCursorPosX(ImGui::GetWindowContentRegionMax().x - itemWidth); if (ImGui::Button("Reset", tVector2(itemWidth, 0.0f))) { @@ -495,6 +499,7 @@ void Viewer::ShowPropertiesWindow(bool* popen) tMath::tiClamp(CurrImage->LoadParams_ASTC.Exposure, 0.0f, 4.0f); } + // The GetWindowContentRegionMax is OK here since width was fixed to a specific size before the Begin call. ImGui::SetCursorPosX(ImGui::GetWindowContentRegionMax().x - itemWidth); if (ImGui::Button("Reset", tVector2(itemWidth, 0.0f))) { @@ -568,6 +573,7 @@ void Viewer::ShowPropertiesWindow(bool* popen) ShowHelpMark("Luminance-only pkm files are represented in this viewer as having a red channel only,\nIf spread is true, the channel is spread to all RGB channels to create a grey-scale image."); } + // The GetWindowContentRegionMax is OK here since width was fixed to a specific size before the Begin call. ImGui::SetCursorPosX(ImGui::GetWindowContentRegionMax().x - itemWidth); if (ImGui::Button("Reset", tVector2(itemWidth, 0.0f))) { @@ -604,6 +610,7 @@ void Viewer::ShowPropertiesWindow(bool* popen) ShowHelpMark("Exposure adjustment [-10, 10]. Hold Ctrl to speedup."); tMath::tiClamp(CurrImage->LoadParams_HDR.Exposure, -10, 10); + // The GetWindowContentRegionMax is OK here since width was fixed to a specific size before the Begin call. ImGui::SetCursorPosX(ImGui::GetWindowContentRegionMax().x - itemWidth); if (ImGui::Button("Reset", tVector2(itemWidth, 0.0f))) { @@ -661,6 +668,7 @@ void Viewer::ShowPropertiesWindow(bool* popen) ShowHelpMark("Upper bound knee taper [3.5, 7.5]. Hold Ctrl to speedup."); tMath::tiClamp(CurrImage->LoadParams_EXR.KneeHigh, 3.5f, 7.5f); + // The GetWindowContentRegionMax is OK here since width was fixed to a specific size before the Begin call. ImGui::SetCursorPosX(ImGui::GetWindowContentRegionMax().x - itemWidth); if (ImGui::Button("Reset", tVector2(itemWidth, 0.0f))) { @@ -720,8 +728,7 @@ void Viewer::ShowPropertiesWindow(bool* popen) ImGui::SameLine(); ShowHelpMark("Which image in a multiframe file to display."); float durButtonSpacing = Viewer::GetUIParamExtent(4.0f, 10.0f); - ImGuiContext& ctx = *GImGui; - const ImGuiStyle& style = ctx.Style; + const ImGuiStyle& style = ImGui::GetStyle(); if (CurrImage->FrameDurationPreviewEnabled) { diff --git a/Src/Quantize.cpp b/Src/Quantize.cpp index e44e1e1f..2e50815d 100644 --- a/Src/Quantize.cpp +++ b/Src/Quantize.cpp @@ -123,11 +123,10 @@ void Viewer::DoQuantizeModal(bool quantizeImagePressed) if (quantizeImagePressed) ImGui::OpenPopup("Quantize"); - float modalWidth = Viewer::GetUIParamScaled(296.0f, 2.5f); - + float modalWidth = Viewer::GetUIParamScaled(308.0f, 2.5f); bool isOpenQuantizeImage = true; ImGui::SetNextWindowSize(tVector2(modalWidth, 0.0f)); - if (!ImGui::BeginPopupModal("Quantize", &isOpenQuantizeImage, ImGuiWindowFlags_AlwaysAutoResize)) + if (!ImGui::BeginPopupModal("Quantize", &isOpenQuantizeImage, ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoScrollbar)) return; float buttonWidth = Viewer::GetUIParamScaled(76.0f, 2.5f); @@ -198,6 +197,8 @@ void Viewer::DoQuantizeModal(bool quantizeImagePressed) ImGui::CloseCurrentPopup(); ImGui::SameLine(); + + // The GetWindowContentRegionMax is OK here since width was fixed to a specific size before the Begin call. ImGui::SetCursorPosX(ImGui::GetWindowContentRegionMax().x - buttonWidth); if (ImGui::IsWindowAppearing()) ImGui::SetKeyboardFocusHere(); diff --git a/Src/Resize.cpp b/Src/Resize.cpp index 926aeab6..8ca0ce79 100644 --- a/Src/Resize.cpp +++ b/Src/Resize.cpp @@ -247,13 +247,13 @@ void Viewer::DoFillColourInterface(const char* toolTipText, bool contactSheetFil if (toolTipText) ShowToolTip(toolTipText); - float buttonWidth = Viewer::GetUIParamScaled(63.0f, 2.5f); + float buttonWidth = Viewer::GetUIParamScaled(56.0f, 2.5f); ImGui::SameLine(); tPicture* picture = CurrImage ? CurrImage->GetCurrentPic() : nullptr; if (ImGui::Button("Origin", tVector2(buttonWidth, 0.0f)) && picture) fillColour->Set(picture->GetPixel(0, 0)); - ShowToolTip("Pick the colour from pixel (0, 0) in the current image."); + ShowToolTip("Pick the colour from pixel (0,0) in the current image."); ImGui::SameLine(); if (ImGui::Button("Cursor", tVector2(buttonWidth, 0.0f))) @@ -286,7 +286,7 @@ void Viewer::DoResizeImageModal(bool resizeImagePressed) ImGui::OpenPopup("Resize Image"); bool isOpenResizeImage = true; - if (!ImGui::BeginPopupModal("Resize Image", &isOpenResizeImage, ImGuiWindowFlags_AlwaysAutoResize)) + if (!ImGui::BeginPopupModal("Resize Image", &isOpenResizeImage, ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoScrollbar)) return; Config::ProfileData& profile = Config::GetProfileData(); @@ -340,7 +340,7 @@ void Viewer::DoResizeCanvasModal(bool resizeCanvasPressed) if (resizeCanvasPressed) ImGui::OpenPopup("Resize Canvas"); bool isOpenResizeCanvas = true; - if (!ImGui::BeginPopupModal("Resize Canvas", &isOpenResizeCanvas, ImGuiWindowFlags_AlwaysAutoResize)) + if (!ImGui::BeginPopupModal("Resize Canvas", &isOpenResizeCanvas, ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoScrollbar)) return; static bool firstOpenAnchor = false; diff --git a/Src/Rotate.cpp b/Src/Rotate.cpp index 20ef2915..b4751eca 100644 --- a/Src/Rotate.cpp +++ b/Src/Rotate.cpp @@ -30,7 +30,7 @@ void Viewer::DoRotateImageModal(bool rotateImagePressed) ImGui::OpenPopup("Rotate Image"); bool isOpenRotateImage = true; - if (!ImGui::BeginPopupModal("Rotate Image", &isOpenRotateImage, ImGuiWindowFlags_AlwaysAutoResize)) + if (!ImGui::BeginPopupModal("Rotate Image", &isOpenRotateImage, ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoScrollbar)) { RotateAnglePreview = 0.0f; return; @@ -100,7 +100,9 @@ void Viewer::DoRotateImageModal(bool rotateImagePressed) } ImGui::SameLine(); - ImGui::SetCursorPosX(ImGui::GetWindowContentRegionMax().x - buttonWidth); + + float rotOffset = Viewer::GetUIParamScaled(254.0f, 2.5f); + ImGui::SetCursorPosX(rotOffset); if (ImGui::IsWindowAppearing()) ImGui::SetKeyboardFocusHere(); @@ -219,7 +221,7 @@ void Viewer::DoLosslessTransformModal(LosslessTransformMode mode) // The unused isOpenRen bool is just so we get a close button in ImGui. bool isOpenRen = true; - if (!ImGui::BeginPopupModal("Lossless Transform", &isOpenRen, ImGuiWindowFlags_AlwaysAutoResize)) + if (!ImGui::BeginPopupModal("Lossless Transform", &isOpenRen, ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoScrollbar)) return; ImGui::Text @@ -251,7 +253,9 @@ void Viewer::DoLosslessTransformModal(LosslessTransformMode mode) ImGui::CloseCurrentPopup(); ImGui::SameLine(); - ImGui::SetCursorPosX(ImGui::GetWindowContentRegionMax().x - buttonWidth*2.0f - ImGui::GetStyle().ItemSpacing.x); + + float normLossOffset = Viewer::GetUIParamScaled(180.0f, 2.5f); + ImGui::SetCursorPosX(normLossOffset); if (Viewer::Button("Normal", tVector2(buttonWidth, 0.0f))) { CurrImage->Unbind(); diff --git a/Src/TacentView.cpp b/Src/TacentView.cpp index bd751d1b..025ce26c 100644 --- a/Src/TacentView.cpp +++ b/Src/TacentView.cpp @@ -217,7 +217,7 @@ namespace Viewer bool Request_OpenFileModal = false; bool Request_OpenDirModal = false; - bool Request_SaveModal = false; + bool Request_SaveCurrentModal = false; bool Request_SaveAsModal = false; bool Request_SaveAllModal = false; bool Request_ResizeImageModal = false; @@ -1276,13 +1276,12 @@ void Viewer::ProgressArc(float radius, float percent, const ImVec4& colour, cons int Viewer::DoMainMenuBar() { - ImGuiContext& ctx = *GImGui; - const ImGuiStyle& style = ctx.Style; + const ImGuiStyle& style = ImGui::GetStyle(); // File requests. bool openFilePressed = Request_OpenFileModal; Request_OpenFileModal = false; bool openDirPressed = Request_OpenDirModal; Request_OpenDirModal = false; - bool savePressed = Request_SaveModal; Request_SaveModal = false; + bool saveCurrentPressed = Request_SaveCurrentModal; Request_SaveCurrentModal = false; bool saveAsPressed = Request_SaveAsModal; Request_SaveAsModal = false; bool saveAllPressed = Request_SaveAllModal; Request_SaveAllModal = false; bool saveContactSheetPressed = Request_ContactSheetModal; Request_ContactSheetModal = false; @@ -1342,7 +1341,7 @@ int Viewer::DoMainMenuBar() tString saveKey = profile.InputBindings.FindModKeyText(Bindings::Operation::Save); bool saveEnabled = CurrImage ? true : false; if (ImGui::MenuItem("Save...", saveKey.Chz(), false, saveEnabled)) - savePressed = true; + saveCurrentPressed = true; tString saveAsKey = profile.InputBindings.FindModKeyText(Bindings::Operation::SaveAs); bool saveAsEnabled = CurrImage ? true : false; @@ -1897,8 +1896,7 @@ int Viewer::DoMainMenuBar() // that require an update every frame. This could be reorganized so that when the operation is executed (in the // big keybindings switch) the call to open the popup is performed, but we'd still need the dialog updates here, // so this gives better encapsulation. - ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, tVector2(4.0f, 3.0f)); // Push D - + // // We deal with all the modals in a single place. Modals are slightly special as we allow keyboard nav during // modals but not otherwise as it would interfere with the viewer's keyboard bindings. We start setting nav off. ImGuiIO& io = ImGui::GetIO(); @@ -1910,7 +1908,7 @@ int Viewer::DoMainMenuBar() DoOpenFileModal (openFilePressed); DoOpenDirModal (openDirPressed); - DoSaveModal (savePressed); + DoSaveCurrentModal (saveCurrentPressed); DoSaveAsModal (saveAsPressed); DoSaveAllModal (saveAllPressed); @@ -1934,7 +1932,6 @@ int Viewer::DoMainMenuBar() DoQuantizeModal (quantizePressed); DoLosslessTransformModal (losslessTransformPressed); - ImGui::PopStyleVar(); // Pop D return menuBarHeight; } @@ -3602,7 +3599,7 @@ void Viewer::KeyCallback(GLFWwindow* window, int key, int scancode, int action, break; case Bindings::Operation::Save: - if (imgAvail) Request_SaveModal = true; + if (imgAvail) Request_SaveCurrentModal = true; break; case Bindings::Operation::SaveAs: