Browse files

Call updateListing() in the update method.

  • Loading branch information...
1 parent 21fc401 commit 4f93bf7f6594920589fa8b20c40c5d3b36a38498 @acaudwell committed Jun 25, 2012
Showing with 16 additions and 12 deletions.
  1. +15 −12 ui/file_selector.cpp
  2. +1 −0 ui/file_selector.h
View
27 ui/file_selector.cpp
@@ -32,7 +32,7 @@ UIFileSelector::UIFileSelector(const std::string& title, const std::string& dir,
addFilter("All Files (*.*)", "");
- current_filter = filter_select->getSelectedOption();
+ current_filter = 0;
changeDir(initial_dir);
}
@@ -67,24 +67,16 @@ bool UIFileSelector::changeDir(const boost::filesystem::path& dir) {
if(!is_directory(dir)) return false;
- std::string dir_string = dir.string();
-
- prettyDirectory(dir_string);
-
- previous_dir = dir_path->text;
-
- dir_path->setText(dir_string);
-
- updateListing();
-
+ next_dir = dir.string();
+
return true;
}
void UIFileSelector::update(float dt) {
UIOptionLabel* selected_filter = filter_select->getSelectedOption();
- if(current_filter != selected_filter) {
+ if(current_filter != selected_filter || !next_dir.empty()) {
current_filter = selected_filter;
updateListing();
}
@@ -132,7 +124,17 @@ void UIFileSelector::confirm() {
}
void UIFileSelector::updateListing() {
+
+ if(!next_dir.empty()) {
+ prettyDirectory(next_dir);
+
+ previous_dir = dir_path->text;
+ dir_path->setText(next_dir);
+
+ next_dir.resize(0);
+ }
+
if(dir_path->text.empty()) return;
boost::filesystem::path p(dir_path->text);
@@ -157,6 +159,7 @@ void UIFileSelector::updateListing() {
current_dir = p;
+ listing->setUI(ui);
listing->clear();
//add .. if there is a parent directory
View
1 ui/file_selector.h
@@ -27,6 +27,7 @@ class UIFileSelector : public UIGroup {
boost::filesystem::path selected_path;
boost::filesystem::path current_dir;
+ std::string next_dir;
UIOptionLabel* current_filter;
UIFileSelectorAction* action;

0 comments on commit 4f93bf7

Please sign in to comment.