Skip to content

Commit

Permalink
[ fd ] Test max selection count
Browse files Browse the repository at this point in the history
  • Loading branch information
ice1000 committed Jan 20, 2021
1 parent 834ee2d commit 0fbb696
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
+ Add `imgui.setWindowTitle` with 3 overloads
+ Add `fileDialog.selections`
+ Add `NativeStrings` for an unmodifiable vector of strings
+ Add `maxSelection` argument to `open[Modal/Dialog]`

## v0.16.0

Expand Down
6 changes: 4 additions & 2 deletions buildSrc/src/GenFDTask.kt
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,11 @@ open class GenFDTask : GenTask("JImFileDialogGen", "imgui_file_dialog", since =
windowFlags, size("Min", default = "0, 0"), size("Max", default = "FLT_MAX, FLT_MAX"),
nativeObjectPtr),
Fun("openDialog", key, string("title"),
filters, string("basePath"), nativeObjectPtr),
filters, string("basePath"),
int("maxSelection", default = 1), nativeObjectPtr),
Fun("openModal", key, string("title"),
filters, string("basePath"), nativeObjectPtr),
filters, string("basePath"),
int("maxSelection", default = 1), nativeObjectPtr),
Fun("close", nativeObjectPtr),
Fun("isOk", "boolean", nativeObjectPtr),
Fun("wasOpenedThisFrame", "boolean", key, nativeObjectPtr),
Expand Down
2 changes: 1 addition & 1 deletion core/jni/project/fd_wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ JNIEXPORT jlong JNICALL
JavaCritical_org_ice1000_jimgui_JImFileDialog_selectedFiles(jlong nativeObjectPtr) {
auto &&map = PTR_J2C(FileDialog, nativeObjectPtr)->GetSelection();
auto *vec = new std::vector<std::string>(map.size());
for (auto &&selection : map) vec->push_back(selection.second);
for (auto &&selection : map) if (!selection.second.empty()) vec->push_back(selection.second);
return PTR_C2J(vec);
}

Expand Down
4 changes: 2 additions & 2 deletions core/test/org/ice1000/jimgui/features/FileDialogTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ public static void main(String... args) {
imGui.checkbox("Use modal dialog", modal);
instance.setExtensionInfo(".java", Sandbox.fromAWT(Color.ORANGE), "[Java]");
if (imGui.button("Open dialog")) {
if (modal.accessValue()) instance.openModal(key, title, filter, pwd);
else instance.openDialog(key, title, filter, pwd);
if (modal.accessValue()) instance.openModal(key, title, filter, pwd, 2);
else instance.openDialog(key, title, filter, pwd, 2);
}
if (instance.display(key)) {
if (instance.isOk()) try (NativeString currentPath = instance.currentPath();
Expand Down

0 comments on commit 0fbb696

Please sign in to comment.