Skip to content

Commit

Permalink
Merge branch 'ui-framework'
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed Aug 11, 2013
2 parents fab3b17 + 451332e commit c2dd04a
Show file tree
Hide file tree
Showing 50 changed files with 727 additions and 282 deletions.
1 change: 1 addition & 0 deletions distrib/win32/setup.iss.template
Expand Up @@ -126,6 +126,7 @@ Source: "doc\LICENSE"; DestDir: "{app}\doc"; Components: Engine
Source: "doc\readme.txt"; DestDir: "{app}\doc"; Components: Engine

; Resources
Source: "modules\appconfig.de"; DestDir: "{app}\modules"; Components: Engine
Source: "modules\bootstrap.de"; DestDir: "{app}\modules"; Components: Engine
Source: "modules\Config.de"; DestDir: "{app}\modules"; Components: Engine
Source: "modules\gui.de"; DestDir: "{app}\modules"; Components: Engine
Expand Down
12 changes: 10 additions & 2 deletions doomsday/client/client.pro
Expand Up @@ -370,6 +370,8 @@ DENG_HEADERS += \
include/ui/widgets/scrollareawidget.h \
include/ui/widgets/styledlogsinkformatter.h \
include/ui/widgets/taskbarwidget.h \
include/ui/widgets/togglewidget.h \
include/ui/widgets/variabletogglewidget.h \
include/ui/widgets/widgetactions.h \
include/ui/windowsystem.h \
include/ui/zonedebug.h \
Expand Down Expand Up @@ -673,6 +675,8 @@ SOURCES += \
src/ui/widgets/scrollareawidget.cpp \
src/ui/widgets/styledlogsinkformatter.cpp \
src/ui/widgets/taskbarwidget.cpp \
src/ui/widgets/togglewidget.cpp \
src/ui/widgets/variabletogglewidget.cpp \
src/ui/widgets/widgetactions.cpp \
src/ui/windowsystem.cpp \
src/ui/zonedebug.cpp \
Expand Down Expand Up @@ -728,8 +732,12 @@ SOURCES += \
SOURCES += src/audio/sys_audiod_sdlmixer.cpp
}

DOOMSDAY_SCRIPTS += \
modules/appconfig.de \
modules/bootstrap.de

OTHER_FILES += \
modules/bootstrap.de \
$$DOOMSDAY_SCRIPTS \
data/cphelp.txt \
include/template.h.template \
src/template.c.template \
Expand All @@ -741,7 +749,7 @@ OTHER_FILES += \
data.files = $$OUT_PWD/../doomsday.pk3

