You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Here is the code of a little confirmation popup (a window with a variable title and yes/no buttons that returns 0 if nothing if clicked, 1 if no, 2 if yes)
The problem is that the popup width is sized to the 2 buttons, not to the title bar. Is there a way to autosize this correctly at first appearing (the title can have variable length) ?
Uint8 Confirm(const std::string& title)
{
static bool showWindow = false;
Uint8 ret = 0;
std::string s = title + "###confirm";
if (!showWindow)
{
ImGui::OpenPopup(s.c_str());
showWindow = true;
}
if (ImGui::BeginPopupModal(s.c_str(),nullptr))
{
if (ImGui::Button("Yes"))
{
showWindow = false;
ImGui::CloseCurrentPopup();
ret = 2;
}
ImGui::SameLine();
if (ImGui::Button("No"))
{
showWindow = false;
ImGui::CloseCurrentPopup();
ret = 1;
}
ImGui::EndPopup();
}
return(ret);
}
The text was updated successfully, but these errors were encountered:
It's been always the case that title bar width doesn't contribute to width calculation.
(e.g. #176 (comment))
I don't imagine we should allocate a window flag for that, we could decide it would be a global style flag however it would be ambiguous and misleading when switching single windows to be using tabs in the docking branch, so I'm not sure this is a good idea right now.
You can enforce a minimum automatic width for the window by using, e.g.
Hi Omar,
Thanks for your answer.
I do not understand why a global flag would not be desirable : I still do not find very "nice" that a simple window opens with its title truncated... But you know the code repercussions better than me ;-)
Anyway, thanks for the trick, it does the job !
Version: Dear ImGui 1.77 WIP (17601)
Branch: master
Back-ends: SFML
Compiler: VS2019 c++
Operating System: win10x64
Hi Omar,
I really have problem with sizing objects...
Here is the code of a little confirmation popup (a window with a variable title and yes/no buttons that returns 0 if nothing if clicked, 1 if no, 2 if yes)
The problem is that the popup width is sized to the 2 buttons, not to the title bar. Is there a way to autosize this correctly at first appearing (the title can have variable length) ?
The text was updated successfully, but these errors were encountered: