mirror of
https://github.com/joel16/NX-Shell.git
synced 2024-11-23 03:39:49 +00:00
popups: Bring back progress bar for copying files
This commit is contained in:
parent
8163a92c98
commit
58727df163
@ -3,6 +3,7 @@
|
||||
|
||||
namespace GUI {
|
||||
bool Init(void);
|
||||
bool SwapBuffers(void);
|
||||
bool Loop(u64 &key);
|
||||
void Render(void);
|
||||
void Exit(void);
|
||||
|
@ -25,6 +25,7 @@ namespace Popups {
|
||||
void OptionsPopup(WindowData &data);
|
||||
void ProgressPopup(float offset, float size, const std::string &title, const std::string &text);
|
||||
void UpdatePopup(bool &state, bool &connection_status, bool &available, const std::string &tag);
|
||||
void ProgressBar(float offset, float size, const std::string &title, const std::string &text);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -40,6 +40,7 @@ typedef struct {
|
||||
s64 total_storage = 0;
|
||||
} WindowData;
|
||||
|
||||
extern WindowData data;
|
||||
extern int sort;
|
||||
|
||||
namespace FileBrowser {
|
||||
@ -48,7 +49,7 @@ namespace FileBrowser {
|
||||
|
||||
namespace Windows {
|
||||
void ResetCheckbox(WindowData &data);
|
||||
void MainWindow(WindowData &data, u64 &key);
|
||||
void MainWindow(WindowData &data, u64 &key, bool progress);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -5,7 +5,9 @@
|
||||
|
||||
#include "config.h"
|
||||
#include "fs.h"
|
||||
#include "language.h"
|
||||
#include "log.h"
|
||||
#include "popups.h"
|
||||
|
||||
// Global vars
|
||||
FsFileSystem *fs;
|
||||
@ -320,7 +322,7 @@ namespace FS {
|
||||
}
|
||||
|
||||
offset += bytes_read;
|
||||
//Popups::ProgressPopup(static_cast<float>(offset), static_cast<float>(size), strings[cfg.lang][Lang::OptionsCopying], filename.c_str());
|
||||
Popups::ProgressBar(static_cast<float>(offset), static_cast<float>(size), strings[cfg.lang][Lang::OptionsCopying], filename.c_str());
|
||||
} while(offset < size);
|
||||
|
||||
delete[] buf;
|
||||
|
@ -94,6 +94,10 @@ namespace GUI {
|
||||
}
|
||||
}
|
||||
|
||||
bool SwapBuffers(void) {
|
||||
return eglSwapBuffers(s_display, s_surface);
|
||||
}
|
||||
|
||||
bool Init(void) {
|
||||
IMGUI_CHECKVERSION();
|
||||
ImGui::CreateContext();
|
||||
@ -157,7 +161,7 @@ namespace GUI {
|
||||
glClearColor(0.00f, 0.00f, 0.00f, 1.00f);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
ImGui_ImplSwitch_RenderDrawData(ImGui::GetDrawData());
|
||||
eglSwapBuffers(s_display, s_surface);
|
||||
GUI::SwapBuffers();
|
||||
}
|
||||
|
||||
void Exit(void) {
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include "windows.h"
|
||||
|
||||
char __application_path[FS_MAX_PATH];
|
||||
WindowData data;
|
||||
|
||||
namespace Services {
|
||||
void SetDefaultTheme(void) {
|
||||
@ -117,7 +118,6 @@ namespace Services {
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
Result ret = 0;
|
||||
WindowData data;
|
||||
u64 key = 0;
|
||||
|
||||
Services::Init();
|
||||
@ -132,7 +132,7 @@ int main(int argc, char* argv[]) {
|
||||
FS::GetTotalStorageSpace(data.total_storage);
|
||||
|
||||
while (GUI::Loop(key)) {
|
||||
Windows::MainWindow(data, key);
|
||||
Windows::MainWindow(data, key, false);
|
||||
GUI::Render();
|
||||
}
|
||||
|
||||
|
@ -1,9 +1,12 @@
|
||||
#include <algorithm>
|
||||
#include <cstring>
|
||||
#include <glad/glad.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "fs.h"
|
||||
#include "gui.h"
|
||||
#include "imgui.h"
|
||||
#include "imgui_impl_switch.h"
|
||||
#include "imgui_internal.h"
|
||||
#include "keyboard.h"
|
||||
#include "language.h"
|
||||
@ -129,9 +132,9 @@ namespace Popups {
|
||||
data.state = WINDOW_STATE_FILEBROWSER;
|
||||
}
|
||||
else {
|
||||
// ImGui::EndPopup();
|
||||
// ImGui::PopStyleVar();
|
||||
// ImGui::Render();
|
||||
ImGui::EndPopup();
|
||||
ImGui::PopStyleVar();
|
||||
ImGui::Render();
|
||||
|
||||
if ((data.checkbox_data.count > 1) && (strcasecmp(data.checkbox_data.cwd, cfg.cwd) != 0))
|
||||
Popups::HandleMultipleCopy(data, &FS::Paste);
|
||||
@ -144,8 +147,9 @@ namespace Popups {
|
||||
}
|
||||
|
||||
copy = !copy;
|
||||
ImGui::CloseCurrentPopup();
|
||||
//ImGui::CloseCurrentPopup();
|
||||
data.state = WINDOW_STATE_FILEBROWSER;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
34
source/popups/progressbar.cpp
Normal file
34
source/popups/progressbar.cpp
Normal file
@ -0,0 +1,34 @@
|
||||
#include <glad/glad.h>
|
||||
#include <switch.h>
|
||||
|
||||
#include "gui.h"
|
||||
#include "imgui_impl_switch.h"
|
||||
#include "log.h"
|
||||
#include "popups.h"
|
||||
#include "windows.h"
|
||||
|
||||
// Todo maybe use a thread to run this?
|
||||
namespace Popups {
|
||||
|
||||
void ProgressBar(float offset, float size, const std::string &title, const std::string &text) {
|
||||
u64 key = ImGui_ImplSwitch_NewFrame();
|
||||
ImGui::NewFrame();
|
||||
|
||||
Windows::MainWindow(data, key, true);
|
||||
Popups::SetupPopup(title.c_str());
|
||||
|
||||
if (ImGui::BeginPopupModal(title.c_str(), nullptr, ImGuiWindowFlags_AlwaysAutoResize)) {
|
||||
ImGui::Text(text.c_str());
|
||||
ImGui::ProgressBar(offset/size, ImVec2(0.0f, 0.0f));
|
||||
}
|
||||
|
||||
Popups::ExitPopup();
|
||||
|
||||
ImGui::Render();
|
||||
glViewport(0, 0, static_cast<int>(ImGui::GetIO().DisplaySize.x), static_cast<int>(ImGui::GetIO().DisplaySize.y));
|
||||
glClearColor(0.00f, 0.00f, 0.00f, 1.00f);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
ImGui_ImplSwitch_RenderDrawData(ImGui::GetDrawData());
|
||||
GUI::SwapBuffers();
|
||||
}
|
||||
}
|
@ -28,7 +28,7 @@ namespace Windows {
|
||||
data.checkbox_data.count = 0;
|
||||
};
|
||||
|
||||
void MainWindow(WindowData &data, u64 &key) {
|
||||
void MainWindow(WindowData &data, u64 &key, bool progress) {
|
||||
Windows::SetupWindow();
|
||||
if (ImGui::Begin("NX-Shell", nullptr, ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse)) {
|
||||
if (ImGui::BeginTabBar("NX-Shell-tabs")) {
|
||||
@ -39,6 +39,9 @@ namespace Windows {
|
||||
}
|
||||
Windows::ExitWindow();
|
||||
|
||||
if (progress)
|
||||
return;
|
||||
|
||||
switch (data.state) {
|
||||
case WINDOW_STATE_OPTIONS:
|
||||
Popups::OptionsPopup(data);
|
||||
|
Loading…
Reference in New Issue
Block a user