Closed zaafar closed 9 months ago
EDITS: update from ImGuiWindowFlags to ImGuiTabItemFlags
You can already detect closure on TabItem() return and decide to not close the tab and show a modal.
I am sorry, I should have said that I am using imgui public API (i.e. BeginTabItem
and EndTabItem
for creating tabs). I am assuming that the TabItem
API you have mentioned is internal. That is fine, I will figure out how to incorporate that. :)
TabItem() is called by BeginTabItem()
. After you call BeginTabItem()
you can check if the bool you passed has changed back to false.
sorry in advance for the c# code.
yes, you are right I can do that (as shown in the code below)
ImGui.BeginTabItem("fakeNameThatITotallyDontUse", ref shouldNotDeleteIfTrue, ImGuiTabItemFlags.None);
// adds logic to remove tab when shouldNotDeleteIfTrue is False
However,
(1) Once I check shouldNotDeleteIfTrue == False ?????
-> Open Model for "Do you want to delete it?" for user -> User select NO -> that tab will go/move to the end. (Actually user doesn't have to select NO for the tab to move to the end, however, when user select Yes, it doesn't matter but that's just a small implementation detail)
this happens because by default in the TAB API "closure is assumed" (as mentioned in the imgui docs as well)
if I use the following code, tab doesn't move to the end of the tab bar because closure isn't assumed.
ImGui.BeginTabItem("fakeNameThatITotallyDontUse", ref shouldNotDeleteIfTrue, ImGuiTabItemFlags.UnsavedDocument);
==Screenshots For Proof of (1)==
starting tab position
pressing X on tab2
tab2 is now on the far right.
hence the TLDR
of the first post :)
My bad, I thought there was a call to mark the tab as reopened but it's not possible presently. I think you are right and maybe the best solution is to introduce a flag.
I have added the ImGuiTabItemFlags_NoAssumedClosure
flag in c58d2c8
This should cherry-pick easily if you need to use this immediately in docking branch.
Thanks!
Thank you, i will test it once there is a release. I don’t think so cherrypick is required, that info in the first post might be wrong.
ignore my last comment, cherry-pick to docking is required.
EDIT: ignore my last comment, I want this in docking but not immediately (when new release is out). :)
@ocornut nothing urgent, i think, you did a mistake in updating changelog https://github.com/ocornut/imgui/commit/c58d2c89c3f91bbd42b66d67f42f6f11363867d3
you modified 1.61 change log rather than latest one.
Thank you. I fixed it and amended the release Changelog with that missing bit indeed! https://github.com/ocornut/imgui/releases/tag/v1.90.1
Version/Branch of Dear ImGui:
Version: v1.90 Branch: docking
My Issue/Question:
Currently ImGuiTabItemFlags_UnsavedDocument is doing 2 things
1: assuming document isn't saved and displaying dot next to the title.
2: tab is selected when clicking the X and closure is not assumed
while this is a perfectly fine usecase for unsaved documents.
my use-case is a bit different, I basically want to ask the user if they really want to close the tab or not
for this use-case (1) isn't necessary i.e. no need to always display a dot on the tab
Following are the screenshot of my usecase
here is me allowing users to add/remove a tab by pressing X (or + sign). You can see all tabs have dot, which isn't required
here is me asking the user (via popup) do you really wanna close the tab after user press X. (to mitigate accidents)
so TLDR: Would be nice if we keep
ImGuiTabItemFlags_UnsavedDocument
as is however introduces a new flag (e.g.ImGuiTabItemFlags_DoNotAssumeClosure
) so folks who want to use just (2) can do that.Thank you for the amazing lib, Cheers!