void FileListBox::StartListing(const char* dirname) { if (dirname) PopulateFileList(dirname); else PopulateFileList(Config::GetInstance()->GetPersonalDataDir().c_str()); }
Widget* FileListBox::ClickUp(const Point2i & mousePosition, uint button) { if (!Contains(mousePosition)) return NULL; ItemBox::ClickUp(mousePosition, button); const std::string *name = (std::string*)GetSelectedValue(); if (name && DoesFolderExist(*name)) { Uint32 now = SDL_GetTicks(); // Check we didn't click too fast if (now - last_time > 1000) PopulateFileList(name->c_str()); return NULL; } return (name) ? this : NULL; }
//***************************************************************************** // // This function performs actions that are common whenever the directory // level is changed up or down. It populates the correct menu structure with // the list of files in the directory. // //***************************************************************************** static bool ProcessDirChange(char *pcDir, uint32_t ui32Level) { FRESULT fresult; uint32_t ui32Reason; uint32_t ui32FileCount; // // Attempt to change to the new directory. // fresult = ChangeToDirectory(pcDir, &ui32Reason); // // If the directory change was successful, populate the // list of files for the new subdirectory. // if((fresult == FR_OK) && (ui32Level < MAX_SUBDIR_DEPTH)) { // // Get a pointer to the current menu for this CWD. // tSlideMenu *psMenu = &g_psFileMenus[ui32Level]; // // Populate the menu items with the file list for the new CWD. // ui32FileCount = PopulateFileList(ui32Level); // // Initialize the file menu with the list of menu items, // which are just files and dirs in the root directory // psMenu->psSlideMenuItems = g_psFileMenuItems[ui32Level & 1]; psMenu->ui32Items = ui32FileCount; // // Set the parent directory, if there is one. If at level 0 // (CWD is root), then there is no parent directory. // if(ui32Level) { psMenu->psParent = &g_psFileMenus[ui32Level - 1]; } else { psMenu->psParent = 0; } // // If we are descending into a new subdir, then initialize the other // menu item fields to default values. // if(ui32Level > g_ui32Level) { psMenu->ui32CenterIndex = 0; psMenu->ui32FocusIndex = 0; psMenu->bMultiSelectable = 0; } // // Return a success indication // return(true); } // // Directory change was not successful // else { // // Return failure indication // return(false); } }