1616#include " IconsFontAwesome.h"
1717#include < imgui.h>
1818#include < imgui_internal.h>
19+ #include < array>
1920
2021namespace nexo ::editor {
2122
@@ -39,29 +40,28 @@ namespace nexo::editor {
3940 ImGuiInputTextFlags_CallbackHistory |
4041 ImGuiInputTextFlags_EnterReturnsTrue;
4142
42- bool searchChanged = false ;
4343 if (ImGui::InputTextWithHint (" ##SearchInput" , " Search assets..." ,
4444 m_searchBuffer.data (), m_searchBuffer.capacity (),
4545 inputFlags,
46- [](ImGuiInputTextCallbackData* data) -> int {
46+ [](ImGuiInputTextCallbackData* data) {
4747 auto * window = static_cast <AssetManagerWindow*>(data->UserData );
48+
4849 if (data->EventFlag == ImGuiInputTextFlags_CallbackEdit) {
49- // Update the search buffer with current text
5050 window->m_searchBuffer = std::string (data->Buf , data->BufTextLen );
5151 window->handleSearchInput ();
52- } else if (data-> EventFlag == ImGuiInputTextFlags_CallbackHistory) {
53- // Handle up/down arrows for search history
54- if (data-> EventKey == ImGuiKey_UpArrow) {
55- auto history = window-> m_searchHistory . getRecentSearches ( 1 );
56- if (!history. empty ()) {
57- data-> DeleteChars ( 0 , data-> BufTextLen );
58- data->InsertChars (0 , history[ 0 ]. c_str () );
59- }
52+ return 0 ;
53+ }
54+
55+ if (data-> EventFlag == ImGuiInputTextFlags_CallbackHistory && data-> EventKey == ImGuiKey_UpArrow) {
56+ auto history = window-> m_searchHistory . getRecentSearches ( 1 );
57+ if (!history. empty ()) {
58+ data->DeleteChars (0 , data-> BufTextLen );
59+ data-> InsertChars ( 0 , history[ 0 ]. c_str ());
6060 }
6161 }
62+
6263 return 0 ;
6364 }, this )) {
64- searchChanged = true ;
6565 applySearch ();
6666 }
6767
@@ -118,9 +118,9 @@ namespace nexo::editor {
118118 // Search mode
119119 ImGui::Text (" Search in:" );
120120 ImGui::SameLine ();
121- const char * searchModes[] = { " Name Only" , " Tags Only" , " Description" , " All Fields" };
122- int currentMode = static_cast <int >(m_searchCriteria.searchMode );
123- if ( ImGui::Combo (" ##SearchMode" , ¤tMode, searchModes, IM_ARRAYSIZE ( searchModes))) {
121+ std::array< const char *, 4 > searchModes = { " Name Only" , " Tags Only" , " Description" , " All Fields" };
122+ if ( auto currentMode = static_cast <int >(m_searchCriteria.searchMode );
123+ ImGui::Combo (" ##SearchMode" , ¤tMode, searchModes. data (), searchModes. size ( ))) {
124124 m_searchCriteria.searchMode = static_cast <assets::SearchMode>(currentMode);
125125 updateSearchFilter ();
126126 }
@@ -129,9 +129,9 @@ namespace nexo::editor {
129129 ImGui::Text (" Asset Types:" );
130130 ImGui::Indent ();
131131 for (int i = 1 ; i < static_cast <int >(assets::AssetType::_COUNT); ++i) {
132- assets::AssetType type = static_cast <assets::AssetType>(i);
133- bool isSelected = m_searchCriteria.allowedTypes .contains (type);
134- if ( ImGui::Checkbox (assets::getAssetTypeName (type), &isSelected)) {
132+ auto type = static_cast <assets::AssetType>(i);
133+ if ( bool isSelected = m_searchCriteria.allowedTypes .contains (type);
134+ ImGui::Checkbox (assets::getAssetTypeName (type), &isSelected)) {
135135 if (isSelected) {
136136 m_searchCriteria.allowedTypes .insert (type);
137137 } else {
@@ -149,8 +149,8 @@ namespace nexo::editor {
149149 ImGui::Separator ();
150150 ImGui::Text (" File Size:" );
151151
152- float minSize = m_searchCriteria.minSize .value_or (0 ) / 1024 .0f ; // Convert to KB
153- float maxSize = m_searchCriteria.maxSize .value_or (0 ) / 1024 .0f ;
152+ float minSize = static_cast < float >( m_searchCriteria.minSize .value_or (0 )) / 1024 .0f ;
153+ float maxSize = static_cast < float >( m_searchCriteria.maxSize .value_or (0 ) ) / 1024 .0f ;
154154
155155 ImGui::PushItemWidth (100 );
156156 if (ImGui::DragFloat (" Min (KB)##MinSize" , &minSize, 1 .0f , 0 .0f , FLT_MAX, " %.1f" )) {
@@ -164,33 +164,7 @@ namespace nexo::editor {
164164 }
165165 ImGui::PopItemWidth ();
166166
167- // Status filters
168- ImGui::Separator ();
169- ImGui::Text (" Asset Status:" );
170-
171- if (ImGui::Checkbox (" Loaded Only" , &m_searchCriteria.onlyLoaded )) {
172- if (m_searchCriteria.onlyLoaded ) {
173- m_searchCriteria.onlyUnloaded = false ;
174- m_searchCriteria.onlyErrored = false ;
175- }
176- updateSearchFilter ();
177- }
178- ImGui::SameLine ();
179- if (ImGui::Checkbox (" Unloaded Only" , &m_searchCriteria.onlyUnloaded )) {
180- if (m_searchCriteria.onlyUnloaded ) {
181- m_searchCriteria.onlyLoaded = false ;
182- m_searchCriteria.onlyErrored = false ;
183- }
184- updateSearchFilter ();
185- }
186- ImGui::SameLine ();
187- if (ImGui::Checkbox (" Errors Only" , &m_searchCriteria.onlyErrored )) {
188- if (m_searchCriteria.onlyErrored ) {
189- m_searchCriteria.onlyLoaded = false ;
190- m_searchCriteria.onlyUnloaded = false ;
191- }
192- updateSearchFilter ();
193- }
167+ drawStatusFilters ();
194168
195169 // Options
196170 ImGui::Separator ();
@@ -349,6 +323,35 @@ namespace nexo::editor {
349323 }
350324 }
351325
326+ void AssetManagerWindow::drawStatusFilters () {
327+ ImGui::Separator ();
328+ ImGui::Text (" Asset Status:" );
329+
330+ if (ImGui::Checkbox (" Loaded Only" , &m_searchCriteria.onlyLoaded )) {
331+ if (m_searchCriteria.onlyLoaded ) {
332+ m_searchCriteria.onlyUnloaded = false ;
333+ m_searchCriteria.onlyErrored = false ;
334+ }
335+ updateSearchFilter ();
336+ }
337+ ImGui::SameLine ();
338+ if (ImGui::Checkbox (" Unloaded Only" , &m_searchCriteria.onlyUnloaded )) {
339+ if (m_searchCriteria.onlyUnloaded ) {
340+ m_searchCriteria.onlyLoaded = false ;
341+ m_searchCriteria.onlyErrored = false ;
342+ }
343+ updateSearchFilter ();
344+ }
345+ ImGui::SameLine ();
346+ if (ImGui::Checkbox (" Errors Only" , &m_searchCriteria.onlyErrored )) {
347+ if (m_searchCriteria.onlyErrored ) {
348+ m_searchCriteria.onlyLoaded = false ;
349+ m_searchCriteria.onlyUnloaded = false ;
350+ }
351+ updateSearchFilter ();
352+ }
353+ }
354+
352355 std::vector<assets::GenericAssetRef> AssetManagerWindow::getFilteredAssets () const {
353356 std::vector<assets::GenericAssetRef> allAssets = assets::AssetCatalog::getInstance ().getAssets ();
354357
0 commit comments