mod.files = \
modules/bootstrap.de \
$$DOOMSDAY_SCRIPTS \
$$DENG_MODULES_DIR/Config.de \
$$DENG_MODULES_DIR/gui.de \
$$DENG_MODULES_DIR/recutil.de
Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions doomsday/client/data/defaultstyle.pack/images.dei
Expand Up @@ -19,6 +19,10 @@ group logo {

image gear { path = "graphics/gear.png" }

group toggle {
image onoff { path = "graphics/toggle-onoff.png" }
}

group progress {
image wheel { path = "graphics/progress-wheel.png" }
image gear { path = "graphics/progress-gear.png" }
Expand Down
7 changes: 7 additions & 0 deletions doomsday/client/include/ui/style.h
Expand Up @@ -44,6 +44,13 @@ class Style
de::ColorBank const &colors() const;
de::ImageBank const &images() const;

// Partial implementation for Font::RichFormat::IStyle.
void richStyleFormat(int contentStyle,
float &sizeFactor,
de::Font::RichFormat::Weight &fontWeight,
de::Font::RichFormat::Style &fontStyle,
int &colorIndex) const;

private:
DENG2_PRIVATE(d)
};
Expand Down
11 changes: 11 additions & 0 deletions doomsday/client/include/ui/widgets/buttonwidget.h
Expand Up @@ -43,6 +43,17 @@ class ButtonWidget : public LabelWidget
*/
DENG2_DEFINE_AUDIENCE(StateChange, void buttonStateChanged(ButtonWidget &button, State state))

/**
* Notified immediately before the button's action is to be triggered. Will
* occur regardless of whether an action has been set.
*/
DENG2_DEFINE_AUDIENCE(Press, void buttonPressed(ButtonWidget &button))

/**
* Notified when the button's action is triggered (could be before or after
* the action). Will not occur if no action has been defined for the
* button.
*/
DENG2_DEFINE_AUDIENCE(Triggered, void buttonActionTriggered(ButtonWidget &button))

public:
Expand Down
1 change: 1 addition & 0 deletions doomsday/client/include/ui/widgets/consolecommandwidget.h
Expand Up @@ -56,6 +56,7 @@ public slots:
signals:
void gotFocus();
void lostFocus();
void commandEntered(de::String const &command);

private:
DENG2_PRIVATE(d)
Expand Down
1 change: 1 addition & 0 deletions doomsday/client/include/ui/widgets/consolewidget.h
Expand Up @@ -73,6 +73,7 @@ public slots:
void focusOnCommandLine();
void openMenu();
void closeMenu();
void commandWasEntered(de::String const &);

protected slots:
void logContentHeightIncreased(int delta);
Expand Down
1 change: 1 addition & 0 deletions doomsday/client/include/ui/widgets/guirootwidget.h
Expand Up @@ -55,6 +55,7 @@ class GuiRootWidget : public de::RootWidget
de::Id roundCorners() const;
de::Id gradientFrame() const;
de::Id borderGlow() const;
de::Id toggleOnOff() const;

static de::GLShaderBank &shaders();

Expand Down
24 changes: 12 additions & 12 deletions doomsday/client/include/ui/widgets/guiwidget.h
Expand Up @@ -220,6 +220,18 @@ class GuiWidget : public QObject, public de::Widget

MouseClickStatus handleMouseClick(de::Event const &event);

/**
* Requests the widget to refresh its geometry, if it has any static
* geometry. Normally this does not need to be called. It is provided
* mostly as a way for subclasses to ensure that geometry is up to date
* when they need it.
*
* @param yes @c true to request, @c false to cancel the request.
*/
void requestGeometry(bool yes = true);

bool geometryRequested() const;

protected:
virtual void addedChildWidget(Widget &widget) /*final*/;
virtual void removedChildWidget(Widget &widget) /*final*/;
Expand Down Expand Up @@ -256,18 +268,6 @@ class GuiWidget : public QObject, public de::Widget

void drawBlurredRect(de::Rectanglei const &rect, de::Vector4f const &color);

/**
* Requests the widget to refresh its geometry, if it has any static
* geometry. Normally this does not need to be called. It is provided
* mostly as a way for subclasses to ensure that geometry is up to date
* when they need it.
*
* @param yes @c true to request, @c false to cancel the request.
*/
void requestGeometry(bool yes = true);

bool geometryRequested() const;

/**
* Extensible mechanism for derived widgets to build their geometry. The
* assumptions with this are 1) the vertex format is de::Vertex2TexRgba, 2)
Expand Down
2 changes: 2 additions & 0 deletions doomsday/client/include/ui/widgets/menuwidget.h
Expand Up @@ -85,6 +85,8 @@ class MenuWidget : public ScrollAreaWidget
*/
void setLayoutSortOrder(ISortOrder *sorting);

GuiWidget *addItem(GuiWidget *anyWidget);

ButtonWidget *addItem(de::String const &styledText, de::Action *action = 0);

ButtonWidget *addItem(de::Image const &image, de::String const &styledText, de::Action *action = 0);
Expand Down
1 change: 1 addition & 0 deletions doomsday/client/include/ui/widgets/popupmenuwidget.h
Expand Up @@ -34,6 +34,7 @@ class PopupMenuWidget : public PopupWidget

ButtonWidget *addItem(de::String const &styledText, de::Action *action = 0,
bool dismissOnTriggered = true);
LabelWidget *addItem(LabelWidget *anyLabelBasedWidget);

GuiWidget *addSeparator(de::String const &optionalLabel = "");

Expand Down
1 change: 0 additions & 1 deletion doomsday/client/include/ui/widgets/taskbarwidget.h
Expand Up @@ -57,7 +57,6 @@ public slots:
void open(bool doAction = true);
void close();
void openMainMenu();
void toggleFPS();
void confirmUnloadGame();
void unloadGame();

Expand Down
61 changes: 61 additions & 0 deletions doomsday/client/include/ui/widgets/togglewidget.h
@@ -0,0 +1,61 @@
/** @file togglewidget.h Toggle widget.
*
* @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_TOGGLEWIDGET_H
#define DENG_CLIENT_TOGGLEWIDGET_H

#include "buttonwidget.h"

/**
* Toggle is a specialized button that maintains an on/off state in addition to
* the state of a ButtonWidget.
*/
class ToggleWidget : public ButtonWidget
{
public:
enum ToggleState {
Active,
Inactive
};

/**
* Audience to be notified whenever the toggle is toggled.
*/
DENG2_DEFINE_AUDIENCE(Toggle, void toggleStateChanged(ToggleWidget &toggle))

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

/**
* Sets the toggle state of the widget.
*/
void setToggleState(ToggleState state, bool notify = true);

void setActive(bool activate) { setToggleState(activate? Active : Inactive); }
void setInactive(bool deactivate) { setToggleState(deactivate? Inactive : Active ); }

ToggleState toggleState() const;

bool isActive() const { return toggleState() == Active; }
bool isInactive() const { return toggleState() == Inactive; }

private:
DENG2_PRIVATE(d)
};

#endif // DENG_CLIENT_TOGGLEWIDGET_H
45 changes: 45 additions & 0 deletions doomsday/client/include/ui/widgets/variabletogglewidget.h
@@ -0,0 +1,45 @@
/** @file variabletogglewidget.h Toggles the value of a variable.
*
* @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_VARIABLETOGGLEWIDGET_H
#define DENG_CLIENT_VARIABLETOGGLEWIDGET_H

#include "togglewidget.h"

#include <de/Variable>

/**
* Widget for toggling the value of a variable.
*/
class VariableToggleWidget : public ToggleWidget
{
public:
/// Thrown when the variable is gone and someone tries to access it. @ingroup errors
DENG2_ERROR(VariableMissingError);

public:
VariableToggleWidget(de::Variable &variable, de::String const &name = "");
VariableToggleWidget(de::String const &styledText, de::Variable &variable, de::String const &name = "");

de::Variable &variable() const;

private:
DENG2_PRIVATE(d)
};

#endif // DENG_CLIENT_VARIABLETOGGLEWIDGET_H
81 changes: 81 additions & 0 deletions doomsday/client/modules/appconfig.de
@@ -0,0 +1,81 @@
# The Doomsday Engine Project -- libdeng2
#
# Copyright (c) 2013 Jaakko Keränen <jaakko.keranen@iki.fi>
#
# 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/>.

#----------------------------------------------------------------------------
# CONFIGURATION FOR THE DOOMSDAY CLIENT
#
# This module contains configuration related scripts for the client
# application. It is automatically imported by Config and used as needed.
#
# TODO: make sure the server doesn't run this

import Version

def setDefaults(d)
# Applies the client's defaults.
# - d: Record where to set the values.

try
import DisplayMode

# The default audio and video subsystems.
d.video = 'opengl'
d.audio = 'fmod'

# Window manager defaults.
record d.window
d.window.fsaa = True # Remove this (should be window-specific).

# Configure the main window.
record d.window.main
d.window.main.showFps = False
d.window.main.center = True
d.window.main.fsaa = True
d.window.main.vsync = True

# The default window parameters depend on the original display mode.
mode = DisplayMode.originalMode()

# By default the fullscreen resolution is the desktop resolution.
d.window.main.fullSize = [mode['width'], mode['height']]

# In windowed mode mode, leave some space on the sides so that
# the first switch to windowed mode does not place the window in an
# inconvenient location. The reduction is done proportionally.
offx = mode['width'] * 0.15
offy = mode['height'] * 0.15
d.window.main.rect = [offx, offy,
mode['width'] - 2*offx,
mode['height'] - 2*offy]
d.window.main.colorDepth = mode['depth']

if Version.OS == 'windows' or Version.OS == 'macx'
d.window.main.fullscreen = True
d.window.main.maximize = False
else
d.window.main.fullscreen = False
d.window.main.maximize = True
end

catch NotFoundError
# DisplayMode isn't available on the server.
end

# Console defaults.
record d.console
d.console.snap = True

0 comments on commit c2dd04a

Please sign in to comment.