将部分枚举类型替换为强枚举类型

This commit is contained in:
Nomango 2018-04-24 21:22:34 +08:00
parent 52bfa595ad
commit 245a6c6e71
15 changed files with 218 additions and 221 deletions

View File

@ -141,25 +141,25 @@ void Input::__updateDeviceState()
ScreenToClient(Window::getHWnd(), &s_MousePosition); ScreenToClient(Window::getHWnd(), &s_MousePosition);
} }
bool Input::isKeyDown(int nKeyCode) bool Input::isKeyDown(KeyCode key)
{ {
if (s_KeyBuffer[static_cast<int>(nKeyCode)] & 0x80) if (s_KeyBuffer[static_cast<int>(key)] & 0x80)
return true; return true;
return false; return false;
} }
bool Input::isKeyPress(int nKeyCode) bool Input::isKeyPress(KeyCode key)
{ {
if ((s_KeyBuffer[static_cast<int>(nKeyCode)] & 0x80) && if ((s_KeyBuffer[static_cast<int>(key)] & 0x80) &&
!(s_KeyRecordBuffer[static_cast<int>(nKeyCode)] & 0x80)) !(s_KeyRecordBuffer[static_cast<int>(key)] & 0x80))
return true; return true;
return false; return false;
} }
bool Input::isKeyRelease(int nKeyCode) bool Input::isKeyRelease(KeyCode key)
{ {
if (!(s_KeyBuffer[static_cast<int>(nKeyCode)] & 0x80) && if (!(s_KeyBuffer[static_cast<int>(key)] & 0x80) &&
(s_KeyRecordBuffer[static_cast<int>(nKeyCode)] & 0x80)) (s_KeyRecordBuffer[static_cast<int>(key)] & 0x80))
return true; return true;
return false; return false;
} }

View File

@ -60,7 +60,7 @@ void e2d::Collider::_render()
} }
} }
int e2d::Collider::getRelationWith(Collider * pCollider) const e2d::Relation e2d::Collider::getRelationWith(Collider * pCollider) const
{ {
if (m_pTransformedGeometry && pCollider->m_pTransformedGeometry) if (m_pTransformedGeometry && pCollider->m_pTransformedGeometry)
{ {
@ -74,7 +74,7 @@ int e2d::Collider::getRelationWith(Collider * pCollider) const
&relation &relation
); );
return relation; return Relation(relation);
} }
} }
return Relation::UNKNOWN; return Relation::UNKNOWN;

View File

@ -6,6 +6,10 @@ e2d::TextStyle::TextStyle()
, color(Color::WHITE) , color(Color::WHITE)
, fontWeight(FontWeight::NORMAL) , fontWeight(FontWeight::NORMAL)
, italic(false) , italic(false)
, alignment(TextAlign::LEFT)
, wrapping(false)
, wrappingWidth(0.0)
, lineSpacing(0.0)
, hasUnderline(false) , hasUnderline(false)
, hasStrikethrough(false) , hasStrikethrough(false)
, hasOutline(true) , hasOutline(true)
@ -20,18 +24,26 @@ e2d::TextStyle::TextStyle(
Color color, Color color,
UINT32 fontWeight, UINT32 fontWeight,
bool italic, bool italic,
TextAlign alignment,
bool wrapping,
double wrappingWidth,
double lineSpacing,
bool hasUnderline, bool hasUnderline,
bool hasStrikethrough, bool hasStrikethrough,
bool hasOutline, bool hasOutline,
Color outlineColor, Color outlineColor,
double outlineWidth, double outlineWidth,
int outlineJoin LineJoin outlineJoin
) )
: fontFamily(fontFamily) : fontFamily(fontFamily)
, fontSize(fontSize) , fontSize(fontSize)
, color(color) , color(color)
, fontWeight(fontWeight) , fontWeight(fontWeight)
, italic(italic) , italic(italic)
, alignment(alignment)
, wrapping(wrapping)
, wrappingWidth(wrappingWidth)
, lineSpacing(lineSpacing)
, hasUnderline(hasUnderline) , hasUnderline(hasUnderline)
, hasStrikethrough(hasStrikethrough) , hasStrikethrough(hasStrikethrough)
, hasOutline(hasOutline) , hasOutline(hasOutline)

View File

