Permalink
Browse files

Merge d1dabb3 into 37c0342

  • Loading branch information...
Sedictious committed Aug 21, 2018
2 parents 37c0342 + d1dabb3 commit 31cc99976abb6709c519596a6daabf2a11c57d42
Showing with 29 additions and 7 deletions.
  1. +10 −3 gui/browser.cpp
  2. +2 −1 gui/browser.h
  3. +7 −2 gui/widgets/edittext.cpp
  4. +10 −1 gui/widgets/edittext.h
@@ -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"
@@ -54,9 +55,9 @@ BrowserDialog::BrowserDialog(const char *title, bool dirBrowser)

// Headline - TODO: should be customizable during creation time
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,6 +29,7 @@
namespace GUI {

class ListWidget;
class EditTextWidget;
class StaticTextWidget;
class CheckboxWidget;
class CommandSender;
@@ -54,7 +55,7 @@ class BrowserDialog : public Dialog {
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;
@@ -132,14 +131,20 @@ 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,13 +48,16 @@ class EditTextWidget : public EditableWidget {
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);

virtual bool wantsFocus() { return true; }

virtual void reflowLayout();


protected:
void drawWidget();
void receivedFocusWidget();
@@ -58,6 +66,7 @@ class EditTextWidget : public EditableWidget {
void startEditMode();
void endEditMode();
void abortEditMode();


Common::Rect getEditRect() const;

0 comments on commit 31cc999

Please sign in to comment.