[studio] Make FilePickerPopup accept on double click of a file
All checks were successful
Build / build (push) Successful in 1m22s
All checks were successful
Build / build (push) Successful in 1m22s
This commit is contained in:
@ -5,6 +5,7 @@
|
|||||||
* Fix file deletion to close file even if not active
|
* Fix file deletion to close file even if not active
|
||||||
* Fix file copy to work when creating a copy with the name of a previously
|
* Fix file copy to work when creating a copy with the name of a previously
|
||||||
deleted file
|
deleted file
|
||||||
|
* Make file picker popup accept on double click of a file
|
||||||
* PaletteEditor: Add RGB key shortcuts for focusing color channels
|
* PaletteEditor: Add RGB key shortcuts for focusing color channels
|
||||||
* PaletteEditor: Add color preview to color editor
|
* PaletteEditor: Add color preview to color editor
|
||||||
* PaletteEditor: Make RGB key shortcuts work when color channel inputs are
|
* PaletteEditor: Make RGB key shortcuts work when color channel inputs are
|
||||||
|
@ -13,7 +13,11 @@ class FilePickerPopup {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
ox::String m_name;
|
ox::String m_name;
|
||||||
FileExplorer m_explorer;
|
struct Explorer: public FileExplorer {
|
||||||
|
mutable bool opened{};
|
||||||
|
explicit Explorer(keel::Context &kctx);
|
||||||
|
void fileOpened(ox::StringViewCR path) const noexcept override;
|
||||||
|
} m_explorer;
|
||||||
ox::Vector<ox::String> const m_fileExts;
|
ox::Vector<ox::String> const m_fileExts;
|
||||||
bool m_open{};
|
bool m_open{};
|
||||||
|
|
||||||
@ -33,6 +37,10 @@ class FilePickerPopup {
|
|||||||
|
|
||||||
ox::Optional<ox::String> draw(Context &ctx) noexcept;
|
ox::Optional<ox::String> draw(Context &ctx) noexcept;
|
||||||
|
|
||||||
|
private:
|
||||||
|
[[nodiscard]]
|
||||||
|
ox::Optional<ox::String> handlePick() noexcept;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,15 @@
|
|||||||
|
|
||||||
namespace studio {
|
namespace studio {
|
||||||
|
|
||||||
|
FilePickerPopup::Explorer::Explorer(keel::Context &kctx):
|
||||||
|
FileExplorer{kctx} {
|
||||||
|
}
|
||||||
|
|
||||||
|
void FilePickerPopup::Explorer::fileOpened(ox::StringViewCR) const noexcept {
|
||||||
|
opened = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
FilePickerPopup::FilePickerPopup(
|
FilePickerPopup::FilePickerPopup(
|
||||||
ox::StringParam name,
|
ox::StringParam name,
|
||||||
keel::Context &kctx,
|
keel::Context &kctx,
|
||||||
@ -41,6 +50,7 @@ void FilePickerPopup::refresh() noexcept {
|
|||||||
void FilePickerPopup::open() noexcept {
|
void FilePickerPopup::open() noexcept {
|
||||||
refresh();
|
refresh();
|
||||||
m_open = true;
|
m_open = true;
|
||||||
|
m_explorer.opened = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FilePickerPopup::close() noexcept {
|
void FilePickerPopup::close() noexcept {
|
||||||
@ -60,16 +70,22 @@ ox::Optional<ox::String> FilePickerPopup::draw(Context &ctx) noexcept {
|
|||||||
if (ig::BeginPopup(ctx.tctx, m_name, m_open, {380, 340})) {
|
if (ig::BeginPopup(ctx.tctx, m_name, m_open, {380, 340})) {
|
||||||
auto const vp = ImGui::GetContentRegionAvail();
|
auto const vp = ImGui::GetContentRegionAvail();
|
||||||
m_explorer.draw(ctx, {vp.x, vp.y - 30});
|
m_explorer.draw(ctx, {vp.x, vp.y - 30});
|
||||||
if (ig::PopupControlsOkCancel(m_open) == ig::PopupResponse::OK) {
|
if (ig::PopupControlsOkCancel(m_open) == ig::PopupResponse::OK || m_explorer.opened) {
|
||||||
auto p = m_explorer.selectedPath();
|
out = handlePick();
|
||||||
if (p) {
|
|
||||||
out.emplace(*p);
|
|
||||||
}
|
|
||||||
close();
|
|
||||||
}
|
}
|
||||||
ImGui::EndPopup();
|
ImGui::EndPopup();
|
||||||
}
|
}
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ox::Optional<ox::String> FilePickerPopup::handlePick() noexcept {
|
||||||
|
ox::Optional<ox::String> out;
|
||||||
|
auto p = m_explorer.selectedPath();
|
||||||
|
if (p) {
|
||||||
|
out.emplace(*p);
|
||||||
|
}
|
||||||
|
close();
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user