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

Method OnInput

Goldleaf/source/ui/ui_BrowserLayout.cpp:44–99  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

42 }
43
44 void BrowserLayout::OnInput(const u64 keys_down, const u64 keys_up, const u64 keys_held, const pu::ui::TouchPoint touch_pos) {
45 if(keys_down & HidNpadButton_B) {
46 if(this->GoBack()) {
47 this->UpdateElements(-1);
48 }
49 else {
50 g_MainApplication->ReturnToParentLayout();
51 }
52 }
53 else if(keys_down & HidNpadButton_X) {
54 if(!g_Clipboard.empty()) {
55 auto exp = fs::GetExplorerForPath(g_Clipboard);
56 const bool clipboard_is_dir = exp->IsDirectory(g_Clipboard);
57 auto entry_icon = clipboard_is_dir ? GetCommonIcon(CommonIconKind::Directory) : GetCommonIconForExtension(fs::GetExtension(g_Clipboard));
58 const auto option = g_MainApplication->DisplayDialog(cfg::Strings.GetString(222), cfg::Strings.GetString(223) + "\n(" + g_Clipboard + ")", { cfg::Strings.GetString(111), cfg::Strings.GetString(18) }, true, entry_icon);
59 if(option == 0) {
60 const auto item_name = fs::GetBaseName(g_Clipboard);
61 g_MainApplication->ShowLayout(g_MainApplication->GetCopyLayout());
62 g_MainApplication->GetCopyLayout()->StartCopy(g_Clipboard, this->GetExplorer()->FullPathFor(item_name));
63 this->UpdateElements();
64 g_Clipboard = "";
65 }
66 }
67 else {
68 g_MainApplication->ShowNotification(cfg::Strings.GetString(224));
69 }
70 }
71 else if(keys_down & HidNpadButton_L) {
72 const auto file_name = ShowKeyboard(cfg::Strings.GetString(225), "");
73 if(!file_name.empty()) {
74 const auto full_path = this->GetExplorer()->FullPathFor(file_name);
75 if(this->GetExplorer()->IsFile(full_path) || this->GetExplorer()->IsDirectory(full_path)) {
76 HandleResult(rc::goldleaf::ResultEntryAlreadyPresent, cfg::Strings.GetString(255));
77 }
78 else {
79 this->GetExplorer()->CreateFile(full_path);
80 g_MainApplication->ShowNotification(cfg::Strings.GetString(227) + " \'" + file_name + "\'");
81 this->UpdateElements();
82 }
83 }
84 }
85 else if(keys_down & HidNpadButton_R) {
86 const auto dir_name = ShowKeyboard(cfg::Strings.GetString(250), "");
87 if(!dir_name.empty()) {
88 const auto full_path = this->GetExplorer()->FullPathFor(dir_name);
89 if(this->GetExplorer()->IsFile(full_path) || this->GetExplorer()->IsDirectory(full_path)) {
90 HandleResult(rc::goldleaf::ResultEntryAlreadyPresent, cfg::Strings.GetString(255));
91 }
92 else {
93 this->GetExplorer()->CreateDirectory(full_path);
94 g_MainApplication->ShowNotification(cfg::Strings.GetString(228) + " \'" + dir_name + "\'");
95 this->UpdateElements();
96 }
97 }
98 }
99 }
100
101 void BrowserLayout::OnFileSelected(const std::string &item, const std::string &full_item, const std::string &pres_full_item) {

Callers

nothing calls this directly

Calls 15

GoBackMethod · 0.95
UpdateElementsMethod · 0.95
GetExplorerMethod · 0.95
GetExplorerForPathFunction · 0.85
GetCommonIconFunction · 0.85
GetExtensionFunction · 0.85
GetBaseNameFunction · 0.85
ShowKeyboardFunction · 0.85
HandleResultFunction · 0.85
ReturnToParentLayoutMethod · 0.80
DisplayDialogMethod · 0.80

Tested by

no test coverage detected