forked from 0ad/0ad
Moves CSize into a separate file and renames it to CSize2D according to other geometric entities.
This was SVN commit r25143.
This commit is contained in:
parent
fa3e501f8f
commit
db84c2a9b2
@ -1228,8 +1228,8 @@ void CGUI::Xeromyces_ReadIcon(XMBElement Element, CXeromyces* pFile)
|
||||
icon.m_SpriteName = attr_value;
|
||||
else if (attr_name == "size")
|
||||
{
|
||||
CSize size;
|
||||
if (!ParseString<CSize>(this, attr_value.FromUTF8(), size))
|
||||
CSize2D size;
|
||||
if (!ParseString<CSize2D>(this, attr_value.FromUTF8(), size))
|
||||
LOGERROR("Error parsing '%s' (\"%s\") inside <icon>.", attr_name, attr_value);
|
||||
else
|
||||
icon.m_Size = size;
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include "gui/SGUIIcon.h"
|
||||
#include "gui/SGUIStyle.h"
|
||||
#include "lib/input.h"
|
||||
#include "maths/Size2D.h"
|
||||
#include "ps/Shapes.h"
|
||||
#include "ps/XML/Xeromyces.h"
|
||||
#include "scriptinterface/ScriptInterface.h"
|
||||
|
@ -35,20 +35,20 @@ extern float g_GuiScale;
|
||||
// TODO Gee: CRect => CPoint ?
|
||||
void SGenerateTextImage::SetupSpriteCall(
|
||||
const bool Left, CGUIText::SSpriteCall& SpriteCall, const float width, const float y,
|
||||
const CSize& Size, const CStr& TextureName, const float BufferZone)
|
||||
const CSize2D& Size, const CStr& TextureName, const float BufferZone)
|
||||
{
|
||||
// TODO Gee: Temp hardcoded values
|
||||
SpriteCall.m_Area.top = y + BufferZone;
|
||||
SpriteCall.m_Area.bottom = y + BufferZone + Size.cy;
|
||||
SpriteCall.m_Area.bottom = y + BufferZone + Size.Height;
|
||||
|
||||
if (Left)
|
||||
{
|
||||
SpriteCall.m_Area.left = BufferZone;
|
||||
SpriteCall.m_Area.right = Size.cx + BufferZone;
|
||||
SpriteCall.m_Area.right = Size.Width + BufferZone;
|
||||
}
|
||||
else
|
||||
{
|
||||
SpriteCall.m_Area.left = width-BufferZone - Size.cx;
|
||||
SpriteCall.m_Area.left = width-BufferZone - Size.Width;
|
||||
SpriteCall.m_Area.right = width-BufferZone;
|
||||
}
|
||||
|
||||
@ -56,7 +56,7 @@ void SGenerateTextImage::SetupSpriteCall(
|
||||
|
||||
m_YFrom = SpriteCall.m_Area.top - BufferZone;
|
||||
m_YTo = SpriteCall.m_Area.bottom + BufferZone;
|
||||
m_Indentation = Size.cx + BufferZone * 2;
|
||||
m_Indentation = Size.Width + BufferZone * 2;
|
||||
}
|
||||
|
||||
CGUIText::CGUIText(const CGUI& pGUI, const CGUIString& string, const CStrW& FontW, const float Width, const float BufferZone, const IGUIObject* pObject)
|
||||
@ -102,8 +102,8 @@ CGUIText::CGUIText(const CGUI& pGUI, const CGUIString& string, const CStrW& Font
|
||||
|
||||
pos_last_img = std::max(pos_last_img, i);
|
||||
|
||||
x += Feedback.m_Size.cx;
|
||||
prelim_line_height = std::max(prelim_line_height, Feedback.m_Size.cy);
|
||||
x += Feedback.m_Size.Width;
|
||||
prelim_line_height = std::max(prelim_line_height, Feedback.m_Size.Height);
|
||||
|
||||
// If Width is 0, then there's no word-wrapping, disable NewLine.
|
||||
if (((Width != 0 && (x > Width - BufferZone || Feedback.m_NewLine)) || i == static_cast<int>(string.m_Words.size()) - 2) &&
|
||||
@ -147,7 +147,7 @@ void CGUIText::SetupSpriteCalls(
|
||||
Image.SetupSpriteCall(j == CGUIString::SFeedback::Left, SpriteCall, Width, _y, icon.m_Size, icon.m_SpriteName, BufferZone);
|
||||
|
||||
// Check if image is the lowest thing.
|
||||
m_Size.cy = std::max(m_Size.cy, Image.m_YTo);
|
||||
m_Size.Height = std::max(m_Size.Height, Image.m_YTo);
|
||||
|
||||
Images[j].emplace_back(Image);
|
||||
m_SpriteCalls.emplace_back(std::move(SpriteCall));
|
||||
@ -171,7 +171,7 @@ void CGUIText::ComputeLineSize(
|
||||
const int i,
|
||||
const int temp_from,
|
||||
float& x,
|
||||
CSize& line_size) const
|
||||
CSize2D& line_size) const
|
||||
{
|
||||
for (int j = temp_from; j <= i; ++j)
|
||||
{
|
||||
@ -184,7 +184,7 @@ void CGUIText::ComputeLineSize(
|
||||
string.GenerateTextCall(pGUI, Feedback2, Font, string.m_Words[j], string.m_Words[j+1], FirstLine);
|
||||
|
||||
// Append X value.
|
||||
x += Feedback2.m_Size.cx;
|
||||
x += Feedback2.m_Size.Width;
|
||||
|
||||
if (Width != 0 && x > width_range_to && j != temp_from && !Feedback2.m_NewLine)
|
||||
{
|
||||
@ -192,12 +192,12 @@ void CGUIText::ComputeLineSize(
|
||||
// word and the next. When we're wrapping, we need subtract the width of the
|
||||
// space after the last word on the line before the wrap.
|
||||
CFontMetrics currentFont(Font);
|
||||
line_size.cx -= currentFont.GetCharacterWidth(*L" ");
|
||||
line_size.Width -= currentFont.GetCharacterWidth(*L" ");
|
||||
break;
|
||||
}
|
||||
|
||||
// Let line_size.cy be the maximum m_Height we encounter.
|
||||
line_size.cy = std::max(line_size.cy, Feedback2.m_Size.cy);
|
||||
line_size.Height = std::max(line_size.Height, Feedback2.m_Size.Height);
|
||||
|
||||
// If the current word is an explicit new line ("\n"),
|
||||
// break now before adding the width of this character.
|
||||
@ -206,7 +206,7 @@ void CGUIText::ComputeLineSize(
|
||||
if (Width != 0 && Feedback2.m_NewLine)
|
||||
break;
|
||||
|
||||
line_size.cx += Feedback2.m_Size.cx;
|
||||
line_size.Width += Feedback2.m_Size.Width;
|
||||
}
|
||||
}
|
||||
|
||||
@ -237,14 +237,14 @@ bool CGUIText::ProcessLine(
|
||||
// Reset X for the next loop
|
||||
x = width_range_from;
|
||||
|
||||
CSize line_size;
|
||||
CSize2D line_size;
|
||||
ComputeLineSize(pGUI, string, Font, FirstLine, Width, width_range_to, i, temp_from, x, line_size);
|
||||
|
||||
// Reset x once more
|
||||
x = width_range_from;
|
||||
|
||||
// Move down, because font drawing starts from the baseline
|
||||
y += line_size.cy;
|
||||
y += line_size.Height;
|
||||
|
||||
const float dx = GetLineOffset(align, width_range_from, width_range_to, line_size);
|
||||
|
||||
@ -255,8 +255,8 @@ bool CGUIText::ProcessLine(
|
||||
x = BufferZone;
|
||||
|
||||
// Update dimensions
|
||||
m_Size.cx = std::max(m_Size.cx, line_size.cx + BufferZone * 2);
|
||||
m_Size.cy = std::max(m_Size.cy, y + BufferZone);
|
||||
m_Size.Width = std::max(m_Size.Width, line_size.Width + BufferZone * 2);
|
||||
m_Size.Height = std::max(m_Size.Height, y + BufferZone);
|
||||
|
||||
FirstLine = false;
|
||||
|
||||
@ -315,7 +315,7 @@ float CGUIText::GetLineOffset(
|
||||
const EAlign align,
|
||||
const float width_range_from,
|
||||
const float width_range_to,
|
||||
const CSize& line_size) const
|
||||
const CSize2D& line_size) const
|
||||
{
|
||||
switch (align)
|
||||
{
|
||||
@ -324,10 +324,10 @@ float CGUIText::GetLineOffset(
|
||||
return 0.f;
|
||||
|
||||
case EAlign::CENTER:
|
||||
return ((width_range_to - width_range_from) - line_size.cx) / 2;
|
||||
return ((width_range_to - width_range_from) - line_size.Width) / 2;
|
||||
|
||||
case EAlign::RIGHT:
|
||||
return width_range_to - line_size.cx;
|
||||
return width_range_to - line_size.Width;
|
||||
|
||||
default:
|
||||
debug_warn(L"Broken EAlign in CGUIText()");
|
||||
@ -370,14 +370,14 @@ bool CGUIText::AssembleCalls(
|
||||
{
|
||||
tc.m_Pos = CPos(dx + x + x_pointer, y);
|
||||
|
||||
x_pointer += tc.m_Size.cx;
|
||||
x_pointer += tc.m_Size.Width;
|
||||
|
||||
if (tc.m_pSpriteCall)
|
||||
tc.m_pSpriteCall->m_Area += tc.m_Pos - CSize(0, tc.m_pSpriteCall->m_Area.GetHeight());
|
||||
tc.m_pSpriteCall->m_Area += tc.m_Pos - CSize2D(0, tc.m_pSpriteCall->m_Area.GetHeight());
|
||||
}
|
||||
|
||||
// Append X value.
|
||||
x += Feedback2.m_Size.cx;
|
||||
x += Feedback2.m_Size.Width;
|
||||
|
||||
// The first word overrides the width limit, what we
|
||||
// do, in those cases, are just drawing that word even
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "gui/CGUISprite.h"
|
||||
#include "gui/SettingTypes/CGUIColor.h"
|
||||
#include "gui/SettingTypes/EAlign.h"
|
||||
#include "maths/Size2D.h"
|
||||
#include "ps/CStrIntern.h"
|
||||
#include "ps/Shapes.h"
|
||||
|
||||
@ -106,7 +107,7 @@ public:
|
||||
/**
|
||||
* Size
|
||||
*/
|
||||
CSize m_Size;
|
||||
CSize2D m_Size;
|
||||
|
||||
/**
|
||||
* The string that is suppose to be rendered.
|
||||
@ -172,7 +173,7 @@ public:
|
||||
*/
|
||||
void Draw(CGUI& pGUI, const CGUIColor& DefaultColor, const CPos& pos, const float z, const CRect& clipping) const;
|
||||
|
||||
const CSize& GetSize() const { return m_Size; }
|
||||
const CSize2D& GetSize() const { return m_Size; }
|
||||
|
||||
const std::list<SSpriteCall>& GetSpriteCalls() const { return m_SpriteCalls; }
|
||||
|
||||
@ -209,7 +210,7 @@ public:
|
||||
const EAlign align,
|
||||
const float width_range_from,
|
||||
const float width_range_to,
|
||||
const CSize& line_size) const;
|
||||
const CSize2D& line_size) const;
|
||||
|
||||
void ComputeLineRange(
|
||||
const SGenerateTextImages& Images,
|
||||
@ -229,7 +230,7 @@ public:
|
||||
const int i,
|
||||
const int temp_from,
|
||||
float& x,
|
||||
CSize& line_size) const;
|
||||
CSize2D& line_size) const;
|
||||
|
||||
bool AssembleCalls(
|
||||
const CGUI& pGUI,
|
||||
@ -261,7 +262,7 @@ public:
|
||||
* Width and height of the whole output, used when setting up
|
||||
* scrollbars and such.
|
||||
*/
|
||||
CSize m_Size;
|
||||
CSize2D m_Size;
|
||||
};
|
||||
|
||||
struct SGenerateTextImage
|
||||
@ -277,7 +278,7 @@ struct SGenerateTextImage
|
||||
|
||||
void SetupSpriteCall(
|
||||
const bool Left, CGUIText::SSpriteCall& SpriteCall, const float width, const float y,
|
||||
const CSize& Size, const CStr& TextureName, const float BufferZone);
|
||||
const CSize2D& Size, const CStr& TextureName, const float BufferZone);
|
||||
};
|
||||
|
||||
#endif // INCLUDED_GUITEXT
|
||||
|
@ -106,7 +106,7 @@ bool CGUI::ParseString<CGUIColor>(const CGUI* pGUI, const CStrW& Value, CGUIColo
|
||||
}
|
||||
|
||||
template <>
|
||||
bool CGUI::ParseString<CSize>(const CGUI* UNUSED(pGUI), const CStrW& Value, CSize& Output)
|
||||
bool CGUI::ParseString<CSize2D>(const CGUI* UNUSED(pGUI), const CStrW& Value, CSize2D& Output)
|
||||
{
|
||||
const unsigned int NUM_COORDS = 2;
|
||||
float coords[NUM_COORDS];
|
||||
@ -117,23 +117,23 @@ bool CGUI::ParseString<CSize>(const CGUI* UNUSED(pGUI), const CStrW& Value, CSiz
|
||||
{
|
||||
if (stream.eof())
|
||||
{
|
||||
LOGWARNING("Too few CSize parameters (min %i). Your input: '%s'", NUM_COORDS, Value.ToUTF8().c_str());
|
||||
LOGWARNING("Too few CSize2D parameters (min %i). Your input: '%s'", NUM_COORDS, Value.ToUTF8().c_str());
|
||||
return false;
|
||||
}
|
||||
stream >> coords[i];
|
||||
if ((stream.rdstate() & std::wstringstream::failbit) != 0)
|
||||
{
|
||||
LOGWARNING("Unable to parse CSize parameters. Your input: '%s'", Value.ToUTF8().c_str());
|
||||
LOGWARNING("Unable to parse CSize2D parameters. Your input: '%s'", Value.ToUTF8().c_str());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Output.cx = coords[0];
|
||||
Output.cy = coords[1];
|
||||
Output.Width = coords[0];
|
||||
Output.Height = coords[1];
|
||||
|
||||
if (!stream.eof())
|
||||
{
|
||||
LOGWARNING("Too many CSize parameters (max %i). Your input: '%s'", NUM_COORDS, Value.ToUTF8().c_str());
|
||||
LOGWARNING("Too many CSize2D parameters (max %i). Your input: '%s'", NUM_COORDS, Value.ToUTF8().c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -111,10 +111,10 @@ void IGUITextOwner::CalculateTextPosition(CRect& ObjSize, CPos& TextPos, CGUITex
|
||||
break;
|
||||
case EVAlign::CENTER:
|
||||
// Round to integer pixel values, else the fonts look awful
|
||||
TextPos.y = floorf(ObjSize.CenterPoint().y - Text.GetSize().cy / 2.f);
|
||||
TextPos.y = floorf(ObjSize.CenterPoint().y - Text.GetSize().Height / 2.f);
|
||||
break;
|
||||
case EVAlign::BOTTOM:
|
||||
TextPos.y = ObjSize.bottom - Text.GetSize().cy;
|
||||
TextPos.y = ObjSize.bottom - Text.GetSize().Height;
|
||||
break;
|
||||
default:
|
||||
debug_warn(L"Broken EVAlign in CButton::SetupText()");
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2020 Wildfire Games.
|
||||
/* Copyright (C) 2021 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@ -235,18 +235,18 @@ void CChart::SetupText()
|
||||
const float width = GetChartRect().GetWidth();
|
||||
if (m_EqualX)
|
||||
{
|
||||
CSize text_size = AddFormattedValue(m_FormatX, m_RightTop.X, m_Font, m_BufferZone);
|
||||
CSize2D text_size = AddFormattedValue(m_FormatX, m_RightTop.X, m_Font, m_BufferZone);
|
||||
m_TextPositions.emplace_back(GetChartRect().BottomRight() - text_size);
|
||||
}
|
||||
else
|
||||
for (int i = 0; i < 3; ++i)
|
||||
{
|
||||
CSize text_size = AddFormattedValue(m_FormatX, m_RightTop.X - (m_RightTop.X - m_LeftBottom.X) / 3 * i, m_Font, m_BufferZone);
|
||||
CSize2D text_size = AddFormattedValue(m_FormatX, m_RightTop.X - (m_RightTop.X - m_LeftBottom.X) / 3 * i, m_Font, m_BufferZone);
|
||||
m_TextPositions.emplace_back(GetChartRect().BottomRight() - text_size - CPos(width / 3 * i, 0.f));
|
||||
}
|
||||
}
|
||||
|
||||
CSize CChart::AddFormattedValue(const CStrW& format, const float value, const CStrW& font, const float buffer_zone)
|
||||
CSize2D CChart::AddFormattedValue(const CStrW& format, const float value, const CStrW& font, const float buffer_zone)
|
||||
{
|
||||
// TODO: we need to catch cases with equal formatted values.
|
||||
CGUIString gui_str;
|
||||
@ -278,7 +278,7 @@ CSize CChart::AddFormattedValue(const CStrW& format, const float value, const CS
|
||||
else
|
||||
{
|
||||
LOGERROR("Unsupported chart format: " + format.EscapeToPrintableASCII());
|
||||
return CSize();
|
||||
return CSize2D();
|
||||
}
|
||||
|
||||
return AddText(gui_str, font, 0, buffer_zone).GetSize();
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2020 Wildfire Games.
|
||||
/* Copyright (C) 2021 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@ -24,6 +24,7 @@
|
||||
#include "gui/SettingTypes/CGUIColor.h"
|
||||
#include "gui/SettingTypes/CGUIList.h"
|
||||
#include "gui/SettingTypes/CGUISeries.h"
|
||||
#include "maths/Size2D.h"
|
||||
#include "maths/Vector2D.h"
|
||||
|
||||
#include <vector>
|
||||
@ -104,7 +105,7 @@ private:
|
||||
// Represents axes as triangles and draws them with DrawTriangleStrip.
|
||||
void DrawAxes(const CShaderProgramPtr& shader) const;
|
||||
|
||||
CSize AddFormattedValue(const CStrW& format, const float value, const CStrW& font, const float buffer_zone);
|
||||
CSize2D AddFormattedValue(const CStrW& format, const float value, const CStrW& font, const float buffer_zone);
|
||||
|
||||
void UpdateBounds();
|
||||
};
|
||||
|
@ -1124,8 +1124,8 @@ void CInput::HandleMessage(SGUIMessage& Message)
|
||||
|
||||
// Tell the IME where to draw the candidate list
|
||||
SDL_Rect rect;
|
||||
rect.h = m_CachedActualSize.GetSize().cy;
|
||||
rect.w = m_CachedActualSize.GetSize().cx;
|
||||
rect.h = m_CachedActualSize.GetSize().Height;
|
||||
rect.w = m_CachedActualSize.GetSize().Width;
|
||||
rect.x = m_CachedActualSize.TopLeft().x;
|
||||
rect.y = m_CachedActualSize.TopLeft().y;
|
||||
SDL_SetTextInputRect(&rect);
|
||||
|
@ -141,7 +141,7 @@ void CList::SetupText(bool append)
|
||||
}
|
||||
|
||||
m_ItemsYPositions[i] = buffered_y;
|
||||
buffered_y += text->GetSize().cy;
|
||||
buffered_y += text->GetSize().Height;
|
||||
}
|
||||
|
||||
m_ItemsYPositions[m_List.m_Items.size()] = buffered_y;
|
||||
|
@ -76,7 +76,7 @@ void COList::SetupText()
|
||||
gui_string.SetValue(column.m_Heading);
|
||||
|
||||
const CGUIText& text = AddText(gui_string, m_Font, width, m_BufferZone);
|
||||
m_HeadingHeight = std::max(m_HeadingHeight, text.GetSize().cy + COLUMN_SHIFT.y);
|
||||
m_HeadingHeight = std::max(m_HeadingHeight, text.GetSize().Height + COLUMN_SHIFT.y);
|
||||
}
|
||||
|
||||
// Generate texts
|
||||
@ -102,7 +102,7 @@ void COList::SetupText()
|
||||
align_string.SetValue(L" ");
|
||||
text = &AddText(align_string, m_Font, width, m_BufferZone);
|
||||
}
|
||||
shift = std::max(shift, text->GetSize().cy);
|
||||
shift = std::max(shift, text->GetSize().Height);
|
||||
}
|
||||
buffered_y += shift;
|
||||
}
|
||||
|
@ -105,7 +105,7 @@ void CText::SetupText()
|
||||
if (m_ScrollBottom && GetScrollBar(0).GetPos() > GetScrollBar(0).GetMaxPos() - 1.5f)
|
||||
bottom = true;
|
||||
|
||||
GetScrollBar(0).SetScrollRange(m_GeneratedTexts[0].GetSize().cy);
|
||||
GetScrollBar(0).SetScrollRange(m_GeneratedTexts[0].GetSize().Height);
|
||||
GetScrollBar(0).SetScrollSpace(m_CachedActualSize.GetHeight());
|
||||
|
||||
GetScrollBar(0).SetX(m_CachedActualSize.right);
|
||||
|
@ -87,8 +87,8 @@ void CTooltip::SetupText()
|
||||
|
||||
const CPos& mousepos = m_Independent ? m_pGUI.GetMousePos() : m_MousePos;
|
||||
|
||||
float textwidth = m_GeneratedTexts[0].GetSize().cx;
|
||||
float textheight = m_GeneratedTexts[0].GetSize().cy;
|
||||
float textwidth = m_GeneratedTexts[0].GetSize().Width;
|
||||
float textheight = m_GeneratedTexts[0].GetSize().Height;
|
||||
|
||||
CGUISize size;
|
||||
size.pixel.left = mousepos.x + m_Offset.x;
|
||||
|
@ -18,8 +18,8 @@
|
||||
#ifndef INCLUDED_SGUIICON
|
||||
#define INCLUDED_SGUIICON
|
||||
|
||||
#include "maths/Size2D.h"
|
||||
#include "ps/CStr.h"
|
||||
#include "ps/Shapes.h"
|
||||
|
||||
/**
|
||||
* Icon, you create them in the XML file with root element <setup>.
|
||||
@ -37,7 +37,7 @@ struct SGUIIcon
|
||||
CStr m_SpriteName;
|
||||
|
||||
// Size
|
||||
CSize m_Size;
|
||||
CSize2D m_Size;
|
||||
};
|
||||
|
||||
#endif // INCLUDED_SGUIICON
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include "gui/SettingTypes/CGUISeries.h"
|
||||
#include "gui/SettingTypes/CGUISize.h"
|
||||
#include "lib/external_libraries/libsdl.h"
|
||||
#include "maths/Size2D.h"
|
||||
#include "maths/Vector2D.h"
|
||||
#include "ps/Hotkey.h"
|
||||
#include "ps/CLogger.h"
|
||||
@ -157,28 +158,28 @@ template<> void ScriptInterface::ToJSVal<CGUIColor>(const ScriptRequest& rq, JS:
|
||||
*/
|
||||
template<> bool ScriptInterface::FromJSVal<CGUIColor>(const ScriptRequest& rq, JS::HandleValue v, CGUIColor& out) = delete;
|
||||
|
||||
template<> void ScriptInterface::ToJSVal<CSize>(const ScriptRequest& rq, JS::MutableHandleValue ret, const CSize& val)
|
||||
template<> void ScriptInterface::ToJSVal<CSize2D>(const ScriptRequest& rq, JS::MutableHandleValue ret, const CSize2D& val)
|
||||
{
|
||||
CreateObject(rq, ret, "width", val.cx, "height", val.cy);
|
||||
CreateObject(rq, ret, "width", val.Width, "height", val.Height);
|
||||
}
|
||||
|
||||
template<> bool ScriptInterface::FromJSVal<CSize>(const ScriptRequest& rq, JS::HandleValue v, CSize& out)
|
||||
template<> bool ScriptInterface::FromJSVal<CSize2D>(const ScriptRequest& rq, JS::HandleValue v, CSize2D& out)
|
||||
{
|
||||
if (!v.isObject())
|
||||
{
|
||||
LOGERROR("CSize value must be an object!");
|
||||
LOGERROR("CSize2D value must be an object!");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!FromJSProperty(rq, v, "width", out.cx))
|
||||
if (!FromJSProperty(rq, v, "width", out.Width))
|
||||
{
|
||||
LOGERROR("Failed to get CSize.cx property");
|
||||
LOGERROR("Failed to get CSize2D.Width property");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!FromJSProperty(rq, v, "height", out.cy))
|
||||
if (!FromJSProperty(rq, v, "height", out.Height))
|
||||
{
|
||||
LOGERROR("Failed to get CSize.cy property");
|
||||
LOGERROR("Failed to get CSize2D.Height property");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -46,7 +46,7 @@ void CGUIString::SFeedback::Reset()
|
||||
m_Images[Right].clear();
|
||||
m_TextCalls.clear();
|
||||
m_SpriteCalls.clear();
|
||||
m_Size = CSize();
|
||||
m_Size = CSize2D();
|
||||
m_NewLine = false;
|
||||
}
|
||||
|
||||
@ -129,11 +129,11 @@ void CGUIString::GenerateTextCall(const CGUI& pGUI, SFeedback& Feedback, CStrInt
|
||||
// Get Icon from icon database in pGUI
|
||||
const SGUIIcon& icon = pGUI.GetIcon(path);
|
||||
|
||||
const CSize& size = icon.m_Size;
|
||||
const CSize2D& size = icon.m_Size;
|
||||
|
||||
// append width, and make maximum height the height.
|
||||
Feedback.m_Size.cx += size.cx;
|
||||
Feedback.m_Size.cy = std::max(Feedback.m_Size.cy, size.cy);
|
||||
Feedback.m_Size.Width += size.Width;
|
||||
Feedback.m_Size.Height = std::max(Feedback.m_Size.Height, size.Height);
|
||||
|
||||
// These are also needed later
|
||||
TextCall.m_Size = size;
|
||||
@ -145,9 +145,9 @@ void CGUIString::GenerateTextCall(const CGUI& pGUI, SFeedback& Feedback, CStrInt
|
||||
if (tagAttrib.attrib == L"displace" && !tagAttrib.value.empty())
|
||||
{
|
||||
// Displace the sprite
|
||||
CSize displacement;
|
||||
CSize2D displacement;
|
||||
// Parse the value
|
||||
if (!CGUI::ParseString<CSize>(&pGUI, tagAttrib.value, displacement))
|
||||
if (!CGUI::ParseString<CSize2D>(&pGUI, tagAttrib.value, displacement))
|
||||
LOGERROR("Error parsing 'displace' value for tag [ICON]");
|
||||
else
|
||||
SpriteCall.m_Area += displacement;
|
||||
@ -206,7 +206,7 @@ void CGUIString::GenerateTextCall(const CGUI& pGUI, SFeedback& Feedback, CStrInt
|
||||
}
|
||||
|
||||
// Calculate the size of the font
|
||||
CSize size;
|
||||
CSize2D size;
|
||||
int cx, cy;
|
||||
CFontMetrics font (TextCall.m_Font);
|
||||
font.CalculateStringSize(TextCall.m_String.c_str(), cx, cy);
|
||||
@ -215,12 +215,12 @@ void CGUIString::GenerateTextCall(const CGUI& pGUI, SFeedback& Feedback, CStrInt
|
||||
if (!FirstLine)
|
||||
cy = font.GetLineSpacing();
|
||||
|
||||
size.cx = (float)cx;
|
||||
size.cy = (float)cy;
|
||||
size.Width = (float)cx;
|
||||
size.Height = (float)cy;
|
||||
|
||||
// Append width, and make maximum height the height.
|
||||
Feedback.m_Size.cx += size.cx;
|
||||
Feedback.m_Size.cy = std::max(Feedback.m_Size.cy, size.cy);
|
||||
Feedback.m_Size.Width += size.Width;
|
||||
Feedback.m_Size.Height = std::max(Feedback.m_Size.Height, size.Height);
|
||||
|
||||
// These are also needed later
|
||||
TextCall.m_Size = size;
|
||||
|
@ -149,7 +149,7 @@ public:
|
||||
/**
|
||||
* Width and Height *feedback*
|
||||
*/
|
||||
CSize m_Size;
|
||||
CSize2D m_Size;
|
||||
|
||||
/**
|
||||
* If the word inputted was a new line.
|
||||
|
@ -18,7 +18,7 @@
|
||||
#ifndef INCLUDED_EALIGN
|
||||
#define INCLUDED_EALIGN
|
||||
|
||||
enum EAlign
|
||||
enum class EAlign
|
||||
{
|
||||
LEFT,
|
||||
RIGHT,
|
||||
|
@ -79,14 +79,14 @@ public:
|
||||
void test_size()
|
||||
{
|
||||
TestLogger nolog;
|
||||
CSize test;
|
||||
CSize2D test;
|
||||
|
||||
TS_ASSERT(CGUI::ParseString<CSize>(nullptr, CStrW(L"0.0 10.0"), test));
|
||||
TS_ASSERT_EQUALS(CSize(0.0, 10.0), test);
|
||||
TS_ASSERT(CGUI::ParseString<CSize2D>(nullptr, CStrW(L"0.0 10.0"), test));
|
||||
TS_ASSERT_EQUALS(CSize2D(0.0, 10.0), test);
|
||||
|
||||
TS_ASSERT(!CGUI::ParseString<CSize>(nullptr, CStrW(L"0"), test));
|
||||
TS_ASSERT(!CGUI::ParseString<CSize>(nullptr, CStrW(L"0 10 20"), test));
|
||||
TS_ASSERT(!CGUI::ParseString<CSize>(nullptr, CStrW(L"0,0 10,0"), test));
|
||||
TS_ASSERT(!CGUI::ParseString<CSize2D>(nullptr, CStrW(L"0"), test));
|
||||
TS_ASSERT(!CGUI::ParseString<CSize2D>(nullptr, CStrW(L"0 10 20"), test));
|
||||
TS_ASSERT(!CGUI::ParseString<CSize2D>(nullptr, CStrW(L"0,0 10,0"), test));
|
||||
}
|
||||
|
||||
void test_pos()
|
||||
|
93
source/maths/Size2D.cpp
Normal file
93
source/maths/Size2D.cpp
Normal file
@ -0,0 +1,93 @@
|
||||
/* Copyright (C) 2021 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. 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.
|
||||
*
|
||||
* 0 A.D. 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 0 A.D. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "precompiled.h"
|
||||
|
||||
#include "Size2D.h"
|
||||
|
||||
#include "ps/Shapes.h"
|
||||
|
||||
CSize2D::CSize2D() = default;
|
||||
|
||||
CSize2D::CSize2D(const CSize2D& size) : Width(size.Width), Height(size.Height)
|
||||
{
|
||||
}
|
||||
|
||||
CSize2D::CSize2D(const float width, const float height) : Width(width), Height(height)
|
||||
{
|
||||
}
|
||||
|
||||
CSize2D& CSize2D::operator=(const CSize2D& size)
|
||||
{
|
||||
Width = size.Width;
|
||||
Height = size.Height;
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool CSize2D::operator==(const CSize2D& size) const
|
||||
{
|
||||
return Width == size.Width && Height == size.Height;
|
||||
}
|
||||
|
||||
bool CSize2D::operator!=(const CSize2D& size) const
|
||||
{
|
||||
return !(*this == size);
|
||||
}
|
||||
|
||||
CSize2D CSize2D::operator+(const CSize2D& size) const
|
||||
{
|
||||
return CSize2D(Width + size.Width, Height + size.Height);
|
||||
}
|
||||
|
||||
CSize2D CSize2D::operator-(const CSize2D& size) const
|
||||
{
|
||||
return CSize2D(Width - size.Width, Height - size.Height);
|
||||
}
|
||||
|
||||
CSize2D CSize2D::operator/(const float a) const
|
||||
{
|
||||
return CSize2D(Width / a, Height / a);
|
||||
}
|
||||
|
||||
CSize2D CSize2D::operator*(const float a) const
|
||||
{
|
||||
return CSize2D(Width * a, Height * a);
|
||||
}
|
||||
|
||||
void CSize2D::operator+=(const CSize2D& size)
|
||||
{
|
||||
Width += size.Width;
|
||||
Height += size.Height;
|
||||
}
|
||||
|
||||
void CSize2D::operator-=(const CSize2D& size)
|
||||
{
|
||||
Width -= size.Width;
|
||||
Height -= size.Height;
|
||||
}
|
||||
|
||||
void CSize2D::operator/=(const float a)
|
||||
{
|
||||
Width /= a;
|
||||
Height /= a;
|
||||
}
|
||||
|
||||
void CSize2D::operator*=(const float a)
|
||||
{
|
||||
Width *= a;
|
||||
Height *= a;
|
||||
}
|
52
source/maths/Size2D.h
Normal file
52
source/maths/Size2D.h
Normal file
@ -0,0 +1,52 @@
|
||||
/* Copyright (C) 2021 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. 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.
|
||||
*
|
||||
* 0 A.D. 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 0 A.D. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef INCLUDED_SIZE2D
|
||||
#define INCLUDED_SIZE2D
|
||||
|
||||
class CPos;
|
||||
class CRect;
|
||||
|
||||
/*
|
||||
* Provides an interface for a size - geometric property in R2.
|
||||
*/
|
||||
class CSize2D
|
||||
{
|
||||
public:
|
||||
CSize2D();
|
||||
CSize2D(const CSize2D& size);
|
||||
CSize2D(const float width, const float height);
|
||||
|
||||
CSize2D& operator=(const CSize2D& size);
|
||||
bool operator==(const CSize2D& size) const;
|
||||
bool operator!=(const CSize2D& size) const;
|
||||
|
||||
CSize2D operator+(const CSize2D& size) const;
|
||||
CSize2D operator-(const CSize2D& size) const;
|
||||
CSize2D operator/(const float a) const;
|
||||
CSize2D operator*(const float a) const;
|
||||
|
||||
void operator+=(const CSize2D& a);
|
||||
void operator-=(const CSize2D& a);
|
||||
void operator/=(const float a);
|
||||
void operator*=(const float a);
|
||||
|
||||
public:
|
||||
float Width = 0.0f, Height = 0.0f;
|
||||
};
|
||||
|
||||
#endif // INCLUDED_SIZE2D
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2019 Wildfire Games.
|
||||
/* Copyright (C) 2021 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@ -19,6 +19,8 @@
|
||||
|
||||
#include "Shapes.h"
|
||||
|
||||
#include "maths/Size2D.h"
|
||||
|
||||
CRect::CRect() :
|
||||
left(0.f), top(0.f), right(0.f), bottom(0.f)
|
||||
{
|
||||
@ -34,8 +36,8 @@ CRect::CRect(const CPos &pos) :
|
||||
{
|
||||
}
|
||||
|
||||
CRect::CRect(const CSize& size) :
|
||||
left(0.f), top(0.f), right(size.cx), bottom(size.cy)
|
||||
CRect::CRect(const CSize2D& size) :
|
||||
left(0.f), top(0.f), right(size.Width), bottom(size.Height)
|
||||
{
|
||||
}
|
||||
|
||||
@ -44,8 +46,8 @@ CRect::CRect(const CPos& upperleft, const CPos& bottomright) :
|
||||
{
|
||||
}
|
||||
|
||||
CRect::CRect(const CPos& pos, const CSize& size) :
|
||||
left(pos.x), top(pos.y), right(pos.x + size.cx), bottom(pos.y + size.cy)
|
||||
CRect::CRect(const CPos& pos, const CSize2D& size) :
|
||||
left(pos.x), top(pos.y), right(pos.x + size.Width), bottom(pos.y + size.Height)
|
||||
{
|
||||
}
|
||||
|
||||
@ -96,9 +98,9 @@ CRect CRect::operator+(const CPos& a) const
|
||||
return CRect(left + a.x, top + a.y, right + a.x, bottom + a.y);
|
||||
}
|
||||
|
||||
CRect CRect::operator+(const CSize& a) const
|
||||
CRect CRect::operator+(const CSize2D& a) const
|
||||
{
|
||||
return CRect(left + a.cx, top + a.cy, right + a.cx, bottom + a.cy);
|
||||
return CRect(left + a.Width, top + a.Height, right + a.Width, bottom + a.Height);
|
||||
}
|
||||
|
||||
CRect CRect::operator-(const CRect& a) const
|
||||
@ -111,9 +113,9 @@ CRect CRect::operator-(const CPos& a) const
|
||||
return CRect(left - a.x, top - a.y, right - a.x, bottom - a.y);
|
||||
}
|
||||
|
||||
CRect CRect::operator-(const CSize& a) const
|
||||
CRect CRect::operator-(const CSize2D& a) const
|
||||
{
|
||||
return CRect(left - a.cx, top - a.cy, right - a.cx, bottom - a.cy);
|
||||
return CRect(left - a.Width, top - a.Height, right - a.Width, bottom - a.Height);
|
||||
}
|
||||
|
||||
void CRect::operator+=(const CRect& a)
|
||||
@ -132,12 +134,12 @@ void CRect::operator+=(const CPos& a)
|
||||
bottom += a.y;
|
||||
}
|
||||
|
||||
void CRect::operator+=(const CSize& a)
|
||||
void CRect::operator+=(const CSize2D& a)
|
||||
{
|
||||
left += a.cx;
|
||||
top += a.cy;
|
||||
right += a.cx;
|
||||
bottom += a.cy;
|
||||
left += a.Width;
|
||||
top += a.Height;
|
||||
right += a.Width;
|
||||
bottom += a.Height;
|
||||
}
|
||||
|
||||
void CRect::operator-=(const CRect& a)
|
||||
@ -156,12 +158,12 @@ void CRect::operator-=(const CPos& a)
|
||||
bottom -= a.y;
|
||||
}
|
||||
|
||||
void CRect::operator-=(const CSize& a)
|
||||
void CRect::operator-=(const CSize2D& a)
|
||||
{
|
||||
left -= a.cx;
|
||||
top -= a.cy;
|
||||
right -= a.cx;
|
||||
bottom -= a.cy;
|
||||
left -= a.Width;
|
||||
top -= a.Height;
|
||||
right -= a.Width;
|
||||
bottom -= a.Height;
|
||||
}
|
||||
|
||||
float CRect::GetWidth() const
|
||||
@ -174,9 +176,9 @@ float CRect::GetHeight() const
|
||||
return bottom-top;
|
||||
}
|
||||
|
||||
CSize CRect::GetSize() const
|
||||
CSize2D CRect::GetSize() const
|
||||
{
|
||||
return CSize(right - left, bottom - top);
|
||||
return CSize2D(right - left, bottom - top);
|
||||
}
|
||||
|
||||
CPos CRect::TopLeft() const
|
||||
@ -227,7 +229,7 @@ CPos::CPos(const CPos& pos) : x(pos.x), y(pos.y)
|
||||
{
|
||||
}
|
||||
|
||||
CPos::CPos(const CSize& s) : x(s.cx), y(s.cy)
|
||||
CPos::CPos(const CSize2D& s) : x(s.Width), y(s.Height)
|
||||
{
|
||||
}
|
||||
|
||||
@ -267,9 +269,9 @@ CPos CPos::operator+(const CPos& a) const
|
||||
return CPos(x + a.x, y + a.y);
|
||||
}
|
||||
|
||||
CPos CPos::operator+(const CSize& a) const
|
||||
CPos CPos::operator+(const CSize2D& a) const
|
||||
{
|
||||
return CPos(x + a.cx, y + a.cy);
|
||||
return CPos(x + a.Width, y + a.Height);
|
||||
}
|
||||
|
||||
CPos CPos::operator-(const CPos& a) const
|
||||
@ -277,9 +279,9 @@ CPos CPos::operator-(const CPos& a) const
|
||||
return CPos(x - a.x, y - a.y);
|
||||
}
|
||||
|
||||
CPos CPos::operator-(const CSize& a) const
|
||||
CPos CPos::operator-(const CSize2D& a) const
|
||||
{
|
||||
return CPos(x - a.cx, y - a.cy);
|
||||
return CPos(x - a.Width, y - a.Height);
|
||||
}
|
||||
|
||||
void CPos::operator+=(const CPos& a)
|
||||
@ -288,10 +290,10 @@ void CPos::operator+=(const CPos& a)
|
||||
y += a.y;
|
||||
}
|
||||
|
||||
void CPos::operator+=(const CSize& a)
|
||||
void CPos::operator+=(const CSize2D& a)
|
||||
{
|
||||
x += a.cx;
|
||||
y += a.cy;
|
||||
x += a.Width;
|
||||
y += a.Height;
|
||||
}
|
||||
|
||||
void CPos::operator-=(const CPos& a)
|
||||
@ -300,101 +302,8 @@ void CPos::operator-=(const CPos& a)
|
||||
y -= a.y;
|
||||
}
|
||||
|
||||
void CPos::operator-=(const CSize& a)
|
||||
void CPos::operator-=(const CSize2D& a)
|
||||
{
|
||||
x -= a.cx;
|
||||
y -= a.cy;
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
CSize::CSize() : cx(0.f), cy(0.f)
|
||||
{
|
||||
}
|
||||
|
||||
CSize::CSize(const CSize& size) : cx(size.cx), cy(size.cy)
|
||||
{
|
||||
}
|
||||
|
||||
CSize::CSize(const CRect &rect) : cx(rect.GetWidth()), cy(rect.GetHeight())
|
||||
{
|
||||
}
|
||||
|
||||
CSize::CSize(const CPos &pos) : cx(pos.x), cy(pos.y)
|
||||
{
|
||||
}
|
||||
|
||||
CSize::CSize(const float sx, const float sy) : cx(sx), cy(sy)
|
||||
{
|
||||
}
|
||||
|
||||
CSize& CSize::operator=(const CSize& a)
|
||||
{
|
||||
cx = a.cx;
|
||||
cy = a.cy;
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool CSize::operator==(const CSize &a) const
|
||||
{
|
||||
return cx == a.cx && cy == a.cy;
|
||||
}
|
||||
|
||||
bool CSize::operator!=(const CSize& a) const
|
||||
{
|
||||
return !(*this == a);
|
||||
}
|
||||
|
||||
CSize CSize::operator-() const
|
||||
{
|
||||
return CSize(-cx, -cy);
|
||||
}
|
||||
|
||||
CSize CSize::operator+() const
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
|
||||
CSize CSize::operator+(const CSize& a) const
|
||||
{
|
||||
return CSize(cx + a.cx, cy + a.cy);
|
||||
}
|
||||
|
||||
CSize CSize::operator-(const CSize& a) const
|
||||
{
|
||||
return CSize(cx - a.cx, cy - a.cy);
|
||||
}
|
||||
|
||||
CSize CSize::operator/(const float a) const
|
||||
{
|
||||
return CSize(cx / a, cy / a);
|
||||
}
|
||||
|
||||
CSize CSize::operator*(const float a) const
|
||||
{
|
||||
return CSize(cx * a, cy * a);
|
||||
}
|
||||
|
||||
void CSize::operator+=(const CSize& a)
|
||||
{
|
||||
cx += a.cx;
|
||||
cy += a.cy;
|
||||
}
|
||||
|
||||
void CSize::operator-=(const CSize& a)
|
||||
{
|
||||
cx -= a.cx;
|
||||
cy -= a.cy;
|
||||
}
|
||||
|
||||
void CSize::operator/=(const float a)
|
||||
{
|
||||
cx /= a;
|
||||
cy /= a;
|
||||
}
|
||||
|
||||
void CSize::operator*=(const float a)
|
||||
{
|
||||
cx *= a;
|
||||
cy *= a;
|
||||
x -= a.Width;
|
||||
y -= a.Height;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2019 Wildfire Games.
|
||||
/* Copyright (C) 2021 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@ -15,18 +15,11 @@
|
||||
* along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/*
|
||||
--Overview--
|
||||
|
||||
Classes mostly useful for representing 2D screen overlays;
|
||||
includes functionality for overlay position, color, texture and borders.
|
||||
*/
|
||||
|
||||
#ifndef INCLUDED_SHAPES
|
||||
#define INCLUDED_SHAPES
|
||||
|
||||
class CPos;
|
||||
class CSize;
|
||||
class CSize2D;
|
||||
|
||||
|
||||
/**
|
||||
@ -39,9 +32,9 @@ class CRect
|
||||
public:
|
||||
CRect();
|
||||
CRect(const CPos &pos);
|
||||
CRect(const CSize &size);
|
||||
CRect(const CSize2D &size);
|
||||
CRect(const CPos &upperleft, const CPos &bottomright);
|
||||
CRect(const CPos &pos, const CSize &size);
|
||||
CRect(const CPos &pos, const CSize2D &size);
|
||||
CRect(const float l, const float t, const float r, const float b);
|
||||
CRect(const CRect&);
|
||||
|
||||
@ -53,17 +46,17 @@ public:
|
||||
|
||||
CRect operator+(const CRect& a) const;
|
||||
CRect operator+(const CPos& a) const;
|
||||
CRect operator+(const CSize& a) const;
|
||||
CRect operator+(const CSize2D& a) const;
|
||||
CRect operator-(const CRect& a) const;
|
||||
CRect operator-(const CPos& a) const;
|
||||
CRect operator-(const CSize& a) const;
|
||||
CRect operator-(const CSize2D& a) const;
|
||||
|
||||
void operator+=(const CRect& a);
|
||||
void operator+=(const CPos& a);
|
||||
void operator+=(const CSize& a);
|
||||
void operator+=(const CSize2D& a);
|
||||
void operator-=(const CRect& a);
|
||||
void operator-=(const CPos& a);
|
||||
void operator-=(const CSize& a);
|
||||
void operator-=(const CSize2D& a);
|
||||
|
||||
/**
|
||||
* @return Width of Rectangle
|
||||
@ -78,7 +71,7 @@ public:
|
||||
/**
|
||||
* Get Size
|
||||
*/
|
||||
CSize GetSize() const;
|
||||
CSize2D GetSize() const;
|
||||
|
||||
/**
|
||||
* Get Position equivalent to top/left corner
|
||||
@ -128,14 +121,14 @@ public:
|
||||
/**
|
||||
* Made to represent screen positions and delta values.
|
||||
* @see CRect
|
||||
* @see CSize
|
||||
* @see CSize2D
|
||||
*/
|
||||
class CPos
|
||||
{
|
||||
public:
|
||||
CPos();
|
||||
CPos(const CPos& pos);
|
||||
CPos(const CSize &pos);
|
||||
CPos(const CSize2D &pos);
|
||||
CPos(const float px, const float py);
|
||||
|
||||
CPos& operator=(const CPos& a);
|
||||
@ -145,14 +138,14 @@ public:
|
||||
CPos operator+() const;
|
||||
|
||||
CPos operator+(const CPos& a) const;
|
||||
CPos operator+(const CSize& a) const;
|
||||
CPos operator+(const CSize2D& a) const;
|
||||
CPos operator-(const CPos& a) const;
|
||||
CPos operator-(const CSize& a) const;
|
||||
CPos operator-(const CSize2D& a) const;
|
||||
|
||||
void operator+=(const CPos& a);
|
||||
void operator+=(const CSize& a);
|
||||
void operator+=(const CSize2D& a);
|
||||
void operator-=(const CPos& a);
|
||||
void operator-=(const CSize& a);
|
||||
void operator-=(const CSize2D& a);
|
||||
|
||||
public:
|
||||
/**
|
||||
@ -161,44 +154,4 @@ public:
|
||||
float x, y;
|
||||
};
|
||||
|
||||
/**
|
||||
* Made to represent a screen size, should in philosophy
|
||||
* be made of unsigned ints, but for the sake of compatibility
|
||||
* with CRect and CPos it's not.
|
||||
* @see CRect
|
||||
* @see CPos
|
||||
*/
|
||||
class CSize
|
||||
{
|
||||
public:
|
||||
CSize();
|
||||
CSize(const CRect &rect);
|
||||
CSize(const CPos &pos);
|
||||
CSize(const CSize& size);
|
||||
CSize(const float sx, const float sy);
|
||||
|
||||
CSize& operator=(const CSize& a);
|
||||
bool operator==(const CSize& a) const;
|
||||
bool operator!=(const CSize& a) const;
|
||||
CSize operator-() const;
|
||||
CSize operator+() const;
|
||||
|
||||
CSize operator+(const CSize& a) const;
|
||||
CSize operator-(const CSize& a) const;
|
||||
CSize operator/(const float a) const;
|
||||
CSize operator*(const float a) const;
|
||||
|
||||
void operator+=(const CSize& a);
|
||||
void operator-=(const CSize& a);
|
||||
void operator/=(const float a);
|
||||
void operator*=(const float a);
|
||||
|
||||
public:
|
||||
/**
|
||||
* Size
|
||||
*/
|
||||
float cx, cy;
|
||||
};
|
||||
|
||||
|
||||
#endif // INCLUDED_SHAPES
|
||||
|
Loading…
Reference in New Issue
Block a user