MCPcopy Create free account
hub / github.com/XorTroll/Goldleaf / UpdateElements

Method UpdateElements

Goldleaf/source/ui/ui_BrowserLayout.cpp:703–744  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

701 }
702
703 void BrowserLayout::UpdateElements(const int idx) {
704 g_Settings.ApplyToMenu(this->browse_menu);
705 const auto contents = this->cur_exp->GetContents();
706 this->browse_menu->ClearItems();
707 this->ResetMenuHead();
708 this->browse_menu->SetVisible(!contents.empty());
709 this->empty_dir_text->SetVisible(contents.empty());
710 if(!contents.empty()) {
711 for(const auto &item: contents) {
712 if(g_Settings.json_settings.fs.value().ignore_hidden_files.value() && IsHiddenContent(item)) {
713 continue;
714 }
715
716 auto menu_item = pu::ui::elm::MenuItem::New(item);
717 menu_item->SetColor(g_Settings.GetColorScheme().text);
718 if(this->cur_exp->IsDirectory(item)) {
719 menu_item->SetIcon(this->cur_exp->IsDirectoryEmpty(item) ? GetCommonIcon(CommonIconKind::DirectoryEmpty) : GetCommonIcon(CommonIconKind::Directory));
720 }
721 else {
722 const auto ext = LowerCaseString(fs::GetExtension(item));
723 menu_item->SetIcon(GetCommonIconForExtension(ext));
724 }
725 menu_item->AddOnKey(std::bind(&BrowserLayout::fsItems_DefaultKey, this, item));
726 menu_item->AddOnKey(std::bind(&BrowserLayout::fsItems_Y, this, item), HidNpadButton_Y);
727 this->browse_menu->AddItem(menu_item);
728 }
729 u32 tmp_idx = 0;
730 if(idx < 0) {
731 if(!g_EntryIndexStack.empty()) {
732 tmp_idx = g_EntryIndexStack.top();
733 g_EntryIndexStack.pop();
734 }
735 }
736 else {
737 tmp_idx = static_cast<u32>(idx);
738 if(tmp_idx >= contents.size()) {
739 tmp_idx = 0;
740 }
741 }
742 this->browse_menu->SetSelectedIndex(tmp_idx);
743 }
744 }
745
746 void BrowserLayout::ResetMenuHead() {
747 g_MainApplication->LoadMenuHead(this->cur_exp->GetPresentableCwd());

Callers 6

OnInputMethod · 0.95
OnFileSelectedMethod · 0.95
OnDirectorySelectedMethod · 0.95
PromptDeleteFileMethod · 0.95
fsItems_DefaultKeyMethod · 0.95

Calls 10

ResetMenuHeadMethod · 0.95
IsHiddenContentFunction · 0.85
GetCommonIconFunction · 0.85
LowerCaseStringFunction · 0.85
GetExtensionFunction · 0.85
ApplyToMenuMethod · 0.80
GetContentsMethod · 0.80
IsDirectoryMethod · 0.45
IsDirectoryEmptyMethod · 0.45

Tested by

no test coverage detected