Folder as Workspace (implementation done)

This commit is contained in:
Don Ho 2016-02-08 01:34:33 +01:00
parent 7d0d874296
commit 058c9d5923
12 changed files with 92 additions and 55 deletions

View File

@ -105,12 +105,13 @@ ToolBarButtonUnit toolBarIcons[] = {
//-------------------------------------------------------------------------------------//
{0, IDI_SEPARATOR_ICON, IDI_SEPARATOR_ICON, IDI_SEPARATOR_ICON, IDI_SEPARATOR_ICON},
//-------------------------------------------------------------------------------------//
{IDM_VIEW_WRAP, IDI_VIEW_WRAP_OFF_ICON, IDI_VIEW_WRAP_ON_ICON, IDI_VIEW_WRAP_OFF_ICON, IDR_WRAP},
{IDM_VIEW_WRAP, IDI_VIEW_WRAP_OFF_ICON, IDI_VIEW_WRAP_ON_ICON, IDI_VIEW_WRAP_OFF_ICON, IDR_WRAP},
{IDM_VIEW_ALL_CHARACTERS, IDI_VIEW_ALL_CHAR_OFF_ICON, IDI_VIEW_ALL_CHAR_ON_ICON, IDI_VIEW_ALL_CHAR_OFF_ICON, IDR_INVISIBLECHAR},
{IDM_VIEW_INDENT_GUIDE, IDI_VIEW_INDENT_OFF_ICON, IDI_VIEW_INDENT_ON_ICON, IDI_VIEW_INDENT_OFF_ICON, IDR_INDENTGUIDE},
{IDM_LANG_USER_DLG, IDI_VIEW_UD_DLG_OFF_ICON, IDI_VIEW_UD_DLG_ON_ICON, IDI_VIEW_UD_DLG_OFF_ICON, IDR_SHOWPANNEL},
{IDM_VIEW_DOC_MAP, IDI_VIEW_UD_DLG_OFF_ICON, IDI_VIEW_UD_DLG_ON_ICON, IDI_VIEW_UD_DLG_OFF_ICON, IDR_DOCMAP},
{IDM_VIEW_FUNC_LIST, IDI_VIEW_UD_DLG_OFF_ICON, IDI_VIEW_UD_DLG_ON_ICON, IDI_VIEW_UD_DLG_OFF_ICON, IDR_FUNC_LIST},
{IDM_VIEW_FILEBROWSER, IDI_VIEW_UD_DLG_OFF_ICON, IDI_VIEW_UD_DLG_ON_ICON, IDI_VIEW_UD_DLG_OFF_ICON, IDR_FILEBROWSER},
//-------------------------------------------------------------------------------------//
{0, IDI_SEPARATOR_ICON, IDI_SEPARATOR_ICON, IDI_SEPARATOR_ICON, IDI_SEPARATOR_ICON},
@ -5374,7 +5375,7 @@ void Notepad_plus::launchFileBrowser(const vector<generic_string> & folders)
::SendMessage(_pPublicInterface->getHSelf(), NPPM_MODELESSDIALOG, MODELESSDIALOGREMOVE, (WPARAM)_pFileBrowser->getHSelf());
// define the default docking behaviour
data.uMask = DWS_DF_CONT_LEFT | DWS_ICONTAB;
data.hIconTab = (HICON)::LoadImage(_pPublicInterface->getHinst(), MAKEINTRESOURCE(IDR_PROJECTPANEL_ICO), IMAGE_ICON, 14, 14, LR_LOADMAP3DCOLORS | LR_LOADTRANSPARENT);
data.hIconTab = (HICON)::LoadImage(_pPublicInterface->getHinst(), MAKEINTRESOURCE(IDR_FILEBROWSER_ICO), IMAGE_ICON, 14, 14, LR_LOADMAP3DCOLORS | LR_LOADTRANSPARENT);
data.pszModuleName = NPP_INTERNAL_FUCTION_STR;
// the dlgDlg should be the index of funcItem where the current function pointer is

View File

@ -158,9 +158,12 @@ IDR_CLOSETAB_HOVER BITMAP "icons/closeTabButton_hover.bmp"
IDR_CLOSETAB_PUSH BITMAP "icons/closeTabButton_push.bmp"
IDR_DOCMAP BITMAP "icons/docMap.bmp"
IDR_FUNC_LIST BITMAP "icons/functionList.bmp"
IDR_FILEBROWSER BITMAP "icons/fileBrowser.bmp"
IDR_DOCMAP_ICO ICON "icons/docMap.ico"
IDR_FUNC_LIST_ICO ICON "icons/functionList.ico"
IDR_PROJECTPANEL_ICO ICON "icons/projectPanel.ico"
IDR_FILEBROWSER_ICO ICON "icons/fileBrowser.ico"
IDR_CLIPBOARDPANEL_ICO ICON "icons/clipboardPanel.ico"
IDR_ASCIIPANEL_ICO ICON "icons/asciiPanel.ico"
IDR_DOCSWITCHER_ICO ICON "icons/docSwitcher.ico"
@ -197,6 +200,8 @@ IDI_PROJECT_FOLDEROPEN BITMAP "icons/project_folder_open.bmp"
IDI_PROJECT_FOLDERCLOSE BITMAP "icons/project_folder_close.bmp"
IDI_PROJECT_FILE BITMAP "icons/project_file.bmp"
IDI_PROJECT_FILEINVALID BITMAP "icons/project_file_invalid.bmp"
IDI_FB_ROOTOPEN BITMAP "icons/fb_root_open.bmp"
IDI_FB_ROOTCLOSE BITMAP "icons/fb_root_close.bmp"
IDI_FUNCLIST_ROOT BITMAP "icons/project_file.bmp"
IDI_FUNCLIST_NODE BITMAP "icons/funcList_node.bmp"

View File

@ -38,6 +38,7 @@
#include "ProjectPanel.h"
#include "documentMap.h"
#include "functionListPanel.h"
#include "fileBrowser.h"
using namespace std;
@ -1513,6 +1514,12 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
_pProjectPanel_3->setForegroundColor(style._fgColor);
}
if (_pFileBrowser)
{
_pFileBrowser->setBackgroundColor(style._bgColor);
_pFileBrowser->setForegroundColor(style._fgColor);
}
if (_pDocMap)
_pDocMap->setSyntaxHiliting();

View File

@ -35,6 +35,7 @@
#include "VerticalFileSwitcher.h"
#include "documentMap.h"
#include "functionListPanel.h"
#include "fileBrowser.h"
#include "Sorters.h"
#include "LongRunningOperation.h"
@ -514,14 +515,41 @@ void Notepad_plus::command(int id)
case IDM_VIEW_FILEBROWSER:
{
NppParameters *pNppParam = NppParameters::getInstance();
launchFileBrowser(pNppParam->getFileBrowserRoots());
if (_pFileBrowser == nullptr) // first launch, check in params to open folders
{
NppParameters *pNppParam = NppParameters::getInstance();
launchFileBrowser(pNppParam->getFileBrowserRoots());
if (_pFileBrowser != nullptr)
{
checkMenuItem(IDM_VIEW_FILEBROWSER, true);
_toolBar.setCheck(IDM_VIEW_FILEBROWSER, true);
_pFileBrowser->setClosed(false);
}
}
else
{
if (not _pFileBrowser->isClosed())
{
_pFileBrowser->display(false);
_pFileBrowser->setClosed(true);
checkMenuItem(IDM_VIEW_FILEBROWSER, false);
_toolBar.setCheck(IDM_VIEW_FILEBROWSER, false);
}
else
{
vector<generic_string> dummy;
launchFileBrowser(dummy);
checkMenuItem(IDM_VIEW_FILEBROWSER, true);
_toolBar.setCheck(IDM_VIEW_FILEBROWSER, true);
_pFileBrowser->setClosed(false);
}
}
}
break;
case IDM_VIEW_DOC_MAP:
{
if (_pDocMap && (!_pDocMap->isClosed()))
if (_pDocMap && (not _pDocMap->isClosed()))
{
_pDocMap->display(false);
_pDocMap->vzDlgDisplay(false);
@ -544,7 +572,7 @@ void Notepad_plus::command(int id)
case IDM_VIEW_FUNC_LIST:
{
if (_pFuncList && (!_pFuncList->isClosed()))
if (_pFuncList && (not _pFuncList->isClosed()))
{
_pFuncList->display(false);
_pFuncList->setClosed(true);

View File

@ -40,10 +40,10 @@
#define INDEX_OPEN_ROOT 0
#define INDEX_CLOSE_ROOT 1
#define INDEX_OPEN_NODE 3
#define INDEX_CLOSED_NODE 4
#define INDEX_LEAF 5
#define INDEX_LEAF_INVALID 6
#define INDEX_OPEN_NODE 2
#define INDEX_CLOSE_NODE 3
#define INDEX_LEAF 4
#define GET_X_LPARAM(lp) ((int)(short)LOWORD(lp))
#define GET_Y_LPARAM(lp) ((int)(short)HIWORD(lp))
@ -86,21 +86,19 @@ INT_PTR CALLBACK FileBrowser::run_dlgProc(UINT message, WPARAM wParam, LPARAM lP
FileBrowser::initPopupMenus();
_treeView.init(_hInst, _hSelf, ID_FILEBROWSERTREEVIEW);
setImageList(IDI_PROJECT_WORKSPACE, IDI_PROJECT_WORKSPACEDIRTY, IDI_PROJECT_PROJECT, IDI_PROJECT_FOLDEROPEN, IDI_PROJECT_FOLDERCLOSE, IDI_PROJECT_FILE, IDI_PROJECT_FILEINVALID);
setImageList(IDI_FB_ROOTOPEN, IDI_FB_ROOTCLOSE, IDI_PROJECT_FOLDEROPEN, IDI_PROJECT_FOLDERCLOSE, IDI_PROJECT_FILE);
_treeView.addCanNotDropInList(INDEX_OPEN_ROOT);
_treeView.addCanNotDropInList(INDEX_CLOSE_ROOT);
_treeView.addCanNotDropInList(INDEX_OPEN_NODE);
_treeView.addCanNotDropInList(INDEX_CLOSED_NODE);
_treeView.addCanNotDropInList(INDEX_CLOSE_NODE);
_treeView.addCanNotDropInList(INDEX_LEAF);
_treeView.addCanNotDropInList(INDEX_LEAF_INVALID);
_treeView.addCanNotDragOutList(INDEX_OPEN_ROOT);
_treeView.addCanNotDragOutList(INDEX_CLOSE_ROOT);
_treeView.addCanNotDragOutList(INDEX_OPEN_NODE);
_treeView.addCanNotDragOutList(INDEX_CLOSED_NODE);
_treeView.addCanNotDragOutList(INDEX_CLOSE_NODE);
_treeView.addCanNotDragOutList(INDEX_LEAF);
_treeView.addCanNotDragOutList(INDEX_LEAF_INVALID);
_treeView.makeLabelEditable(false);
_treeView.display();
@ -265,6 +263,7 @@ void FileBrowser::initPopupMenus()
_hRootMenu = ::CreatePopupMenu();
::InsertMenu(_hRootMenu, 0, MF_BYCOMMAND, IDM_FILEBROWSER_REMOVEROOTFOLDER, TEXT("Remove"));
::InsertMenu(_hRootMenu, 0, MF_BYCOMMAND, (UINT)-1, 0);
::InsertMenu(_hRootMenu, 0, MF_BYCOMMAND, IDM_FILEBROWSER_COPYEPATH, TEXT("Copy path"));
::InsertMenu(_hRootMenu, 0, MF_BYCOMMAND, IDM_FILEBROWSER_EXPLORERHERE, TEXT("Explorer here"));
::InsertMenu(_hRootMenu, 0, MF_BYCOMMAND, IDM_FILEBROWSER_CMDHERE, TEXT("CMD here"));
@ -277,6 +276,8 @@ void FileBrowser::initPopupMenus()
//::InsertMenu(_hFolderMenu, 0, MF_BYCOMMAND, IDM_FILEBROWSER_ADDFILES, edit_addfiles.c_str());
_hFileMenu = ::CreatePopupMenu();
::InsertMenu(_hFileMenu, 0, MF_BYCOMMAND, IDM_FILEBROWSER_OPENINNPP, TEXT("Open"));
::InsertMenu(_hFileMenu, 0, MF_BYCOMMAND, (UINT)-1, 0);
::InsertMenu(_hFileMenu, 0, MF_BYCOMMAND, IDM_FILEBROWSER_COPYEPATH, TEXT("Copy path"));
::InsertMenu(_hFileMenu, 0, MF_BYCOMMAND, IDM_FILEBROWSER_EXPLORERHERE, TEXT("Explorer here"));
::InsertMenu(_hFileMenu, 0, MF_BYCOMMAND, IDM_FILEBROWSER_CMDHERE, TEXT("CMD here"));
@ -286,11 +287,11 @@ void FileBrowser::initPopupMenus()
}
BOOL FileBrowser::setImageList(int root_clean_id, int root_dirty_id, int project_id, int open_node_id, int closed_node_id, int leaf_id, int ivalid_leaf_id)
BOOL FileBrowser::setImageList(int root_clean_id, int root_dirty_id, int open_node_id, int closed_node_id, int leaf_id)
{
HBITMAP hbmp;
COLORREF maskColour = RGB(192, 192, 192);
const int nbBitmaps = 7;
const int nbBitmaps = 5;
// Creation of image list
if ((_hImaLst = ImageList_Create(CX_BITMAP, CY_BITMAP, ILC_COLOR32 | ILC_MASK, nbBitmaps, 0)) == NULL)
@ -309,12 +310,6 @@ BOOL FileBrowser::setImageList(int root_clean_id, int root_dirty_id, int project
ImageList_AddMasked(_hImaLst, hbmp, maskColour);
DeleteObject(hbmp);
hbmp = LoadBitmap(_hInst, MAKEINTRESOURCE(project_id));
if (hbmp == NULL)
return FALSE;
ImageList_AddMasked(_hImaLst, hbmp, maskColour);
DeleteObject(hbmp);
hbmp = LoadBitmap(_hInst, MAKEINTRESOURCE(open_node_id));
if (hbmp == NULL)
return FALSE;
@ -333,12 +328,6 @@ BOOL FileBrowser::setImageList(int root_clean_id, int root_dirty_id, int project
ImageList_AddMasked(_hImaLst, hbmp, maskColour);
DeleteObject(hbmp);
hbmp = LoadBitmap(_hInst, MAKEINTRESOURCE(ivalid_leaf_id));
if (hbmp == NULL)
return FALSE;
ImageList_AddMasked(_hImaLst, hbmp, maskColour);
DeleteObject(hbmp);
if (ImageList_GetImageCount(_hImaLst) < nbBitmaps)
return FALSE;
@ -447,21 +436,10 @@ void FileBrowser::openSelectFile()
// test the path - if it's a file, open it, otherwise just fold or unfold it
if (not ::PathFileExists(fullPath.c_str()))
return;
TVITEM tvItem;
tvItem.mask = TVIF_IMAGE | TVIF_SELECTEDIMAGE;
if (::PathIsDirectory(fullPath.c_str()))
{
tvItem.iImage = INDEX_LEAF_INVALID;
tvItem.iSelectedImage = INDEX_LEAF_INVALID;
}
else
{
::SendMessage(_hParent, NPPM_DOOPEN, 0, (LPARAM)(fullPath.c_str()));
tvItem.iImage = INDEX_LEAF;
tvItem.iSelectedImage = INDEX_LEAF;
}
TreeView_SetItem(_treeView.getHSelf(), &tvItem);
return;
::SendMessage(_hParent, NPPM_DOOPEN, 0, (LPARAM)(fullPath.c_str()));
}
@ -516,8 +494,7 @@ void FileBrowser::notified(LPNMHDR notification)
}
else
{
tvItem.iImage = INDEX_LEAF_INVALID;
tvItem.iSelectedImage = INDEX_LEAF_INVALID;
//TODO: remove it
}
TreeView_SetItem(_treeView.getHSelf(), &tvItem);
}
@ -601,13 +578,24 @@ void FileBrowser::notified(LPNMHDR notification)
{
if (nmtv->action == TVE_COLLAPSE)
{
_treeView.setItemImage(nmtv->itemNew.hItem, INDEX_CLOSED_NODE, INDEX_CLOSED_NODE);
_treeView.setItemImage(nmtv->itemNew.hItem, INDEX_CLOSE_NODE, INDEX_CLOSE_NODE);
}
else if (nmtv->action == TVE_EXPAND)
{
_treeView.setItemImage(nmtv->itemNew.hItem, INDEX_OPEN_NODE, INDEX_OPEN_NODE);
}
}
else if (getNodeType(nmtv->itemNew.hItem) == browserNodeType_root)
{
if (nmtv->action == TVE_COLLAPSE)
{
_treeView.setItemImage(nmtv->itemNew.hItem, INDEX_CLOSE_ROOT, INDEX_CLOSE_ROOT);
}
else if (nmtv->action == TVE_EXPAND)
{
_treeView.setItemImage(nmtv->itemNew.hItem, INDEX_OPEN_ROOT, INDEX_OPEN_ROOT);
}
}
}
break;
@ -683,7 +671,7 @@ void FileBrowser::showContextMenu(int x, int y)
HTREEITEM FileBrowser::createNewFolder(HTREEITEM hTreeItem, const TCHAR *folderName)
{
HTREEITEM addedItem = _treeView.addItem(folderName, hTreeItem, INDEX_CLOSED_NODE);
HTREEITEM addedItem = _treeView.addItem(folderName, hTreeItem, INDEX_CLOSE_NODE);
TreeView_Expand(_treeView.getHSelf(), hTreeItem, TVE_EXPAND);
TreeView_EditLabel(_treeView.getHSelf(), addedItem);
@ -768,6 +756,12 @@ void FileBrowser::popupMenuCmd(int cmdID)
}
break;
case IDM_FILEBROWSER_OPENINNPP:
{
openSelectFile();
}
break;
case IDM_FILEBROWSER_REMOVEALLROOTS:
{
for (int i = _folderUpdaters.size() - 1; i >= 0; --i)
@ -984,11 +978,11 @@ HTREEITEM FileBrowser::createFolderItemsFromDirStruct(HTREEITEM hParentItem, con
size_t len = lstrlen(rootPath);
if (rootPath[len - 1] == '\\')
rootPath[len - 1] = '\0';
hFolderItem = _treeView.addItem(directoryStructure._name.c_str(), TVI_ROOT, INDEX_CLOSED_NODE, rootPath);
hFolderItem = _treeView.addItem(directoryStructure._name.c_str(), TVI_ROOT, INDEX_CLOSE_ROOT, rootPath);
}
else
{
hFolderItem = _treeView.addItem(directoryStructure._name.c_str(), hParentItem, INDEX_CLOSED_NODE);
hFolderItem = _treeView.addItem(directoryStructure._name.c_str(), hParentItem, INDEX_CLOSE_NODE);
}
for (size_t i = 0; i < directoryStructure._subFolders.size(); ++i)
@ -1102,7 +1096,7 @@ bool FileBrowser::addInTree(generic_string rootPath, generic_string addItemFullP
// No found, good - Action
if (::PathIsDirectory(addItemFullPath.c_str()))
{
_treeView.addItem(linarPathArray[0].c_str(), node, INDEX_CLOSED_NODE);
_treeView.addItem(linarPathArray[0].c_str(), node, INDEX_CLOSE_NODE);
}
else
{

View File

@ -179,7 +179,7 @@ protected:
void initPopupMenus();
void destroyMenus();
BOOL setImageList(int root_clean_id, int root_dirty_id, int project_id, int open_node_id, int closed_node_id, int leaf_id, int ivalid_leaf_id);
BOOL setImageList(int root_clean_id, int root_dirty_id, int open_node_id, int closed_node_id, int leaf_id);
HTREEITEM createNewFolder(HTREEITEM hTreeItem, const TCHAR *folderName);

View File

@ -40,10 +40,9 @@
/*
#define IDM_FILEBROWSER_ADDFILES (IDD_FILEBROWSER_MENU + 3)
#define IDM_FILEBROWSER_DELETEFILE (IDD_FILEBROWSER_MENU + 5)
*/
#define IDM_FILEBROWSER_OPENINNPP (IDD_FILEBROWSER_MENU + 5)
#define IDM_FILEBROWSER_COPYEPATH (IDD_FILEBROWSER_MENU + 6)
#define IDM_FILEBROWSER_EXPLORERHERE (IDD_FILEBROWSER_MENU + 8)
#define IDM_FILEBROWSER_CMDHERE (IDD_FILEBROWSER_MENU + 9)

Binary file not shown.

After

Width:  |  Height:  |  Size: 822 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 822 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

@ -139,6 +139,8 @@
#define IDI_PROJECT_FOLDERCLOSE 605
#define IDI_PROJECT_FILE 606
#define IDI_PROJECT_FILEINVALID 607
#define IDI_FB_ROOTOPEN 608
#define IDI_FB_ROOTCLOSE 609
#define IDI_FUNCLIST_ROOT 620
#define IDI_FUNCLIST_NODE 621
@ -185,6 +187,7 @@
#define IDR_M_PLAYRECORD 1526
#define IDR_DOCMAP 1527
#define IDR_FUNC_LIST 1528
#define IDR_FILEBROWSER 1529
#define IDR_CLOSETAB 1530
#define IDR_CLOSETAB_INACT 1531
#define IDR_CLOSETAB_HOVER 1532
@ -196,7 +199,7 @@
#define IDR_CLIPBOARDPANEL_ICO 1537
#define IDR_ASCIIPANEL_ICO 1538
#define IDR_DOCSWITCHER_ICO 1539
#define IDR_FILEBROWSER_ICO 1540
#define ID_MACRO 20000
#define ID_MACRO_LIMIT 20200