Skip to content

Commit

Permalink
Port "Popups: open/close functions" api
Browse files Browse the repository at this point in the history
  • Loading branch information
SpaiR committed Jul 9, 2022
1 parent a4051f8 commit 217eb02
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 56 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -975,5 +975,20 @@ class ImGui : ApiMetadata() {
argInt("flags", optional = true)
}
method("EndPopup")

// Popups: open/close functions
method("OpenPopup") {
argString("strId")
argInt("popupFlags", optional = true)
}
method("OpenPopup") {
argInt("id")
argInt("popupFlags", optional = true)
}
method("OpenPopupOnItemClick") {
argString("strId", optional = true, default = "NULL")
argInt("popupFlags", optional = true)
}
method("CloseCurrentPopup")
}
}
56 changes: 0 additions & 56 deletions imgui-binding/src/main/java/imgui/ImGui.java
Original file line number Diff line number Diff line change
Expand Up @@ -362,62 +362,6 @@ public static void listBox(String label, ImInt currentItem, String[] items, int
return flag;
*/

// Popups: open/close functions
// - OpenPopup(): set popup state to open. ImGuiPopupFlags are available for opening options.
// - If not modal: they can be closed by clicking anywhere outside them, or by pressing ESCAPE.
// - CloseCurrentPopup(): use inside the BeginPopup()/EndPopup() scope to close manually.
// - CloseCurrentPopup() is called by default by Selectable()/MenuItem() when activated (FIXME: need some options).
// - Use ImGuiPopupFlags_NoOpenOverExistingPopup to avoid opening a popup if there's already one at the same level. This is equivalent to e.g. testing for !IsAnyPopupOpen() prior to OpenPopup().

/**
* Call to mark popup as open (don't call every frame!).
*/
public static native void openPopup(String strId); /*
ImGui::OpenPopup(strId);
*/

/**
* Call to mark popup as open (don't call every frame!).
*/
public static native void openPopup(String strId, int imGuiPopupFlags); /*
ImGui::OpenPopup(strId, imGuiPopupFlags);
*/

/**
* Helper to open popup when clicked on last item. return true when just opened. (note: actually triggers on the mouse _released_ event to be consistent with popup behaviors)
*/
public static native void openPopupOnItemClick(); /*
ImGui::OpenPopupOnItemClick();
*/

/**
* Helper to open popup when clicked on last item. return true when just opened. (note: actually triggers on the mouse _released_ event to be consistent with popup behaviors)
*/
public static native void openPopupOnItemClick(String strId); /*
ImGui::OpenPopupOnItemClick(strId);
*/

/**
* Helper to open popup when clicked on last item. return true when just opened. (note: actually triggers on the mouse _released_ event to be consistent with popup behaviors)
*/
public static native void openPopupOnItemClick(int imGuiPopupFlags); /*
ImGui::OpenPopupOnItemClick(NULL, imGuiPopupFlags);
*/

/**
* Helper to open popup when clicked on last item. return true when just opened. (note: actually triggers on the mouse _released_ event to be consistent with popup behaviors)
*/
public static native void openPopupOnItemClick(String strId, int imGuiPopupFlags); /*
ImGui::OpenPopupOnItemClick(strId, imGuiPopupFlags);
*/

/**
* Manually close the popup we have begin-ed into.
*/
public static native void closeCurrentPopup(); /*
ImGui::CloseCurrentPopup();
*/

// Popups: open+begin combined functions helpers
// - Helpers to do OpenPopup+BeginPopup where the Open action is triggered by e.g. hovering an item and right-clicking.
// - They are convenient to easily create context menus, hence the name.
Expand Down

0 comments on commit 217eb02

Please sign in to comment.