Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Refactor|UI|Task Bar: Custom widgets as submenus; improved task bar b…
…ehavior

Added a SubwidgetItem class that allows one to create a custom
popup widget as the submenu of a menu item. MenuWidget now knows
how to handle these items.

Refactored task bar to use SubwidgetItem rather than its own
solution for creating the various configuration dialogs.

When the console command line gets focus, task bar closes any open
menus.
  • Loading branch information
skyjake committed Dec 17, 2013
1 parent bd6c41b commit a88ec2e
Show file tree
Hide file tree
Showing 10 changed files with 216 additions and 134 deletions.
2 changes: 2 additions & 0 deletions doomsday/client/client.pro
Expand Up @@ -185,6 +185,7 @@ DENG_CONVENIENCE_HEADERS += \
include/ui/Margins \
include/ui/Stylist \
include/ui/SubmenuItem \
include/ui/SubwidgetItem \
include/ui/VariableToggleItem \
include/Vertex \
include/WallEdge \
Expand Down Expand Up @@ -415,6 +416,7 @@ DENG_HEADERS += \
include/ui/framework/signalaction.h \
include/ui/framework/stylist.h \
include/ui/framework/submenuitem.h \
include/ui/framework/subwidgetitem.h \
include/ui/framework/textdrawable.h \
include/ui/framework/variabletoggleitem.h \
include/ui/framework/widgetactions.h \
Expand Down
1 change: 1 addition & 0 deletions doomsday/client/include/ui/SubwidgetItem
@@ -0,0 +1 @@
#include "framework/subwidgetitem.h"
65 changes: 65 additions & 0 deletions doomsday/client/include/ui/framework/subwidgetitem.h
@@ -0,0 +1,65 @@
/** @file subwidgetitem.h
*
* @authors Copyright (c) 2013 Jaakko Keränen <jaakko.keranen@iki.fi>
*
* @par License
* GPL: http://www.gnu.org/licenses/gpl.html
*
* <small>This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version. This program is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
* Public License for more details. You should have received a copy of the GNU
* General Public License along with this program; if not, see:
* http://www.gnu.org/licenses</small>
*/

#ifndef DENG_CLIENT_UI_SUBWIDGETITEM_H
#define DENG_CLIENT_UI_SUBWIDGETITEM_H

#include "../uidefs.h"
#include "item.h"

#include <de/Image>

class PopupWidget;

namespace ui {

/**
* UI context item that opens a widget as a popup.
*/
class SubwidgetItem : public Item
{
public:
typedef PopupWidget *(*WidgetConstructor)();

public:
SubwidgetItem(de::String const &label, ui::Direction openingDirection,
WidgetConstructor constructor)
: Item(ShownAsButton, label)
, _constructor(constructor)
, _dir(openingDirection) {}

SubwidgetItem(de::Image const &image, de::String const &label, ui::Direction openingDirection,
WidgetConstructor constructor)
: Item(ShownAsButton, label)
, _constructor(constructor)
, _dir(openingDirection)
, _image(image) {}

PopupWidget *makeWidget() const { return _constructor(); }
ui::Direction openingDirection() const { return _dir; }
de::Image image() const { return _image; }

private:
WidgetConstructor _constructor;
ui::Direction _dir;
de::Image _image;
};

} // namespace ui

#endif // DENG_CLIENT_UI_SUBWIDGETITEM_H
2 changes: 2 additions & 0 deletions doomsday/client/include/ui/widgets/consolewidget.h
Expand Up @@ -65,13 +65,15 @@ class ConsoleWidget : public GuiWidget

signals:
void commandModeChanged();
void commandLineGotFocus();

public slots:
void openLog();
void closeLog();
void clearLog();
void showFullLog();
void setFullyOpaque();
void commandLineFocusGained();
void commandLineFocusLost();
void focusOnCommandLine();
void openMenu();
Expand Down
2 changes: 1 addition & 1 deletion doomsday/client/include/ui/widgets/panelwidget.h
Expand Up @@ -98,7 +98,7 @@ public slots:
* Opens the panel, positioning it appropriately so that is anchored to the
* position specified with setAnchor().
*/
void open();
virtual void open();

/**
* Closes the panel. The widget is dismissed once the closing animation
Expand Down
5 changes: 0 additions & 5 deletions doomsday/client/include/ui/widgets/taskbarwidget.h
Expand Up @@ -62,11 +62,6 @@ public slots:
void unloadGame();
void showAbout();
void showUpdaterSettings();
void showRendererSettings();
void showVideoSettings();
void showAudioSettings();
void showInputSettings();
void showNetworkSettings();

protected slots:
void updateCommandLineLayout();
Expand Down
14 changes: 10 additions & 4 deletions doomsday/client/src/ui/widgets/consolewidget.cpp
Expand Up @@ -287,17 +287,23 @@ ConsoleWidget::ConsoleWidget() : GuiWidget("console"), d(new Instance(this))
// Signals.
connect(d->log, SIGNAL(contentHeightIncreased(int)), this, SLOT(logContentHeightIncreased(int)));

connect(d->cmdLine, SIGNAL(gotFocus()), this, SLOT(setFullyOpaque()));
connect(d->cmdLine, SIGNAL(gotFocus()), this, SLOT(openLog()));
connect(d->cmdLine, SIGNAL(gotFocus()), this, SLOT(commandLineFocusGained()));
connect(d->cmdLine, SIGNAL(lostFocus()), this, SLOT(commandLineFocusLost()));
connect(d->cmdLine, SIGNAL(commandEntered(de::String)), this, SLOT(commandWasEntered(de::String)));

connect(d->scriptCmd, SIGNAL(gotFocus()), this, SLOT(setFullyOpaque()));
connect(d->scriptCmd, SIGNAL(gotFocus()), this, SLOT(openLog()));
connect(d->scriptCmd, SIGNAL(gotFocus()), this, SLOT(commandLineFocusGained()));
connect(d->scriptCmd, SIGNAL(lostFocus()), this, SLOT(commandLineFocusLost()));
connect(d->scriptCmd, SIGNAL(commandEntered(de::String)), this, SLOT(commandWasEntered(de::String)));
}

void ConsoleWidget::commandLineFocusGained()
{
setFullyOpaque();
openLog();

emit commandLineGotFocus();
}

ButtonWidget &ConsoleWidget::button()
{
return *d->button;
Expand Down
2 changes: 1 addition & 1 deletion doomsday/client/src/ui/widgets/dialogwidget.cpp
Expand Up @@ -472,7 +472,7 @@ void DialogWidget::open()
d->modality = NonModal;

DENG2_ASSERT(hasRoot());
prepare();
prepare(); // calls base class's open()
}

ui::ActionItem *DialogWidget::defaultActionItem()
Expand Down

0 comments on commit a88ec2e

Please sign in to comment.