GUI: Add editable path in file browser dialog
This commit is contained in:
parent
37c0342b32
commit
4188ba1252
4 changed files with 23 additions and 5 deletions
|
@ -22,6 +22,7 @@
|
|||
|
||||
#include "gui/browser.h"
|
||||
#include "gui/gui-manager.h"
|
||||
#include "gui/widgets/edittext.h"
|
||||
#include "gui/widgets/list.h"
|
||||
|
||||
#include "common/config-manager.h"
|
||||
|
@ -56,7 +57,7 @@ BrowserDialog::BrowserDialog(const char *title, bool dirBrowser)
|
|||
new StaticTextWidget(this, "Browser.Headline", title);
|
||||
|
||||
// Current path - TODO: handle long paths ?
|
||||
_currentPath = new StaticTextWidget(this, "Browser.Path", "DUMMY");
|
||||
_currentPath = new EditTextWidget(this, "Browser.Path", "DUMMY");
|
||||
|
||||
// Add file list
|
||||
_fileList = new ListWidget(this, "Browser.List");
|
||||
|
@ -94,6 +95,12 @@ void BrowserDialog::open() {
|
|||
|
||||
void BrowserDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) {
|
||||
switch (cmd) {
|
||||
//Search for typed-in directory
|
||||
case kExitTxtCmd:
|
||||
_node = Common::FSNode(_currentPath->getEditString());
|
||||
updateListing();
|
||||
break;
|
||||
//Search by text input
|
||||
case kChooseCmd:
|
||||
if (_isDirBrowser) {
|
||||
// If nothing is selected in the list widget, choose the current dir.
|
||||
|
@ -157,7 +164,7 @@ void BrowserDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data
|
|||
|
||||
void BrowserDialog::updateListing() {
|
||||
// Update the path display
|
||||
_currentPath->setLabel(_node.getPath());
|
||||
_currentPath->setEditString(_node.getPath());
|
||||
|
||||
// We memorize the last visited path.
|
||||
ConfMan.set("browser_lastpath", _node.getPath());
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
namespace GUI {
|
||||
|
||||
class ListWidget;
|
||||
class StaticTextWidget;
|
||||
class EditTextWidget;
|
||||
class CheckboxWidget;
|
||||
class CommandSender;
|
||||
|
||||
|
@ -54,7 +54,7 @@ protected:
|
|||
const void *_chooseRef;
|
||||
#else
|
||||
ListWidget *_fileList;
|
||||
StaticTextWidget *_currentPath;
|
||||
EditTextWidget *_currentPath;
|
||||
Common::FSNode _node;
|
||||
Common::FSList _nodeContent;
|
||||
bool _showHidden;
|
||||
|
|
|
@ -64,7 +64,6 @@ void EditTextWidget::reflowLayout() {
|
|||
EditableWidget::reflowLayout();
|
||||
}
|
||||
|
||||
|
||||
void EditTextWidget::handleMouseDown(int x, int y, int button, int clickCount) {
|
||||
if (!isEnabled())
|
||||
return;
|
||||
|
@ -133,13 +132,19 @@ void EditTextWidget::startEditMode() {
|
|||
void EditTextWidget::endEditMode() {
|
||||
releaseFocus();
|
||||
|
||||
sendCommand(kExitTxtCmd, 0);
|
||||
sendCommand(_finishCmd, 0);
|
||||
}
|
||||
|
||||
void EditTextWidget::abortEditMode() {
|
||||
setEditString(_backupString);
|
||||
sendCommand(_cmd, 0);
|
||||
|
||||
releaseFocus();
|
||||
}
|
||||
|
||||
Common::String EditTextWidget::getEditString() {
|
||||
return _backupString;
|
||||
}
|
||||
|
||||
} // End of namespace GUI
|
||||
|
|
|
@ -25,9 +25,14 @@
|
|||
|
||||
#include "gui/widgets/editable.h"
|
||||
#include "common/str.h"
|
||||
#include "gui/dialog.h"
|
||||
|
||||
namespace GUI {
|
||||
|
||||
enum {
|
||||
kExitTxtCmd = 'TXTE'
|
||||
};
|
||||
|
||||
/* EditTextWidget */
|
||||
class EditTextWidget : public EditableWidget {
|
||||
protected:
|
||||
|
@ -43,6 +48,7 @@ public:
|
|||
EditTextWidget(GuiObject *boss, const String &name, const String &text, const char *tooltp = 0, uint32 cmd = 0, uint32 finishCmd = 0);
|
||||
|
||||
void setEditString(const String &str);
|
||||
String getEditString();
|
||||
|
||||
virtual void handleMouseDown(int x, int y, int button, int clickCount);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue