Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Rectangle, Clock, Animation, rules, Widget and RootWidget.
- Loading branch information
Showing
43 changed files
with
2,518 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
#include "widgets/animation.h" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
#include "widgets/animationvector.h" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
#include "core/clock.h" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
#include "widgets/constantrule.h" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
#include "widgets/derivedrule.h" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
#include "widgets/operatorrule.h" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
#include "rectangle.h" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
#include "widgets/rectanglerule.h" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
#include "widgets/rootwidget.h" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
#include "widgets/rule.h" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
#include "widgets/scalarrule.h" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
#include "widgets/widget.h" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/** @file clock.cpp Time source. | ||
* | ||
* @authors Copyright © 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 "de/Clock" | ||
|
||
namespace de { | ||
|
||
Clock::Clock() | ||
{} | ||
|
||
Clock::~Clock() | ||
{} | ||
|
||
void Clock::setTime(Time const ¤tTime) | ||
{ | ||
bool changed = (_time != currentTime); | ||
|
||
_time = currentTime; | ||
|
||
if(changed) | ||
{ | ||
emit timeChanged(); | ||
} | ||
} | ||
|
||
void Clock::advanceTime(Time::Delta const &span) | ||
{ | ||
setTime(_time + span); | ||
} | ||
|
||
Time::Delta Clock::elapsed() const | ||
{ | ||
return _time - _startedAt; | ||
} | ||
|
||
Time const &Clock::time() const | ||
{ | ||
return _time; | ||
} | ||
|
||
} // namespace de |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/* | ||
* The Doomsday Engine Project -- libdeng2 | ||
* | ||
* Copyright (c) 2009-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/>. | ||
*/ | ||
|
||
#ifndef LIBDENG2_CLOCK_H | ||
#define LIBDENG2_CLOCK_H | ||
|
||
#include <QObject> | ||
#include "../Time" | ||
|
||
namespace de { | ||
|
||
/** | ||
* Time source. | ||
* @ingroup core | ||
*/ | ||
class Clock : public QObject | ||
{ | ||
Q_OBJECT | ||
|
||
public: | ||
Clock(); | ||
|
||
virtual ~Clock(); | ||
|
||
virtual void setTime(Time const ¤tTime); | ||
|
||
void advanceTime(Time::Delta const &span); | ||
|
||
/** | ||
* Returns the amount of time elapsed since the clock was created. | ||
* @return Elapsed time. | ||
*/ | ||
Time::Delta elapsed() const; | ||
|
||
/** | ||
* Returns a reference to the current time. | ||
* | ||
* @return Current time. | ||
*/ | ||
Time const &time() const; | ||
|
||
signals: | ||
void timeChanged(); | ||
|
||
private: | ||
Time _startedAt; | ||
Time _time; | ||
}; | ||
|
||
} // namespace de | ||
|
||
#endif /* LIBDENG2_ICLOCK_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
/* | ||
* The Doomsday Engine Project -- libdeng2 | ||
* | ||
* Copyright (c) 2009-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/>. | ||
*/ | ||
|
||
#ifndef LIBDENG2_RECTANGLE_H | ||
#define LIBDENG2_RECTANGLE_H | ||
|
||
#include "../Vector" | ||
|
||
namespace de { | ||
|
||
/** | ||
* Template for 2D rectangles. The members are public for convenient access. | ||
* | ||
* @ingroup math | ||
*/ | ||
template <typename VectorType> | ||
class Rectangle | ||
{ | ||
public: | ||
typedef VectorType Corner; | ||
typedef typename Corner::ValueType Type; | ||
|
||
public: | ||
Rectangle() {} | ||
Rectangle(const Corner& tl, const Corner& br) : topLeft(tl), bottomRight(br) {} | ||
Type width() const { return abs(bottomRight.x - topLeft.x); } | ||
Type height() const { return abs(bottomRight.y - topLeft.y); } | ||
Vector2<Type> size() const { return Vector2<Type>(width(), height()); } | ||
void setWidth(Type w) { bottomRight.x = topLeft.x + w; } | ||
void setHeight(Type h) { bottomRight.y = topLeft.y + h; } | ||
void setSize(const Vector2<Type>& s) { setWidth(s.x); setHeight(s.y); } | ||
void include(const Corner& point) { | ||
topLeft = topLeft.min(point); | ||
bottomRight = bottomRight.max(point); | ||
} | ||
bool contains(const Corner& point) const { | ||
return point >= topLeft && point <= bottomRight; | ||
} | ||
String asText() const { | ||
return "[" + topLeft.asText() + ", " + bottomRight.asText() + "]"; | ||
} | ||
Corner topRight() const { | ||
return Corner(bottomRight.x, topLeft.y); | ||
} | ||
Corner bottomLeft() const { | ||
return Corner(topLeft.x, bottomRight.y); | ||
} | ||
Corner midLeft() const { | ||
return Corner(topLeft.x, (topLeft.y + bottomRight.y)/2.0); | ||
} | ||
Corner midRight() const { | ||
return Corner(bottomRight.x, (topLeft.y + bottomRight.y)/2.0); | ||
} | ||
Corner midTop() const { | ||
return Corner((topLeft.x + bottomRight.x)/2.0, topLeft.y); | ||
} | ||
Corner midBottom() const { | ||
return Corner((topLeft.x + bottomRight.x)/2.0, bottomRight.y); | ||
} | ||
Corner middle() const { | ||
return Corner((topLeft.x + bottomRight.x)/2.0, (topLeft.y + bottomRight.y)/2.0); | ||
} | ||
|
||
public: | ||
Corner topLeft; | ||
Corner bottomRight; | ||
}; | ||
|
||
// Common types. | ||
typedef Rectangle<Vector2i> Rectanglei; | ||
typedef Rectangle<Vector2ui> Rectangleui; | ||
typedef Rectangle<Vector2f> Rectanglef; | ||
|
||
} // namespace de | ||
|
||
#endif /* LIBDENG2_RECTANGLE_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.