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)
set(CMAKE_CXX_FLAGS "-stdlib=libc++")
set(CMAKE_CXX_STANDARD 11)
project(Tyro)
@ -32,9 +33,12 @@ else()
message(FATAL_ERROR "Compiler ${CMAKE_CXX_COMPILER} has no C++11 support.")
endif()
# Silence some useless errors
if (${CMAKE_CXX_COMPILER_ID} MATCHES "Clang")
# Silence some useless errors
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()
# wxwidgets stuff

View File

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

View File

@ -43,7 +43,7 @@ public:
{
if ( ! wxApp::OnInit()) return false;
this->SetSystemOptions();
TyroApp::SetSystemOptions();
this->SetAppName(APP_NAME);
this->SetVendorName(APP_VENDOR);
@ -162,7 +162,7 @@ private:
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;
}
@ -170,13 +170,14 @@ private:
/**
* Toolkit-specific settings
*/
void SetSystemOptions()
void static SetSystemOptions()
{
#ifdef __WXMAC__
wxSystemOptions::SetOption("osx.openfiledialog.always-show-types", 1);
#endif
#ifdef __WXMSW__
#ifdef __WXMSW_
wxSystemOptions::SetOption("msw.remap", 0);_
wxSystemOptions::SetOption("msw.display.directdraw", 1);
#endif
}

View File

@ -6,7 +6,7 @@
// Application config
const wxString APP_NAME = "Tyro";
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";
// Command-line arguments

View File

@ -1,3 +1,5 @@
#include <unordered_set>
#include "src/widgets/FilePane.h"
#include "src/widgets/MainFrame.h"
@ -34,7 +36,6 @@ FilePane::FilePane(
wxALIGN_LEFT,
wxCOL_RESIZABLE | wxCOL_SORTABLE);
}
FilePane::~FilePane()
@ -61,86 +62,113 @@ void FilePane::OpenFolder(wxTreeListEvent& event)
* Iterates through the specified folder and creates the tree view
*
* @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();
wxDir::GetAllFiles(path, files);
vector<wxString> examined;
vector<wxString>::iterator it;
// std::unordered_set<std::string> dirs;
for (const wxString &file: *files)
{
wxFileName fileName(file);
if (fileName.DirExists("."))
{
fileName.RemoveDir(0);
}
auto dir = std::string(fileName.GetPath());
if (dir.empty())
{
continue;
}
this->dir_set.insert(dir);
}
for (auto& dir: this->dir_set)
{
wxString wdir = wxString(dir);
wxLogDebug("Creating Dir Tree: %s", wdir);
this->DirToTree(wdir, root, wxString("."));
}
}
/**
* 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);
// For loose files, just add directly to the tree
if (filename.GetDirCount() == 1)
// Remove the directory component closest to the root
if (filename.GetDirCount() > 1)
{
auto fullFileName = filename.GetFullPath();
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(fullFileName);
fileData->SetData(dir);
examined.push_back(fullFileName);
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;
}
// Remove the directory component closest to the root
/* filename.RemoveDir(0);
wxArrayString folders = filename.GetDirs();
wxTreeListItem newRootNode = root;
for (const wxString &curr_folder: folders)
{
wxLogDebug(curr_folder);
// 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)
{
}*/
/**
* Open a file you double-click on the file list
*/
void FilePane::OpenFileInEditor(wxTreeListEvent& event)
{
wxTreeListItem item = event.GetItem();
auto data = (wxStringClientData*)this->GetItemData(item);
const wxString& path = data->GetData();
wxLogDebug("Opening file from sidebar: %s", path);
wxString path_arr [1] = { path };
auto files = wxArrayString(1, *path_arr);
Glob_main_frame->OpenFiles(files);

View File

@ -1,5 +1,6 @@
#pragma once
#include <unordered_set>
#include "src/widgets/widget.h"
class FilePane : public wxTreeListCtrl {
@ -16,10 +17,13 @@ public:
private:
wxString curr_path = "";
wxImageList *img_list = nullptr;
unordered_set<std::string> file_set;
unordered_set<std::string> dir_set;
void BindEvents();
void OpenFolder(wxTreeListEvent& event);
void OpenFileInEditor(wxTreeListEvent& event);
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);
};