[imgui] 1. FileExplorer 구현
2023년 7월 5일
목표 # 디렉터리와 일반 파일들의 목록이 보이는 파일탐색기 구현 파일을 열거나 삭제하거나 파일명을 수정하는 등의 작업이 가능하도록 구현 구현 코드 # 메인 함수 # main.cpp의 프레임 반복문에서 호출되는 render 함수 1void render(WindowClass &window_obj) 2{ 3 window_obj.Draw("FileExplorer_Own"); 4} FileExplorer의 구현코드 render.h 1#include <cstdint> 2#include <string_view> 3#include <filesystem> 4// c++17의 filesystem 헤더 추가 5 6namespace fs = std::filesystem; 7 8class WindowClass 9{ 10public: 11 // 생성자. WindowClass가 생성되며 현재파일위치를 가져옴 12 WindowClass() : currentPath(fs::current_path()), selectedPath(fs::path{}) {}; 13 14 void Draw(std::string_view label); 15 16private: 17 void DrawMenu(); // 윈도우의 최상단 메뉴바 출력 18 void DrawContent(); // 현재 디렉토리의 파일 리스트 출력 19 void DrawActions(); // 선택된 파일경로, open, rename, delete 버튼 출력 20 void DrawFilter(); // 확장자 필터링용 입력필드 출력 21 22 void renameFilePopup(); // 팝업 Dialog 로직 23 void deleteFilePopup(); 24 25 // 실제 동작을 수행하는 함수 26 bool renameFile(const fs::path& oldPath, const fs::path& newPath); 27 bool deleteFile(const fs::path& path); 28 29 void openFileWithDefaultEditor(); // 파일을 원하는 프로그램으로 열기 로직 30 31private: 32 fs::path currentPath; // 현재 디렉토리 33 fs::path selectedPath; // 선택된 디렉토리 34 35 bool renameDialogOpen = false; // DialogOpen true/false 36 bool deleteDialogOpen = false; 37}; 38 39void render(WindowClass &window_obj); render. ...