Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Gauthier Quesnel
irritator
Commits
d0a1bdca
Commit
d0a1bdca
authored
Apr 21, 2021
by
Gauthier Quesnel
Browse files
gui: improve file dialog API
parent
a0e0de77
Changes
3
Hide whitespace changes
Inline
Side-by-side
app/gui/dialog-file.cpp
View file @
d0a1bdca
...
...
@@ -368,8 +368,11 @@ struct file_dialog
file_dialog
fd
;
// static const char8_t* filters[] = { u8".irt", nullptr };
bool
load_file_dialog
(
std
::
filesystem
::
path
&
out
)
load_file_dialog
(
std
::
filesystem
::
path
&
out
,
const
char
*
title
,
const
char8_t
**
filters
)
{
if
(
fd
.
current
.
empty
())
{
fd
.
fill_drives
();
...
...
@@ -381,7 +384,7 @@ load_file_dialog(std::filesystem::path& out)
std
::
filesystem
::
path
next
;
bool
res
=
false
;
if
(
ImGui
::
BeginPopupModal
(
"Select file path to load"
))
{
if
(
ImGui
::
BeginPopupModal
(
title
))
{
bool
path_click
=
false
;
fd
.
show_drives
(
&
path_click
,
&
next
);
...
...
@@ -442,7 +445,6 @@ load_file_dialog(std::filesystem::path& out)
if
(
path_click
)
{
fd
.
paths
.
clear
();
static
const
char8_t
*
filters
[]
=
{
u8".irt"
,
nullptr
};
fd
.
extension_filters
=
filters
;
fd
.
file_filters
=
nullptr
;
...
...
@@ -484,8 +486,11 @@ load_file_dialog(std::filesystem::path& out)
return
res
;
}
// static const char8_t* filters[] = { u8".irt", nullptr };
bool
save_file_dialog
(
std
::
filesystem
::
path
&
out
)
save_file_dialog
(
std
::
filesystem
::
path
&
out
,
const
char
*
title
,
const
char8_t
**
filters
)
{
if
(
fd
.
current
.
empty
())
{
fd
.
fill_drives
();
...
...
@@ -504,7 +509,7 @@ save_file_dialog(std::filesystem::path& out)
std
::
filesystem
::
path
next
;
bool
res
=
false
;
if
(
ImGui
::
BeginPopupModal
(
"Select file path to save"
))
{
if
(
ImGui
::
BeginPopupModal
(
title
))
{
bool
path_click
=
false
;
fd
.
show_drives
(
&
path_click
,
&
next
);
...
...
@@ -573,7 +578,6 @@ save_file_dialog(std::filesystem::path& out)
if
(
path_click
)
{
fd
.
paths
.
clear
();
static
const
char8_t
*
filters
[]
=
{
u8".irt"
,
nullptr
};
fd
.
extension_filters
=
filters
;
fd
.
file_filters
=
nullptr
;
...
...
app/gui/gui.hpp
View file @
d0a1bdca
...
...
@@ -30,10 +30,14 @@ get_executable_directory();
/* Filesytem dialog box */
bool
load_file_dialog
(
std
::
filesystem
::
path
&
out
);
load_file_dialog
(
std
::
filesystem
::
path
&
out
,
const
char
*
title
,
const
char8_t
**
filters
);
bool
save_file_dialog
(
std
::
filesystem
::
path
&
out
);
save_file_dialog
(
std
::
filesystem
::
path
&
out
,
const
char
*
title
,
const
char8_t
**
filters
);
bool
select_directory_dialog
(
std
::
filesystem
::
path
&
out
);
...
...
app/gui/node-editor.cpp
View file @
d0a1bdca
...
...
@@ -2468,8 +2468,11 @@ editor::show_editor() noexcept
}
if
(
show_load_file_dialog
)
{
ImGui
::
OpenPopup
(
"Select file path to load"
);
if
(
load_file_dialog
(
path
))
{
const
char
*
title
=
"Select file path to load"
;
const
char8_t
*
filters
[]
=
{
u8".irt"
,
nullptr
};
ImGui
::
OpenPopup
(
title
);
if
(
load_file_dialog
(
path
,
title
,
filters
))
{
show_load_file_dialog
=
false
;
log_w
.
log
(
5
,
"Load file from %s: "
,
(
const
char
*
)
path
.
u8string
().
c_str
());
...
...
@@ -2492,8 +2495,11 @@ editor::show_editor() noexcept
if
(
show_save_file_dialog
)
{
if
(
sim
.
models
.
size
())
{
ImGui
::
OpenPopup
(
"Select file path to save"
);
if
(
save_file_dialog
(
path
))
{
const
char
*
title
=
"Select file path to save"
;
const
char8_t
*
filters
[]
=
{
u8".irt"
,
nullptr
};
ImGui
::
OpenPopup
(
title
);
if
(
save_file_dialog
(
path
,
title
,
filters
))
{
show_save_file_dialog
=
false
;
log_w
.
log
(
5
,
"Save file to %s
\n
"
,
(
const
char
*
)
path
.
u8string
().
c_str
());
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment