Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GUI: Add editable path in "Add Game" tab #1273

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions gui/browser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
*/

#include "gui/browser.h"
#include "gui/widgets/edittext.h"
#include "gui/gui-manager.h"
#include "gui/widgets/list.h"

Expand Down Expand Up @@ -53,10 +54,9 @@ BrowserDialog::BrowserDialog(const char *title, bool dirBrowser)
_showHidden = false;

// 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 +94,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 +163,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
4 changes: 2 additions & 2 deletions gui/browser.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
namespace GUI {

class ListWidget;
class StaticTextWidget;
class EditTextWidget;
class CheckboxWidget;
class CommandSender;

Expand All @@ -54,7 +54,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