editor searchBar added

This commit is contained in:
BannZay 2016-08-21 02:47:39 +03:00
parent 585f9e572f
commit 52d8efdfde
2 changed files with 28 additions and 2 deletions

View file

@ -3818,10 +3818,10 @@ void CEditor::RenderFileDialog()
aPath[0] = 0;
str_format(aBuf, sizeof(aBuf), "Current path: %s", aPath);
UI()->DoLabel(&PathBox, aBuf, 10.0f, -1, -1);
// filebox
if(m_FileDialogStorageType == IStorage::TYPE_SAVE)
{
// filebox
static float s_FileBoxID = 0;
UI()->DoLabel(&FileBoxLabel, "Filename:", 10.0f, -1, -1);
if(DoEditBox(&s_FileBoxID, &FileBox, m_aFileDialogFileName, sizeof(m_aFileDialogFileName), 10.0f, &s_FileBoxID))
@ -3833,6 +3833,29 @@ void CEditor::RenderFileDialog()
m_FilesSelectedIndex = -1;
}
}
else
{
//searchbox
FileBox.VSplitRight(250, &FileBox, 0);
CUIRect ClearBox;
FileBox.VSplitRight(15, &FileBox, &ClearBox);
static float s_SearchBoxID = 0;
UI()->DoLabel(&FileBoxLabel, "Search:", 10.0f, -1, -1);
DoEditBox(&s_SearchBoxID, &FileBox, m_aFileDialogSearchText, sizeof(m_aFileDialogSearchText), 10.0f, &s_SearchBoxID,false,CUI::CORNER_L);
// clearSearchbox button
{
static int s_ClearButton = 0;
RenderTools()->DrawUIRect(&ClearBox, vec4(1, 1, 1, 0.33f)*ButtonColorMul(&s_ClearButton), CUI::CORNER_R, 3.0f);
UI()->DoLabel(&ClearBox, "×", 10.0f, 0);
if (UI()->DoButtonLogic(&s_ClearButton, "×", 0, &ClearBox))
{
m_aFileDialogSearchText[0] = 0;
UI()->SetActiveItem(&s_SearchBoxID);
}
}
}
int Num = (int)(View.h/17.0f)+1;
static int ScrollBar = 0;
@ -3945,6 +3968,7 @@ void CEditor::RenderFileDialog()
UI()->ClipEnable(&View);
for(int i = 0; i < m_FileList.size(); i++)
if (!m_aFileDialogSearchText[0] || str_find_nocase (m_FileList[i].m_aName, m_aFileDialogSearchText))
AddFileDialogEntry(i, &View);
// disable clipping again
@ -4082,6 +4106,7 @@ void CEditor::InvokeFileDialog(int StorageType, int FileType, const char *pTitle
m_pfnFileDialogFunc = pfnFunc;
m_pFileDialogUser = pUser;
m_aFileDialogFileName[0] = 0;
m_aFileDialogSearchText[0] = 0;
m_aFileDialogCurrentFolder[0] = 0;
m_aFileDialogCurrentLink[0] = 0;
m_pFileDialogPath = m_aFileDialogCurrentFolder;

View file

@ -810,6 +810,7 @@ public:
char m_aFileDialogFileName[MAX_PATH_LENGTH];
char m_aFileDialogCurrentFolder[MAX_PATH_LENGTH];
char m_aFileDialogCurrentLink[MAX_PATH_LENGTH];
char m_aFileDialogSearchText[64];
char *m_pFileDialogPath;
bool m_aFileDialogActivate;
int m_FileDialogFileType;