Skip to content

Commit

Permalink
Merge d1dabb3 into 37c0342
Browse files Browse the repository at this point in the history
  • Loading branch information
Sedictious committed Aug 21, 2018
2 parents 37c0342 + d1dabb3 commit 31cc999
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 7 deletions.
13 changes: 10 additions & 3 deletions gui/browser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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());
Expand Down
3 changes: 2 additions & 1 deletion gui/browser.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
namespace GUI {

class ListWidget;
class EditTextWidget;
class StaticTextWidget;
class CheckboxWidget;
class CommandSender;
Expand All @@ -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;
Expand Down
9 changes: 7 additions & 2 deletions gui/widgets/edittext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ void EditTextWidget::reflowLayout() {
EditableWidget::reflowLayout();
}


void EditTextWidget::handleMouseDown(int x, int y, int button, int clickCount) {
if (!isEnabled())
return;
Expand Down Expand Up @@ -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
11 changes: 10 additions & 1 deletion gui/widgets/edittext.h
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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();
Expand All @@ -58,6 +66,7 @@ class EditTextWidget : public EditableWidget {
void startEditMode();
void endEditMode();
void abortEditMode();


Common::Rect getEditRect() const;

Expand Down

0 comments on commit 31cc999

Please sign in to comment.