Add feature to select/show current file in Folder As Workspace
A new button is added in Folder As Workspace to select and show the current editing file in Folder As Workspace. To make Bitmap background transparent with alpha channel in photoshop: https://www.youtube.com/watch?v=8hNEJ7kaw8g&feature=emb_logo Close #7736
This commit is contained in:
parent
53452d96e0
commit
bc2b5ac2ce
@ -206,6 +206,8 @@ 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_FB_SELECTCURRENTFILE BITMAP "icons/fb_select_current_file.bmp"
|
||||
|
||||
IDI_FUNCLIST_ROOT BITMAP "icons/project_file.bmp"
|
||||
IDI_FUNCLIST_NODE BITMAP "icons/funcList_node.bmp"
|
||||
IDI_FUNCLIST_LEAF BITMAP "icons/funcList_leaf.bmp"
|
||||
@ -213,7 +215,6 @@ IDI_FUNCLIST_LEAF BITMAP "icons/funcList_leaf.bmp"
|
||||
IDI_FUNCLIST_SORTBUTTON BITMAP "icons/funclstSort.bmp"
|
||||
IDI_FUNCLIST_RELOADBUTTON BITMAP "icons/funclstReload.bmp"
|
||||
|
||||
|
||||
IDI_VIEW_DOC_MAP_ON_ICON ICON "icons/docMap_on.ico"
|
||||
IDI_VIEW_DOC_MAP_OFF_ICON ICON "icons/docMap_off.ico"
|
||||
IDI_VIEW_FUNCLIST_ON_ICON ICON "icons/funcList_on.ico"
|
||||
|
@ -53,6 +53,7 @@
|
||||
#define FB_ADDFILE (WM_USER + 1024)
|
||||
#define FB_RMFILE (WM_USER + 1025)
|
||||
#define FB_RNFILE (WM_USER + 1026)
|
||||
#define FB_CMD_AIMFILE 1
|
||||
|
||||
FileBrowser::~FileBrowser()
|
||||
{
|
||||
@ -79,12 +80,52 @@ vector<generic_string> split(const generic_string & string2split, TCHAR sep)
|
||||
return splitedStrings;
|
||||
};
|
||||
|
||||
bool isRelatedRootFolder(const generic_string & relatedRoot, const generic_string & subFolder)
|
||||
{
|
||||
if (relatedRoot.empty())
|
||||
return false;
|
||||
|
||||
if (subFolder.empty())
|
||||
return false;
|
||||
|
||||
size_t pos = subFolder.find(relatedRoot);
|
||||
if (pos != 0) // pos == 0 is the necessary condition, but not enough
|
||||
return false;
|
||||
|
||||
vector<generic_string> relatedRootArray = split(relatedRoot, '\\');
|
||||
vector<generic_string> subFolderArray = split(subFolder, '\\');
|
||||
|
||||
size_t index2Compare = relatedRootArray.size() - 1;
|
||||
|
||||
return relatedRootArray[index2Compare] == subFolderArray[index2Compare];
|
||||
}
|
||||
|
||||
INT_PTR CALLBACK FileBrowser::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
switch (message)
|
||||
{
|
||||
case WM_INITDIALOG :
|
||||
{
|
||||
NppParameters& nppParam = NppParameters::getInstance();
|
||||
int style = WS_CHILD | WS_VISIBLE | CCS_ADJUSTABLE | TBSTYLE_AUTOSIZE | TBSTYLE_FLAT | TBSTYLE_LIST | TBSTYLE_TRANSPARENT | BTNS_AUTOSIZE | BTNS_SEP | TBSTYLE_TOOLTIPS;
|
||||
_hToolbarMenu = CreateWindowEx(WS_EX_LAYOUTRTL, TOOLBARCLASSNAME, NULL, style, 0, 0, 0, 0, _hSelf, nullptr, _hInst, NULL);
|
||||
TBBUTTON tbButtons[1];
|
||||
// Add the bmap image into toolbar's imagelist
|
||||
TBADDBITMAP addbmp = { _hInst, 0 };
|
||||
addbmp.nID = IDI_FB_SELECTCURRENTFILE;
|
||||
::SendMessage(_hToolbarMenu, TB_ADDBITMAP, 1, reinterpret_cast<LPARAM>(&addbmp));
|
||||
tbButtons[0].idCommand = FB_CMD_AIMFILE;
|
||||
tbButtons[0].iBitmap = 0;
|
||||
tbButtons[0].fsState = TBSTATE_ENABLED;
|
||||
tbButtons[0].fsStyle = BTNS_BUTTON | BTNS_AUTOSIZE;
|
||||
tbButtons[0].iString = reinterpret_cast<INT_PTR>(TEXT(""));
|
||||
::SendMessage(_hToolbarMenu, TB_BUTTONSTRUCTSIZE, sizeof(TBBUTTON), 0);
|
||||
::SendMessage(_hToolbarMenu, TB_SETBUTTONSIZE, 0, MAKELONG(nppParam._dpiManager.scaleX(20), nppParam._dpiManager.scaleY(20)));
|
||||
::SendMessage(_hToolbarMenu, TB_SETPADDING, 0, MAKELONG(30, 0));
|
||||
::SendMessage(_hToolbarMenu, TB_ADDBUTTONS, sizeof(tbButtons) / sizeof(TBBUTTON), reinterpret_cast<LPARAM>(&tbButtons));
|
||||
::SendMessage(_hToolbarMenu, TB_AUTOSIZE, 0, 0);
|
||||
ShowWindow(_hToolbarMenu, SW_SHOW);
|
||||
|
||||
FileBrowser::initPopupMenus();
|
||||
|
||||
_treeView.init(_hInst, _hSelf, ID_FILEBROWSERTREEVIEW);
|
||||
@ -130,10 +171,16 @@ INT_PTR CALLBACK FileBrowser::run_dlgProc(UINT message, WPARAM wParam, LPARAM lP
|
||||
{
|
||||
int width = LOWORD(lParam);
|
||||
int height = HIWORD(lParam);
|
||||
int extraValue = NppParameters::getInstance()._dpiManager.scaleX(4);
|
||||
|
||||
RECT toolbarMenuRect;
|
||||
::GetClientRect(_hToolbarMenu, &toolbarMenuRect);
|
||||
|
||||
::MoveWindow(_hToolbarMenu, 0, 0, width, toolbarMenuRect.bottom, TRUE);
|
||||
|
||||
HWND hwnd = _treeView.getHSelf();
|
||||
if (hwnd)
|
||||
::MoveWindow(hwnd, 0, 0, width, height, TRUE);
|
||||
::MoveWindow(hwnd, 0, toolbarMenuRect.bottom + extraValue, width, height - toolbarMenuRect.bottom - extraValue, TRUE);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -144,12 +191,23 @@ INT_PTR CALLBACK FileBrowser::run_dlgProc(UINT message, WPARAM wParam, LPARAM lP
|
||||
|
||||
case WM_COMMAND:
|
||||
{
|
||||
switch (LOWORD(wParam))
|
||||
{
|
||||
case FB_CMD_AIMFILE:
|
||||
{
|
||||
selectCurrentEditingFile();
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
popupMenuCmd(LOWORD(wParam));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case WM_DESTROY:
|
||||
{
|
||||
::DestroyWindow(_hToolbarMenu);
|
||||
_treeView.destroy();
|
||||
destroyMenus();
|
||||
break;
|
||||
@ -290,6 +348,31 @@ void FileBrowser::initPopupMenus()
|
||||
::InsertMenu(_hFileMenu, 0, MF_BYCOMMAND, IDM_FILEBROWSER_CMDHERE, cmdHere.c_str());
|
||||
}
|
||||
|
||||
bool FileBrowser::selectCurrentEditingFile()
|
||||
{
|
||||
TCHAR currentDocPath[MAX_PATH] = { '0' };
|
||||
::SendMessage(_hParent, NPPM_GETFULLCURRENTPATH, MAX_PATH, reinterpret_cast<LPARAM>(currentDocPath));
|
||||
generic_string rootFolderPath = currentDocPath;
|
||||
size_t nbFolderUpdaters = _folderUpdaters.size();
|
||||
for (size_t i = 0; i < nbFolderUpdaters; ++i)
|
||||
{
|
||||
if (isRelatedRootFolder(_folderUpdaters[i]->_rootFolder._rootPath, rootFolderPath))
|
||||
{
|
||||
generic_string rootPath = _folderUpdaters[i]->_rootFolder._rootPath;
|
||||
generic_string pathSuffix = rootFolderPath.substr(rootPath.size() + 1, rootFolderPath.size() - rootPath.size());
|
||||
vector<generic_string> linarPathArray = split(pathSuffix, '\\');
|
||||
|
||||
HTREEITEM foundItem = findInTree(rootPath, nullptr, linarPathArray);
|
||||
if (foundItem)
|
||||
{
|
||||
_treeView.selectItem(foundItem);
|
||||
_treeView.getFocus();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
BOOL FileBrowser::setImageList(int root_clean_id, int root_dirty_id, int open_node_id, int closed_node_id, int leaf_id)
|
||||
{
|
||||
@ -393,12 +476,12 @@ void FileBrowser::openSelectFile()
|
||||
{
|
||||
// Get the selected item
|
||||
HTREEITEM selectedNode = _treeView.getSelection();
|
||||
if (not selectedNode) return;
|
||||
if (!selectedNode) return;
|
||||
|
||||
generic_string fullPath = getNodePath(selectedNode);
|
||||
|
||||
// test the path - if it's a file, open it, otherwise just fold or unfold it
|
||||
if (not ::PathFileExists(fullPath.c_str()))
|
||||
if (!::PathFileExists(fullPath.c_str()))
|
||||
return;
|
||||
if (::PathIsDirectory(fullPath.c_str()))
|
||||
return;
|
||||
@ -857,26 +940,6 @@ void FileBrowser::getDirectoryStructure(const TCHAR *dir, const std::vector<gene
|
||||
::FindClose(hFile);
|
||||
}
|
||||
|
||||
bool isRelatedRootFolder(const generic_string & relatedRoot, const generic_string & subFolder)
|
||||
{
|
||||
if (relatedRoot.empty())
|
||||
return false;
|
||||
|
||||
if (subFolder.empty())
|
||||
return false;
|
||||
|
||||
size_t pos = subFolder.find(relatedRoot);
|
||||
if (pos != 0) // pos == 0 is the necessary condition, but not enough
|
||||
return false;
|
||||
|
||||
vector<generic_string> relatedRootArray = split(relatedRoot, '\\');
|
||||
vector<generic_string> subFolderArray = split(subFolder, '\\');
|
||||
|
||||
size_t index2Compare = relatedRootArray.size() - 1;
|
||||
|
||||
return relatedRootArray[index2Compare] == subFolderArray[index2Compare];
|
||||
}
|
||||
|
||||
void FileBrowser::addRootFolder(generic_string rootFolderPath)
|
||||
{
|
||||
if (!::PathFileExists(rootFolderPath.c_str()))
|
||||
|
@ -157,6 +157,8 @@ public:
|
||||
generic_string getSelectedItemPath() const;
|
||||
|
||||
protected:
|
||||
HWND _hToolbarMenu = nullptr;
|
||||
|
||||
TreeView _treeView;
|
||||
HIMAGELIST _hImaLst = nullptr;
|
||||
|
||||
@ -172,6 +174,7 @@ protected:
|
||||
|
||||
BrowserNodeType getNodeType(HTREEITEM hItem);
|
||||
void popupMenuCmd(int cmdID);
|
||||
bool selectCurrentEditingFile();
|
||||
virtual INT_PTR CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam);
|
||||
void notified(LPNMHDR notification);
|
||||
void showContextMenu(int x, int y);
|
||||
|
BIN
PowerEditor/src/icons/fb_select_current_file.bmp
Normal file
BIN
PowerEditor/src/icons/fb_select_current_file.bmp
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.1 KiB |
@ -144,6 +144,7 @@
|
||||
#define IDI_PROJECT_FILEINVALID 607
|
||||
#define IDI_FB_ROOTOPEN 608
|
||||
#define IDI_FB_ROOTCLOSE 609
|
||||
#define IDI_FB_SELECTCURRENTFILE 610
|
||||
|
||||
#define IDI_FUNCLIST_ROOT 620
|
||||
#define IDI_FUNCLIST_NODE 621
|
||||
|
Loading…
Reference in New Issue
Block a user