some optimization
minor minor minor minor minor minor minor minor minor minor fixes
This commit is contained in:
parent
d76a4de248
commit
0742b0c02d
|
|
@ -36,7 +36,16 @@ namespace kiwano
|
|||
{
|
||||
}
|
||||
|
||||
void Action::UpdateStep(NodePtr const& target, Duration dt)
|
||||
void Action::Init(NodePtr target)
|
||||
{
|
||||
}
|
||||
|
||||
void Action::Update(NodePtr target, Duration dt)
|
||||
{
|
||||
Complete(target);
|
||||
}
|
||||
|
||||
void Action::UpdateStep(NodePtr target, Duration dt)
|
||||
{
|
||||
elapsed_ += dt;
|
||||
|
||||
|
|
@ -72,7 +81,7 @@ namespace kiwano
|
|||
}
|
||||
}
|
||||
|
||||
void Action::Complete(NodePtr const& target)
|
||||
void Action::Complete(NodePtr target)
|
||||
{
|
||||
if (cb_loop_done_)
|
||||
cb_loop_done_();
|
||||
|
|
@ -90,7 +99,7 @@ namespace kiwano
|
|||
++loops_done_;
|
||||
}
|
||||
|
||||
void Action::Restart(NodePtr const & target)
|
||||
void Action::Restart(NodePtr target)
|
||||
{
|
||||
status_ = Status::NotStarted;
|
||||
elapsed_ = 0;
|
||||
|
|
|
|||
|
|
@ -95,20 +95,20 @@ namespace kiwano
|
|||
|
||||
inline Duration GetElapsed() const { return elapsed_; }
|
||||
|
||||
inline ActionCallback const& GetDoneCallback() const { return cb_done_; }
|
||||
inline ActionCallback GetDoneCallback() const { return cb_done_; }
|
||||
|
||||
inline ActionCallback const& GetLoopDoneCallback() const { return cb_loop_done_; }
|
||||
inline ActionCallback GetLoopDoneCallback() const { return cb_loop_done_; }
|
||||
|
||||
protected:
|
||||
virtual void Init(NodePtr const& target) {}
|
||||
virtual void Init(NodePtr target);
|
||||
|
||||
virtual void Update(NodePtr const& target, Duration dt) { Complete(target); }
|
||||
virtual void Update(NodePtr target, Duration dt);
|
||||
|
||||
void UpdateStep(NodePtr const& target, Duration dt);
|
||||
void UpdateStep(NodePtr target, Duration dt);
|
||||
|
||||
void Complete(NodePtr const& target);
|
||||
void Complete(NodePtr target);
|
||||
|
||||
void Restart(NodePtr const& target);
|
||||
void Restart(NodePtr target);
|
||||
|
||||
protected:
|
||||
Status status_;
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@
|
|||
// THE SOFTWARE.
|
||||
|
||||
#include "ActionGroup.h"
|
||||
#include "Node.h"
|
||||
#include "../base/logs.h"
|
||||
|
||||
namespace kiwano
|
||||
|
|
@ -42,7 +43,7 @@ namespace kiwano
|
|||
{
|
||||
}
|
||||
|
||||
void ActionGroup::Init(NodePtr const& target)
|
||||
void ActionGroup::Init(NodePtr target)
|
||||
{
|
||||
if (actions_.IsEmpty())
|
||||
{
|
||||
|
|
@ -63,7 +64,7 @@ namespace kiwano
|
|||
}
|
||||
}
|
||||
|
||||
void ActionGroup::Update(NodePtr const& target, Duration dt)
|
||||
void ActionGroup::Update(NodePtr target, Duration dt)
|
||||
{
|
||||
if (sequence_)
|
||||
{
|
||||
|
|
@ -101,7 +102,7 @@ namespace kiwano
|
|||
}
|
||||
}
|
||||
|
||||
void ActionGroup::Add(ActionPtr const& action)
|
||||
void ActionGroup::Add(ActionPtr action)
|
||||
{
|
||||
if (action)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ namespace kiwano
|
|||
|
||||
// 添加动作
|
||||
void Add(
|
||||
ActionPtr const& action
|
||||
ActionPtr action
|
||||
);
|
||||
|
||||
// 添加多个动作
|
||||
|
|
@ -60,10 +60,10 @@ namespace kiwano
|
|||
|
||||
protected:
|
||||
// 初始化动作
|
||||
void Init(NodePtr const& target) override;
|
||||
void Init(NodePtr target) override;
|
||||
|
||||
// 更新动作
|
||||
void Update(NodePtr const& target, Duration dt) override;
|
||||
void Update(NodePtr target, Duration dt) override;
|
||||
|
||||
protected:
|
||||
bool sequence_;
|
||||
|
|
|
|||
|
|
@ -46,9 +46,9 @@ namespace kiwano
|
|||
inline ActionHelper& SetName(String const& name) { base->SetName(name); return (*this); }
|
||||
|
||||
// 获取指针
|
||||
inline ActionPtr const& Get() const { return base; }
|
||||
inline ActionPtr Get() const { return base; }
|
||||
|
||||
inline ActionHelper(ActionPtr const& base) : base(base) {}
|
||||
inline ActionHelper(ActionPtr base) : base(base) {}
|
||||
|
||||
inline operator ActionPtr() const { return base; }
|
||||
|
||||
|
|
@ -83,12 +83,14 @@ namespace kiwano
|
|||
inline TweenHelper& SetName(String const& name) { base->SetName(name); return (*this); }
|
||||
|
||||
// 获取指针
|
||||
inline ActionTweenPtr const& Get() const { return base; }
|
||||
inline ActionTweenPtr Get() const { return base; }
|
||||
|
||||
inline TweenHelper(ActionTweenPtr const& base) : base(base) {}
|
||||
inline TweenHelper(ActionTweenPtr base) : base(base) {}
|
||||
|
||||
inline operator ActionPtr() const { return base; }
|
||||
|
||||
inline operator ActionTweenPtr() const { return base; }
|
||||
|
||||
protected:
|
||||
ActionTweenPtr base;
|
||||
};
|
||||
|
|
@ -189,7 +191,7 @@ namespace kiwano
|
|||
|
||||
static inline TweenHelper
|
||||
Path(
|
||||
GeometryPtr const& geo, /* ¼¸ºÎͼÐÎ */
|
||||
GeometryPtr geo, /* ¼¸ºÎͼÐÎ */
|
||||
bool rotating = false, /* 沿路径切线方向旋转 */
|
||||
float start = 0.f, /* 起点 */
|
||||
float end = 1.f) /* 终点 */
|
||||
|
|
@ -198,7 +200,7 @@ namespace kiwano
|
|||
}
|
||||
|
||||
static inline TweenHelper
|
||||
Animation(FramesPtr const& frames)
|
||||
Animation(FramesPtr frames)
|
||||
{
|
||||
return TweenHelper(new kiwano::Animation(0, frames));
|
||||
}
|
||||
|
|
@ -221,6 +223,9 @@ namespace kiwano
|
|||
return ActionHelper(new kiwano::ActionGroup(actions, false));
|
||||
}
|
||||
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable : 4996)
|
||||
|
||||
KGE_DEPRECATED("Tween::Sequence is deprecated, use Tween::Group instead")
|
||||
static inline ActionHelper
|
||||
Sequence(Array<ActionPtr> const& actions)
|
||||
|
|
@ -234,5 +239,7 @@ namespace kiwano
|
|||
{
|
||||
return ActionHelper(new kiwano::ActionGroup(actions, false));
|
||||
}
|
||||
|
||||
#pragma warning(pop)
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,11 +19,12 @@
|
|||
// THE SOFTWARE.
|
||||
|
||||
#include "ActionManager.h"
|
||||
#include "Node.h"
|
||||
#include "../base/logs.h"
|
||||
|
||||
namespace kiwano
|
||||
{
|
||||
void ActionManager::UpdateActions(NodePtr const& target, Duration dt)
|
||||
void ActionManager::UpdateActions(NodePtr target, Duration dt)
|
||||
{
|
||||
if (actions_.IsEmpty() || !target)
|
||||
return;
|
||||
|
|
@ -41,7 +42,7 @@ namespace kiwano
|
|||
}
|
||||
}
|
||||
|
||||
ActionPtr ActionManager::AddAction(ActionPtr const& action)
|
||||
ActionPtr ActionManager::AddAction(ActionPtr action)
|
||||
{
|
||||
KGE_ASSERT(action && "AddAction failed, NULL pointer exception");
|
||||
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ namespace kiwano
|
|||
public:
|
||||
// 添加动作
|
||||
ActionPtr AddAction(
|
||||
ActionPtr const& action
|
||||
ActionPtr action
|
||||
);
|
||||
|
||||
// 获取动作
|
||||
|
|
@ -51,7 +51,7 @@ namespace kiwano
|
|||
Actions const& GetAllActions() const;
|
||||
|
||||
protected:
|
||||
void UpdateActions(NodePtr const& target, Duration dt);
|
||||
void UpdateActions(NodePtr target, Duration dt);
|
||||
|
||||
protected:
|
||||
Actions actions_;
|
||||
|
|
|
|||
|
|
@ -28,6 +28,13 @@ namespace kiwano
|
|||
// Ease Functions
|
||||
//-------------------------------------------------------
|
||||
|
||||
inline EaseFunc MakeEaseIn(float rate) { return std::bind(math::EaseIn, std::placeholders::_1, rate); }
|
||||
inline EaseFunc MakeEaseOut(float rate) { return std::bind(math::EaseOut, std::placeholders::_1, rate); }
|
||||
inline EaseFunc MakeEaseInOut(float rate) { return std::bind(math::EaseInOut, std::placeholders::_1, rate); }
|
||||
inline EaseFunc MakeEaseElasticIn(float period) { return std::bind(math::EaseElasticIn, std::placeholders::_1, period); }
|
||||
inline EaseFunc MakeEaseElasticOut(float period) { return std::bind(math::EaseElasticOut, std::placeholders::_1, period); }
|
||||
inline EaseFunc MakeEaseElasticInOut(float period) { return std::bind(math::EaseElasticInOut, std::placeholders::_1, period); }
|
||||
|
||||
EaseFunc Ease::Linear = math::Linear;
|
||||
EaseFunc Ease::EaseIn = MakeEaseIn(2.f);
|
||||
EaseFunc Ease::EaseOut = MakeEaseOut(2.f);
|
||||
|
|
@ -91,7 +98,7 @@ namespace kiwano
|
|||
return dur_;
|
||||
}
|
||||
|
||||
void ActionTween::Update(NodePtr const& target, Duration dt)
|
||||
void ActionTween::Update(NodePtr target, Duration dt)
|
||||
{
|
||||
float percent;
|
||||
|
||||
|
|
@ -135,7 +142,7 @@ namespace kiwano
|
|||
delta_pos_ = vector;
|
||||
}
|
||||
|
||||
void ActionMoveBy::Init(NodePtr const& target)
|
||||
void ActionMoveBy::Init(NodePtr target)
|
||||
{
|
||||
if (target)
|
||||
{
|
||||
|
|
@ -143,7 +150,7 @@ namespace kiwano
|
|||
}
|
||||
}
|
||||
|
||||
void ActionMoveBy::UpdateTween(NodePtr const& target, float percent)
|
||||
void ActionMoveBy::UpdateTween(NodePtr target, float percent)
|
||||
{
|
||||
Point diff = target->GetPosition() - prev_pos_;
|
||||
start_pos_ = start_pos_ + diff;
|
||||
|
|
@ -175,7 +182,7 @@ namespace kiwano
|
|||
return new (std::nothrow) ActionMoveTo(dur_, end_pos_, ease_func_);
|
||||
}
|
||||
|
||||
void ActionMoveTo::Init(NodePtr const& target)
|
||||
void ActionMoveTo::Init(NodePtr target)
|
||||
{
|
||||
ActionMoveBy::Init(target);
|
||||
delta_pos_ = end_pos_ - start_pos_;
|
||||
|
|
@ -204,7 +211,7 @@ namespace kiwano
|
|||
return new (std::nothrow) ActionJumpBy(dur_, -delta_pos_, height_, jumps_, ease_func_);
|
||||
}
|
||||
|
||||
void ActionJumpBy::Init(NodePtr const& target)
|
||||
void ActionJumpBy::Init(NodePtr target)
|
||||
{
|
||||
if (target)
|
||||
{
|
||||
|
|
@ -212,7 +219,7 @@ namespace kiwano
|
|||
}
|
||||
}
|
||||
|
||||
void ActionJumpBy::UpdateTween(NodePtr const& target, float percent)
|
||||
void ActionJumpBy::UpdateTween(NodePtr target, float percent)
|
||||
{
|
||||
float frac = fmod(percent * jumps_, 1.f);
|
||||
float x = delta_pos_.x * percent;
|
||||
|
|
@ -239,7 +246,7 @@ namespace kiwano
|
|||
return new (std::nothrow) ActionJumpTo(dur_, end_pos_, height_, jumps_, ease_func_);
|
||||
}
|
||||
|
||||
void ActionJumpTo::Init(NodePtr const& target)
|
||||
void ActionJumpTo::Init(NodePtr target)
|
||||
{
|
||||
ActionJumpBy::Init(target);
|
||||
delta_pos_ = end_pos_ - start_pos_;
|
||||
|
|
@ -264,7 +271,7 @@ namespace kiwano
|
|||
delta_y_ = scale_y;
|
||||
}
|
||||
|
||||
void ActionScaleBy::Init(NodePtr const& target)
|
||||
void ActionScaleBy::Init(NodePtr target)
|
||||
{
|
||||
if (target)
|
||||
{
|
||||
|
|
@ -273,7 +280,7 @@ namespace kiwano
|
|||
}
|
||||
}
|
||||
|
||||
void ActionScaleBy::UpdateTween(NodePtr const& target, float percent)
|
||||
void ActionScaleBy::UpdateTween(NodePtr target, float percent)
|
||||
{
|
||||
target->SetScale(start_scale_x_ + delta_x_ * percent, start_scale_y_ + delta_y_ * percent);
|
||||
}
|
||||
|
|
@ -307,7 +314,7 @@ namespace kiwano
|
|||
return new (std::nothrow) ActionScaleTo(dur_, end_scale_x_, end_scale_y_, ease_func_);
|
||||
}
|
||||
|
||||
void ActionScaleTo::Init(NodePtr const& target)
|
||||
void ActionScaleTo::Init(NodePtr target)
|
||||
{
|
||||
ActionScaleBy::Init(target);
|
||||
delta_x_ = end_scale_x_ - start_scale_x_;
|
||||
|
|
@ -325,7 +332,7 @@ namespace kiwano
|
|||
delta_val_ = opacity;
|
||||
}
|
||||
|
||||
void ActionOpacityBy::Init(NodePtr const& target)
|
||||
void ActionOpacityBy::Init(NodePtr target)
|
||||
{
|
||||
if (target)
|
||||
{
|
||||
|
|
@ -333,7 +340,7 @@ namespace kiwano
|
|||
}
|
||||
}
|
||||
|
||||
void ActionOpacityBy::UpdateTween(NodePtr const& target, float percent)
|
||||
void ActionOpacityBy::UpdateTween(NodePtr target, float percent)
|
||||
{
|
||||
target->SetOpacity(start_val_ + delta_val_ * percent);
|
||||
}
|
||||
|
|
@ -359,7 +366,7 @@ namespace kiwano
|
|||
return new (std::nothrow) ActionOpacityTo(dur_, end_val_, ease_func_);
|
||||
}
|
||||
|
||||
void ActionOpacityTo::Init(NodePtr const& target)
|
||||
void ActionOpacityTo::Init(NodePtr target)
|
||||
{
|
||||
ActionOpacityBy::Init(target);
|
||||
delta_val_ = end_val_ - start_val_;
|
||||
|
|
@ -386,7 +393,7 @@ namespace kiwano
|
|||
{
|
||||
}
|
||||
|
||||
void ActionRotateBy::Init(NodePtr const& target)
|
||||
void ActionRotateBy::Init(NodePtr target)
|
||||
{
|
||||
if (target)
|
||||
{
|
||||
|
|
@ -394,7 +401,7 @@ namespace kiwano
|
|||
}
|
||||
}
|
||||
|
||||
void ActionRotateBy::UpdateTween(NodePtr const& target, float percent)
|
||||
void ActionRotateBy::UpdateTween(NodePtr target, float percent)
|
||||
{
|
||||
float rotation = start_val_ + delta_val_ * percent;
|
||||
if (rotation > 360.f)
|
||||
|
|
@ -424,7 +431,7 @@ namespace kiwano
|
|||
return new (std::nothrow) ActionRotateTo(dur_, end_val_, ease_func_);
|
||||
}
|
||||
|
||||
void ActionRotateTo::Init(NodePtr const& target)
|
||||
void ActionRotateTo::Init(NodePtr target)
|
||||
{
|
||||
ActionRotateBy::Init(target);
|
||||
delta_val_ = end_val_ - start_val_;
|
||||
|
|
@ -435,7 +442,7 @@ namespace kiwano
|
|||
// ActionPath
|
||||
//-------------------------------------------------------
|
||||
|
||||
ActionPath::ActionPath(Duration duration, GeometryPtr const& geo, bool rotating, float start, float end, EaseFunc func)
|
||||
ActionPath::ActionPath(Duration duration, GeometryPtr geo, bool rotating, float start, float end, EaseFunc func)
|
||||
: ActionTween(duration, func)
|
||||
, start_(start)
|
||||
, end_(end)
|
||||
|
|
@ -454,12 +461,12 @@ namespace kiwano
|
|||
return new ActionPath(dur_, geo_, rotating_, end_, start_, ease_func_);
|
||||
}
|
||||
|
||||
void ActionPath::Init(NodePtr const& target)
|
||||
void ActionPath::Init(NodePtr target)
|
||||
{
|
||||
start_pos_ = target->GetPosition();
|
||||
}
|
||||
|
||||
void ActionPath::UpdateTween(NodePtr const& target, float percent)
|
||||
void ActionPath::UpdateTween(NodePtr target, float percent)
|
||||
{
|
||||
float length = geo_->GetLength() * std::min(std::max((end_ - start_) * percent + start_, 0.f), 1.f);
|
||||
|
||||
|
|
|
|||
|
|
@ -65,13 +65,6 @@ namespace kiwano
|
|||
static KGE_API EaseFunc SineInOut;
|
||||
};
|
||||
|
||||
inline EaseFunc MakeEaseIn(float rate) { return std::bind(math::EaseIn, std::placeholders::_1, rate); }
|
||||
inline EaseFunc MakeEaseOut(float rate) { return std::bind(math::EaseOut, std::placeholders::_1, rate); }
|
||||
inline EaseFunc MakeEaseInOut(float rate) { return std::bind(math::EaseInOut, std::placeholders::_1, rate); }
|
||||
inline EaseFunc MakeEaseElasticIn(float period) { return std::bind(math::EaseElasticIn, std::placeholders::_1, period); }
|
||||
inline EaseFunc MakeEaseElasticOut(float period) { return std::bind(math::EaseElasticOut, std::placeholders::_1, period); }
|
||||
inline EaseFunc MakeEaseElasticInOut(float period) { return std::bind(math::EaseElasticInOut, std::placeholders::_1, period); }
|
||||
|
||||
|
||||
// 补间动画
|
||||
class KGE_API ActionTween
|
||||
|
|
@ -97,9 +90,9 @@ namespace kiwano
|
|||
void SetDuration(Duration duration);
|
||||
|
||||
protected:
|
||||
void Update(NodePtr const& target, Duration dt) override;
|
||||
void Update(NodePtr target, Duration dt) override;
|
||||
|
||||
virtual void UpdateTween(NodePtr const& target, float percent) = 0;
|
||||
virtual void UpdateTween(NodePtr target, float percent) = 0;
|
||||
|
||||
protected:
|
||||
Duration dur_;
|
||||
|
|
@ -125,9 +118,9 @@ namespace kiwano
|
|||
ActionPtr Reverse() const override;
|
||||
|
||||
protected:
|
||||
void Init(NodePtr const& target) override;
|
||||
void Init(NodePtr target) override;
|
||||
|
||||
void UpdateTween(NodePtr const& target, float percent) override;
|
||||
void UpdateTween(NodePtr target, float percent) override;
|
||||
|
||||
protected:
|
||||
Point start_pos_;
|
||||
|
|
@ -158,7 +151,7 @@ namespace kiwano
|
|||
}
|
||||
|
||||
protected:
|
||||
void Init(NodePtr const& target) override;
|
||||
void Init(NodePtr target) override;
|
||||
|
||||
protected:
|
||||
Point end_pos_;
|
||||
|
|
@ -185,9 +178,9 @@ namespace kiwano
|
|||
ActionPtr Reverse() const override;
|
||||
|
||||
protected:
|
||||
void Init(NodePtr const& target) override;
|
||||
void Init(NodePtr target) override;
|
||||
|
||||
void UpdateTween(NodePtr const& target, float percent) override;
|
||||
void UpdateTween(NodePtr target, float percent) override;
|
||||
|
||||
protected:
|
||||
Point start_pos_;
|
||||
|
|
@ -222,7 +215,7 @@ namespace kiwano
|
|||
}
|
||||
|
||||
protected:
|
||||
void Init(NodePtr const& target) override;
|
||||
void Init(NodePtr target) override;
|
||||
|
||||
protected:
|
||||
Point end_pos_;
|
||||
|
|
@ -254,9 +247,9 @@ namespace kiwano
|
|||
ActionPtr Reverse() const override;
|
||||
|
||||
protected:
|
||||
void Init(NodePtr const& target) override;
|
||||
void Init(NodePtr target) override;
|
||||
|
||||
void UpdateTween(NodePtr const& target, float percent) override;
|
||||
void UpdateTween(NodePtr target, float percent) override;
|
||||
|
||||
protected:
|
||||
float start_scale_x_;
|
||||
|
|
@ -295,7 +288,7 @@ namespace kiwano
|
|||
}
|
||||
|
||||
protected:
|
||||
void Init(NodePtr const& target) override;
|
||||
void Init(NodePtr target) override;
|
||||
|
||||
protected:
|
||||
float end_scale_x_;
|
||||
|
|
@ -321,9 +314,9 @@ namespace kiwano
|
|||
ActionPtr Reverse() const override;
|
||||
|
||||
protected:
|
||||
void Init(NodePtr const& target) override;
|
||||
void Init(NodePtr target) override;
|
||||
|
||||
void UpdateTween(NodePtr const& target, float percent) override;
|
||||
void UpdateTween(NodePtr target, float percent) override;
|
||||
|
||||
protected:
|
||||
float start_val_;
|
||||
|
|
@ -353,7 +346,7 @@ namespace kiwano
|
|||
}
|
||||
|
||||
protected:
|
||||
void Init(NodePtr const& target) override;
|
||||
void Init(NodePtr target) override;
|
||||
|
||||
protected:
|
||||
float end_val_;
|
||||
|
|
@ -404,9 +397,9 @@ namespace kiwano
|
|||
ActionPtr Reverse() const override;
|
||||
|
||||
protected:
|
||||
void Init(NodePtr const& target) override;
|
||||
void Init(NodePtr target) override;
|
||||
|
||||
void UpdateTween(NodePtr const& target, float percent) override;
|
||||
void UpdateTween(NodePtr target, float percent) override;
|
||||
|
||||
protected:
|
||||
float start_val_;
|
||||
|
|
@ -436,7 +429,7 @@ namespace kiwano
|
|||
}
|
||||
|
||||
protected:
|
||||
void Init(NodePtr const& target) override;
|
||||
void Init(NodePtr target) override;
|
||||
|
||||
protected:
|
||||
float end_val_;
|
||||
|
|
@ -450,7 +443,7 @@ namespace kiwano
|
|||
public:
|
||||
ActionPath(
|
||||
Duration duration, /* 持续时长 */
|
||||
GeometryPtr const& geo, /* ¼¸ºÎͼÐÎ */
|
||||
GeometryPtr geo, /* ¼¸ºÎͼÐÎ */
|
||||
bool rotating = false, /* 沿路径切线方向旋转 */
|
||||
float start = 0.f, /* 起点 */
|
||||
float end = 1.f, /* 终点 */
|
||||
|
|
@ -464,9 +457,9 @@ namespace kiwano
|
|||
ActionPtr Reverse() const override;
|
||||
|
||||
protected:
|
||||
void Init(NodePtr const& target) override;
|
||||
void Init(NodePtr target) override;
|
||||
|
||||
void UpdateTween(NodePtr const& target, float percent) override;
|
||||
void UpdateTween(NodePtr target, float percent) override;
|
||||
|
||||
protected:
|
||||
bool rotating_;
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ namespace kiwano
|
|||
{
|
||||
}
|
||||
|
||||
Animation::Animation(Duration duration, FramesPtr const& animation, EaseFunc func)
|
||||
Animation::Animation(Duration duration, FramesPtr animation, EaseFunc func)
|
||||
: ActionTween(duration, func)
|
||||
, frames_(nullptr)
|
||||
{
|
||||
|
|
@ -46,12 +46,12 @@ namespace kiwano
|
|||
return frames_;
|
||||
}
|
||||
|
||||
void Animation::SetFrames(FramesPtr const& frames)
|
||||
void Animation::SetFrames(FramesPtr frames)
|
||||
{
|
||||
frames_ = frames;
|
||||
}
|
||||
|
||||
void Animation::Init(NodePtr const& target)
|
||||
void Animation::Init(NodePtr target)
|
||||
{
|
||||
if (!frames_ || frames_->GetFrames().empty())
|
||||
{
|
||||
|
|
@ -66,15 +66,15 @@ namespace kiwano
|
|||
}
|
||||
}
|
||||
|
||||
void Animation::UpdateTween(NodePtr const& target, float percent)
|
||||
void Animation::UpdateTween(NodePtr target, float percent)
|
||||
{
|
||||
auto sprite_target = dynamic_cast<Sprite*>(target.Get());
|
||||
|
||||
KGE_ASSERT(sprite_target && "Animation only supports Sprites");
|
||||
|
||||
const auto& frames = frames_->GetFrames();
|
||||
int size = frames.size();
|
||||
int index = std::min(static_cast<int>(math::Floor(size * percent)), size - 1);
|
||||
auto size = frames.size();
|
||||
auto index = std::min(static_cast<size_t>(math::Floor(size * percent)), size - 1);
|
||||
|
||||
sprite_target->Load(frames[index]);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ namespace kiwano
|
|||
|
||||
Animation(
|
||||
Duration duration, /* 动画时长 */
|
||||
FramesPtr const& frames, /* ÐòÁÐÖ¡ */
|
||||
FramesPtr frames, /* ÐòÁÐÖ¡ */
|
||||
EaseFunc func = nullptr /* 速度变化 */
|
||||
);
|
||||
|
||||
|
|
@ -43,7 +43,7 @@ namespace kiwano
|
|||
|
||||
// 设置动画
|
||||
void SetFrames(
|
||||
FramesPtr const& frames
|
||||
FramesPtr frames
|
||||
);
|
||||
|
||||
// 获取该动作的拷贝对象
|
||||
|
|
@ -53,9 +53,9 @@ namespace kiwano
|
|||
ActionPtr Reverse() const override;
|
||||
|
||||
protected:
|
||||
void Init(NodePtr const& target) override;
|
||||
void Init(NodePtr target) override;
|
||||
|
||||
void UpdateTween(NodePtr const& target, float percent) override;
|
||||
void UpdateTween(NodePtr target, float percent) override;
|
||||
|
||||
protected:
|
||||
FramesPtr frames_;
|
||||
|
|
|
|||
|
|
@ -249,7 +249,7 @@ namespace kiwano
|
|||
cache_expired_ = true;
|
||||
}
|
||||
|
||||
void Canvas::DrawImage(ImagePtr const & image, float opacity)
|
||||
void Canvas::DrawImage(ImagePtr image, float opacity)
|
||||
{
|
||||
if (image && image->GetBitmap())
|
||||
{
|
||||
|
|
@ -297,7 +297,7 @@ namespace kiwano
|
|||
);
|
||||
}
|
||||
|
||||
void Canvas::DrawGeometry(GeometryPtr const & geo)
|
||||
void Canvas::DrawGeometry(GeometryPtr geo)
|
||||
{
|
||||
if (geo && geo->geo_)
|
||||
{
|
||||
|
|
@ -375,7 +375,7 @@ namespace kiwano
|
|||
cache_expired_ = true;
|
||||
}
|
||||
|
||||
void Canvas::FillGeometry(GeometryPtr const & geo)
|
||||
void Canvas::FillGeometry(GeometryPtr geo)
|
||||
{
|
||||
if (geo && geo->geo_)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ namespace kiwano
|
|||
|
||||
// 뺌暠튬
|
||||
void DrawImage(
|
||||
ImagePtr const& image,
|
||||
ImagePtr image,
|
||||
float opacity = 1.f
|
||||
);
|
||||
|
||||
|
|
@ -97,7 +97,7 @@ namespace kiwano
|
|||
|
||||
// 뺌섯부暠近긋움
|
||||
void DrawGeometry(
|
||||
GeometryPtr const& geo
|
||||
GeometryPtr geo
|
||||
);
|
||||
|
||||
// 輕념途近
|
||||
|
|
@ -127,7 +127,7 @@ namespace kiwano
|
|||
|
||||
// 輕념섯부暠近
|
||||
void FillGeometry(
|
||||
GeometryPtr const& geo
|
||||
GeometryPtr geo
|
||||
);
|
||||
|
||||
// 역迦삥齡쨌쓺
|
||||
|
|
|
|||
|
|
@ -51,10 +51,11 @@ namespace kiwano
|
|||
|
||||
void DebugNode::OnRender()
|
||||
{
|
||||
Renderer::Instance().SetTransform(Matrix{});
|
||||
Renderer::Instance().GetSolidColorBrush()->SetColor(D2D1::ColorF(0.0f, 0.0f, 0.0f, 0.5f));
|
||||
|
||||
Renderer::Instance().GetDeviceResources()->GetD2DDeviceContext()->FillRectangle(
|
||||
D2D1_RECT_F{ 10, 10, 30 + debug_text_->GetWidth(), 30 + debug_text_->GetHeight() },
|
||||
D2D1_RECT_F{ 10, 10, 30 + debug_text_->GetLayoutSize().x, 30 + debug_text_->GetLayoutSize().y },
|
||||
Renderer::Instance().GetSolidColorBrush()
|
||||
);
|
||||
}
|
||||
|
|
@ -85,8 +86,6 @@ namespace kiwano
|
|||
ss << "Memory: " << pmc.PrivateUsage / 1024 << "kb";
|
||||
|
||||
debug_text_->SetText(ss.str());
|
||||
|
||||
debug_text_->SetSize(debug_text_->GetLayoutSize());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ namespace kiwano
|
|||
{
|
||||
}
|
||||
|
||||
void Frames::Add(ImagePtr const& frame)
|
||||
void Frames::Add(ImagePtr frame)
|
||||
{
|
||||
KGE_ASSERT(frame && "Frames::Add failed, NULL pointer exception");
|
||||
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ namespace kiwano
|
|||
|
||||
// 添加关键帧
|
||||
void Add(
|
||||
ImagePtr const& frame
|
||||
ImagePtr frame
|
||||
);
|
||||
|
||||
// 添加多个关键帧
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ namespace kiwano
|
|||
{
|
||||
}
|
||||
|
||||
GeometryNode::GeometryNode(GeometryPtr const& geometry)
|
||||
GeometryNode::GeometryNode(GeometryPtr geometry)
|
||||
: GeometryNode()
|
||||
{
|
||||
SetGeometry(geometry);
|
||||
|
|
@ -41,7 +41,7 @@ namespace kiwano
|
|||
{
|
||||
}
|
||||
|
||||
void GeometryNode::SetGeometry(GeometryPtr const& geometry)
|
||||
void GeometryNode::SetGeometry(GeometryPtr geometry)
|
||||
{
|
||||
geometry_ = geometry;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,14 +32,14 @@ namespace kiwano
|
|||
GeometryNode();
|
||||
|
||||
GeometryNode(
|
||||
GeometryPtr const& geometry
|
||||
GeometryPtr geometry
|
||||
);
|
||||
|
||||
virtual ~GeometryNode();
|
||||
|
||||
// ÉčÖĂĐÎ×´
|
||||
void SetGeometry(
|
||||
GeometryPtr const& geometry
|
||||
GeometryPtr geometry
|
||||
);
|
||||
|
||||
// ÉčÖĂĚîłäŃŐÉŤ
|
||||
|
|
@ -63,7 +63,7 @@ namespace kiwano
|
|||
);
|
||||
|
||||
// ťńČĄĐÎ×´
|
||||
GeometryPtr const& GetGeometry() const { return geometry_; }
|
||||
GeometryPtr GetGeometry() const { return geometry_; }
|
||||
|
||||
// ťńČĄĚîłäŃŐÉŤ
|
||||
Color GetFillColor() const { return fill_color_; }
|
||||
|
|
|
|||
|
|
@ -58,9 +58,8 @@ namespace kiwano
|
|||
|
||||
void Node::Update(Duration dt)
|
||||
{
|
||||
if (update_pausing_)
|
||||
return;
|
||||
|
||||
if (!update_pausing_)
|
||||
{
|
||||
UpdateActions(this, dt);
|
||||
UpdateTimers(dt);
|
||||
|
||||
|
|
@ -68,6 +67,7 @@ namespace kiwano
|
|||
cb_update_(dt);
|
||||
|
||||
OnUpdate(dt);
|
||||
}
|
||||
|
||||
if (!children_.IsEmpty())
|
||||
{
|
||||
|
|
@ -451,7 +451,7 @@ namespace kiwano
|
|||
dirty_transform_ = true;
|
||||
}
|
||||
|
||||
void Node::AddChild(NodePtr const& child)
|
||||
void Node::AddChild(NodePtr child)
|
||||
{
|
||||
KGE_ASSERT(child && "Node::AddChild failed, NULL pointer exception");
|
||||
|
||||
|
|
@ -537,7 +537,7 @@ namespace kiwano
|
|||
}
|
||||
}
|
||||
|
||||
void Node::RemoveChild(NodePtr const& child)
|
||||
void Node::RemoveChild(NodePtr child)
|
||||
{
|
||||
RemoveChild(child.Get());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -325,7 +325,7 @@ namespace kiwano
|
|||
|
||||
// 添加子节点
|
||||
void AddChild(
|
||||
NodePtr const& child
|
||||
NodePtr child
|
||||
);
|
||||
|
||||
// 添加多个子节点
|
||||
|
|
@ -348,7 +348,7 @@ namespace kiwano
|
|||
|
||||
// 移除子节点
|
||||
void RemoveChild(
|
||||
NodePtr const& child
|
||||
NodePtr child
|
||||
);
|
||||
|
||||
// 移除子节点
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ namespace kiwano
|
|||
{
|
||||
scene_ = this;
|
||||
|
||||
SetAnchor(0, 0);
|
||||
SetSize(Renderer::Instance().GetOutputSize());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ namespace kiwano
|
|||
{
|
||||
}
|
||||
|
||||
Sprite::Sprite(ImagePtr const& image)
|
||||
Sprite::Sprite(ImagePtr image)
|
||||
: image_(nullptr)
|
||||
{
|
||||
Load(image);
|
||||
|
|
@ -51,7 +51,7 @@ namespace kiwano
|
|||
{
|
||||
}
|
||||
|
||||
bool Sprite::Load(ImagePtr const& image)
|
||||
bool Sprite::Load(ImagePtr image)
|
||||
{
|
||||
if (image)
|
||||
{
|
||||
|
|
@ -90,7 +90,7 @@ namespace kiwano
|
|||
);
|
||||
}
|
||||
|
||||
ImagePtr const& Sprite::GetImage() const
|
||||
ImagePtr Sprite::GetImage() const
|
||||
{
|
||||
return image_;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ namespace kiwano
|
|||
Sprite();
|
||||
|
||||
explicit Sprite(
|
||||
ImagePtr const& image
|
||||
ImagePtr image
|
||||
);
|
||||
|
||||
explicit Sprite(
|
||||
|
|
@ -53,7 +53,7 @@ namespace kiwano
|
|||
|
||||
// 加载图片
|
||||
bool Load(
|
||||
ImagePtr const& image
|
||||
ImagePtr image
|
||||
);
|
||||
|
||||
// 将图片裁剪为矩形
|
||||
|
|
@ -62,7 +62,7 @@ namespace kiwano
|
|||
);
|
||||
|
||||
// 获取 Image 对象
|
||||
ImagePtr const& GetImage() const;
|
||||
ImagePtr GetImage() const;
|
||||
|
||||
// 渲染精灵
|
||||
void OnRender() override;
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ namespace kiwano
|
|||
rotation == other.rotation;
|
||||
}
|
||||
|
||||
inline math::Matrix ToMatrix() const
|
||||
inline Matrix ToMatrix() const
|
||||
{
|
||||
// matrix multiplication is optimized by expression template
|
||||
return Matrix::Scaling(scale)
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ namespace kiwano
|
|||
return done_;
|
||||
}
|
||||
|
||||
void Transition::Init(ScenePtr const& prev, ScenePtr const& next)
|
||||
void Transition::Init(ScenePtr prev, ScenePtr next)
|
||||
{
|
||||
process_ = 0;
|
||||
delta_ = Duration{};
|
||||
|
|
@ -147,7 +147,7 @@ namespace kiwano
|
|||
{
|
||||
}
|
||||
|
||||
void BoxTransition::Init(ScenePtr const& prev, ScenePtr const& next)
|
||||
void BoxTransition::Init(ScenePtr prev, ScenePtr next)
|
||||
{
|
||||
Transition::Init(prev, next);
|
||||
|
||||
|
|
@ -189,7 +189,7 @@ namespace kiwano
|
|||
{
|
||||
}
|
||||
|
||||
void EmergeTransition::Init(ScenePtr const& prev, ScenePtr const& next)
|
||||
void EmergeTransition::Init(ScenePtr prev, ScenePtr next)
|
||||
{
|
||||
Transition::Init(prev, next);
|
||||
|
||||
|
|
@ -214,7 +214,7 @@ namespace kiwano
|
|||
{
|
||||
}
|
||||
|
||||
void FadeTransition::Init(ScenePtr const& prev, ScenePtr const& next)
|
||||
void FadeTransition::Init(ScenePtr prev, ScenePtr next)
|
||||
{
|
||||
Transition::Init(prev, next);
|
||||
|
||||
|
|
@ -248,7 +248,7 @@ namespace kiwano
|
|||
{
|
||||
}
|
||||
|
||||
void MoveTransition::Init(ScenePtr const& prev, ScenePtr const& next)
|
||||
void MoveTransition::Init(ScenePtr prev, ScenePtr next)
|
||||
{
|
||||
Transition::Init(prev, next);
|
||||
|
||||
|
|
@ -327,7 +327,7 @@ namespace kiwano
|
|||
{
|
||||
}
|
||||
|
||||
void RotationTransition::Init(ScenePtr const& prev, ScenePtr const& next)
|
||||
void RotationTransition::Init(ScenePtr prev, ScenePtr next)
|
||||
{
|
||||
Transition::Init(prev, next);
|
||||
|
||||
|
|
|
|||
|
|
@ -43,8 +43,8 @@ namespace kiwano
|
|||
|
||||
protected:
|
||||
virtual void Init(
|
||||
ScenePtr const& prev,
|
||||
ScenePtr const& next
|
||||
ScenePtr prev,
|
||||
ScenePtr next
|
||||
);
|
||||
|
||||
virtual void Update(Duration dt);
|
||||
|
|
@ -84,8 +84,8 @@ namespace kiwano
|
|||
void Update(Duration dt) override;
|
||||
|
||||
virtual void Init(
|
||||
ScenePtr const& prev,
|
||||
ScenePtr const& next
|
||||
ScenePtr prev,
|
||||
ScenePtr next
|
||||
) override;
|
||||
};
|
||||
|
||||
|
|
@ -103,8 +103,8 @@ namespace kiwano
|
|||
void Update(Duration dt) override;
|
||||
|
||||
virtual void Init(
|
||||
ScenePtr const& prev,
|
||||
ScenePtr const& next
|
||||
ScenePtr prev,
|
||||
ScenePtr next
|
||||
) override;
|
||||
};
|
||||
|
||||
|
|
@ -122,8 +122,8 @@ namespace kiwano
|
|||
void Update(Duration dt) override;
|
||||
|
||||
virtual void Init(
|
||||
ScenePtr const& prev,
|
||||
ScenePtr const& next
|
||||
ScenePtr prev,
|
||||
ScenePtr next
|
||||
) override;
|
||||
};
|
||||
|
||||
|
|
@ -142,8 +142,8 @@ namespace kiwano
|
|||
void Update(Duration dt) override;
|
||||
|
||||
virtual void Init(
|
||||
ScenePtr const& prev,
|
||||
ScenePtr const& next
|
||||
ScenePtr prev,
|
||||
ScenePtr next
|
||||
) override;
|
||||
|
||||
void Reset() override;
|
||||
|
|
@ -169,8 +169,8 @@ namespace kiwano
|
|||
void Update(Duration dt) override;
|
||||
|
||||
virtual void Init(
|
||||
ScenePtr const& prev,
|
||||
ScenePtr const& next
|
||||
ScenePtr prev,
|
||||
ScenePtr next
|
||||
) override;
|
||||
|
||||
void Reset() override;
|
||||
|
|
|
|||
|
|
@ -126,7 +126,7 @@ namespace kiwano
|
|||
// 图层属性
|
||||
struct LayerProperties
|
||||
{
|
||||
math::Rect area;
|
||||
Rect area;
|
||||
float opacity;
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ namespace kiwano
|
|||
}
|
||||
}
|
||||
|
||||
EventListenerPtr EventDispatcher::AddListener(EventListenerPtr const & listener)
|
||||
EventListenerPtr EventDispatcher::AddListener(EventListenerPtr listener)
|
||||
{
|
||||
KGE_ASSERT(listener && "AddListener failed, NULL pointer exception");
|
||||
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ namespace kiwano
|
|||
public:
|
||||
// 添加监听器
|
||||
EventListenerPtr AddListener(
|
||||
EventListenerPtr const& listener
|
||||
EventListenerPtr listener
|
||||
);
|
||||
|
||||
// 添加监听器
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ namespace kiwano
|
|||
};
|
||||
|
||||
template <typename _Ty>
|
||||
using SmartPtr = IntrusivePtr<_Ty, DefaultIntrusivePtrManager, true>;
|
||||
using SmartPtr = IntrusivePtr<_Ty, DefaultIntrusivePtrManager>;
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ namespace kiwano
|
|||
}
|
||||
}
|
||||
|
||||
void TimerManager::AddTimer(TimerPtr const& timer)
|
||||
void TimerManager::AddTimer(TimerPtr timer)
|
||||
{
|
||||
KGE_ASSERT(timer && "AddTimer failed, NULL pointer exception");
|
||||
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ namespace kiwano
|
|||
public:
|
||||
// 添加任务
|
||||
void AddTimer(
|
||||
TimerPtr const& timer
|
||||
TimerPtr timer
|
||||
);
|
||||
|
||||
// 启动任务
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ namespace kiwano
|
|||
return Duration(dur_ - other.dur_);
|
||||
}
|
||||
|
||||
Time Time::Now() KGE_NOEXCEPT
|
||||
Time Time::Now() noexcept
|
||||
{
|
||||
static LARGE_INTEGER freq = {};
|
||||
if (freq.QuadPart == 0LL)
|
||||
|
|
|
|||
|
|
@ -177,7 +177,7 @@ namespace kiwano
|
|||
// 获取当前时间
|
||||
// 由于该时间点基于系统启动时间开始计算, 所以无法格式化该时间,
|
||||
// 也无法获得该时间的 Unix 时间戳
|
||||
static Time Now() KGE_NOEXCEPT;
|
||||
static Time Now() noexcept;
|
||||
|
||||
private:
|
||||
long dur_;
|
||||
|
|
|
|||
|
|
@ -25,14 +25,6 @@
|
|||
|
||||
namespace kiwano
|
||||
{
|
||||
//
|
||||
// Array
|
||||
// Lightweight std::vector<>-like class
|
||||
//
|
||||
template<typename _Ty, typename _Alloc, typename _Manager>
|
||||
class Array;
|
||||
|
||||
|
||||
//
|
||||
// ArrayManager<> with memory operations
|
||||
//
|
||||
|
|
@ -42,6 +34,7 @@ namespace kiwano
|
|||
|
||||
//
|
||||
// Array<>
|
||||
// Lightweight std::vector<>-like class
|
||||
//
|
||||
template<
|
||||
typename _Ty,
|
||||
|
|
@ -68,14 +61,14 @@ namespace kiwano
|
|||
inline Array(size_type count, const _Ty& val) : Array() { assign(count, val); }
|
||||
inline Array(initializer_list list) : Array() { assign(list); }
|
||||
inline Array(const Array& src) : Array() { assign(src); }
|
||||
inline Array(Array&& src) : Array() { swap(src); }
|
||||
inline Array(Array&& src) noexcept : Array() { swap(src); }
|
||||
inline ~Array() { destroy(); }
|
||||
|
||||
template <typename _Iter>
|
||||
inline Array(_Iter first, _Iter last) : Array() { assign(first, last); }
|
||||
|
||||
inline Array& operator=(const Array& src) { if (&src != this) { resize(src.size_); manager::copy_data(begin(), src.cbegin(), size_); } return (*this); }
|
||||
inline Array& operator=(Array&& src) { swap(src); return *this; }
|
||||
inline Array& operator=(Array&& src) noexcept { swap(src); return *this; }
|
||||
inline Array& operator=(initializer_list list) { if (list.size()) { assign(list.begin(), list.end()); } else clear(); return (*this); }
|
||||
|
||||
inline Array& assign(size_type count, const _Ty& val) { if (count > 0) { resize(count); manager::copy_data(begin(), count, val); } else clear(); return (*this); }
|
||||
|
|
@ -86,7 +79,7 @@ namespace kiwano
|
|||
inline void assign(_Iter first, _Iter last) { auto diff = std::distance(first, last); resize((size_type)diff); auto data = begin(); while (first != last) (*data++) = (*first++); }
|
||||
|
||||
inline void clear() { destroy(); size_ = capacity_ = 0; data_ = nullptr; }
|
||||
inline void swap(Array& rhs) { std::swap(size_, rhs.size_); std::swap(capacity_, rhs.capacity_); std::swap(data_, rhs.data_); }
|
||||
inline void swap(Array& rhs) noexcept { std::swap(size_, rhs.size_); std::swap(capacity_, rhs.capacity_); std::swap(data_, rhs.data_); }
|
||||
|
||||
inline void resize(size_type new_size) { resize(new_size, _Ty()); }
|
||||
inline void resize(size_type new_size, const _Ty& v);
|
||||
|
|
@ -215,7 +208,7 @@ namespace kiwano
|
|||
struct __ArrayManager<_Ty, _Alloc, false>
|
||||
{
|
||||
using value_type = _Ty;
|
||||
using size_type = int;
|
||||
using size_type = size_t;
|
||||
using allocator_type = typename _Alloc;
|
||||
|
||||
static inline void copy_data(value_type* dest, const value_type* src, size_type count) { if (src == dest) return; ::memcpy(dest, src, (size_t)count * sizeof(value_type)); }
|
||||
|
|
@ -244,7 +237,7 @@ namespace kiwano
|
|||
struct __ArrayManager<_Ty, _Alloc, true>
|
||||
{
|
||||
using value_type = _Ty;
|
||||
using size_type = int;
|
||||
using size_type = size_t;
|
||||
using allocator_type = typename _Alloc;
|
||||
|
||||
static inline void copy_data(value_type* dest, const value_type* src, size_type count) { if (src == dest) return; while (count--) (*dest++) = (*src++); }
|
||||
|
|
|
|||
|
|
@ -39,7 +39,9 @@ namespace kiwano
|
|||
};
|
||||
|
||||
// ComPtr<> is a smart pointer for COM
|
||||
template <typename _Ty>
|
||||
using ComPtr = IntrusivePtr<_Ty, ComPtrManager, ::std::is_base_of<IUnknown, _Ty>::value>;
|
||||
template<
|
||||
typename _Ty,
|
||||
typename = typename std::enable_if<std::is_base_of<IUnknown, _Ty>::value, int>::type>
|
||||
using ComPtr = IntrusivePtr<_Ty, ComPtrManager>;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,65 +25,55 @@
|
|||
|
||||
namespace kiwano
|
||||
{
|
||||
template <typename _Ty, typename _Manager, bool _Enable>
|
||||
class IntrusivePtr;
|
||||
|
||||
template <typename _Ty, typename _Manager>
|
||||
class IntrusivePtr<_Ty, _Manager, false>;
|
||||
|
||||
|
||||
template <typename _Ty, typename _Manager>
|
||||
using RealIntrusivePtr = IntrusivePtr<_Ty, _Manager, true>;
|
||||
|
||||
template <typename _Ty, typename _Manager>
|
||||
class IntrusivePtr<_Ty, _Manager, true>
|
||||
class IntrusivePtr
|
||||
{
|
||||
_Ty* ptr_{ nullptr };
|
||||
|
||||
public:
|
||||
using Type = _Ty;
|
||||
|
||||
IntrusivePtr() KGE_NOEXCEPT {}
|
||||
IntrusivePtr() noexcept {}
|
||||
|
||||
IntrusivePtr(nullptr_t) KGE_NOEXCEPT {}
|
||||
IntrusivePtr(nullptr_t) noexcept {}
|
||||
|
||||
IntrusivePtr(Type* p) KGE_NOEXCEPT : ptr_(p)
|
||||
IntrusivePtr(Type* p) noexcept : ptr_(p)
|
||||
{
|
||||
typename _Manager::AddRef(ptr_);
|
||||
}
|
||||
|
||||
IntrusivePtr(const IntrusivePtr& other) KGE_NOEXCEPT
|
||||
IntrusivePtr(const IntrusivePtr& other) noexcept
|
||||
: ptr_(other.ptr_)
|
||||
{
|
||||
typename _Manager::AddRef(ptr_);
|
||||
}
|
||||
|
||||
template <typename _UTy>
|
||||
IntrusivePtr(const RealIntrusivePtr<_UTy, _Manager>& other) KGE_NOEXCEPT
|
||||
IntrusivePtr(const IntrusivePtr<_UTy, _Manager>& other) noexcept
|
||||
: ptr_(other.Get())
|
||||
{
|
||||
typename _Manager::AddRef(ptr_);
|
||||
}
|
||||
|
||||
IntrusivePtr(IntrusivePtr&& other) KGE_NOEXCEPT
|
||||
IntrusivePtr(IntrusivePtr&& other) noexcept
|
||||
{
|
||||
ptr_ = other.ptr_;
|
||||
other.ptr_ = nullptr;
|
||||
}
|
||||
|
||||
~IntrusivePtr() KGE_NOEXCEPT
|
||||
~IntrusivePtr() noexcept
|
||||
{
|
||||
typename _Manager::Release(ptr_);
|
||||
}
|
||||
|
||||
inline Type* Get() const KGE_NOEXCEPT { return ptr_; }
|
||||
inline Type* Get() const noexcept { return ptr_; }
|
||||
|
||||
inline void Reset() KGE_NOEXCEPT
|
||||
inline void Reset() noexcept
|
||||
{
|
||||
IntrusivePtr{}.Swap(*this);
|
||||
}
|
||||
|
||||
inline void Swap(IntrusivePtr& other) KGE_NOEXCEPT
|
||||
inline void Swap(IntrusivePtr& other) noexcept
|
||||
{
|
||||
std::swap(ptr_, other.ptr_);
|
||||
}
|
||||
|
|
@ -106,18 +96,18 @@ namespace kiwano
|
|||
return &ptr_;
|
||||
}
|
||||
|
||||
inline operator bool() const KGE_NOEXCEPT { return ptr_ != nullptr; }
|
||||
inline operator bool() const noexcept { return ptr_ != nullptr; }
|
||||
|
||||
inline bool operator !() const KGE_NOEXCEPT { return ptr_ == 0; }
|
||||
inline bool operator !() const noexcept { return ptr_ == 0; }
|
||||
|
||||
inline IntrusivePtr& operator =(const IntrusivePtr& other) KGE_NOEXCEPT
|
||||
inline IntrusivePtr& operator =(const IntrusivePtr& other) noexcept
|
||||
{
|
||||
if (other.ptr_ != ptr_)
|
||||
IntrusivePtr(other).Swap(*this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline IntrusivePtr& operator =(IntrusivePtr&& other) KGE_NOEXCEPT
|
||||
inline IntrusivePtr& operator =(IntrusivePtr&& other) noexcept
|
||||
{
|
||||
typename _Manager::Release(ptr_);
|
||||
ptr_ = other.ptr_;
|
||||
|
|
@ -125,14 +115,14 @@ namespace kiwano
|
|||
return *this;
|
||||
}
|
||||
|
||||
inline IntrusivePtr& operator =(Type* p) KGE_NOEXCEPT
|
||||
inline IntrusivePtr& operator =(Type* p) noexcept
|
||||
{
|
||||
if (p != ptr_)
|
||||
IntrusivePtr(p).Swap(*this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline IntrusivePtr& operator =(nullptr_t) KGE_NOEXCEPT
|
||||
inline IntrusivePtr& operator =(nullptr_t) noexcept
|
||||
{
|
||||
if (nullptr != ptr_)
|
||||
IntrusivePtr{}.Swap(*this);
|
||||
|
|
@ -141,67 +131,67 @@ namespace kiwano
|
|||
};
|
||||
|
||||
template <class _Ty, class _UTy, class _Manager>
|
||||
inline bool operator==(RealIntrusivePtr<_Ty, _Manager> const& lhs, RealIntrusivePtr<_UTy, _Manager> const& rhs) KGE_NOEXCEPT
|
||||
inline bool operator==(IntrusivePtr<_Ty, _Manager> const& lhs, IntrusivePtr<_UTy, _Manager> const& rhs) noexcept
|
||||
{
|
||||
return lhs.Get() == rhs.Get();
|
||||
}
|
||||
|
||||
template <class _Ty, class _UTy, class _Manager>
|
||||
inline bool operator!=(RealIntrusivePtr<_Ty, _Manager> const& lhs, RealIntrusivePtr<_UTy, _Manager> const& rhs) KGE_NOEXCEPT
|
||||
inline bool operator!=(IntrusivePtr<_Ty, _Manager> const& lhs, IntrusivePtr<_UTy, _Manager> const& rhs) noexcept
|
||||
{
|
||||
return lhs.Get() != rhs.Get();
|
||||
}
|
||||
|
||||
template <class _Ty, class _UTy, class _Manager>
|
||||
inline bool operator<(RealIntrusivePtr<_Ty, _Manager> const& lhs, RealIntrusivePtr<_UTy, _Manager> const& rhs) KGE_NOEXCEPT
|
||||
inline bool operator<(IntrusivePtr<_Ty, _Manager> const& lhs, IntrusivePtr<_UTy, _Manager> const& rhs) noexcept
|
||||
{
|
||||
return lhs.Get() < rhs.Get();
|
||||
}
|
||||
|
||||
template <class _Ty, class _Manager>
|
||||
inline bool operator==(RealIntrusivePtr<_Ty, _Manager> const& lhs, _Ty* rhs) KGE_NOEXCEPT
|
||||
inline bool operator==(IntrusivePtr<_Ty, _Manager> const& lhs, _Ty* rhs) noexcept
|
||||
{
|
||||
return lhs.Get() == rhs;
|
||||
}
|
||||
|
||||
template <class _Ty, class _Manager>
|
||||
inline bool operator!=(RealIntrusivePtr<_Ty, _Manager> const& lhs, _Ty* rhs) KGE_NOEXCEPT
|
||||
inline bool operator!=(IntrusivePtr<_Ty, _Manager> const& lhs, _Ty* rhs) noexcept
|
||||
{
|
||||
return lhs.Get() != rhs;
|
||||
}
|
||||
|
||||
template <class _Ty, class _Manager>
|
||||
inline bool operator==(_Ty* lhs, RealIntrusivePtr<_Ty, _Manager> const& rhs) KGE_NOEXCEPT
|
||||
inline bool operator==(_Ty* lhs, IntrusivePtr<_Ty, _Manager> const& rhs) noexcept
|
||||
{
|
||||
return lhs == rhs.Get();
|
||||
}
|
||||
|
||||
template <class _Ty, class _Manager>
|
||||
inline bool operator!=(_Ty* lhs, RealIntrusivePtr<_Ty, _Manager> const& rhs) KGE_NOEXCEPT
|
||||
inline bool operator!=(_Ty* lhs, IntrusivePtr<_Ty, _Manager> const& rhs) noexcept
|
||||
{
|
||||
return lhs != rhs.Get();
|
||||
}
|
||||
|
||||
template <class _Ty, class _Manager>
|
||||
inline bool operator==(RealIntrusivePtr<_Ty, _Manager> const& lhs, nullptr_t) KGE_NOEXCEPT
|
||||
inline bool operator==(IntrusivePtr<_Ty, _Manager> const& lhs, nullptr_t) noexcept
|
||||
{
|
||||
return !static_cast<bool>(lhs);
|
||||
}
|
||||
|
||||
template <class _Ty, class _Manager>
|
||||
inline bool operator!=(RealIntrusivePtr<_Ty, _Manager> const& lhs, nullptr_t) KGE_NOEXCEPT
|
||||
inline bool operator!=(IntrusivePtr<_Ty, _Manager> const& lhs, nullptr_t) noexcept
|
||||
{
|
||||
return static_cast<bool>(lhs);
|
||||
}
|
||||
|
||||
template <class _Ty, class _Manager>
|
||||
inline bool operator==(nullptr_t, RealIntrusivePtr<_Ty, _Manager> const& rhs) KGE_NOEXCEPT
|
||||
inline bool operator==(nullptr_t, IntrusivePtr<_Ty, _Manager> const& rhs) noexcept
|
||||
{
|
||||
return !static_cast<bool>(rhs);
|
||||
}
|
||||
|
||||
template <class _Ty, class _Manager>
|
||||
inline bool operator!=(nullptr_t, RealIntrusivePtr<_Ty, _Manager> const& rhs) KGE_NOEXCEPT
|
||||
inline bool operator!=(nullptr_t, IntrusivePtr<_Ty, _Manager> const& rhs) noexcept
|
||||
{
|
||||
return static_cast<bool>(rhs);
|
||||
}
|
||||
|
|
@ -209,7 +199,7 @@ namespace kiwano
|
|||
// template class cannot specialize std::swap,
|
||||
// so implement a swap function in kiwano namespace
|
||||
template <class _Ty, class _Manager>
|
||||
inline void swap(RealIntrusivePtr<_Ty, _Manager>& lhs, RealIntrusivePtr<_Ty, _Manager>& rhs) KGE_NOEXCEPT
|
||||
inline void swap(IntrusivePtr<_Ty, _Manager>& lhs, IntrusivePtr<_Ty, _Manager>& rhs) noexcept
|
||||
{
|
||||
lhs.Swap(rhs);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -363,7 +363,7 @@ namespace kiwano
|
|||
{
|
||||
using difference_type = std::ptrdiff_t;
|
||||
|
||||
inline primitive_iterator(int it = 0) : it_(it) {}
|
||||
inline primitive_iterator(difference_type it = 0) : it_(it) {}
|
||||
|
||||
inline void set_begin() { it_ = 0; }
|
||||
inline void set_end() { it_ = 1; }
|
||||
|
|
@ -392,7 +392,7 @@ namespace kiwano
|
|||
inline bool operator>=(primitive_iterator const& other) const { return it_ >= other.it_; }
|
||||
|
||||
private:
|
||||
int it_;
|
||||
difference_type it_;
|
||||
};
|
||||
|
||||
template <typename _BasicJsonTy>
|
||||
|
|
|
|||
|
|
@ -106,7 +106,7 @@ namespace kiwano
|
|||
String(std::wstring const& str);
|
||||
String(String const& rhs);
|
||||
String(String const& rhs, size_type pos, size_type count = npos);
|
||||
String(String && rhs);
|
||||
String(String && rhs) noexcept;
|
||||
~String();
|
||||
|
||||
template <typename _Iter>
|
||||
|
|
@ -191,7 +191,7 @@ namespace kiwano
|
|||
std::string to_string() const;
|
||||
std::wstring to_wstring() const;
|
||||
|
||||
void swap(String& rhs);
|
||||
void swap(String& rhs) noexcept;
|
||||
size_t hash() const;
|
||||
|
||||
public:
|
||||
|
|
@ -245,7 +245,7 @@ namespace kiwano
|
|||
inline String& operator=(const wchar_t* cstr) { if (const_str_ != cstr) String{ cstr }.swap(*this); return *this; }
|
||||
inline String& operator=(std::wstring const& str) { String{ str }.swap(*this); return *this; }
|
||||
inline String& operator=(String const& rhs) { if (this != &rhs) String{ rhs }.swap(*this); return *this; }
|
||||
inline String& operator=(String && rhs) { if (this != &rhs) String{ rhs }.swap(*this); return *this; }
|
||||
inline String& operator=(String && rhs) noexcept { if (this != &rhs) String{ rhs }.swap(*this); return *this; }
|
||||
|
||||
public:
|
||||
static const String::size_type npos = static_cast<size_type>(-1);
|
||||
|
|
@ -537,7 +537,7 @@ namespace kiwano
|
|||
assign(rhs, pos, count);
|
||||
}
|
||||
|
||||
inline String::String(String && rhs)
|
||||
inline String::String(String && rhs) noexcept
|
||||
: str_(rhs.str_)
|
||||
, size_(rhs.size_)
|
||||
, capacity_(rhs.capacity_)
|
||||
|
|
@ -1074,7 +1074,7 @@ namespace kiwano
|
|||
size_ = capacity_ = 0;
|
||||
}
|
||||
|
||||
inline void String::swap(String & rhs)
|
||||
inline void String::swap(String & rhs) noexcept
|
||||
{
|
||||
std::swap(const_str_, rhs.const_str_);
|
||||
std::swap(size_, rhs.size_);
|
||||
|
|
|
|||
|
|
@ -29,6 +29,43 @@ namespace kiwano
|
|||
|
||||
namespace __closure_detail
|
||||
{
|
||||
//
|
||||
// is_callable
|
||||
//
|
||||
|
||||
namespace __callable_detail
|
||||
{
|
||||
template <typename _Ty, typename _Ret, typename... _Args>
|
||||
struct helper
|
||||
{
|
||||
template <typename _Uty> static int test(...);
|
||||
|
||||
template <typename _Uty, _Ret(_Uty::*)(_Args...)> struct class_mem;
|
||||
template <typename _Uty> static char test(class_mem<_Uty, &_Uty::operator()>*);
|
||||
|
||||
template <typename _Uty, _Ret(_Uty::*)(_Args...) const> struct class_const_mem;
|
||||
template <typename _Uty> static char test(class_const_mem<_Uty, &_Uty::operator()>*);
|
||||
|
||||
template<
|
||||
typename _Uty,
|
||||
typename _Uret = typename std::decay<decltype(std::declval<_Uty>().operator()(std::declval<_Args>()...))>::type,
|
||||
typename = typename std::enable_if<std::is_convertible<_Ret, _Uret>::value>::type>
|
||||
static char test(int);
|
||||
|
||||
static constexpr bool value = sizeof(test<_Ty>(0)) == sizeof(char);
|
||||
};
|
||||
}
|
||||
|
||||
template<typename _Ty, typename _Ret, typename... _Args>
|
||||
struct is_callable
|
||||
: public std::bool_constant<__callable_detail::helper<_Ty, _Ret, _Args...>::value>
|
||||
{
|
||||
};
|
||||
|
||||
//
|
||||
// Callable
|
||||
//
|
||||
|
||||
template<typename _Ret, typename... _Args>
|
||||
class Callable
|
||||
{
|
||||
|
|
@ -195,7 +232,15 @@ namespace kiwano
|
|||
rhs.callable_ = nullptr;
|
||||
}
|
||||
|
||||
template <typename _Ty>
|
||||
Closure(_Ret(*func)(_Args...))
|
||||
{
|
||||
callable_ = __closure_detail::ProxyCallable<_Ret(*)(_Args...), _Ret, _Args...>::Make(std::move(func));
|
||||
if (callable_) callable_->AddRef();
|
||||
}
|
||||
|
||||
template<
|
||||
typename _Ty,
|
||||
typename = typename std::enable_if<__closure_detail::is_callable<_Ty, _Ret, _Args...>::value, int>::type>
|
||||
Closure(_Ty val)
|
||||
{
|
||||
callable_ = __closure_detail::ProxyCallable<_Ty, _Ret, _Args...>::Make(std::move(val));
|
||||
|
|
@ -204,7 +249,7 @@ namespace kiwano
|
|||
|
||||
template<typename _Ty,
|
||||
typename _Uty,
|
||||
typename std::enable_if<std::is_same<_Ty, _Uty>::value || std::is_base_of<_Ty, _Uty>::value, int>::type = 0>
|
||||
typename = typename std::enable_if<std::is_same<_Ty, _Uty>::value || std::is_base_of<_Ty, _Uty>::value, int>::type>
|
||||
Closure(_Uty* ptr, _Ret(_Ty::* func)(_Args...))
|
||||
{
|
||||
callable_ = __closure_detail::ProxyMemCallable<_Ty, _Ret, _Args...>::Make(ptr, func);
|
||||
|
|
@ -213,7 +258,7 @@ namespace kiwano
|
|||
|
||||
template<typename _Ty,
|
||||
typename _Uty,
|
||||
typename std::enable_if<std::is_same<_Ty, _Uty>::value || std::is_base_of<_Ty, _Uty>::value, int>::type = 0>
|
||||
typename = typename std::enable_if<std::is_same<_Ty, _Uty>::value || std::is_base_of<_Ty, _Uty>::value, int>::type>
|
||||
Closure(_Uty* ptr, _Ret(_Ty::* func)(_Args...) const)
|
||||
{
|
||||
callable_ = __closure_detail::ProxyConstMemCallable<_Ty, _Ret, _Args...>::Make(ptr, func);
|
||||
|
|
@ -274,9 +319,9 @@ namespace kiwano
|
|||
|
||||
template<typename _Ty,
|
||||
typename _Uty,
|
||||
typename std::enable_if<
|
||||
typename = typename std::enable_if<
|
||||
std::is_same<_Ty, _Uty>::value || std::is_base_of<_Ty, _Uty>::value, int
|
||||
>::type = 0,
|
||||
>::type,
|
||||
typename _Ret,
|
||||
typename... _Args>
|
||||
inline Closure<_Ret(_Args...)> MakeClosure(_Uty* ptr, _Ret(_Ty::* func)(_Args...))
|
||||
|
|
@ -286,9 +331,9 @@ namespace kiwano
|
|||
|
||||
template<typename _Ty,
|
||||
typename _Uty,
|
||||
typename std::enable_if<
|
||||
typename = typename std::enable_if<
|
||||
std::is_same<_Ty, _Uty>::value || std::is_base_of<_Ty, _Uty>::value, int
|
||||
>::type = 0,
|
||||
>::type,
|
||||
typename _Ret,
|
||||
typename... _Args>
|
||||
inline Closure<_Ret(_Args...)> MakeClosure(_Uty* ptr, _Ret(_Ty::* func)(_Args...) const)
|
||||
|
|
|
|||
|
|
@ -33,10 +33,11 @@
|
|||
# define VS_2013 1800
|
||||
# define VS_2015 1900
|
||||
# define VS_2017 1900
|
||||
# define VS_2019 1920
|
||||
#endif
|
||||
|
||||
#if VS_VER < VS_2013
|
||||
# error Kiwano only supports Visual Studio 2013 and above
|
||||
#if VS_VER < VS_2015
|
||||
# error Kiwano only supports Visual Studio 2015 and above
|
||||
#endif
|
||||
|
||||
#ifndef WINVER
|
||||
|
|
@ -84,15 +85,6 @@
|
|||
#endif
|
||||
|
||||
|
||||
#if VS_VER >= VS_2015
|
||||
# define KGE_NOEXCEPT noexcept
|
||||
# define KGE_CONSTEXPR constexpr
|
||||
#else
|
||||
# define KGE_NOEXCEPT throw()
|
||||
# define KGE_CONSTEXPR const
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef KGE_ASSERT
|
||||
# ifdef KGE_DEBUG
|
||||
# define KGE_ASSERT(EXPR) assert(EXPR)
|
||||
|
|
|
|||
|
|
@ -27,43 +27,49 @@ namespace kiwano
|
|||
{
|
||||
namespace math
|
||||
{
|
||||
struct Matrix
|
||||
template <typename _Ty, typename _Lty, typename _Rty>
|
||||
struct MatrixMultiply;
|
||||
|
||||
template <typename _Ty>
|
||||
struct MatrixT
|
||||
{
|
||||
using value_type = _Ty;
|
||||
|
||||
union
|
||||
{
|
||||
struct
|
||||
{
|
||||
float m[6]; // m[3][2]
|
||||
_Ty m[6]; // m[3][2]
|
||||
};
|
||||
|
||||
struct
|
||||
{
|
||||
float
|
||||
_Ty
|
||||
_11, _12,
|
||||
_21, _22,
|
||||
_31, _32;
|
||||
};
|
||||
};
|
||||
|
||||
Matrix()
|
||||
MatrixT()
|
||||
: _11(1.f), _12(0.f)
|
||||
, _21(0.f), _22(1.f)
|
||||
, _31(0.f), _32(0.f)
|
||||
{
|
||||
}
|
||||
|
||||
Matrix(float _11, float _12, float _21, float _22, float _31, float _32)
|
||||
MatrixT(value_type _11, value_type _12, value_type _21, value_type _22, value_type _31, value_type _32)
|
||||
: _11(_11), _12(_12), _21(_21), _22(_22), _31(_31), _32(_32)
|
||||
{
|
||||
}
|
||||
|
||||
explicit Matrix(const float* p)
|
||||
explicit MatrixT(const value_type* p)
|
||||
{
|
||||
for (int i = 0; i < 6; i++)
|
||||
m[i] = p[i];
|
||||
}
|
||||
|
||||
Matrix(Matrix const& other)
|
||||
MatrixT(MatrixT const& other)
|
||||
: _11(other._11), _12(other._12)
|
||||
, _21(other._21), _22(other._22)
|
||||
, _31(other._31), _32(other._32)
|
||||
|
|
@ -71,7 +77,7 @@ namespace kiwano
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
Matrix(T const& other)
|
||||
MatrixT(T const& other)
|
||||
{
|
||||
for (int i = 0; i < 6; i++)
|
||||
m[i] = other[i];
|
||||
|
|
@ -92,17 +98,17 @@ namespace kiwano
|
|||
);
|
||||
}
|
||||
|
||||
Rect Transform(const Rect & rect) const
|
||||
RectT<value_type> Transform(const Rect & rect) const
|
||||
{
|
||||
Vec2 top_left = Transform(rect.GetLeftTop());
|
||||
Vec2 top_right = Transform(rect.GetRightTop());
|
||||
Vec2 bottom_left = Transform(rect.GetLeftBottom());
|
||||
Vec2 bottom_right = Transform(rect.GetRightBottom());
|
||||
Vec2T<value_type> top_left = Transform(rect.GetLeftTop());
|
||||
Vec2T<value_type> top_right = Transform(rect.GetRightTop());
|
||||
Vec2T<value_type> bottom_left = Transform(rect.GetLeftBottom());
|
||||
Vec2T<value_type> bottom_right = Transform(rect.GetRightBottom());
|
||||
|
||||
float left = std::min(std::min(top_left.x, top_right.x), std::min(bottom_left.x, bottom_right.x));
|
||||
float right = std::max(std::max(top_left.x, top_right.x), std::max(bottom_left.x, bottom_right.x));
|
||||
float top = std::min(std::min(top_left.y, top_right.y), std::min(bottom_left.y, bottom_right.y));
|
||||
float bottom = std::max(std::max(top_left.y, top_right.y), std::max(bottom_left.y, bottom_right.y));
|
||||
value_type left = std::min(std::min(top_left.x, top_right.x), std::min(bottom_left.x, bottom_right.x));
|
||||
value_type right = std::max(std::max(top_left.x, top_right.x), std::max(bottom_left.x, bottom_right.x));
|
||||
value_type top = std::min(std::min(top_left.y, top_right.y), std::min(bottom_left.y, bottom_right.y));
|
||||
value_type bottom = std::max(std::max(top_left.y, top_right.y), std::max(bottom_left.y, bottom_right.y));
|
||||
|
||||
return Rect{ left, top, (right - left), (bottom - top) };
|
||||
}
|
||||
|
|
@ -113,20 +119,20 @@ namespace kiwano
|
|||
_32 += _12 * v.x + _22 * v.y;
|
||||
}
|
||||
|
||||
inline float operator [](unsigned int index) const
|
||||
inline value_type operator [](unsigned int index) const
|
||||
{
|
||||
return m[index];
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline Matrix& operator =(T const& other)
|
||||
template <typename _Lty, typename _Rty>
|
||||
inline MatrixT& operator= (MatrixMultiply<value_type, _Lty, _Rty> const& other)
|
||||
{
|
||||
for (int i = 0; i < 6; i++)
|
||||
m[i] = other[i];
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline float Determinant() const
|
||||
inline value_type Determinant() const
|
||||
{
|
||||
return (_11 * _22) - (_12 * _21);
|
||||
}
|
||||
|
|
@ -143,27 +149,27 @@ namespace kiwano
|
|||
return 0 != Determinant();
|
||||
}
|
||||
|
||||
static inline Matrix Translation(const Vec2& v)
|
||||
static inline MatrixT Translation(const Vec2& v)
|
||||
{
|
||||
return Matrix(
|
||||
return MatrixT(
|
||||
1.f, 0.f,
|
||||
0.f, 1.f,
|
||||
v.x, v.y
|
||||
);
|
||||
}
|
||||
|
||||
static inline Matrix Translation(
|
||||
float x,
|
||||
float y)
|
||||
static inline MatrixT Translation(
|
||||
value_type x,
|
||||
value_type y)
|
||||
{
|
||||
return Translation(Vec2(x, y));
|
||||
}
|
||||
|
||||
static inline Matrix Scaling(
|
||||
static inline MatrixT Scaling(
|
||||
const Vec2& v,
|
||||
const Vec2& center = Vec2())
|
||||
{
|
||||
return Matrix(
|
||||
return MatrixT(
|
||||
v.x, 0.f,
|
||||
0.f, v.y,
|
||||
center.x - v.x * center.x,
|
||||
|
|
@ -171,21 +177,21 @@ namespace kiwano
|
|||
);
|
||||
}
|
||||
|
||||
static inline Matrix Scaling(
|
||||
float x,
|
||||
float y,
|
||||
static inline MatrixT Scaling(
|
||||
value_type x,
|
||||
value_type y,
|
||||
const Vec2& center = Vec2())
|
||||
{
|
||||
return Scaling(Vec2(x, y), center);
|
||||
}
|
||||
|
||||
static inline Matrix Rotation(
|
||||
float angle,
|
||||
static inline MatrixT Rotation(
|
||||
value_type angle,
|
||||
const Vec2& center = Vec2())
|
||||
{
|
||||
float s = math::Sin(angle);
|
||||
float c = math::Cos(angle);
|
||||
return Matrix(
|
||||
value_type s = math::Sin(angle);
|
||||
value_type c = math::Cos(angle);
|
||||
return MatrixT(
|
||||
c, s,
|
||||
-s, c,
|
||||
center.x * (1 - c) + center.y * s,
|
||||
|
|
@ -193,25 +199,25 @@ namespace kiwano
|
|||
);
|
||||
}
|
||||
|
||||
static inline Matrix Skewing(
|
||||
float angle_x,
|
||||
float angle_y,
|
||||
static inline MatrixT Skewing(
|
||||
value_type angle_x,
|
||||
value_type angle_y,
|
||||
const Vec2& center = Vec2())
|
||||
{
|
||||
float tx = math::Tan(angle_x);
|
||||
float ty = math::Tan(angle_y);
|
||||
return Matrix(
|
||||
value_type tx = math::Tan(angle_x);
|
||||
value_type ty = math::Tan(angle_y);
|
||||
return MatrixT(
|
||||
1.f, -ty,
|
||||
-tx, 1.f,
|
||||
center.y * tx, center.x * ty
|
||||
);
|
||||
}
|
||||
|
||||
static inline Matrix Invert(Matrix const& matrix)
|
||||
static inline MatrixT Invert(MatrixT const& matrix)
|
||||
{
|
||||
float det = 1.f / matrix.Determinant();
|
||||
value_type det = 1.f / matrix.Determinant();
|
||||
|
||||
return Matrix(
|
||||
return MatrixT(
|
||||
det * matrix._22,
|
||||
-det * matrix._12,
|
||||
-det * matrix._21,
|
||||
|
|
@ -224,18 +230,18 @@ namespace kiwano
|
|||
|
||||
|
||||
// Use template expression to optimize matrix multiply
|
||||
template <typename L, typename R>
|
||||
template <typename _Ty, typename _Lty, typename _Rty>
|
||||
struct MatrixMultiply
|
||||
{
|
||||
L const& lhs;
|
||||
R const& rhs;
|
||||
_Lty const& lhs;
|
||||
_Rty const& rhs;
|
||||
|
||||
MatrixMultiply(L const& lhs, R const& rhs)
|
||||
MatrixMultiply(_Lty const& lhs, _Rty const& rhs)
|
||||
: lhs(lhs)
|
||||
, rhs(rhs)
|
||||
{}
|
||||
|
||||
inline float operator [](unsigned int index) const
|
||||
inline _Ty operator [](unsigned int index) const
|
||||
{
|
||||
switch (index)
|
||||
{
|
||||
|
|
@ -257,15 +263,25 @@ namespace kiwano
|
|||
}
|
||||
};
|
||||
|
||||
inline MatrixMultiply<Matrix, Matrix> operator *(Matrix const& lhs, Matrix const& rhs)
|
||||
template <typename _Ty>
|
||||
inline
|
||||
MatrixMultiply<_Ty, MatrixT<_Ty>, MatrixT<_Ty>>
|
||||
operator *(MatrixT<_Ty> const& lhs, MatrixT<_Ty> const& rhs)
|
||||
{
|
||||
return MatrixMultiply<Matrix, Matrix>(lhs, rhs);
|
||||
return MatrixMultiply<_Ty, MatrixT<_Ty>, MatrixT<_Ty>>(lhs, rhs);
|
||||
}
|
||||
|
||||
template <typename L, typename R>
|
||||
inline MatrixMultiply<MatrixMultiply<L, R>, Matrix> operator *(MatrixMultiply<L, R> const& lhs, Matrix const& rhs)
|
||||
template <typename _Ty, typename _Lty, typename _Rty>
|
||||
inline
|
||||
MatrixMultiply<_Ty, MatrixMultiply<_Ty, _Lty, _Rty>, MatrixT<_Ty>>
|
||||
operator *(MatrixMultiply<_Ty, _Lty, _Rty> const& lhs, MatrixT<_Ty> const& rhs)
|
||||
{
|
||||
return MatrixMultiply<MatrixMultiply<L, R>, Matrix>(lhs, rhs);
|
||||
return MatrixMultiply<_Ty, MatrixMultiply<_Ty, _Lty, _Rty>, MatrixT<_Ty>>(lhs, rhs);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
namespace kiwano
|
||||
{
|
||||
using Matrix = kiwano::math::MatrixT<float>;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,24 +26,29 @@ namespace kiwano
|
|||
namespace math
|
||||
{
|
||||
// 矩形
|
||||
struct Rect
|
||||
template <typename _Ty>
|
||||
struct RectT
|
||||
{
|
||||
Vec2 origin; // ×óÉϽÇ×ø±ê
|
||||
Vec2 size; // ¿í¶ÈºÍ¸ß¶È
|
||||
public:
|
||||
using value_type = _Ty;
|
||||
|
||||
Rect() {}
|
||||
Vec2T<value_type> origin; // ×óÉϽÇ×ø±ê
|
||||
Vec2T<value_type> size; // ¿í¶ÈºÍ¸ß¶È
|
||||
|
||||
Rect(
|
||||
float x,
|
||||
float y,
|
||||
float width,
|
||||
float height
|
||||
public:
|
||||
RectT() {}
|
||||
|
||||
RectT(
|
||||
value_type x,
|
||||
value_type y,
|
||||
value_type width,
|
||||
value_type height
|
||||
)
|
||||
: origin(x, y)
|
||||
, size(width, height)
|
||||
{}
|
||||
|
||||
Rect(
|
||||
RectT(
|
||||
const Vec2& pos,
|
||||
const Vec2& size
|
||||
)
|
||||
|
|
@ -51,26 +56,26 @@ namespace kiwano
|
|||
, size(size.x, size.y)
|
||||
{}
|
||||
|
||||
Rect(
|
||||
const Rect& other
|
||||
RectT(
|
||||
const RectT& other
|
||||
)
|
||||
: origin(other.origin.x, other.origin.y)
|
||||
, size(other.size.x, other.size.y)
|
||||
{}
|
||||
|
||||
Rect& operator= (const Rect& other)
|
||||
RectT& operator= (const RectT& other)
|
||||
{
|
||||
origin = other.origin;
|
||||
size = other.size;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline bool operator== (const Rect& rect) const
|
||||
inline bool operator== (const RectT& rect) const
|
||||
{
|
||||
return (origin == rect.origin) && (size == rect.size);
|
||||
}
|
||||
|
||||
inline void Set(float x, float y, float width, float height) { origin = Vec2{ x, y }; size = Vec2{ width, height }; }
|
||||
inline void Set(value_type x, value_type y, value_type width, value_type height) { origin = Vec2{ x, y }; size = Vec2{ width, height }; }
|
||||
|
||||
inline Vec2 GetCenter() const { return Vec2{ origin.x + size.x / 2, origin.y + size.y / 2 }; }
|
||||
|
||||
|
|
@ -82,13 +87,13 @@ namespace kiwano
|
|||
|
||||
inline Vec2 GetLeftBottom() const { return Vec2{ GetLeft(), GetBottom() }; }
|
||||
|
||||
inline float GetLeft() const { return origin.x; }
|
||||
inline value_type GetLeft() const { return origin.x; }
|
||||
|
||||
inline float GetTop() const { return origin.y; }
|
||||
inline value_type GetTop() const { return origin.y; }
|
||||
|
||||
inline float GetRight() const { return origin.x + size.x; }
|
||||
inline value_type GetRight() const { return origin.x + size.x; }
|
||||
|
||||
inline float GetBottom() const { return origin.y + size.y; }
|
||||
inline value_type GetBottom() const { return origin.y + size.y; }
|
||||
|
||||
inline bool IsEmpty() const { return origin.IsOrigin() && size.IsOrigin(); }
|
||||
|
||||
|
|
@ -100,7 +105,7 @@ namespace kiwano
|
|||
}
|
||||
|
||||
// 判断两矩形是否相交
|
||||
inline bool Intersects(const Rect& rect) const
|
||||
inline bool Intersects(const RectT& rect) const
|
||||
{
|
||||
return !((origin.x + size.x) < rect.origin.x ||
|
||||
(rect.origin.x + rect.size.x) < origin.x ||
|
||||
|
|
@ -110,3 +115,8 @@ namespace kiwano
|
|||
};
|
||||
}
|
||||
}
|
||||
|
||||
namespace kiwano
|
||||
{
|
||||
using Rect = kiwano::math::RectT<float>;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,18 +25,21 @@ namespace kiwano
|
|||
{
|
||||
namespace math
|
||||
{
|
||||
struct Vec2
|
||||
template <typename _Ty>
|
||||
struct Vec2T
|
||||
{
|
||||
float x;
|
||||
float y;
|
||||
using value_type = _Ty;
|
||||
|
||||
Vec2() : x(0.f), y(0.f) {}
|
||||
value_type x;
|
||||
value_type y;
|
||||
|
||||
Vec2(float x, float y) : x(x), y(y) {}
|
||||
Vec2T() : x(0.f), y(0.f) {}
|
||||
|
||||
Vec2(const Vec2& other) : x(other.x), y(other.y) {}
|
||||
Vec2T(value_type x, value_type y) : x(x), y(y) {}
|
||||
|
||||
inline float Length() const
|
||||
Vec2T(const Vec2T& other) : x(other.x), y(other.y) {}
|
||||
|
||||
inline value_type Length() const
|
||||
{
|
||||
return math::Sqrt(x * x + y * y);
|
||||
}
|
||||
|
|
@ -46,46 +49,51 @@ namespace kiwano
|
|||
return (x == 0) && (y == 0);
|
||||
}
|
||||
|
||||
inline void Set(float x, float y)
|
||||
inline void Set(value_type x, value_type y)
|
||||
{
|
||||
this->x = x;
|
||||
this->y = y;
|
||||
}
|
||||
|
||||
inline const Vec2 operator + (const Vec2 & other) const
|
||||
inline const Vec2T operator + (const Vec2T & other) const
|
||||
{
|
||||
return Vec2(x + other.x, y + other.y);
|
||||
return Vec2T(x + other.x, y + other.y);
|
||||
}
|
||||
|
||||
inline const Vec2 operator - (const Vec2 & other) const
|
||||
inline const Vec2T operator - (const Vec2T & other) const
|
||||
{
|
||||
return Vec2(x - other.x, y - other.y);
|
||||
return Vec2T(x - other.x, y - other.y);
|
||||
}
|
||||
|
||||
inline const Vec2 operator * (float val) const
|
||||
inline const Vec2T operator * (value_type val) const
|
||||
{
|
||||
return Vec2(x * val, y * val);
|
||||
return Vec2T(x * val, y * val);
|
||||
}
|
||||
|
||||
inline const Vec2 operator / (float val) const
|
||||
inline const Vec2T operator / (value_type val) const
|
||||
{
|
||||
return Vec2(x / val, y / val);
|
||||
return Vec2T(x / val, y / val);
|
||||
}
|
||||
|
||||
inline const Vec2 operator - () const
|
||||
inline const Vec2T operator - () const
|
||||
{
|
||||
return Vec2(-x, -y);
|
||||
return Vec2T(-x, -y);
|
||||
}
|
||||
|
||||
inline bool operator== (const Vec2& other) const
|
||||
inline bool operator== (const Vec2T& other) const
|
||||
{
|
||||
return (x == other.x) && (y == other.y);
|
||||
}
|
||||
|
||||
inline bool operator!= (const Vec2& other) const
|
||||
inline bool operator!= (const Vec2T& other) const
|
||||
{
|
||||
return (x != other.x) || (y != other.y);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
namespace kiwano
|
||||
{
|
||||
using Vec2 = kiwano::math::Vec2T<float>;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,8 +28,6 @@
|
|||
|
||||
namespace kiwano
|
||||
{
|
||||
using namespace kiwano::math;
|
||||
|
||||
typedef Vec2 Point;
|
||||
typedef Vec2 Size;
|
||||
using Point = Vec2;
|
||||
using Size = Vec2;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -262,7 +262,7 @@ namespace kiwano
|
|||
::curl_global_cleanup();
|
||||
}
|
||||
|
||||
void HttpClient::Send(HttpRequestPtr const & request)
|
||||
void HttpClient::Send(HttpRequestPtr request)
|
||||
{
|
||||
if (!request)
|
||||
return;
|
||||
|
|
@ -300,7 +300,7 @@ namespace kiwano
|
|||
}
|
||||
}
|
||||
|
||||
void HttpClient::Perform(HttpRequestPtr const & request, HttpResponsePtr const & response)
|
||||
void HttpClient::Perform(HttpRequestPtr request, HttpResponsePtr response)
|
||||
{
|
||||
bool ok = false;
|
||||
long response_code = 0;
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ namespace kiwano
|
|||
|
||||
public:
|
||||
void Send(
|
||||
HttpRequestPtr const& request
|
||||
HttpRequestPtr request
|
||||
);
|
||||
|
||||
inline void SetTimeoutForConnect(Duration timeout)
|
||||
|
|
@ -78,8 +78,8 @@ namespace kiwano
|
|||
void NetworkThread();
|
||||
|
||||
void Perform(
|
||||
HttpRequestPtr const& request,
|
||||
HttpResponsePtr const& response
|
||||
HttpRequestPtr request,
|
||||
HttpResponsePtr response
|
||||
);
|
||||
|
||||
void DispatchResponseCallback();
|
||||
|
|
|
|||
|
|
@ -28,14 +28,14 @@ namespace kiwano
|
|||
: public Object
|
||||
{
|
||||
public:
|
||||
inline HttpResponse(HttpRequestPtr const& request)
|
||||
inline HttpResponse(HttpRequestPtr request)
|
||||
: request_(request)
|
||||
, succeed_(false)
|
||||
, response_code_(0)
|
||||
{
|
||||
}
|
||||
|
||||
inline HttpRequestPtr const& GetRequest() const
|
||||
inline HttpRequestPtr GetRequest() const
|
||||
{
|
||||
return request_;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -187,7 +187,7 @@ namespace kiwano
|
|||
}
|
||||
}
|
||||
|
||||
void Application::EnterScene(ScenePtr const & scene)
|
||||
void Application::EnterScene(ScenePtr scene)
|
||||
{
|
||||
KGE_ASSERT(scene && "Application::EnterScene failed, NULL pointer exception");
|
||||
|
||||
|
|
@ -197,7 +197,7 @@ namespace kiwano
|
|||
next_scene_ = scene;
|
||||
}
|
||||
|
||||
void Application::EnterScene(ScenePtr const& scene, TransitionPtr const& transition)
|
||||
void Application::EnterScene(ScenePtr scene, TransitionPtr transition)
|
||||
{
|
||||
EnterScene(scene);
|
||||
|
||||
|
|
@ -212,7 +212,7 @@ namespace kiwano
|
|||
}
|
||||
}
|
||||
|
||||
ScenePtr const& Application::GetCurrentScene()
|
||||
ScenePtr Application::GetCurrentScene()
|
||||
{
|
||||
return curr_scene_;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -105,17 +105,17 @@ namespace kiwano
|
|||
|
||||
// Çл»³¡¾°
|
||||
void EnterScene(
|
||||
ScenePtr const& scene /* 场景 */
|
||||
ScenePtr scene /* 场景 */
|
||||
);
|
||||
|
||||
// Çл»³¡¾°
|
||||
void EnterScene(
|
||||
ScenePtr const& scene, /* 场景 */
|
||||
TransitionPtr const& transition /* 场景动画 */
|
||||
ScenePtr scene, /* 场景 */
|
||||
TransitionPtr transition /* 场景动画 */
|
||||
);
|
||||
|
||||
// »ñÈ¡µ±Ç°³¡¾°
|
||||
ScenePtr const& GetCurrentScene();
|
||||
ScenePtr GetCurrentScene();
|
||||
|
||||
// »ñÈ¡Ö÷´°¿Ú
|
||||
inline Window* GetWindow() const { return main_window_; }
|
||||
|
|
|
|||
|
|
@ -38,17 +38,17 @@ namespace kiwano
|
|||
}
|
||||
}
|
||||
|
||||
inline D2D1_POINT_2F const& ConvertToPoint2F(math::Vec2 const& point)
|
||||
inline D2D1_POINT_2F const& ConvertToPoint2F(Vec2 const& point)
|
||||
{
|
||||
return reinterpret_cast<D2D1_POINT_2F const&>(point);
|
||||
}
|
||||
|
||||
inline D2D1_SIZE_F const& ConvertToSizeF(math::Vec2 const& size)
|
||||
inline D2D1_SIZE_F const& ConvertToSizeF(Vec2 const& size)
|
||||
{
|
||||
return reinterpret_cast<D2D1_SIZE_F const&>(size);
|
||||
}
|
||||
|
||||
inline D2D1_RECT_F ConvertToRectF(math::Rect const& rect)
|
||||
inline D2D1_RECT_F ConvertToRectF(Rect const& rect)
|
||||
{
|
||||
return D2D1_RECT_F{ rect.origin.x, rect.origin.y, rect.origin.x + rect.size.x, rect.origin.y + rect.size.y };
|
||||
}
|
||||
|
|
@ -58,7 +58,7 @@ namespace kiwano
|
|||
return reinterpret_cast<D2D1_COLOR_F const&>(color);
|
||||
}
|
||||
|
||||
inline D2D1_MATRIX_3X2_F const& ConvertToMatrix3x2F(math::Matrix const& matrix)
|
||||
inline D2D1_MATRIX_3X2_F const& ConvertToMatrix3x2F(Matrix const& matrix)
|
||||
{
|
||||
return reinterpret_cast<D2D1_MATRIX_3X2_F const&>(matrix);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -227,7 +227,7 @@ namespace kiwano
|
|||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT Renderer::DrawImage(ImagePtr const & image, Rect const& dest_rect)
|
||||
HRESULT Renderer::DrawImage(ImagePtr image, Rect const& dest_rect)
|
||||
{
|
||||
if (!device_context_)
|
||||
return E_UNEXPECTED;
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ namespace kiwano
|
|||
);
|
||||
|
||||
HRESULT DrawImage(
|
||||
ImagePtr const& image,
|
||||
ImagePtr image,
|
||||
Rect const& dest_rect
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -79,6 +79,11 @@ namespace kiwano
|
|||
pressed_callback_ = func;
|
||||
}
|
||||
|
||||
void Button::SetReleasedCallback(const Callback& func)
|
||||
{
|
||||
released_callback_ = func;
|
||||
}
|
||||
|
||||
void Button::SetMouseOverCallback(const Callback & func)
|
||||
{
|
||||
mouse_over_callback_ = func;
|
||||
|
|
@ -130,6 +135,9 @@ namespace kiwano
|
|||
{
|
||||
SetStatus(Status::Hover);
|
||||
|
||||
if (released_callback_)
|
||||
released_callback_();
|
||||
|
||||
if (click_callback_)
|
||||
click_callback_();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,16 +27,16 @@ namespace kiwano
|
|||
class KGE_API Button
|
||||
: public Sprite
|
||||
{
|
||||
public:
|
||||
using Callback = Closure<void()>;
|
||||
|
||||
public:
|
||||
Button();
|
||||
|
||||
explicit Button(
|
||||
Callback const& click /* 按钮点击回调函数 */
|
||||
);
|
||||
|
||||
explicit Button(
|
||||
Button(
|
||||
Callback const& click, /* 按钮点击回调函数 */
|
||||
Callback const& pressed, /* 按钮按下回调函数 */
|
||||
Callback const& mouse_over, /* 按钮移入回调函数 */
|
||||
|
|
@ -63,6 +63,11 @@ namespace kiwano
|
|||
const Callback& func
|
||||
);
|
||||
|
||||
// 设置按钮被抬起时的回调函数
|
||||
void SetReleasedCallback(
|
||||
const Callback& func
|
||||
);
|
||||
|
||||
// 设置鼠标移入按钮时的回调函数
|
||||
void SetMouseOverCallback(
|
||||
const Callback& func
|
||||
|
|
@ -88,6 +93,7 @@ namespace kiwano
|
|||
Status status_;
|
||||
Callback click_callback_;
|
||||
Callback pressed_callback_;
|
||||
Callback released_callback_;
|
||||
Callback mouse_over_callback_;
|
||||
Callback mouse_out_callback_;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ namespace kiwano
|
|||
return enabled_;
|
||||
}
|
||||
|
||||
int Menu::GetButtonCount() const
|
||||
size_t Menu::GetButtonCount() const
|
||||
{
|
||||
return buttons_.size();
|
||||
}
|
||||
|
|
@ -59,7 +59,7 @@ namespace kiwano
|
|||
}
|
||||
}
|
||||
|
||||
void Menu::AddButton(ButtonPtr const& button)
|
||||
void Menu::AddButton(ButtonPtr button)
|
||||
{
|
||||
if (button)
|
||||
{
|
||||
|
|
@ -69,7 +69,7 @@ namespace kiwano
|
|||
}
|
||||
}
|
||||
|
||||
bool Menu::RemoveButton(ButtonPtr const& button)
|
||||
bool Menu::RemoveButton(ButtonPtr button)
|
||||
{
|
||||
if (buttons_.empty())
|
||||
{
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ namespace kiwano
|
|||
bool IsEnable() const;
|
||||
|
||||
// 获取菜单中的按钮数量
|
||||
int GetButtonCount() const;
|
||||
size_t GetButtonCount() const;
|
||||
|
||||
// 设置菜单启用或禁用
|
||||
void SetEnabled(
|
||||
|
|
@ -47,12 +47,12 @@ namespace kiwano
|
|||
|
||||
// 添加按钮
|
||||
void AddButton(
|
||||
ButtonPtr const& button
|
||||
ButtonPtr button
|
||||
);
|
||||
|
||||
// 移除按钮
|
||||
bool RemoveButton(
|
||||
ButtonPtr const& button
|
||||
ButtonPtr button
|
||||
);
|
||||
|
||||
// 获取所有按钮
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ namespace kiwano
|
|||
return false;
|
||||
}
|
||||
|
||||
bool ResLoader::AddImage(String const & id, ImagePtr const & image)
|
||||
bool ResLoader::AddImage(String const & id, ImagePtr image)
|
||||
{
|
||||
if (image)
|
||||
{
|
||||
|
|
@ -68,7 +68,7 @@ namespace kiwano
|
|||
return false;
|
||||
}
|
||||
|
||||
int ResLoader::AddFrames(String const& id, Array<Resource> const& images)
|
||||
size_t ResLoader::AddFrames(String const& id, Array<Resource> const& images)
|
||||
{
|
||||
if (images.empty())
|
||||
return 0;
|
||||
|
|
@ -100,7 +100,7 @@ namespace kiwano
|
|||
return 0;
|
||||
}
|
||||
|
||||
int ResLoader::AddFrames(String const& id, Array<ImagePtr> const& images)
|
||||
size_t ResLoader::AddFrames(String const& id, Array<ImagePtr> const& images)
|
||||
{
|
||||
if (images.empty())
|
||||
return 0;
|
||||
|
|
@ -114,7 +114,7 @@ namespace kiwano
|
|||
return 0;
|
||||
}
|
||||
|
||||
int ResLoader::AddFrames(String const & id, Resource const & image, int cols, int rows)
|
||||
size_t ResLoader::AddFrames(String const & id, Resource const & image, int cols, int rows)
|
||||
{
|
||||
if (cols <= 0 || rows <= 0)
|
||||
return 0;
|
||||
|
|
@ -153,7 +153,7 @@ namespace kiwano
|
|||
return 0;
|
||||
}
|
||||
|
||||
int ResLoader::AddFrames(String const & id, Resource const & image, Array<Rect> const & crop_rects)
|
||||
size_t ResLoader::AddFrames(String const & id, Resource const & image, Array<Rect> const & crop_rects)
|
||||
{
|
||||
ImagePtr raw = new (std::nothrow) Image;
|
||||
if (!raw || !raw->Load(LocateRes(image, search_paths_)))
|
||||
|
|
@ -181,7 +181,7 @@ namespace kiwano
|
|||
return 0;
|
||||
}
|
||||
|
||||
bool ResLoader::AddFrames(String const & id, FramesPtr const & frames)
|
||||
bool ResLoader::AddFrames(String const & id, FramesPtr frames)
|
||||
{
|
||||
if (frames)
|
||||
{
|
||||
|
|
@ -191,7 +191,7 @@ namespace kiwano
|
|||
return false;
|
||||
}
|
||||
|
||||
bool ResLoader::AddObj(String const& id, ObjectPtr const& obj)
|
||||
bool ResLoader::AddObj(String const& id, ObjectPtr obj)
|
||||
{
|
||||
if (obj)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -33,27 +33,27 @@ namespace kiwano
|
|||
bool AddImage(String const& id, Resource const& image);
|
||||
|
||||
// 添加图片
|
||||
bool AddImage(String const& id, ImagePtr const& image);
|
||||
bool AddImage(String const& id, ImagePtr image);
|
||||
|
||||
// 添加帧集合
|
||||
int AddFrames(String const& id, Array<Resource> const& images);
|
||||
size_t AddFrames(String const& id, Array<Resource> const& images);
|
||||
|
||||
// 添加帧集合
|
||||
int AddFrames(String const& id, Array<ImagePtr> const& images);
|
||||
size_t AddFrames(String const& id, Array<ImagePtr> const& images);
|
||||
|
||||
// 添加帧集合
|
||||
// 按行列数裁剪图片
|
||||
int AddFrames(String const& id, Resource const& image, int cols, int rows = 1);
|
||||
size_t AddFrames(String const& id, Resource const& image, int cols, int rows = 1);
|
||||
|
||||
// 添加帧集合
|
||||
// 按指定裁剪矩形裁剪图片
|
||||
int AddFrames(String const& id, Resource const& image, Array<Rect> const& crop_rects);
|
||||
size_t AddFrames(String const& id, Resource const& image, Array<Rect> const& crop_rects);
|
||||
|
||||
// 添加帧集合
|
||||
bool AddFrames(String const& id, FramesPtr const& frames);
|
||||
bool AddFrames(String const& id, FramesPtr frames);
|
||||
|
||||
// 添加对象
|
||||
bool AddObj(String const& id, ObjectPtr const& obj);
|
||||
bool AddObj(String const& id, ObjectPtr obj);
|
||||
|
||||
ImagePtr GetImage(String const& id) const;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue