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
16c7940e
Commit
16c7940e
authored
Nov 25, 2020
by
Gauthier Quesnel
Committed by
Gauthier Quesnel
Nov 26, 2020
Browse files
gui: fix width of the load/save dialog widgets
parent
a2da659d
Changes
2
Hide whitespace changes
Inline
Side-by-side
app/gui/dialog-file.cpp
View file @
16c7940e
...
...
@@ -101,7 +101,8 @@ struct file_dialog
#if defined(__APPLE__)
// @TODO Remove this part when XCode allows u8string find/compare.
while
(
*
filters
)
{
if
(
p
.
extension
().
u8string
()
==
reinterpret_cast
<
const
char
*>
(
*
filters
))
if
(
p
.
extension
().
u8string
()
==
reinterpret_cast
<
const
char
*>
(
*
filters
))
return
true
;
++
filters
;
...
...
@@ -237,7 +238,9 @@ 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
(
"Select file path to load"
,
nullptr
,
ImGuiWindowFlags_AlwaysAutoResize
))
{
bool
path_click
=
false
;
fd
.
show_drives
(
&
path_click
,
&
next
);
...
...
@@ -246,10 +249,10 @@ load_file_dialog(std::filesystem::path& out)
fd
.
show_path
(
&
path_click
,
&
next
);
if
(
!
path_click
)
{
Im
Vec2
size
=
ImGui
::
GetContentRegionMax
();
size
.
y
*=
0.8
f
;
ImGui
::
BeginChild
(
"##select_files"
,
size
);
Im
Gui
::
BeginChild
(
"##select_files"
,
ImVec2
{
0.
f
,
350.
f
},
true
,
ImGuiWindowFlags_HorizontalScrollbar
);
if
(
ImGui
::
Selectable
(
"..##select_file"
,
(
fd
.
selected
==
".."
)))
{
if
(
next
.
empty
())
{
...
...
@@ -264,9 +267,11 @@ load_file_dialog(std::filesystem::path& out)
fd
.
temp
.
clear
();
if
(
std
::
filesystem
::
is_directory
(
*
it
))
{
#if defined(__APPLE__)
// @TODO Remove this part when XCode allows u8string concatenation.
// @TODO Remove this part when XCode allows u8string
// concatenation.
fd
.
temp
=
"[Dir] "
;
fd
.
temp
+=
reinterpret_cast
<
const
char
*>
(
it
->
filename
().
u8string
().
c_str
());
fd
.
temp
+=
reinterpret_cast
<
const
char
*>
(
it
->
filename
().
u8string
().
c_str
());
#else
fd
.
temp
=
u8"[Dir] "
;
fd
.
temp
+=
it
->
filename
().
u8string
();
...
...
@@ -307,10 +312,12 @@ load_file_dialog(std::filesystem::path& out)
ImGui
::
Text
(
"File Name: %s"
,
(
const
char
*
)
fd
.
selected
.
u8string
().
c_str
());
float
width
=
ImGui
::
GetContentRegionAvailWidth
();
ImGui
::
PushItemWidth
(
width
);
const
auto
item_spacing
=
ImGui
::
GetStyle
().
ItemSpacing
.
x
;
const
auto
region_width
=
ImGui
::
GetContentRegionAvail
().
x
;
const
auto
button_size
=
ImVec2
{
(
region_width
-
item_spacing
)
/
2.
f
,
0
};
if
(
ImGui
::
Button
(
"Ok"
,
ImVec2
(
width
/
2
,
0
)
))
{
if
(
ImGui
::
Button
(
"Ok"
,
button_size
))
{
auto
sel
=
fd
.
current
;
sel
/=
fd
.
selected
;
out
=
sel
;
...
...
@@ -320,12 +327,10 @@ load_file_dialog(std::filesystem::path& out)
ImGui
::
SetItemDefaultFocus
();
ImGui
::
SameLine
();
if
(
ImGui
::
Button
(
"Cancel"
,
ImVec2
(
width
/
2
,
0
)
))
{
if
(
ImGui
::
Button
(
"Cancel"
,
button_size
))
{
res
=
true
;
}
ImGui
::
PopItemWidth
();
if
(
res
)
{
ImGui
::
CloseCurrentPopup
();
fd
.
clear
();
...
...
@@ -357,7 +362,9 @@ 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
(
"Select file path to save"
,
nullptr
,
ImGuiWindowFlags_AlwaysAutoResize
))
{
bool
path_click
=
false
;
fd
.
show_drives
(
&
path_click
,
&
next
);
...
...
@@ -366,10 +373,10 @@ save_file_dialog(std::filesystem::path& out)
fd
.
show_path
(
&
path_click
,
&
next
);
if
(
!
path_click
)
{
Im
Vec2
size
=
ImGui
::
GetContentRegionMax
();
size
.
y
*=
0.8
f
;
ImGui
::
BeginChild
(
"##select_files"
,
size
);
Im
Gui
::
BeginChild
(
"##select_files"
,
ImVec2
{
0.
f
,
350.
f
},
true
,
ImGuiWindowFlags_HorizontalScrollbar
);
if
(
ImGui
::
Selectable
(
"..##select_file"
,
(
fd
.
selected
==
".."
)))
{
if
(
next
.
empty
())
{
next
=
fd
.
current
.
parent_path
();
...
...
@@ -383,7 +390,8 @@ save_file_dialog(std::filesystem::path& out)
fd
.
temp
.
clear
();
if
(
std
::
filesystem
::
is_directory
(
*
it
))
#if defined(__APPLE__)
// @TODO Remove this part when XCode allows u8string concatenation.
// @TODO Remove this part when XCode allows u8string
// concatenation.
fd
.
temp
=
"[Dir] "
;
#else
fd
.
temp
=
u8"[Dir] "
;
...
...
@@ -438,10 +446,11 @@ save_file_dialog(std::filesystem::path& out)
ImGui
::
Text
(
"Directory name: %s"
,
(
const
char
*
)
fd
.
current
.
u8string
().
c_str
());
float
width
=
ImGui
::
GetContentRegionAvailWidth
();
ImGui
::
PushItemWidth
(
width
);
const
auto
item_spacing
=
ImGui
::
GetStyle
().
ItemSpacing
.
x
;
const
auto
region_width
=
ImGui
::
GetContentRegionAvail
().
x
;
const
auto
button_size
=
ImVec2
{
(
region_width
-
item_spacing
)
/
2.
f
,
0
};
if
(
ImGui
::
Button
(
"Ok"
,
ImVec2
(
width
/
2
,
0
)
))
{
if
(
ImGui
::
Button
(
"Ok"
,
button_size
))
{
auto
sel
=
fd
.
current
;
sel
/=
fd
.
buffer
;
out
=
sel
;
...
...
@@ -451,12 +460,10 @@ save_file_dialog(std::filesystem::path& out)
ImGui
::
SetItemDefaultFocus
();
ImGui
::
SameLine
();
if
(
ImGui
::
Button
(
"Cancel"
,
ImVec2
(
width
/
2
,
0
)
))
{
if
(
ImGui
::
Button
(
"Cancel"
,
button_size
))
{
res
=
true
;
}
ImGui
::
PopItemWidth
();
if
(
res
)
{
ImGui
::
CloseCurrentPopup
();
fd
.
clear
();
...
...
app/gui/node-editor.cpp
View file @
16c7940e
...
...
@@ -2437,10 +2437,7 @@ editor::show_editor() noexcept
}
if
(
show_load_file_dialog
)
{
auto
size
=
ImGui
::
GetContentRegionMax
();
ImGui
::
SetNextWindowSize
(
ImVec2
(
size
.
x
*
0.7
f
,
size
.
y
*
0.7
f
));
ImGui
::
OpenPopup
(
"Select file path to load"
);
if
(
load_file_dialog
(
path
))
{
show_load_file_dialog
=
false
;
log_w
.
log
(
...
...
@@ -2465,9 +2462,6 @@ editor::show_editor() noexcept
if
(
show_save_file_dialog
)
{
if
(
sim
.
models
.
size
())
{
ImGui
::
OpenPopup
(
"Select file path to save"
);
auto
size
=
ImGui
::
GetContentRegionMax
();
ImGui
::
SetNextWindowSize
(
ImVec2
(
size
.
x
*
0.7
f
,
size
.
y
*
0.7
f
));
if
(
save_file_dialog
(
path
))
{
show_save_file_dialog
=
false
;
log_w
.
log
(
...
...
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