Skip to content

Commit

Permalink
Client|UI: Improved integration between task bar, console, and game
Browse files Browse the repository at this point in the history
The console widget is now a more integral part of the task bar. The
command line is in the task bar, and when it gains focus, the log
history opens.

When the task bar is open, Esc will now first close and unfocus the
console. The second press of Esc will close the task bar.

Shift-Esc will always move focus to the console command line.

Clicking on the LegacyWidget will clear UI focus, allowing the game
to receive events.
  • Loading branch information
skyjake committed Jun 3, 2013
1 parent 2280dd7 commit f6faeb7
Show file tree
Hide file tree
Showing 11 changed files with 206 additions and 56 deletions.
8 changes: 7 additions & 1 deletion doomsday/client/include/ui/widgets/consolecommandwidget.h
Expand Up @@ -28,14 +28,20 @@
* Whenever the current game changes, the lexicon is automatically updated to
* include the terms of the loaded game.
*/
class ConsoleCommandWidget : public LineEditWidget
class ConsoleCommandWidget : public QObject, public LineEditWidget
{
Q_OBJECT

public:
ConsoleCommandWidget(de::String const &name = "");

// Events.
void focusGained();
bool handleEvent(de::Event const &event);

signals:
void gotFocus();

private:
DENG2_PRIVATE(d)
};
Expand Down
11 changes: 8 additions & 3 deletions doomsday/client/include/ui/widgets/consolewidget.h
Expand Up @@ -22,6 +22,7 @@
#include <QObject>

#include "guiwidget.h"
#include "buttonwidget.h"
#include "consolecommandwidget.h"
#include "logwidget.h"

Expand All @@ -38,20 +39,24 @@ class ConsoleWidget : public QObject, public GuiWidget
public:
ConsoleWidget();

ButtonWidget &button();
ConsoleCommandWidget &commandLine();
LogWidget &log();

de::Rule const &shift();

bool isOpen() const;
bool isLogOpen() const;

// Events.
void viewResized();
void update();
bool handleEvent(de::Event const &event);

public slots:
void open();
void close();
void openLog();
void closeLog();
void clearLog();
void showFullLog();

protected slots:
void logContentHeightIncreased(int delta);
Expand Down
5 changes: 4 additions & 1 deletion doomsday/client/include/ui/widgets/taskbarwidget.h
Expand Up @@ -23,7 +23,7 @@
#include <de/Action>

#include "guiwidget.h"
#include "consolecommandwidget.h"
#include "consolewidget.h"

/**
* Task bar that acts as the primary UI element of the client's UI.
Expand All @@ -35,6 +35,9 @@ class TaskBarWidget : public QObject, public GuiWidget
public:
TaskBarWidget();

ConsoleWidget &console();
ConsoleCommandWidget &commandLine();

bool isOpen() const;
de::Rule const &shift();

Expand Down
8 changes: 5 additions & 3 deletions doomsday/client/src/con_main.cpp
Expand Up @@ -63,6 +63,8 @@
# include "clientapp.h"
# include "ui/windowsystem.h"
# include "ui/clientwindow.h"
# include "ui/widgets/consolewidget.h"
# include "ui/widgets/taskbarwidget.h"
# include "ui/busyvisual.h"
# include "updater/downloaddialog.h"
#endif
Expand Down Expand Up @@ -1463,11 +1465,11 @@ void Con_Open(int yes)
#ifdef __CLIENT__
if(yes)
{
ClientWindow::main().console().open();
ClientWindow::main().console().openLog();
}
else
{
ClientWindow::main().console().close();
ClientWindow::main().console().closeLog();
}
#endif

Expand Down Expand Up @@ -2619,7 +2621,7 @@ D_CMD(OpenClose)
}
else
{
Con_Open(!ClientWindow::main().console().isOpen());
Con_Open(!ClientWindow::main().console().isLogOpen());
}
return true;
}
Expand Down
5 changes: 5 additions & 0 deletions doomsday/client/src/dd_main.cpp
Expand Up @@ -1452,6 +1452,7 @@ bool DD_ChangeGame(de::Game& game, bool allowReload = false)
GL_ResetTextureManager();
GL_SetFilter(false);

// Trap the mouse automatically when loading a game in fullscreen.
{
ClientWindow &mainWin = ClientWindow::main();
mainWin.taskBar().close();
Expand Down Expand Up @@ -1702,6 +1703,10 @@ bool DD_ChangeGame(de::Game& game, bool allowReload = false)
{
ClientWindow::main().taskBar().open();
}
else
{
ClientWindow::main().console().clearLog();
}
#endif
return true;
}
Expand Down
17 changes: 11 additions & 6 deletions doomsday/client/src/ui/clientwindow.cpp
Expand Up @@ -63,7 +63,7 @@ DENG2_OBSERVES(Canvas, FocusChange)
/// Root of the nomal UI widgets of this window.
GuiRootWidget root;
TaskBarWidget *taskBar;
ConsoleWidget *console;
//ConsoleWidget *console;

GuiRootWidget busyRoot;

Expand All @@ -73,7 +73,7 @@ DENG2_OBSERVES(Canvas, FocusChange)
needRecreateCanvas(false),
mode(Normal),
root(thisPublic),
console(0),
//console(0),
busyRoot(thisPublic)
{
/// @todo The decision whether to receive input notifications from the
Expand Down Expand Up @@ -110,20 +110,25 @@ DENG2_OBSERVES(Canvas, FocusChange)
.setInput(Rule::Width, root.viewWidth());
root.add(taskBar);

/*
Rule const &unit = ClientApp::windowSystem().style().rules().rule("unit");
console = new ConsoleWidget;
console->rule()
.setInput(Rule::Bottom, taskBar->rule().top() - unit)
.setInput(Rule::Left, root.viewLeft() + console->shift());
root.add(console);

QObject::connect(taskBar, SIGNAL(closed()), console, SLOT(close()));
QObject::connect(taskBar, SIGNAL(opened()), console, SLOT(clearLog()));
*/

taskBar->setOpeningAction(new CommandAction("menu open"));
taskBar->setClosingAction(new CommandAction("menu close"));

//connect(taskBar, SIGNAL(opened()), console, SLOT(clearLog()));
//connect(taskBar, SIGNAL(opened()), console, SLOT(open()));
//connect(taskBar, SIGNAL(closed()), console, SLOT(close()));

root.setFocus(&taskBar->commandLine());

// Initially the widget is disabled. It will be enabled when the window
// is visible and ready to be drawn.
legacy->disable();
Expand Down Expand Up @@ -284,7 +289,7 @@ TaskBarWidget &ClientWindow::taskBar()

ConsoleWidget &ClientWindow::console()
{
return *d->console;
return d->taskBar->console();
}

void ClientWindow::setMode(Mode const &mode)
Expand Down
5 changes: 5 additions & 0 deletions doomsday/client/src/ui/widgets/consolecommandwidget.cpp
Expand Up @@ -66,6 +66,11 @@ ConsoleCommandWidget::ConsoleCommandWidget(String const &name)
d->updateLexicon();
}

void ConsoleCommandWidget::focusGained()
{
emit gotFocus();
}

bool ConsoleCommandWidget::handleEvent(Event const &event)
{
if(hasFocus() && event.isKeyDown())
Expand Down

0 comments on commit f6faeb7

Please sign in to comment.