2019-04-11 14:40:54 +08:00
|
|
|
// Copyright (c) 2016-2018 Kiwano - Nomango
|
2020-01-21 10:09:55 +08:00
|
|
|
//
|
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:
|
2020-01-21 10:09:55 +08:00
|
|
|
//
|
2019-03-31 01:37:06 +08:00
|
|
|
// The above copyright notice and this permission notice shall be included in
|
|
|
|
|
// all copies or substantial portions of the Software.
|
2020-01-21 10:09:55 +08:00
|
|
|
//
|
2019-03-31 01:37:06 +08:00
|
|
|
// 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-10-11 21:55:29 +08:00
|
|
|
#include <kiwano/2d/Actor.h>
|
2020-02-10 18:03:35 +08:00
|
|
|
#include <kiwano/render/Layer.h>
|
2020-01-17 16:55:47 +08:00
|
|
|
#include <kiwano/render/RenderContext.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
|
|
|
{
|
2020-02-10 18:03:35 +08:00
|
|
|
KGE_DECLARE_SMART_PTR(LayerActor);
|
2020-01-21 10:09:55 +08:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* \addtogroup Actors
|
|
|
|
|
* @{
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* \~chinese
|
2020-02-11 12:09:59 +08:00
|
|
|
* @brief 图层角色
|
2020-01-21 10:09:55 +08:00
|
|
|
*/
|
2020-02-10 18:03:35 +08:00
|
|
|
class KGE_API LayerActor : public Actor
|
2020-01-21 10:09:55 +08:00
|
|
|
{
|
|
|
|
|
public:
|
2020-02-06 16:54:47 +08:00
|
|
|
/// \~chinese
|
2020-02-10 17:32:04 +08:00
|
|
|
/// @brief 创建图层
|
2020-02-10 18:03:35 +08:00
|
|
|
static LayerActorPtr Create();
|
2020-02-06 16:54:47 +08:00
|
|
|
|
2020-02-10 18:03:35 +08:00
|
|
|
LayerActor();
|
2019-03-31 01:37:06 +08:00
|
|
|
|
2020-02-10 18:03:35 +08:00
|
|
|
virtual ~LayerActor();
|
2019-08-20 19:32:36 +08:00
|
|
|
|
2020-01-21 10:09:55 +08:00
|
|
|
/// \~chinese
|
2020-02-10 17:32:04 +08:00
|
|
|
/// @brief 是否开启消息吞没
|
2020-01-21 10:09:55 +08:00
|
|
|
bool IsSwallowEventsEnabled() const;
|
2019-08-20 19:32:36 +08:00
|
|
|
|
2020-01-21 10:09:55 +08:00
|
|
|
/// \~chinese
|
2020-02-16 20:14:01 +08:00
|
|
|
/// @brief 获取图层
|
|
|
|
|
LayerPtr GetLayer() const;
|
2019-08-20 19:32:36 +08:00
|
|
|
|
2020-01-21 10:09:55 +08:00
|
|
|
/// \~chinese
|
2020-02-11 12:09:59 +08:00
|
|
|
/// @brief 设置图层
|
|
|
|
|
/// @param layer 图层
|
2020-02-16 20:14:01 +08:00
|
|
|
void SetLayer(LayerPtr layer);
|
2019-12-23 18:05:08 +08:00
|
|
|
|
2020-01-21 10:09:55 +08:00
|
|
|
/// \~chinese
|
2020-02-11 12:09:59 +08:00
|
|
|
/// @brief 设置消息吞没功能
|
|
|
|
|
/// @param enabled 是否启用
|
|
|
|
|
void SetSwallowEvents(bool enabled);
|
2019-12-23 18:05:08 +08:00
|
|
|
|
2020-01-21 10:09:55 +08:00
|
|
|
/// \~chinese
|
2020-02-11 12:09:59 +08:00
|
|
|
/// @brief 设置图层透明度
|
|
|
|
|
/// @param opacity 透明度
|
|
|
|
|
void SetOpacity(float opacity) override;
|
2019-03-31 01:37:06 +08:00
|
|
|
|
2020-01-21 10:09:55 +08:00
|
|
|
bool DispatchEvent(Event* evt) override;
|
2019-08-20 19:32:36 +08:00
|
|
|
|
2020-01-21 10:09:55 +08:00
|
|
|
protected:
|
|
|
|
|
void Render(RenderContext& ctx) override;
|
2019-04-20 00:21:44 +08:00
|
|
|
|
2020-01-21 10:09:55 +08:00
|
|
|
bool CheckVisibility(RenderContext& ctx) const override;
|
2019-12-23 18:05:08 +08:00
|
|
|
|
2020-01-21 10:09:55 +08:00
|
|
|
private:
|
2020-02-16 20:14:01 +08:00
|
|
|
bool swallow_;
|
|
|
|
|
LayerPtr layer_;
|
2020-01-21 10:09:55 +08:00
|
|
|
};
|
2019-12-23 18:05:08 +08:00
|
|
|
|
2020-01-21 10:09:55 +08:00
|
|
|
/** @} */
|
2019-12-23 18:05:08 +08:00
|
|
|
|
2020-02-10 18:03:35 +08:00
|
|
|
inline bool LayerActor::IsSwallowEventsEnabled() const
|
2020-01-21 10:09:55 +08:00
|
|
|
{
|
|
|
|
|
return swallow_;
|
|
|
|
|
}
|
2019-12-23 18:05:08 +08:00
|
|
|
|
2020-02-10 18:03:35 +08:00
|
|
|
inline void LayerActor::SetSwallowEvents(bool enabled)
|
2020-01-21 10:09:55 +08:00
|
|
|
{
|
|
|
|
|
swallow_ = enabled;
|
|
|
|
|
}
|
2019-12-23 18:05:08 +08:00
|
|
|
|
2020-02-16 20:14:01 +08:00
|
|
|
inline void LayerActor::SetLayer(LayerPtr layer)
|
2020-01-21 10:09:55 +08:00
|
|
|
{
|
2020-02-10 18:03:35 +08:00
|
|
|
layer_ = layer;
|
2020-01-21 10:09:55 +08:00
|
|
|
}
|
2019-12-23 18:05:08 +08:00
|
|
|
|
2020-02-16 20:14:01 +08:00
|
|
|
inline LayerPtr LayerActor::GetLayer() const
|
2020-02-11 12:09:59 +08:00
|
|
|
{
|
|
|
|
|
return layer_;
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-21 10:09:55 +08:00
|
|
|
} // namespace kiwano
|