Ugly progress commit

This commit is contained in:
Timothy Warren 2019-05-14 16:23:47 -04:00
parent 564640cac2
commit 6befab1b4c
6 changed files with 107 additions and 70 deletions

View File

@ -3,6 +3,7 @@
################################################################################ ################################################################################
cmake_minimum_required (VERSION 2.8) cmake_minimum_required (VERSION 2.8)
set(CMAKE_CXX_FLAGS "-stdlib=libc++")
set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD 11)
project(Tyro) project(Tyro)
@ -32,9 +33,12 @@ else()
message(FATAL_ERROR "Compiler ${CMAKE_CXX_COMPILER} has no C++11 support.") message(FATAL_ERROR "Compiler ${CMAKE_CXX_COMPILER} has no C++11 support.")
endif() endif()
# Silence some useless errors
if (${CMAKE_CXX_COMPILER_ID} MATCHES "Clang") if (${CMAKE_CXX_COMPILER_ID} MATCHES "Clang")
# Silence some useless errors
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-potentially-evaluated-expression") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-potentially-evaluated-expression")
# Set the correct standard lib
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -stdlib=libc++ -lc++abi")
endif() endif()
# wxwidgets stuff # wxwidgets stuff

View File

@ -4,10 +4,10 @@ mkdir -p build
unset MACOSX_DEPLOYMENT_TARGET unset MACOSX_DEPLOYMENT_TARGET
unset CMAKE_OSX_SYSROOT unset CMAKE_OSX_SYSROOT
export MACOSX_DEPLOYMENT_TARGET="10.7" export MACOSX_DEPLOYMENT_TARGET="10.9"
export CMAKE_OSX_SYSROOT="/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk" export CMAKE_OSX_SYSROOT="/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk"
cd build cd build
cmake .. cmake -stdlib=libc++ ..
make "$@" make "$@"
cd .. cd ..

View File

@ -43,7 +43,7 @@ public:
{ {
if ( ! wxApp::OnInit()) return false; if ( ! wxApp::OnInit()) return false;
this->SetSystemOptions(); TyroApp::SetSystemOptions();
this->SetAppName(APP_NAME); this->SetAppName(APP_NAME);
this->SetVendorName(APP_VENDOR); this->SetVendorName(APP_VENDOR);
@ -162,7 +162,7 @@ private:
wxLogDebug("Current display: %ix%i", mode.w, mode.h); wxLogDebug("Current display: %ix%i", mode.w, mode.h);
wxSize base((int)((float)mode.w * 0.8), (int)((float)mode.h * 0.8)); wxSize base((int)((float)mode.w * 0.9), (int)((float)mode.h * 0.9));
return base; return base;
} }
@ -170,13 +170,14 @@ private:
/** /**
* Toolkit-specific settings * Toolkit-specific settings
*/ */
void SetSystemOptions() void static SetSystemOptions()
{ {
#ifdef __WXMAC__ #ifdef __WXMAC__
wxSystemOptions::SetOption("osx.openfiledialog.always-show-types", 1); wxSystemOptions::SetOption("osx.openfiledialog.always-show-types", 1);
#endif #endif
#ifdef __WXMSW__ #ifdef __WXMSW_
wxSystemOptions::SetOption("msw.remap", 0);_
wxSystemOptions::SetOption("msw.display.directdraw", 1); wxSystemOptions::SetOption("msw.display.directdraw", 1);
#endif #endif
} }

View File

@ -6,7 +6,7 @@
// Application config // Application config
const wxString APP_NAME = "Tyro"; const wxString APP_NAME = "Tyro";
const wxString APP_VENDOR = "Aviat Ion"; const wxString APP_VENDOR = "Aviat Ion";
const wxString APP_VERSION = "0.9.1"; const wxString APP_VERSION = "0.10.0";
const wxString APP_VERSION_MORE = "Pre-release"; const wxString APP_VERSION_MORE = "Pre-release";
// Command-line arguments // Command-line arguments

View File

@ -1,3 +1,5 @@
#include <unordered_set>
#include "src/widgets/FilePane.h" #include "src/widgets/FilePane.h"
#include "src/widgets/MainFrame.h" #include "src/widgets/MainFrame.h"
@ -34,7 +36,6 @@ FilePane::FilePane(
wxALIGN_LEFT, wxALIGN_LEFT,
wxCOL_RESIZABLE | wxCOL_SORTABLE); wxCOL_RESIZABLE | wxCOL_SORTABLE);
} }
FilePane::~FilePane() FilePane::~FilePane()
@ -61,86 +62,113 @@ void FilePane::OpenFolder(wxTreeListEvent& event)
* Iterates through the specified folder and creates the tree view * Iterates through the specified folder and creates the tree view
* *
* @access private * @access private
* @param wxString &path
* @param wxTreeListItem &root
*/ */
void FilePane::CreateTree(const wxString &path, wxTreeListItem &root, int level) void FilePane::CreateTree(const wxString &path, wxTreeListItem &root)
{ {
// So yeah, this doesn't really work right.
// It seems I need to create a tree from the list of file paths,
// after which this should be much simpler.
// @TODO Fix
auto *files = new wxArrayString(); auto *files = new wxArrayString();
wxDir::GetAllFiles(path, files); wxDir::GetAllFiles(path, files);
vector<wxString> examined;
vector<wxString>::iterator it;
for (const wxString &item : *files)
{
wxFileName filename(item);
// For loose files, just add directly to the tree // std::unordered_set<std::string> dirs;
if (filename.GetDirCount() == 1)
{
auto fullFileName = filename.GetFullPath();
auto fileData = new wxStringClientData(); for (const wxString &file: *files)
fileData->SetData(fullFileName); {
wxFileName fileName(file);
examined.push_back(fullFileName); if (fileName.DirExists("."))
{
fileName.RemoveDir(0);
}
this->AppendItem(root, filename.GetFullName(), Icon_File, Icon_File, fileData); auto dir = std::string(fileName.GetPath());
continue;
}
// Remove the directory component closest to the root if (dir.empty())
/* filename.RemoveDir(0); {
continue;
}
wxArrayString folders = filename.GetDirs(); this->dir_set.insert(dir);
}
wxTreeListItem newRootNode = root; for (auto& dir: this->dir_set)
{
for (const wxString &curr_folder: folders) wxString wdir = wxString(dir);
{ wxLogDebug("Creating Dir Tree: %s", wdir);
wxLogDebug(curr_folder); this->DirToTree(wdir, root, wxString("."));
}
// Check if directory has already been created
it = find(examined.begin(), examined.end(), curr_folder);
if (it != examined.end()) continue;
// Create the directory node if it doesn't exist
auto fileData = new wxStringClientData();
fileData->SetData(curr_folder);
wxTreeListItem current = this->AppendItem(
newRootNode,
curr_folder,
Icon_FolderClosed,
Icon_FolderOpened,
fileData);
examined.push_back(curr_folder);
newRootNode = current;
this->CreateTree(curr_folder, root);
} */
}
} }
/*void FilePane::CreateFolderTree(StringVector dirList, wxTreeListItem &root) /**
* Recursively create directory tree from list of files
*
* @access private
*/
void FilePane::DirToTree(const wxString &path, wxTreeListItem &root, const wxString &parent)
{ {
auto fullPath = parent.Clone();
}*/ fullPath += "/";
fullPath += path;
auto *files = new wxArrayString();
wxDir::GetAllFiles(path, files);
for (const wxString &item: *files)
{
wxFileName filename(item);
// Remove the directory component closest to the root
if (filename.GetDirCount() > 1)
{
filename.RemoveDir(0);
}
const wxArrayString dirs = filename.GetDirs();
// See if the path already exists on the tree
/* for (const wxString &dir: dirs)
{
this->dir_it = find(this->examined.begin(), this->examined.end(), dir);
if (dir_it != this->examined.end())
{
break;
}
auto fileData = new wxStringClientData();
fileData->SetData(dir);
auto dir_node = this->AppendItem(root, dir, Icon_FolderClosed, Icon_FolderOpened, fileData);
this->examined.push_back(dir);
this->CreateTree(dir, dir_node);
break;
}*/
// If the file is at the root, add it to the tree
if (filename.GetDirCount() == 1)
{
filename.MakeAbsolute();
auto fileData = new wxStringClientData();
fileData->SetData(filename.GetFullPath());
this->AppendItem(root, filename.GetFullName(), Icon_File, Icon_File, fileData);
continue;
}
}
}
/**
* Open a file you double-click on the file list
*/
void FilePane::OpenFileInEditor(wxTreeListEvent& event) void FilePane::OpenFileInEditor(wxTreeListEvent& event)
{ {
wxTreeListItem item = event.GetItem(); wxTreeListItem item = event.GetItem();
auto data = (wxStringClientData*)this->GetItemData(item); auto data = (wxStringClientData*)this->GetItemData(item);
const wxString& path = data->GetData(); const wxString& path = data->GetData();
wxLogDebug("Opening file from sidebar: %s", path);
wxString path_arr [1] = { path }; wxString path_arr [1] = { path };
auto files = wxArrayString(1, *path_arr); auto files = wxArrayString(1, *path_arr);
Glob_main_frame->OpenFiles(files); Glob_main_frame->OpenFiles(files);

View File

@ -1,5 +1,6 @@
#pragma once #pragma once
#include <unordered_set>
#include "src/widgets/widget.h" #include "src/widgets/widget.h"
class FilePane : public wxTreeListCtrl { class FilePane : public wxTreeListCtrl {
@ -16,10 +17,13 @@ public:
private: private:
wxString curr_path = ""; wxString curr_path = "";
wxImageList *img_list = nullptr; wxImageList *img_list = nullptr;
unordered_set<std::string> file_set;
unordered_set<std::string> dir_set;
void BindEvents(); void BindEvents();
void OpenFolder(wxTreeListEvent& event); void OpenFolder(wxTreeListEvent& event);
void OpenFileInEditor(wxTreeListEvent& event); void OpenFileInEditor(wxTreeListEvent& event);
void InitImageList(); void InitImageList();
void CreateTree(const wxString &path, wxTreeListItem &root, int level = 0); void CreateTree(const wxString &path, wxTreeListItem &root);
void DirToTree(const wxString &path, wxTreeListItem &root, const wxString &parent);
}; };