Magic_Game/src/kiwano/2d/Layer.h

82 lines
2.4 KiB
C
Raw Normal View History

2019-04-11 14:40:54 +08:00
// Copyright (c) 2016-2018 Kiwano - Nomango
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#pragma once
#include "Actor.h"
2019-08-20 19:32:36 +08:00
#include "..\renderer\LayerArea.h"
#include "..\renderer\RenderTarget.h"
2019-04-11 14:40:54 +08:00
namespace kiwano
{
2019-04-11 14:40:54 +08:00
class KGE_API Layer
: public Actor
{
public:
Layer();
virtual ~Layer();
2019-08-20 19:32:36 +08:00
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>к<EFBFBD><D0BA><EFBFBD><EFBFBD>Ի<EFBFBD>ȡͼ<C8A1><CDBC><EFBFBD>¼<EFBFBD>
2019-08-18 22:49:44 +08:00
virtual void OnMouseButtonDown(Int32 btn, Point const& p) {}
virtual void OnMouseButtonUp(Int32 btn, Point const& p) {}
virtual void OnMouseMoved(Point const& p) {}
2019-08-18 22:49:44 +08:00
virtual void OnMouseWheel(Float32 wheel) {}
virtual void OnKeyDown(Int32 key) {}
virtual void OnKeyUp(Int32 key) {}
virtual void OnChar(char c) {}
2019-08-20 19:32:36 +08:00
// <20>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2>û
inline bool IsSwallowEventsEnabled() const { return swallow_; }
// <20><>û<EFBFBD><C3BB>Ϣ
2019-08-20 19:32:36 +08:00
inline void SetSwallowEvents(bool enabled) { swallow_ = enabled; }
// <20><><EFBFBD>òü<C3B2><C3BC><EFBFBD><EFBFBD><EFBFBD>
void SetClipRect(Rect const& clip_rect);
// <20><><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC>͸<EFBFBD><CDB8><EFBFBD><EFBFBD>
void SetOpacity(Float32 opacity) override;
// <20><><EFBFBD>ü<EFBFBD><C3BC><EFBFBD><EFBFBD>ɲ<EFBFBD>
void SetMaskGeometry(Geometry const& mask);
// <20><><EFBFBD>ü<EFBFBD><C3BC><EFBFBD><EFBFBD>ɲ<EFBFBD><C9B2>Ķ<EFBFBD>ά<EFBFBD>
void SetMaskTransform(Matrix3x2 const& transform);
// <20><><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
inline void SetArea(LayerArea const& area) { area_ = area; }
// <20><>ȡͼ<C8A1><CDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
inline LayerArea const& GetArea() const { return area_; }
public:
void Dispatch(Event& evt) override;
protected:
2019-08-20 19:32:36 +08:00
void Render(RenderTarget* rt) override;
void HandleMessages(Event const& evt);
protected:
2019-08-20 19:32:36 +08:00
bool swallow_;
LayerArea area_;
};
}