aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChatziargyriou Eleftheria2018-08-18 09:37:59 +0300
committerThierry Crozat2018-08-22 00:39:51 +0100
commit4188ba12523dd625725769ee4e830760ccec36a6 (patch)
tree70ef015f25348cd588a906f9541a8678eb85d56e
parent37c0342b32dbbdb7712e8e78fd959cfbb0331af2 (diff)
downloadscummvm-rg350-4188ba12523dd625725769ee4e830760ccec36a6.tar.gz
scummvm-rg350-4188ba12523dd625725769ee4e830760ccec36a6.tar.bz2
scummvm-rg350-4188ba12523dd625725769ee4e830760ccec36a6.zip
GUI: Add editable path in file browser dialog
-rw-r--r--gui/browser.cpp11
-rw-r--r--gui/browser.h4
-rw-r--r--gui/widgets/edittext.cpp7
-rw-r--r--gui/widgets/edittext.h6
4 files changed, 23 insertions, 5 deletions
diff --git a/gui/browser.cpp b/gui/browser.cpp
index 67b0dd9174..0e2d6b87bc 100644
--- a/gui/browser.cpp
+++ b/gui/browser.cpp
@@ -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());
diff --git a/gui/browser.h b/gui/browser.h
index 10663f547e..557563e0fa 100644
--- a/gui/browser.h
+++ b/gui/browser.h
@@ -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;
diff --git a/gui/widgets/edittext.cpp b/gui/widgets/edittext.cpp
index b0e68985d1..540dc27932 100644
--- a/gui/widgets/edittext.cpp
+++ b/gui/widgets/edittext.cpp
@@ -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
diff --git a/gui/widgets/edittext.h b/gui/widgets/edittext.h
index 7376ae70ff..d382c8f067 100644
--- a/gui/widgets/edittext.h
+++ b/gui/widgets/edittext.h
@@ -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);