@ -114,7 +114,7 @@ void e2d::ColliderManager::__updateCollider(e2d::Collider * pActiveCollider)
if (IsCollideWith(pActiveNode, pPassiveNode)) if (IsCollideWith(pActiveNode, pPassiveNode))
{ {
// 判断两碰撞体交集情况 // 判断两碰撞体交集情况
int relation = pActiveCollider->getRelationWith(pPassiveCollider); Relation relation = pActiveCollider->getRelationWith(pPassiveCollider);
// 忽略 UNKNOWN 和 DISJOINT 情况 // 忽略 UNKNOWN 和 DISJOINT 情况
if (relation != Relation::UNKNOWN && relation != Relation::DISJOINT) if (relation != Relation::UNKNOWN && relation != Relation::DISJOINT)
{ {

View File

@ -6,7 +6,7 @@
e2d::Button::Button() e2d::Button::Button()
: m_Callback(nullptr) : m_Callback(nullptr)
, m_eBtnState(Button::NORMAL) , m_eBtnState(ButtonState::NORMAL)
, m_bEnable(true) , m_bEnable(true)
, m_bIsSelected(false) , m_bIsSelected(false)
, m_pNormal(nullptr) , m_pNormal(nullptr)
@ -18,7 +18,7 @@ e2d::Button::Button()
e2d::Button::Button(Node * normal, Function func) e2d::Button::Button(Node * normal, Function func)
: m_Callback(nullptr) : m_Callback(nullptr)
, m_eBtnState(Button::NORMAL) , m_eBtnState(ButtonState::NORMAL)
, m_bEnable(true) , m_bEnable(true)
, m_bIsSelected(false) , m_bIsSelected(false)
, m_pNormal(nullptr) , m_pNormal(nullptr)
@ -32,7 +32,7 @@ e2d::Button::Button(Node * normal, Function func)
e2d::Button::Button(Node * normal, Node * selected, Function func) e2d::Button::Button(Node * normal, Node * selected, Function func)
: m_Callback(nullptr) : m_Callback(nullptr)
, m_eBtnState(Button::NORMAL) , m_eBtnState(ButtonState::NORMAL)
, m_bEnable(true) , m_bEnable(true)
, m_bIsSelected(false) , m_bIsSelected(false)
, m_pNormal(nullptr) , m_pNormal(nullptr)
@ -47,7 +47,7 @@ e2d::Button::Button(Node * normal, Node * selected, Function func)
e2d::Button::Button(Node * normal, Node * mouseover, Node * selected, Function func) e2d::Button::Button(Node * normal, Node * mouseover, Node * selected, Function func)
: m_Callback(nullptr) : m_Callback(nullptr)
, m_eBtnState(Button::NORMAL) , m_eBtnState(ButtonState::NORMAL)
, m_bEnable(true) , m_bEnable(true)
, m_bIsSelected(false) , m_bIsSelected(false)
, m_pNormal(nullptr) , m_pNormal(nullptr)
@ -63,7 +63,7 @@ e2d::Button::Button(Node * normal, Node * mouseover, Node * selected, Function f
e2d::Button::Button(Node * normal, Node * mouseover, Node * selected, Node * disabled, Function func) e2d::Button::Button(Node * normal, Node * mouseover, Node * selected, Node * disabled, Function func)
: m_Callback(nullptr) : m_Callback(nullptr)
, m_eBtnState(Button::NORMAL) , m_eBtnState(ButtonState::NORMAL)
, m_bEnable(true) , m_bEnable(true)
, m_bIsSelected(false) , m_bIsSelected(false)
, m_pNormal(nullptr) , m_pNormal(nullptr)
@ -210,21 +210,21 @@ void e2d::Button::onFixedUpdate()
{ {
if (m_pNormal->isPointIn(Input::getMousePos())) if (m_pNormal->isPointIn(Input::getMousePos()))
{ {
_setState(Button::SELECTED); _setState(ButtonState::SELECTED);
return; return;
} }
} }
else if (m_pNormal->isPointIn(Input::getMousePos())) else if (m_pNormal->isPointIn(Input::getMousePos()))
{ {
_setState(Button::MOUSEOVER); _setState(ButtonState::MOUSEOVER);
return; return;
} }
_setState(Button::NORMAL); _setState(ButtonState::NORMAL);
} }
} }
void e2d::Button::_setState(BTN_STATE state) void e2d::Button::_setState(ButtonState state)
{ {
if (m_eBtnState != state) if (m_eBtnState != state)
{ {
@ -242,11 +242,11 @@ void e2d::Button::_updateVisiable()
if (m_bEnable) if (m_bEnable)
{ {
if (m_eBtnState == Button::SELECTED && m_pSelected) if (m_eBtnState == ButtonState::SELECTED && m_pSelected)
{ {
m_pSelected->setVisiable(true); m_pSelected->setVisiable(true);
} }
else if (m_eBtnState == Button::MOUSEOVER && m_pMouseover) else if (m_eBtnState == ButtonState::MOUSEOVER && m_pMouseover)
{ {
m_pMouseover->setVisiable(true); m_pMouseover->setVisiable(true);
} }

View File

@ -561,7 +561,7 @@ void e2d::Node::setProperty(NodeProperty prop)
this->setSkew(prop.skewAngleX, prop.skewAngleY); this->setSkew(prop.skewAngleX, prop.skewAngleY);
} }
void e2d::Node::setCollider(int nColliderType) void e2d::Node::setCollider(ColliderType nColliderType)
{ {
switch (nColliderType) switch (nColliderType)
{ {
@ -960,7 +960,7 @@ bool e2d::Node::isIntersectWith(const Node * pNode) const
// 如果存在碰撞体,用碰撞体判断 // 如果存在碰撞体,用碰撞体判断
if (this->m_pCollider && pNode->m_pCollider) if (this->m_pCollider && pNode->m_pCollider)
{ {
int relation = this->m_pCollider->getRelationWith(pNode->m_pCollider); Relation relation = this->m_pCollider->getRelationWith(pNode->m_pCollider);
if ((relation != Relation::UNKNOWN) && if ((relation != Relation::UNKNOWN) &&
(relation != Relation::DISJOINT)) (relation != Relation::DISJOINT))
{ {

View File

@ -63,7 +63,7 @@ double e2d::Shape::getStrokeWidth() const
return m_fStrokeWidth; return m_fStrokeWidth;
} }
int e2d::Shape::getStyle() const e2d::ShapeStyle e2d::Shape::getStyle() const
{ {
return m_nStyle; return m_nStyle;
} }
@ -83,7 +83,7 @@ void e2d::Shape::setStrokeWidth(double strokeWidth)
m_fStrokeWidth = static_cast<float>(strokeWidth); m_fStrokeWidth = static_cast<float>(strokeWidth);
} }
void e2d::Shape::setStyle(int style) void e2d::Shape::setStyle(ShapeStyle style)
{ {
m_nStyle = style; m_nStyle = style;
} }

View File

@ -2,22 +2,14 @@
e2d::Text::Text() e2d::Text::Text()
: m_bWrappingEnable(false) : m_TextStyle()
, m_TextStyle()
, m_nAlign(TextAlign::LEFT)
, m_fLineSpacing(0.0f)
, m_fWrappingWidth(0.0f)
, m_pDWriteTextLayout(nullptr) , m_pDWriteTextLayout(nullptr)
, m_pDWriteTextFormat(nullptr) , m_pDWriteTextFormat(nullptr)
{ {
} }
e2d::Text::Text(String text) e2d::Text::Text(String text)
: m_bWrappingEnable(false) : m_TextStyle()
, m_TextStyle()
, m_nAlign(TextAlign::LEFT)
, m_fLineSpacing(0.0f)
, m_fWrappingWidth(0.0f)
, m_pDWriteTextLayout(nullptr) , m_pDWriteTextLayout(nullptr)
, m_pDWriteTextFormat(nullptr) , m_pDWriteTextFormat(nullptr)
, m_sText(text) , m_sText(text)
@ -26,11 +18,7 @@ e2d::Text::Text(String text)
} }
e2d::Text::Text(TextStyle textStyle) e2d::Text::Text(TextStyle textStyle)
: m_bWrappingEnable(false) : m_TextStyle(textStyle)
, m_TextStyle(textStyle)
, m_nAlign(TextAlign::LEFT)
, m_fLineSpacing(0.0f)
, m_fWrappingWidth(0.0f)
, m_pDWriteTextLayout(nullptr) , m_pDWriteTextLayout(nullptr)
, m_pDWriteTextFormat(nullptr) , m_pDWriteTextFormat(nullptr)
{ {
@ -38,11 +26,7 @@ e2d::Text::Text(TextStyle textStyle)
} }
e2d::Text::Text(String text, TextStyle textStyle) e2d::Text::Text(String text, TextStyle textStyle)
: m_bWrappingEnable(false) : m_TextStyle(textStyle)
, m_TextStyle(textStyle)
, m_nAlign(TextAlign::LEFT)
, m_fLineSpacing(0.0f)
, m_fWrappingWidth(0.0f)
, m_pDWriteTextLayout(nullptr) , m_pDWriteTextLayout(nullptr)
, m_pDWriteTextFormat(nullptr) , m_pDWriteTextFormat(nullptr)
, m_sText(text) , m_sText(text)
@ -57,28 +41,32 @@ e2d::Text::Text(
UINT32 color, UINT32 color,
UINT32 fontWeight, UINT32 fontWeight,
bool italic, bool italic,
TextAlign alignment,
bool wrapping,
double wrappingWidth,
double lineSpacing,
bool hasUnderline, bool hasUnderline,
bool hasStrikethrough, bool hasStrikethrough,
bool hasOutline, bool hasOutline,
UINT32 outlineColor, UINT32 outlineColor,
UINT32 outlineWidth UINT32 outlineWidth
) )
: m_bWrappingEnable(false) : m_TextStyle(
, m_TextStyle(
fontFamily, fontFamily,
fontSize, fontSize,
color, color,
fontWeight, fontWeight,
italic, italic,
alignment,
wrapping,
wrappingWidth,
lineSpacing,
hasUnderline, hasUnderline,
hasStrikethrough, hasStrikethrough,
hasOutline, hasOutline,
outlineColor, outlineColor,
outlineWidth outlineWidth
) )
, m_nAlign(TextAlign::LEFT)
, m_fLineSpacing(0.0f)
, m_fWrappingWidth(0.0f)
, m_pDWriteTextLayout(nullptr) , m_pDWriteTextLayout(nullptr)
, m_pDWriteTextFormat(nullptr) , m_pDWriteTextFormat(nullptr)
, m_sText(text) , m_sText(text)
@ -132,7 +120,7 @@ double e2d::Text::getOutlineWidth() const
return m_TextStyle.outlineWidth; return m_TextStyle.outlineWidth;
} }
int e2d::Text::getOutlineJoin() const e2d::LineJoin e2d::Text::getOutlineJoin() const
{ {
return m_TextStyle.outlineJoin; return m_TextStyle.outlineJoin;
} }
@ -191,7 +179,7 @@ void e2d::Text::setFontFamily(String fontFamily)
void e2d::Text::setFontSize(double fontSize) void e2d::Text::setFontSize(double fontSize)
{ {
m_TextStyle.fontSize = static_cast<float>(fontSize); m_TextStyle.fontSize = fontSize;
_reset(); _reset();
} }
@ -212,30 +200,42 @@ void e2d::Text::setItalic(bool value)
_reset(); _reset();
} }
void e2d::Text::setWrapping(bool wrapping)
{
if (m_TextStyle.wrapping != wrapping)
{
m_TextStyle.wrapping = wrapping;
_reset();
}
}
void e2d::Text::setWrappingWidth(double fWrappingWidth) void e2d::Text::setWrappingWidth(double fWrappingWidth)
{ {
if (m_fWrappingWidth != fWrappingWidth) if (m_TextStyle.wrappingWidth != fWrappingWidth)
{ {
m_fWrappingWidth = max(static_cast<float>(fWrappingWidth), 0); m_TextStyle.wrappingWidth = max(fWrappingWidth, 0);
m_bWrappingEnable = (m_fWrappingWidth > FLT_MIN);
_reset(); if (m_TextStyle.wrapping)
{
_reset();
}
} }
} }
void e2d::Text::setLineSpacing(double fLineSpacing) void e2d::Text::setLineSpacing(double fLineSpacing)
{ {
if (m_fLineSpacing != fLineSpacing) if (m_TextStyle.lineSpacing != fLineSpacing)
{ {
m_fLineSpacing = static_cast<float>(fLineSpacing); m_TextStyle.lineSpacing = fLineSpacing;
_reset(); _reset();
} }
} }
void e2d::Text::setAlignment(int nAlign) void e2d::Text::setAlignment(TextAlign align)
{ {
if (m_nAlign != nAlign) if (m_TextStyle.alignment != align)
{ {
m_nAlign = nAlign; m_TextStyle.alignment = align;
_reset(); _reset();
} }
} }
@ -277,7 +277,7 @@ void e2d::Text::setOutlineWidth(double outlineWidth)
m_TextStyle.outlineWidth = outlineWidth; m_TextStyle.outlineWidth = outlineWidth;
} }
void e2d::Text::setOutlineJoin(int outlineJoin) void e2d::Text::setOutlineJoin(LineJoin outlineJoin)
{ {
m_TextStyle.outlineJoin = outlineJoin; m_TextStyle.outlineJoin = outlineJoin;
} }
@ -331,9 +331,9 @@ void e2d::Text::_createFormat()
if (m_pDWriteTextFormat) if (m_pDWriteTextFormat)
{ {
// 设置文字对齐方式 // 设置文字对齐方式
m_pDWriteTextFormat->SetTextAlignment(DWRITE_TEXT_ALIGNMENT(m_nAlign)); m_pDWriteTextFormat->SetTextAlignment(DWRITE_TEXT_ALIGNMENT(m_TextStyle.alignment));
// 设置行间距 // 设置行间距
if (m_fLineSpacing == 0.0f) if (m_TextStyle.lineSpacing == 0.0)
{ {
m_pDWriteTextFormat->SetLineSpacing(DWRITE_LINE_SPACING_METHOD_DEFAULT, 0, 0); m_pDWriteTextFormat->SetLineSpacing(DWRITE_LINE_SPACING_METHOD_DEFAULT, 0, 0);
} }
@ -341,12 +341,12 @@ void e2d::Text::_createFormat()
{ {
m_pDWriteTextFormat->SetLineSpacing( m_pDWriteTextFormat->SetLineSpacing(
DWRITE_LINE_SPACING_METHOD_UNIFORM, DWRITE_LINE_SPACING_METHOD_UNIFORM,
m_fLineSpacing, static_cast<FLOAT>(m_TextStyle.lineSpacing),
m_fLineSpacing * 0.8f static_cast<FLOAT>(m_TextStyle.lineSpacing) * 0.8f
); );
} }
// 打开文本自动换行时,设置换行属性 // 打开文本自动换行时,设置换行属性
if (m_bWrappingEnable) if (m_TextStyle.wrapping)
{ {
m_pDWriteTextFormat->SetWordWrapping(DWRITE_WORD_WRAPPING_WRAP); m_pDWriteTextFormat->SetWordWrapping(DWRITE_WORD_WRAPPING_WRAP);
} }
@ -379,13 +379,13 @@ void e2d::Text::_createLayout()
// 创建 TextLayout // 创建 TextLayout
HRESULT hr; HRESULT hr;
// 对文本自动换行情况下进行处理 // 对文本自动换行情况下进行处理
if (m_bWrappingEnable) if (m_TextStyle.wrapping)
{ {
hr = Renderer::getIDWriteFactory()->CreateTextLayout( hr = Renderer::getIDWriteFactory()->CreateTextLayout(
m_sText, m_sText,
length, length,
m_pDWriteTextFormat, m_pDWriteTextFormat,
m_fWrappingWidth, static_cast<FLOAT>(m_TextStyle.wrappingWidth),
0, 0,
&m_pDWriteTextLayout &m_pDWriteTextLayout
); );

View File

@ -1,7 +1,7 @@
#include "..\e2dtransition.h" #include "..\e2dtransition.h"
#include "..\e2dnode.h" #include "..\e2dnode.h"
e2d::TransitionMove::TransitionMove(double duration, int direct) e2d::TransitionMove::TransitionMove(double duration, Direct direct)
: Transition(duration) : Transition(duration)
, m_Direct(direct) , m_Direct(direct)
{ {

View File

@ -157,17 +157,17 @@ class Input
public: public:
// 检测键盘某按键是否正被按下 // 检测键盘某按键是否正被按下
static bool isKeyDown( static bool isKeyDown(
int nKeyCode KeyCode key
); );
// 检测键盘某按键是否被点击 // 检测键盘某按键是否被点击
static bool isKeyPress( static bool isKeyPress(
int nKeyCode KeyCode key
); );
// 检测键盘某按键是否正在松开 // 检测键盘某按键是否正在松开
static bool isKeyRelease( static bool isKeyRelease(
int nKeyCode KeyCode key
); );
// 检测鼠标左键是否正被按下 // 检测鼠标左键是否正被按下

View File

@ -21,7 +21,7 @@ public:
virtual ~Collider(); virtual ~Collider();
// 判断两碰撞体的交集关系 // 判断两碰撞体的交集关系
virtual int getRelationWith( virtual Relation getRelationWith(
Collider * pCollider Collider * pCollider
) const; ) const;

View File

@ -334,166 +334,142 @@ public:
// 文本对齐方式 // 文本对齐方式
class TextAlign enum class TextAlign : int
{ {
public: LEFT, /* 左对齐 */
enum : int RIGHT, /* 右对齐 */
{ CENTER /* 居中对齐 */
LEFT, /* 左对齐 */
RIGHT, /* 右对齐 */
CENTER /* 居中对齐 */
};
}; };
// 键值集合 // 键值集合
class KeyCode enum class KeyCode : int
{ {
public: UP = 0xC8,
enum : int LEFT = 0xCB,
{ RIGHT = 0xCD,
UP = 0xC8, DOWN = 0xD0,
LEFT = 0xCB, ENTER = 0x1C,
RIGHT = 0xCD, SPACE = 0x39,
DOWN = 0xD0, ESC = 0x01,
ENTER = 0x1C, BACK = 0x0E,
SPACE = 0x39, TAB = 0x0F,
ESC = 0x01, PAUSE = 0xC5,
BACK = 0x0E, Q = 0x10,
TAB = 0x0F, W = 0x11,
PAUSE = 0xC5, E = 0x12,
Q = 0x10, R = 0x13,
W = 0x11, T = 0x14,
E = 0x12, Y = 0x15,
R = 0x13, U = 0x16,
T = 0x14, I = 0x17,
Y = 0x15, O = 0x18,
U = 0x16, P = 0x19,
I = 0x17, A = 0x1E,
O = 0x18, S = 0x1F,
P = 0x19, D = 0x20,
A = 0x1E, F = 0x21,
S = 0x1F, G = 0x22,
D = 0x20, H = 0x23,
F = 0x21, J = 0x24,
G = 0x22, K = 0x25,
H = 0x23, L = 0x26,
J = 0x24, Z = 0x2C,
K = 0x25, X = 0x2D,
L = 0x26, C = 0x2E,
Z = 0x2C, V = 0x2F,
X = 0x2D, B = 0x30,
C = 0x2E, N = 0x31,
V = 0x2F, M = 0x32,
B = 0x30, NUM1 = 0x02,
N = 0x31, NUM2 = 0x03,
M = 0x32, NUM3 = 0x04,
NUM1 = 0x02, NUM4 = 0x05,
NUM2 = 0x03, NUM5 = 0x06,
NUM3 = 0x04, NUM6 = 0x07,
NUM4 = 0x05, NUM7 = 0x08,
NUM5 = 0x06, NUM8 = 0x09,
NUM6 = 0x07, NUM9 = 0x0A,
NUM7 = 0x08, NUM0 = 0x0B,
NUM8 = 0x09, NUMPAD7 = 0x47,
NUM9 = 0x0A, NUMPAD8 = 0x48,
NUM0 = 0x0B, NUMPAD9 = 0x49,
NUMPAD7 = 0x47, NUMPAD4 = 0x4B,
NUMPAD8 = 0x48, NUMPAD5 = 0x4C,
NUMPAD9 = 0x49, NUMPAD6 = 0x4D,
NUMPAD4 = 0x4B, NUMPAD1 = 0x4F,
NUMPAD5 = 0x4C, NUMPAD2 = 0x50,
NUMPAD6 = 0x4D, NUMPAD3 = 0x51,
NUMPAD1 = 0x4F, NUMPAD0 = 0x52
NUMPAD2 = 0x50,
NUMPAD3 = 0x51,
NUMPAD0 = 0x52
};
}; };
// 方向 // 方向
class Direct enum class Direct : int
{ {
public: UP, /* 上 */
enum : int DOWN, /* 下 */
{ LEFT, /* 左 */
UP, /* 上 */ RIGHT /* 右 */
DOWN, /* 下 */
LEFT, /* 左 */
RIGHT /* 右 */
};
}; };
// 碰撞体交集关系 // 物体交集关系
class Relation enum class Relation : int
{ {
public: UNKNOWN = 0, /* 关系不确定 */
enum : int DISJOINT = 1, /* 没有交集 */
{ IS_CONTAINED = 2, /* 完全被包含 */
UNKNOWN = 0, /* 关系不确定 */ CONTAINS = 3, /* 完全包含 */
DISJOINT = 1, /* 没有交集 */ OVERLAP = 4 /* 部分重叠 */
IS_CONTAINED = 2, /* 完全被包含 */
CONTAINS = 3, /* 完全包含 */
OVERLAP = 4 /* 部分重叠 */
};
}; };
// 线条相交样式 // 线条相交样式
class LineJoin enum class LineJoin : int
{ {
public: MITER = 0,
enum : int BEVEL = 1,
{ ROUND = 2
MITER = 0,
BEVEL = 1,
ROUND = 2
};
}; };
// 形状样式 // 形状样式
class ShapeStyle enum class ShapeStyle : int
{ {
public: SOLID, /* 填充 */
enum : int ROUND, /* 轮廓 */
{ FILL, /* 轮廓 + 填充 */
SOLID, /* 填充 */
ROUND, /* 轮廓 */
FILL, /* 轮廓 + 填充 */
};
}; };
// 碰撞体类别 // 碰撞体类别
class ColliderType enum class ColliderType : int
{ {
public: RECT, /* 矩形 */
enum : int CIRCLE, /* 圆形 */
{ ELLIPSE /* 椭圆形 */
RECT, /* 矩形 */
CIRCLE, /* 圆形 */
ELLIPSE /* 椭圆形 */
};
}; };
// 文本样式 // 文本样式
struct TextStyle struct TextStyle
{ {
String fontFamily; // 字体 String fontFamily; // 字体
double fontSize; // 字号 double fontSize; // 字号
Color color; // 颜色 Color color; // 颜色
UINT32 fontWeight; // 粗细值 UINT32 fontWeight; // 粗细值
bool italic; // 斜体 bool italic; // 斜体
bool hasUnderline; // 下划线 TextAlign alignment; // 对齐方式
bool hasStrikethrough; // 删除线 bool wrapping; // 打开自动换行
bool hasOutline; // 显示描边 double wrappingWidth; // 自动换行宽度
Color outlineColor; // 描边颜色 double lineSpacing; // 行间距
double outlineWidth; // 描边线宽 bool hasUnderline; // 下划线
int outlineJoin; // 描边线相交样式 bool hasStrikethrough; // 删除线
bool hasOutline; // 显示描边
Color outlineColor; // 描边颜色
double outlineWidth; // 描边线宽
LineJoin outlineJoin; // 描边线相交样式
/* 构造函数 */ /* 构造函数 */
TextStyle(); TextStyle();
@ -504,12 +480,16 @@ struct TextStyle
Color color = Color::WHITE, Color color = Color::WHITE,
UINT32 fontWeight = FontWeight::NORMAL, UINT32 fontWeight = FontWeight::NORMAL,
bool italic = false, bool italic = false,
TextAlign alignment = TextAlign::LEFT,
bool wrapping = false,
double wrappingWidth = 0.0,
double lineSpacing = 0.0,
bool hasUnderline = false, bool hasUnderline = false,
bool hasStrikethrough = false, bool hasStrikethrough = false,
bool hasOutline = true, bool hasOutline = true,
Color outlineColor = Color(Color::BLACK, 0.5), Color outlineColor = Color(Color::BLACK, 0.5),
double outlineWidth = 1.0, double outlineWidth = 1.0,
int outlineJoin = LineJoin::ROUND LineJoin outlineJoin = LineJoin::ROUND
); );
}; };

View File

@ -326,7 +326,7 @@ public:
// 设置碰撞体 // 设置碰撞体
virtual void setCollider( virtual void setCollider(
int nColliderType ColliderType nColliderType
); );
// 设置碰撞体 // 设置碰撞体
@ -566,6 +566,10 @@ public:
UINT32 color = Color::WHITE, /* 颜色 */ UINT32 color = Color::WHITE, /* 颜色 */
UINT32 fontWeight = FontWeight::NORMAL, /* 粗细值 */ UINT32 fontWeight = FontWeight::NORMAL, /* 粗细值 */
bool italic = false, /* 斜体 */ bool italic = false, /* 斜体 */
TextAlign alignment = TextAlign::LEFT, /* 对齐方式 */
bool wrapping = false, /* 打开自动换行 */
double wrappingWidth = 0.0, /* 自动换行宽度 */
double lineSpacing = 0.0, /* 行间距 */
bool hasUnderline = false, /* 下划线 */ bool hasUnderline = false, /* 下划线 */
bool hasStrikethrough = false, /* 删除线 */ bool hasStrikethrough = false, /* 删除线 */
bool hasOutline = true, /* 显示描边 */ bool hasOutline = true, /* 显示描边 */
@ -600,7 +604,7 @@ public:
double getOutlineWidth() const; double getOutlineWidth() const;
// 获取描边线相交样式 // 获取描边线相交样式
int getOutlineJoin() const; LineJoin getOutlineJoin() const;
// 获取文本显示行数 // 获取文本显示行数
int getLineCount() const; int getLineCount() const;
@ -652,7 +656,12 @@ public:
bool value bool value
); );
// 设置文本自动换行的宽度(设置为 0 时关闭自动换行,默认为 0 // 打开或关闭文本自动换行(默认为关闭)
void setWrapping(
bool wrapping
);
// 设置文本自动换行的宽度(默认为 0
void setWrappingWidth( void setWrappingWidth(
double fWrappingWidth double fWrappingWidth
); );
@ -664,7 +673,7 @@ public:
// 设置对齐方式(默认为 TextAlign::LEFT // 设置对齐方式(默认为 TextAlign::LEFT
void setAlignment( void setAlignment(
int nAlign TextAlign align
); );
// 设置下划线(默认值为 false // 设置下划线(默认值为 false
@ -694,7 +703,7 @@ public:
// 设置描边线相交样式 // 设置描边线相交样式
void setOutlineJoin( void setOutlineJoin(
int outlineJoin LineJoin outlineJoin
); );
// 渲染文字 // 渲染文字
@ -712,11 +721,7 @@ protected:
protected: protected:
String m_sText; String m_sText;
bool m_bWrappingEnable; TextStyle m_TextStyle;
float m_fWrappingWidth;
float m_fLineSpacing;
int m_nAlign;
TextStyle m_TextStyle;
IDWriteTextFormat * m_pDWriteTextFormat; IDWriteTextFormat * m_pDWriteTextFormat;
IDWriteTextLayout * m_pDWriteTextLayout; IDWriteTextLayout * m_pDWriteTextLayout;
}; };
@ -797,10 +802,10 @@ public:
protected: protected:
// 按钮状态枚举 // 按钮状态枚举
enum BTN_STATE { NORMAL, MOUSEOVER, SELECTED }; enum class ButtonState { NORMAL, MOUSEOVER, SELECTED };
// 设置按钮状态 // 设置按钮状态
virtual void _setState(BTN_STATE state); virtual void _setState(ButtonState state);
// 刷新按钮显示 // 刷新按钮显示
virtual void _updateVisiable(); virtual void _updateVisiable();
@ -815,7 +820,7 @@ protected:
Node * m_pDisabled; Node * m_pDisabled;
bool m_bEnable; bool m_bEnable;
bool m_bIsSelected; bool m_bIsSelected;
BTN_STATE m_eBtnState; ButtonState m_eBtnState;
Function m_Callback; Function m_Callback;
}; };

View File

@ -15,7 +15,7 @@ public:
virtual ~Shape(); virtual ~Shape();
// »ñÈ¡Ñùʽ // »ñÈ¡Ñùʽ
int getStyle() const; ShapeStyle getStyle() const;
// »ñÈ¡Ìî³äÑÕÉ« // »ñÈ¡Ìî³äÑÕÉ«
Color getFillColor() const; Color getFillColor() const;
@ -42,7 +42,7 @@ public:
); );
// ÉèÖÃÑùʽ // ÉèÖÃÑùʽ
void setStyle(int style); void setStyle(ShapeStyle style);
// äÖȾÐÎ×´ // äÖȾÐÎ×´
virtual void onRender() override; virtual void onRender() override;
@ -55,7 +55,7 @@ protected:
virtual void _renderFill() = 0; virtual void _renderFill() = 0;
protected: protected:
int m_nStyle; ShapeStyle m_nStyle;
float m_fStrokeWidth; float m_fStrokeWidth;
Color m_nLineColor; Color m_nLineColor;
Color m_nFillColor; Color m_nFillColor;

View File

@ -121,8 +121,8 @@ class TransitionMove :
public: public:
// 创建移动式的场景切换动画 // 创建移动式的场景切换动画
TransitionMove( TransitionMove(
double moveDuration, /* 场景移动动画持续时长 */ double moveDuration, /* 场景移动动画持续时长 */
int direct = Direct::LEFT /* 场景移动方向 */ Direct direct = Direct::LEFT /* 场景移动方向 */
); );
protected: protected:
@ -137,7 +137,7 @@ protected:
virtual void _reset() override; virtual void _reset() override;
protected: protected:
int m_Direct; Direct m_Direct;
Vector m_Vector; Vector m_Vector;
Point m_NextPos; Point m_NextPos;
}; };