2019-04-11 14:40:54 +08:00
|
|
|
|
// Copyright (c) 2016-2018 Kiwano - Nomango
|
2019-03-31 01:37:06 +08:00
|
|
|
|
//
|
|
|
|
|
|
// 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
|
2019-08-12 18:30:42 +08:00
|
|
|
|
#include "Actor.h"
|
2019-08-20 19:32:36 +08:00
|
|
|
|
#include "..\renderer\LayerArea.h"
|
|
|
|
|
|
#include "..\renderer\RenderTarget.h"
|
2019-03-31 01:37:06 +08:00
|
|
|
|
|
2019-04-11 14:40:54 +08:00
|
|
|
|
namespace kiwano
|
2019-03-31 01:37:06 +08:00
|
|
|
|
{
|
2019-04-11 14:40:54 +08:00
|
|
|
|
class KGE_API Layer
|
2019-08-12 18:30:42 +08:00
|
|
|
|
: public Actor
|
2019-03-31 01:37:06 +08:00
|
|
|
|
{
|
|
|
|
|
|
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) {}
|
2019-03-31 01:37:06 +08:00
|
|
|
|
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) {}
|
2019-03-31 01:37:06 +08:00
|
|
|
|
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_; }
|
|
|
|
|
|
|
2019-04-20 00:21:44 +08:00
|
|
|
|
// <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_; }
|
2019-04-20 00:21:44 +08:00
|
|
|
|
|
2019-03-31 01:37:06 +08:00
|
|
|
|
public:
|
|
|
|
|
|
void Dispatch(Event& evt) override;
|
|
|
|
|
|
|
|
|
|
|
|
protected:
|
2019-08-20 19:32:36 +08:00
|
|
|
|
void Render(RenderTarget* rt) override;
|
|
|
|
|
|
|
2019-03-31 01:37:06 +08:00
|
|
|
|
void HandleMessages(Event const& evt);
|
2019-04-20 00:21:44 +08:00
|
|
|
|
|
|
|
|
|
|
protected:
|
2019-08-20 19:32:36 +08:00
|
|
|
|
bool swallow_;
|
|
|
|
|
|
LayerArea area_;
|
2019-03-31 01:37:06 +08:00
|
|
|
|
};
|
|
|
|
|
|
}
|