update Components

This commit is contained in:
Nomango 2019-09-10 14:10:13 +08:00
parent ccbaf0573f
commit ab9c650b0a
3 changed files with 31 additions and 23 deletions

View File

@ -20,8 +20,13 @@
#include "Component.h"
#define KGE_DEFINE_COMPONENT_FLAG ( 0x01 << (__COUNTER__ % 32) )
namespace kiwano
{
const Int32 RenderComponent::flag = KGE_DEFINE_COMPONENT_FLAG;
const Int32 UpdateComponent::flag = KGE_DEFINE_COMPONENT_FLAG;
const Int32 EventComponent::flag = KGE_DEFINE_COMPONENT_FLAG;
ComponentBase::ComponentBase()
: flag_(0)

View File

@ -25,9 +25,7 @@
namespace kiwano
{
#define KGE_DEFINE_COMPONENT_FLAG ( 0x01 << (__COUNTER__ % 32) )
// 基础组件
class KGE_API ComponentBase
{
public:
@ -46,49 +44,55 @@ namespace kiwano
class RenderTarget;
// 渲染支持组件
class KGE_API RenderComponent
: public virtual ComponentBase
{
public:
static const Int32 flag = KGE_DEFINE_COMPONENT_FLAG;
RenderComponent();
virtual void BeforeRender() {}
virtual void OnRender(RenderTarget*) {}
virtual void AfterRender() {}
public:
static const Int32 flag;
RenderComponent();
};
// 更新支持组件
class KGE_API UpdateComponent
: public virtual ComponentBase
{
public:
static const Int32 flag = KGE_DEFINE_COMPONENT_FLAG;
UpdateComponent();
virtual void BeforeUpdate() {}
virtual void OnUpdate(Duration) {}
virtual void AfterUpdate() {}
public:
static const Int32 flag;
UpdateComponent();
};
// 事件支持组件
class KGE_API EventComponent
: public virtual ComponentBase
{
public:
static const Int32 flag = KGE_DEFINE_COMPONENT_FLAG;
EventComponent();
virtual void HandleEvent(Event&) {}
virtual void HandleMessage(HWND, UInt32, WPARAM, LPARAM) {}
public:
static const Int32 flag;
EventComponent();
};

View File

@ -209,15 +209,14 @@ namespace kiwano
void ResizeTarget(UInt32 width, UInt32 height);
private:
bool vsync_;
HWND hwnd_;
Color clear_color_;
Size output_size_;
ComPtr<ID2DDeviceResources> d2d_res_;
ComPtr<ID3DDeviceResources> d3d_res_;
ComPtr<ID2D1DrawingStateBlock> drawing_state_block_;
bool vsync_;
HWND hwnd_;
Color clear_color_;
Size output_size_;
ComPtr<ID2DDeviceResources> d2d_res_;
ComPtr<ID3DDeviceResources> d3d_res_;
ComPtr<ID2D1DrawingStateBlock> drawing_state_block_;
ComPtr<IFontCollectionLoader> font_collection_loader_;
ComPtr<IResourceFontFileLoader> res_font_file_loader_;
ComPtr<IResourceFontCollectionLoader> res_font_collection_loader_;