-
-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[API] Implement ImGuiFileDialog extension (#89)
* Initial setup for ImGuiFileDialog extension * Need to resolve linker errors. Working on PaneFun callback. * Remove jni callback code that is not compiling to expose linker error. * Callbacks for paneFun not yet implemented. Linker error still present, seems that some header is being included multiple times. * Fixed linker errors. Added example for demo. * Add support for multiple callbacks * Callbacks work
- Loading branch information
Showing
11 changed files
with
444 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import imgui.extension.imguifiledialog.ImGuiFileDialog; | ||
import imgui.extension.imguifiledialog.callback.ImGuiFileDialogPaneFun; | ||
import imgui.extension.imguifiledialog.flag.ImGuiFileDialogFlags; | ||
import imgui.flag.ImGuiCond; | ||
import imgui.internal.ImGui; | ||
import imgui.type.ImBoolean; | ||
|
||
import java.awt.*; | ||
import java.net.URI; | ||
import java.util.Map; | ||
|
||
public class ExampleImGuiFileDialog { | ||
private static final String URL = "https://github.com/aiekick/ImGuiFileDialog"; | ||
|
||
private static Map<String, String> selection = null; | ||
private static long userData = 0; | ||
private static ImGuiFileDialogPaneFun callback = new ImGuiFileDialogPaneFun() { | ||
@Override | ||
public void paneFun(String filter, long userDatas, boolean canContinue) { | ||
ImGui.text("Filter: " + filter); | ||
} | ||
}; | ||
|
||
public static void show(ImBoolean showImGuiFileDialogDemo) { | ||
ImGui.setNextWindowSize(800, 200, ImGuiCond.Once); | ||
ImGui.setNextWindowPos(ImGui.getMainViewport().getPosX() + 100, ImGui.getMainViewport().getPosY() + 100, ImGuiCond.Once); | ||
if (ImGui.begin("ImGuiFileDialogDemo Demo", showImGuiFileDialogDemo)) { | ||
ImGui.text("This a demo for ImGuiFileDialog"); | ||
|
||
ImGui.alignTextToFramePadding(); | ||
ImGui.text("Repo:"); | ||
ImGui.sameLine(); | ||
if (ImGui.button(URL)) { | ||
try { | ||
Desktop.getDesktop().browse(new URI(URL)); | ||
} catch (Exception e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
|
||
if (ImGui.button("Browse File")) { | ||
ImGuiFileDialog.openModal("browse-key", "Choose File", ".java", ".", callback, 250, 1, 42, ImGuiFileDialogFlags.None); | ||
} | ||
|
||
if (ImGuiFileDialog.display("browse-key", ImGuiFileDialogFlags.None, 200, 400, 800, 600)) { | ||
if (ImGuiFileDialog.isOk()) { | ||
selection = ImGuiFileDialog.getSelection(); | ||
userData = ImGuiFileDialog.getUserDatas(); | ||
} | ||
ImGuiFileDialog.close(); | ||
} | ||
} | ||
|
||
if (selection != null && !selection.isEmpty()) { | ||
ImGui.text("Selected: " + selection.values().stream().findFirst().get()); | ||
ImGui.text("User Data: " + userData); | ||
} | ||
|
||
ImGui.end(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.