Skip to content

Commit

Permalink
Client: Added GUI widget base class and stubs for LegacyWidget
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed Feb 23, 2013
1 parent b25b04c commit 5826480
Show file tree
Hide file tree
Showing 6 changed files with 134 additions and 6 deletions.
2 changes: 2 additions & 0 deletions doomsday/client/client.pro
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,7 @@ DENG_HEADERS += \
include/ui/displaymode_native.h \
include/ui/fi_main.h \
include/ui/finaleinterpreter.h \
include/ui/guiwidget.h \
include/ui/joystick.h \
include/ui/keycode.h \
include/ui/legacywidget.h \
Expand Down Expand Up @@ -622,6 +623,7 @@ SOURCES += \
src/ui/displaymode.cpp \
src/ui/fi_main.cpp \
src/ui/finaleinterpreter.cpp \
src/ui/guiwidget.cpp \
src/ui/keycode.cpp \
src/ui/legacywidget.cpp \
src/ui/mouse_qt.cpp \
Expand Down
51 changes: 51 additions & 0 deletions doomsday/client/include/ui/guiwidget.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/** @file guiwidget.h Base class for graphical widgets.
*
* @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 GUIWIDGET_H
#define GUIWIDGET_H

#include <de/Widget>
#include <de/RuleRectangle>

/**
* Base class for graphical widgets.
* @ingroup gui
*/
class GuiWidget : public de::Widget
{
public:
GuiWidget(de::String const &name = "");
~GuiWidget();

/**
* Returns the rule rectangle that defines the placement of the widget on
* the target canvas.
*/
de::RuleRectangle &rule();

/**
* Returns the rule rectangle that defines the placement of the widget on
* the target canvas.
*/
de::RuleRectangle const &rule() const;

private:
DENG2_PRIVATE(d)
};

#endif // GUIWIDGET_H
9 changes: 7 additions & 2 deletions doomsday/client/include/ui/legacywidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,23 @@
#ifndef CLIENT_LEGACYWIDGET_H
#define CLIENT_LEGACYWIDGET_H

#include <de/Widget>
#include "guiwidget.h"

/**
* Widget for legacy UI components.
* @ingroup gui
*/
class LegacyWidget : public de::Widget
class LegacyWidget : public GuiWidget
{
public:
LegacyWidget(de::String const &name = "");
~LegacyWidget();

void viewResized();
void update();
void draw();
bool handleEvent(de::Event const &event);

private:
DENG2_PRIVATE(d)
};
Expand Down
9 changes: 8 additions & 1 deletion doomsday/client/src/ui/canvaswindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
# include "gl/gl_main.h"
#endif
#include "ui/canvaswindow.h"
#include "ui/legacywidget.h"

#include <assert.h>

Expand All @@ -56,7 +57,13 @@ DENG2_PIMPL(CanvasWindow)
moveFunc(0),
closeFunc(0),
mouseWasTrapped(false)
{}
{
LegacyWidget *legacy = new LegacyWidget;
legacy->rule()
.setLeftTop (rootWidget.viewLeft(), rootWidget.viewTop())
.setRightBottom(rootWidget.viewRight(), rootWidget.viewBottom());
rootWidget.add(legacy);
}
};

CanvasWindow::CanvasWindow(QWidget *parent)
Expand Down
47 changes: 47 additions & 0 deletions doomsday/client/src/ui/guiwidget.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/** @file guiwidget.cpp Base class for graphical widgets.
*
* @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>
*/

#include "ui/guiwidget.h"

using namespace de;

DENG2_PIMPL(GuiWidget)
{
RuleRectangle rule;

Instance(Public *i) : Base(i)
{}
};

GuiWidget::GuiWidget(String const &name) : Widget(name), d(new Instance(this))
{}

GuiWidget::~GuiWidget()
{
delete d;
}

RuleRectangle &GuiWidget::rule()
{
return d->rule;
}

RuleRectangle const &GuiWidget::rule() const
{
return d->rule;
}
22 changes: 19 additions & 3 deletions doomsday/client/src/ui/legacywidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,27 @@ DENG2_PIMPL(LegacyWidget)
};

LegacyWidget::LegacyWidget(String const &name)
: Widget(name), d(new Instance(this))
{
}
: GuiWidget(name), d(new Instance(this))
{}

LegacyWidget::~LegacyWidget()
{
delete d;
}

void LegacyWidget::viewResized()
{
}

void LegacyWidget::update()
{
}

void LegacyWidget::draw()
{
}

bool LegacyWidget::handleEvent(Event const &/*event*/)
{
return false;
}

0 comments on commit 5826480

Please sign in to comment.