 |
Gorgon Game Engine
|
Go to the documentation of this file.
14 #include "../String.h"
17 namespace Gorgon {
namespace Geometry {
37 basic_Bounds(
const T_ &left,
const T_ &top,
const T_ &right,
const T_ &bottom) :
Left(left),
Top(top),
75 while(s!=str.end() && *s==
' ')
81 explicit operator std::string()
const {
220 void Move(
const T_ &x,
const T_ &y) {
416 out<<
"[("<<bounds.
Left<<
", "<<bounds.
Top<<
") - ("<<bounds.
Right<<
", "<<bounds.
Bottom<<
")]";
424 while(in.peek()==
' ')
434 decltype(bounds.
TopLeft()) tl, br;
438 while(in.peek()==
' ')
447 if(in.bad())
return in;
456 while(in.peek()==
' ') {
525 template<
class T_,
class O_>
536 bounds.
Left += other.
X;
538 bounds.
Top += other.
Y;
543 template <
class T_,
class O_>
548 bounds.
Left = T_( (bounds.
Left - xc)*size + xc );
549 bounds.
Right = T_( (bounds.
Right - xc)*size + xc );
550 bounds.
Top = T_( (bounds.
Top - yc)*size + yc );
551 bounds.
Left = T_( (bounds.
Left - yc)*size + yc );
555 template <
class T_,
class O_>
560 bounds.
Left = T_( (bounds.
Left - xc)*sizex + xc );
561 bounds.
Right = T_( (bounds.
Right - xc)*sizex + xc );
562 bounds.
Top = T_( (bounds.
Top - yc)*sizey + yc );
563 bounds.
Left = T_( (bounds.
Left - yc)*sizey + yc );
567 template <
class T_,
class O_>
580 template <
class T_,
class O_>
582 bounds.
Left = T_( (bounds.
Left - origin.
X)*size + origin.
X );
583 bounds.
Right = T_( (bounds.
Right - origin.
X)*size + origin.
X );
584 bounds.
Top = T_( (bounds.
Top - origin.
Y)*size + origin.
Y );
585 bounds.
Left = T_( (bounds.
Left - origin.
Y)*size + origin.
Y );
590 template <
class T_,
class O_>
592 bounds.
Left = T_( (bounds.
Left - origin.
X)*sizex + origin.
X );
593 bounds.
Right = T_( (bounds.
Right - origin.
X)*sizex + origin.
X );
594 bounds.
Top = T_( (bounds.
Top - origin.
Y)*sizey + origin.
Y );
595 bounds.
Left = T_( (bounds.
Left - origin.
Y)*sizey + origin.
Y );
600 template <
class T_,
class O_>
604 bounds.
Top = T_( (bounds.
Top - origin.
Y)*size.
Height + origin.
Y );
626 bounds.
Left = std::min( std::min(tl.
X, tr.
X) , std::min(bl.
X, br.
X) );
627 bounds.
Right = std::max( std::max(tl.
X, tr.
X) , std::max(bl.
X, br.
X) );
628 bounds.
Top = std::min( std::min(tl.
Y, tr.
Y) , std::min(bl.
Y, br.
Y) );
629 bounds.
Bottom= std::max( std::max(tl.
Y, tr.
Y) , std::max(bl.
Y, br.
Y) );
643 Rotate(tl, angle, origin);
644 Rotate(tr, angle, origin);
645 Rotate(bl, angle, origin);
646 Rotate(br, angle, origin);
648 bounds.
Left = std::min( std::min(tl.
X, tr.
X) , std::min(bl.
X, br.
X) );
649 bounds.
Right = std::max( std::max(tl.
X, tr.
X) , std::max(bl.
X, br.
X) );
650 bounds.
Top = std::min( std::min(tl.
Y, tr.
Y) , std::min(bl.
Y, br.
Y) );
651 bounds.
Bottom= std::max( std::max(tl.
Y, tr.
Y) , std::max(bl.
Y, br.
Y) );
657 template <
class T_,
class O_>
662 bounds.
Left = T_( bounds.
Left + (bounds.
Top -yc)*rate );
674 template <
class T_,
class O_>
679 bounds.
Top = T_( bounds.
Top + (bounds.
Left -xc)*rate );
683 bounds.
Top = T_( bounds.
Top + (bounds.
Right -xc)*rate );
691 template <
class T_,
class O_>
694 bounds.
Left = T_( bounds.
Left + (bounds.
Top -origin.
Y)*rate );
706 template <
class T_,
class O_>
709 bounds.
Top = T_( bounds.
Top + (bounds.
Left -origin.
X)*rate );
713 bounds.
Top = T_( bounds.
Top + (bounds.
Right -origin.
X)*rate );
std::string Path
The path of the entry point.
Definition: Filesystem.h:44
std::string GetDocumentsPath()
Returns the path where documents of the user should be saved.
Definition: Linux.cpp:41
bool IsValid() const
Checks whether the iterator is valid.
Definition: Iterator.h:146
This class represents boundaries of 2D objects.
Definition: Bounds.h:27
Atom XA_ATOM
Definition: X11.h:79
void swap(Event< Source_, Args_... > &l, Event< Source_, Args_... > &r)
Swaps two events.
Definition: Event.h:351
Date GetDate()
Returns the current date.
Definition: Linux.cpp:9
void SkewY(basic_Bounds< T_ > &bounds, const O_ &rate)
Skews the given bounds with the given rate along Y axis.
Definition: Bounds.h:675
bool IsInside(const basic_Bounds< T_ > &b, const basic_Point< T_ > &p)
Checks whether the given point is inside this bounds.
Definition: Bounds.h:514
constexpr Type File
File.
Definition: GID.h:84
std::enable_if< decltype(gorgon__enum_tr_loc(T_()))::isupgradedenum, std::string >::type From(const T_ &e)
Definition: Enum.h:303
std::string GetFilename(std::string path)
Returns the filename portion of a file path.
Definition: Filesystem.h:183
basic_Bounds(const basic_Bounds< O_ > &r)
Conversion constructor that creates bounds from another type.
Definition: Bounds.h:68
Atom XdndActionCopy
Definition: X11.h:107
bool Move(const std::string &source, const std::string &target)
Moves a given file or directory.
Definition: Linux.cpp:216
basic_Bounds & operator-=(const basic_Point< T_ > &p)
Offsets this bounds objects by the given coordinates.
Definition: Bounds.h:329
basic_Point< T_ > BottomRight() const
Returns bottom right corner.
Definition: Bounds.h:125
std::string TrimStart(std::string str, const std::string &chars=" \t\n\r")
Strips the whitespace from the start of a string.
Definition: String.h:390
Atom XA_PROTOCOLS
Definition: X11.h:69
bool Contains(const basic_Bounds< T_ > &outer, const basic_Bounds< T_ > &inner)
Checks whether the outer bounds contain inner bounds.
Definition: Bounds.h:520
void Move(const basic_Point< T_ > &p)
Changes the position of the bounds.
Definition: Bounds.h:212
virtual void AddMembers(std::initializer_list< StaticMember * > newmembers)
Adds a list of members to this namespace.
Definition: Reflection.h:1104
unsigned long GetTime()
Returns current time in milliseconds.
Definition: Linux.cpp:34
bool operator!=(const basic_Bounds &other)
Compares two bounds objects.
Definition: Bounds.h:91
Atom XdndFinished
Definition: X11.h:102
basic_Bounds & operator/=(const basic_Size< O_ > &s)
Resizes this bounds objects by the given size. Origin of the operation is {0, 0}.
Definition: Bounds.h:367
const Scripting::Type & Constant()
std::string GetName()
Returns the name of the current operating system in human readable form.
Definition: Linux.cpp:65
bool Open(const std::string &file)
Opens the given file with the related application.
Definition: Linux.cpp:268
bool Writable
Whether the entry point is writable.
Definition: Filesystem.h:53
WeekdayType
Days of week. Starts from sunday.
Definition: Time.h:29
Atom XA_Filelist
Definition: X11.h:110
basic_Bounds & operator+=(const basic_Point< T_ > &p)
Offsets this bounds objects by the given coordinates.
Definition: Bounds.h:319
T_ X
X coordinate.
Definition: Point.h:368
void MapConstructor(ParameterList params)
Definition: Embedding.h:1432
bool ChangeDirectory(const std::string &path)
Changes current working directory.
Definition: Linux.cpp:145
void Normalize()
Normalizes bounds object so that Left and Right and Top and Bottom are ordered properly.
Definition: Bounds.h:97
std::ostream & operator<<(std::ostream &out, const Data &data)
This function parses the code and returns any syntax errors.
Definition: Scripting.h:73
std::string GetEnvVar(const std::string &var)
Returns the value of an environment variable.
Definition: Linux.cpp:17
T_ Height
Height of this size object.
Definition: Size.h:261
T_ Width() const
Calculates and returns the width of the bounds.
Definition: Bounds.h:130
Atom XdndLeave
Definition: X11.h:105
Atom XA_TARGETS
Definition: X11.h:68
This object is thrown from functions that return information rather than status.
Definition: Filesystem.h:22
bool Start(const std::string &name, const std::vector< std::string > &args=std::vector< std::string >())
Starts the given application.
Definition: Linux.cpp:116
void DisplayMessage(const std::string &message)
This function shows a OS message box to display errors, for other messages its better to use in-game ...
Definition: Linux.cpp:104
float Float
Represents floating point data type.
Definition: Types.h:16
std::istream & operator>>(std::istream &in, basic_Bounds< T_ > &bounds)
Stream extractor for bounds.
Definition: Bounds.h:423
std::string Relative(std::string path, std::string base)
Determine shortest relative path from the given path.
Definition: Filesystem.cpp:67
unsigned int Millisecond
This value is from the last second tick.
Definition: Time.h:220
basic_Bounds(const basic_Point< T_ > &topleft, const basic_Size< T_ > &size)
Constructs bounds from the given coordinates and size.
Definition: Bounds.h:49
Atom XdndSelection
Definition: X11.h:100
unsigned int Hour
Hour in 24 hour format.
Definition: Time.h:211
T_ Height() const
Calculates and returns the height of the bounds.
Definition: Bounds.h:135
std::string GetDirectory(std::string filepath)
Returns the directory portion of a file path.
Definition: Filesystem.h:167
void Scale(basic_Bounds< T_ > &bounds, const O_ &size)
Scales the given bounds by the given factor. Center of the bounds is used as origin.
Definition: Bounds.h:544
basic_Bounds(const basic_Point< T_ > &topleft, const T_ &width, const T_ &height)
Constructs bounds from the given coordinates and size.
Definition: Bounds.h:61
basic_Point< T_ > BottomLeft() const
Returns bottom left corner.
Definition: Bounds.h:120
std::string GetAppDataPath()
Returns the directory where the system wide application data is stored.
Definition: Linux.cpp:108
bool IsDirectory(const std::string &path)
Checks whether the given path is a directory.
Definition: Linux.cpp:32
void Translate(basic_Bounds< T_ > &bounds, O_ x, O_ y)
Translation moves the given bounds by the given amount.
Definition: Bounds.h:526
Atom XdndActionMove
Definition: X11.h:108
bool IsHidden(const std::string &path)
Checks whether the given path is hidden.
Definition: Linux.cpp:73
unsigned int Minute
Minute.
Definition: Time.h:214
bool IsColliding(const basic_Bounds< T_ > &l, const basic_Bounds< T_ > &r)
Checks whether two bounds are colliding.
Definition: Bounds.h:500
bool Copy(const std::string &source, const std::string &target)
Copies a file or directory from the given source to destination.
Definition: Linux.cpp:180
basic_Bounds< T_ > Union(const basic_Bounds< T_ > &l, const basic_Bounds< T_ > &r)
Returns the smallest bounds that contains given bounds.
Definition: Bounds.h:488
This class makes working with operators easier.
Definition: Embedding.h:635
T_ Left
Left-most boundary.
Definition: Bounds.h:399
Atom XA_STRING
Definition: X11.h:72
void SkewX(basic_Bounds< T_ > &bounds, const O_ &rate)
Skews the given bounds with the given rate along X axis.
Definition: Bounds.h:658
void swap(PointList< P_ > &left, PointList< P_ > &right)
Definition: PointList.h:396
basic_Point< T_ > TopRight() const
Returns top right corner.
Definition: Bounds.h:110
std::string ExeDirectory()
Returns the directory where the program resides.
Definition: Linux.cpp:220
Root namespace for Gorgon Game Engine.
Definition: Any.h:19
This class represents a 2D geometric size.
Definition: Size.h:23
basic_Bounds(const basic_Point< T_ > &topleft, const basic_Point< T_ > &bottomright)
Constructs minimum bounds that includes the given points.
Definition: Bounds.h:43
This class represents a library.
Definition: Reflection.h:1596
std::string Load(const std::string &filename)
Loads the given file and returns it in a string form.
Definition: Filesystem.cpp:45
std::string GetUsername()
Returns the current username.
Definition: Linux.cpp:27
std::string StartupDirectory()
Returns the directory where the program is started from.
Definition: Filesystem.cpp:18
bool IsExists(const std::string &path)
Checks whether the given path exists.
Definition: Linux.cpp:60
void Destroy()
Destroys the current iterator.
Definition: Linux.cpp:431
std::string GetExtension(std::string path)
Returns the extension of the given path, also converts the extension to lower case.
Definition: Filesystem.cpp:140
basic_Bounds operator-(const basic_Point< T_ > &p) const
Creates a new bounds object that is the offset of this bounds by the given point.
Definition: Bounds.h:240
basic_Bounds(const T_ &left, const T_ &top, const T_ &right, const T_ &bottom)
Constructor that allows coordinates to be specified individually.
Definition: Bounds.h:37
basic_Point< int > Point
Definition: Point.h:598
MonthType Month
Month starts from jan = 1.
Definition: Time.h:202
Atom XdndPosition
Definition: X11.h:104
std::string ToLower(std::string str)
Converts the given string to lowercase.
Definition: String.h:416
bool Save(const std::string &filename, const std::string &data, bool append)
Saves a given data into the filename.
Definition: Filesystem.cpp:31
const Scripting::Type & Library()
contains filesystem Iterator. Lists file and directories.
Atom XdndStatus
Definition: X11.h:103
This iterator allows iteration of directories.
Definition: Iterator.h:22
Atom XA_CLIPBOARD
X11 atoms for various data identifiers.
basic_Bounds & operator|=(const basic_Bounds &b) const
Performs union operation.
Definition: Bounds.h:180
std::string Extract(std::string &original, const std::string &marker, bool trim=false)
Extracts the part of the string up to the given marker.
Definition: String.h:779
basic_Bounds< T_ > Intersect(const basic_Bounds< T_ > &l, const basic_Bounds< T_ > &r)
Creates a new bounds that contains only the intersection of two bounds.
Definition: Bounds.h:471
basic_Bounds & operator*=(const basic_Size< O_ > &s)
Resizes this bounds objects by the given size. Origin of the operation is {0, 0}.
Definition: Bounds.h:356
Atom WM_DELETE_WINDOW
Definition: X11.h:70
basic_Bounds()
Default constructor, does not zero initialize object.
Definition: Bounds.h:33
std::string GetAppSettingPath()
Returns the directory where the system wide application settings is stored.
Definition: Linux.cpp:112
unsigned int Day
Day in month.
Definition: Time.h:205
unsigned long long Size(const std::string &filename)
Returns the size of the given file.
Definition: Filesystem.cpp:22
MonthType
Months, january is 1.
Definition: Time.h:40
basic_Bounds< int > Bounds
Definition: Bounds.h:722
int Timezone
Timezone in minutes, can be negative.
Definition: Time.h:224
basic_Bounds operator*(const basic_Size< O_ > &s)
Creates a new bounds object that is the scaled version of this bounds by the given size.
Definition: Bounds.h:273
bool Readable
Whether the entry point is readable. Currently all entry points are readable.
Definition: Filesystem.h:47
bool operator==(const basic_Bounds &other) const
Compares two bounds objects.
Definition: Bounds.h:86
This class represents a 2D point.
Definition: Point.h:32
@ ConstTag
Marks a parameter or a function constant.
Definition: Reflection.h:95
This class represents a specific date including time information.
Definition: Time.h:26
This class allows embedded types to become scripting types that are passed around as values.
Definition: Embedding.h:1300
basic_Bounds & operator&=(const basic_Bounds &b) const
Performs intersect operation.
Definition: Bounds.h:192
std::string Name
Name or label of the entry point.
Definition: Filesystem.h:59
std::string GetDataPath()
Returns the path where applications can save data related to this user.
Definition: Linux.cpp:53
basic_Bounds operator&(const basic_Bounds &r) const
Performs intersect operation.
Definition: Bounds.h:164
void Move(const T_ &x, const T_ &y)
Changes the position of the bounds.
Definition: Bounds.h:220
std::string GetHomePath()
Returns the home directory of the user.
Definition: Linux.cpp:49
bool Delete(const std::string &path)
Deletes the given file or directory.
Definition: Linux.cpp:106
unsigned char Byte
Represents smallest cell in memory.
Definition: Types.h:9
static const Containers::Collection< Window > & Windows
List of currently created windows.
Definition: Window.h:401
bool IsAdmin()
Check if the currently logged in user is an administrator.
Definition: Linux.cpp:57
This class represents a function parameter description.
Definition: Reflection.h:137
void SetHeight(const T_ &height)
Changes the height of the bounds, anchor is the topleft.
Definition: Bounds.h:207
WeekdayType Weekday
Day of the week, starts from sunday = 0.
Definition: Time.h:208
T_ Right
Right-most boundary.
Definition: Bounds.h:405
basic_Bounds operator/(const basic_Size< O_ > &s)
Creates a new bounds object that is the scale version of this bounds by the given size.
Definition: Bounds.h:285
Atom XA_TIMESTAMP
Definition: X11.h:67
void processmessages()
This method will notify the system should process any messages that coming from the operating system.
Definition: Linux.cpp:281
std::string ExePath()
Returns the the full path of the application.
Definition: Linux.cpp:226
bool Removable
Whether the device is removable.
Definition: Filesystem.h:56
Type
Definition: Shader.h:14
T_ Bottom
Bottom-most boundary.
Definition: Bounds.h:408
basic_Point< T_ > Center() const
Returns center of bounds.
Definition: Bounds.h:115
void Resize(const basic_Size< T_ > &size)
Definition: Bounds.h:145
T_ Y
Y coordinate.
Definition: Point.h:371
std::ostream & operator<<(std::ostream &out, const basic_Bounds< T_ > &bounds)
Allows streaming of bounds.
Definition: Bounds.h:415
basic_Point< T_ > TopLeft() const
Returns top left corner.
Definition: Bounds.h:105
This class allows embedded types to become scripting types that are passed around as references.
Definition: Embedding.h:1406
T_ Width
Width of this size object.
Definition: Size.h:258
Library & FilesystemLib()
Definition: Filesystem.cpp:49
basic_Size< T_ > GetSize() const
Returns the size of the bounds object.
Definition: Bounds.h:141
Atom XdndAware
Definition: X11.h:99
bool IsFile(const std::string &path)
Checks whether the given path is a file.
Definition: Linux.cpp:46
bool IsWritable(const std::string &path)
Checks whether the given path is writable.
Definition: Linux.cpp:64
std::vector< T_ >::const_iterator end(enum_type_id< T_ >)
Definition: Enum.h:288
Atom XdndTypeList
Definition: X11.h:109
basic_Bounds operator|(const basic_Bounds &r) const
Performs union operation.
Definition: Bounds.h:152
unsigned int Second
Second.
Definition: Time.h:217
void Initialize()
Initializes the filesystem module.
Definition: Filesystem.cpp:14
Scripting::Function::Overload * MapFunction(F_ fn, const Type *returntype, ParameterList parameters, P_ ...tags)
Definition: Embedding.h:614
void SetWidth(const T_ &width)
Changes the width of the bounds, anchor is the topleft.
Definition: Bounds.h:202
bool Next()
Next path in the directory.
Definition: Linux.cpp:438
void OpenTerminal()
Opens a terminal window to display output from the stdout.
Definition: Linux.cpp:101
const Scripting::Type & Function()
Definition: Reflection.h:589
std::string CurrentDirectory()
Returns the current working directory.
Definition: Linux.cpp:149
basic_Bounds(const std::string &str)
Definition: Bounds.h:72
void Initialize()
Initializes operating system module.
Definition: Linux.cpp:62
basic_Bounds operator+(const basic_Point< T_ > &p) const
Creates a new bounds object that is the offset of this bounds by the given point.
Definition: Bounds.h:229
Iterator()
Empty constructor. Effectively generates end iterator.
Definition: Iterator.h:45
basic_Bounds< Float > Boundsf
Definition: Bounds.h:719
std::vector< EntryPoint > EntryPoints()
This function returns all entry points in the current system.
Definition: Linux.cpp:232
std::string Canonical(const std::string &path)
Canonicalizes a given relative path.
Definition: Linux.cpp:94
This class represents filesystem entry points (roots, drives).
Definition: Filesystem.h:36
Atom XdndDrop
Definition: X11.h:106
Atom XA_PRIMARY
Definition: X11.h:97
std::string GetName()
Returns the name of the current user.
Definition: Linux.cpp:33
unsigned int Year
Full year.
Definition: Time.h:199
std::string GetAtomName(Atom atom)
Definition: X11.cpp:215
T_ BaseType
Base type of the bounds elements.
Definition: Bounds.h:30
bool CreateDirectory(const std::string &path)
Creates a new directory.
Definition: Linux.cpp:19
Atom XdndEnter
Definition: X11.h:101
T_ Top
Top-most boundary.
Definition: Bounds.h:402
basic_Bounds(const T_ &left, const T_ &top, const basic_Size< T_ > &size)
Constructs bounds from the given coordinates and size.
Definition: Bounds.h:55
void Rotate(basic_Bounds< T_ > &bounds, Float angle)
Rotates the given bounds by the given angle.
Definition: Bounds.h:614