Merge pull request #1236 from YohananDiamond/dialog-nitpicks

Dialog nitpick: properly centering modal popups
This commit is contained in:
tildearrow 2023-08-10 02:41:57 -05:00 committed by GitHub
commit d9cdb787ae
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -77,6 +77,10 @@ bool Particle::update(float frameTime) {
return (life>0); return (life>0);
} }
void centerNextWindow(float w, float h) {
ImGui::SetNextWindowPos(ImVec2(w*0.5,h*0.5),ImGuiCond_Always,ImVec2(0.5,0.5));
}
void FurnaceGUI::bindEngine(DivEngine* eng) { void FurnaceGUI::bindEngine(DivEngine* eng) {
e=eng; e=eng;
wavePreview.setEngine(e); wavePreview.setEngine(e);
@ -4573,6 +4577,7 @@ bool FurnaceGUI::loop() {
ImGui::OpenPopup("System File Dialog Pending"); ImGui::OpenPopup("System File Dialog Pending");
} }
centerNextWindow(canvasW,canvasH);
if (ImGui::BeginPopupModal("System File Dialog Pending",NULL,ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoBackground|ImGuiWindowFlags_NoResize|ImGuiWindowFlags_NoMove)) { if (ImGui::BeginPopupModal("System File Dialog Pending",NULL,ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoBackground|ImGuiWindowFlags_NoResize|ImGuiWindowFlags_NoMove)) {
if (!fileDialog->isOpen()) { if (!fileDialog->isOpen()) {
ImGui::CloseCurrentPopup(); ImGui::CloseCurrentPopup();
@ -5237,6 +5242,7 @@ bool FurnaceGUI::loop() {
MEASURE_BEGIN(popup); MEASURE_BEGIN(popup);
centerNextWindow(canvasW,canvasH);
if (ImGui::BeginPopupModal("Rendering...",NULL,ImGuiWindowFlags_AlwaysAutoResize)) { if (ImGui::BeginPopupModal("Rendering...",NULL,ImGuiWindowFlags_AlwaysAutoResize)) {
ImGui::Text("Please wait..."); ImGui::Text("Please wait...");
if (ImGui::Button("Abort")) { if (ImGui::Button("Abort")) {
@ -5264,6 +5270,7 @@ bool FurnaceGUI::loop() {
ImGui::EndPopup(); ImGui::EndPopup();
} }
centerNextWindow(canvasW,canvasH);
if (ImGui::BeginPopupModal("Error",NULL,ImGuiWindowFlags_AlwaysAutoResize)) { if (ImGui::BeginPopupModal("Error",NULL,ImGuiWindowFlags_AlwaysAutoResize)) {
ImGui::Text("%s",errorString.c_str()); ImGui::Text("%s",errorString.c_str());
if (ImGui::Button("OK")) { if (ImGui::Button("OK")) {
@ -5272,6 +5279,7 @@ bool FurnaceGUI::loop() {
ImGui::EndPopup(); ImGui::EndPopup();
} }
centerNextWindow(canvasW,canvasH);
if (ImGui::BeginPopupModal("Warning",NULL,ImGuiWindowFlags_AlwaysAutoResize)) { if (ImGui::BeginPopupModal("Warning",NULL,ImGuiWindowFlags_AlwaysAutoResize)) {
ImGui::Text("%s",warnString.c_str()); ImGui::Text("%s",warnString.c_str());
switch (warnAction) { switch (warnAction) {
@ -5653,6 +5661,7 @@ bool FurnaceGUI::loop() {
// TODO: // TODO:
// - multiple selection // - multiple selection
// - replace instrument // - replace instrument
centerNextWindow(canvasW,canvasH);
if (ImGui::BeginPopupModal("Select Instrument",NULL,ImGuiWindowFlags_AlwaysAutoResize)) { if (ImGui::BeginPopupModal("Select Instrument",NULL,ImGuiWindowFlags_AlwaysAutoResize)) {
bool quitPlease=false; bool quitPlease=false;
if (pendingInsSingle) { if (pendingInsSingle) {
@ -5731,6 +5740,7 @@ bool FurnaceGUI::loop() {
ImGui::EndPopup(); ImGui::EndPopup();
} }
centerNextWindow(canvasW,canvasH);
if (ImGui::BeginPopupModal("Import Raw Sample",NULL,ImGuiWindowFlags_AlwaysAutoResize)) { if (ImGui::BeginPopupModal("Import Raw Sample",NULL,ImGuiWindowFlags_AlwaysAutoResize)) {
ImGui::Text("Data type:"); ImGui::Text("Data type:");
for (int i=0; i<DIV_SAMPLE_DEPTH_MAX; i++) { for (int i=0; i<DIV_SAMPLE_DEPTH_MAX; i++) {