Layer rename to LayerActor & LayerArea rename to Layer

This commit is contained in:
Nomango 2020-02-10 18:03:35 +08:00
parent f1b62daa9e
commit a96dfc8299
15 changed files with 97 additions and 97 deletions

View File

@ -31,7 +31,7 @@
<ClInclude Include="..\..\src\kiwano\2d\DebugActor.h" />
<ClInclude Include="..\..\src\kiwano\2d\FrameSequence.h" />
<ClInclude Include="..\..\src\kiwano\2d\ShapeActor.h" />
<ClInclude Include="..\..\src\kiwano\2d\Layer.h" />
<ClInclude Include="..\..\src\kiwano\2d\LayerActor.h" />
<ClInclude Include="..\..\src\kiwano\2d\Actor.h" />
<ClInclude Include="..\..\src\kiwano\2d\Stage.h" />
<ClInclude Include="..\..\src\kiwano\2d\Sprite.h" />
@ -81,7 +81,7 @@
<ClInclude Include="..\..\src\kiwano\render\Shape.h" />
<ClInclude Include="..\..\src\kiwano\render\ShapeSink.h" />
<ClInclude Include="..\..\src\kiwano\render\GifImage.h" />
<ClInclude Include="..\..\src\kiwano\render\LayerArea.h" />
<ClInclude Include="..\..\src\kiwano\render\Layer.h" />
<ClInclude Include="..\..\src\kiwano\render\RenderContext.h" />
<ClInclude Include="..\..\src\kiwano\render\Renderer.h" />
<ClInclude Include="..\..\src\kiwano\render\StrokeStyle.h" />
@ -109,7 +109,7 @@
<ClCompile Include="..\..\src\kiwano\2d\FrameSequence.cpp" />
<ClCompile Include="..\..\src\kiwano\2d\ShapeActor.cpp" />
<ClCompile Include="..\..\src\kiwano\2d\GifSprite.cpp" />
<ClCompile Include="..\..\src\kiwano\2d\Layer.cpp" />
<ClCompile Include="..\..\src\kiwano\2d\LayerActor.cpp" />
<ClCompile Include="..\..\src\kiwano\2d\Actor.cpp" />
<ClCompile Include="..\..\src\kiwano\2d\Stage.cpp" />
<ClCompile Include="..\..\src\kiwano\2d\Sprite.cpp" />
@ -154,7 +154,7 @@
<ClCompile Include="..\..\src\kiwano\render\Shape.cpp" />
<ClCompile Include="..\..\src\kiwano\render\ShapeSink.cpp" />
<ClCompile Include="..\..\src\kiwano\render\GifImage.cpp" />
<ClCompile Include="..\..\src\kiwano\render\LayerArea.cpp" />
<ClCompile Include="..\..\src\kiwano\render\Layer.cpp" />
<ClCompile Include="..\..\src\kiwano\render\RenderContext.cpp" />
<ClCompile Include="..\..\src\kiwano\render\Renderer.cpp" />
<ClCompile Include="..\..\src\kiwano\render\StrokeStyle.cpp" />

View File

@ -36,9 +36,6 @@
<ClInclude Include="..\..\src\kiwano\2d\Canvas.h">
<Filter>2d</Filter>
</ClInclude>
<ClInclude Include="..\..\src\kiwano\2d\Layer.h">
<Filter>2d</Filter>
</ClInclude>
<ClInclude Include="..\..\src\kiwano\2d\Sprite.h">
<Filter>2d</Filter>
</ClInclude>
@ -216,9 +213,6 @@
<ClInclude Include="..\..\src\kiwano\render\GifImage.h">
<Filter>render</Filter>
</ClInclude>
<ClInclude Include="..\..\src\kiwano\render\LayerArea.h">
<Filter>render</Filter>
</ClInclude>
<ClInclude Include="..\..\src\kiwano\render\RenderContext.h">
<Filter>render</Filter>
</ClInclude>
@ -303,14 +297,17 @@
<ClInclude Include="..\..\src\kiwano\core\Exception.h">
<Filter>core</Filter>
</ClInclude>
<ClInclude Include="..\..\src\kiwano\2d\LayerActor.h">
<Filter>2d</Filter>
</ClInclude>
<ClInclude Include="..\..\src\kiwano\render\Layer.h">
<Filter>render</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\src\kiwano\2d\Canvas.cpp">
<Filter>2d</Filter>
</ClCompile>
<ClCompile Include="..\..\src\kiwano\2d\Layer.cpp">
<Filter>2d</Filter>
</ClCompile>
<ClCompile Include="..\..\src\kiwano\2d\Sprite.cpp">
<Filter>2d</Filter>
</ClCompile>
@ -458,9 +455,6 @@
<ClCompile Include="..\..\src\kiwano\render\GifImage.cpp">
<Filter>render</Filter>
</ClCompile>
<ClCompile Include="..\..\src\kiwano\render\LayerArea.cpp">
<Filter>render</Filter>
</ClCompile>
<ClCompile Include="..\..\src\kiwano\render\RenderContext.cpp">
<Filter>render</Filter>
</ClCompile>
@ -515,5 +509,11 @@
<ClCompile Include="..\..\src\kiwano\core\Exception.cpp">
<Filter>core</Filter>
</ClCompile>
<ClCompile Include="..\..\src\kiwano\2d\LayerActor.cpp">
<Filter>2d</Filter>
</ClCompile>
<ClCompile Include="..\..\src\kiwano\render\Layer.cpp">
<Filter>render</Filter>
</ClCompile>
</ItemGroup>
</Project>

View File

@ -35,7 +35,7 @@ using ImGuiPipeline = Function<void()>;
* \~chinese
* @brief ImGui图层
*/
class ImGuiLayer : public Layer
class ImGuiLayer : public LayerActor
{
public:
/// \~chinese

View File

@ -95,13 +95,13 @@ void Canvas::SetBrushTransform(Matrix3x2 const& transform)
ctx_->SetTransform(transform);
}
void Canvas::PushLayerArea(LayerArea& area)
void Canvas::PushLayer(Layer& layer)
{
KGE_ASSERT(ctx_);
ctx_->PushLayer(area);
ctx_->PushLayer(layer);
}
void Canvas::PopLayerArea()
void Canvas::PopLayer()
{
KGE_ASSERT(ctx_);
ctx_->PopLayer();

View File

@ -240,12 +240,12 @@ public:
/// \~chinese
/// @brief 添加一个图层
/// @param area 图层区域
void PushLayerArea(LayerArea& area);
/// @param layer 图层
void PushLayer(Layer& layer);
/// \~chinese
/// @brief 删除最近添加的图层
void PopLayerArea();
void PopLayer();
/// \~chinese
/// @brief 添加一个裁剪区域

View File

@ -19,47 +19,47 @@
// THE SOFTWARE.
#pragma once
#include <kiwano/2d/Layer.h>
#include <kiwano/2d/LayerActor.h>
#include <kiwano/render/Renderer.h>
namespace kiwano
{
LayerPtr Layer::Create()
LayerActorPtr LayerActor::Create()
{
LayerPtr ptr = new (std::nothrow) Layer;
LayerActorPtr ptr = new (std::nothrow) LayerActor;
return ptr;
}
Layer::Layer()
LayerActor::LayerActor()
: swallow_(false)
{
}
Layer::~Layer() {}
LayerActor::~LayerActor() {}
void Layer::SetClipRect(Rect const& clip_rect)
void LayerActor::SetClipRect(Rect const& clip_rect)
{
area_.SetAreaRect(clip_rect);
layer_.SetClipRect(clip_rect);
}
void Layer::SetOpacity(float opacity)
void LayerActor::SetOpacity(float opacity)
{
// Actor::SetOpacity(opacity);
area_.SetOpacity(opacity);
layer_.SetOpacity(opacity);
}
void Layer::SetMaskShape(ShapePtr mask)
void LayerActor::SetMaskShape(ShapePtr mask)
{
area_.SetMaskShape(mask);
layer_.SetMaskShape(mask);
}
void Layer::SetMaskTransform(Matrix3x2 const& transform)
void LayerActor::SetMaskTransform(Matrix3x2 const& transform)
{
area_.SetMaskTransform(transform);
layer_.SetMaskTransform(transform);
}
bool Layer::DispatchEvent(Event* evt)
bool LayerActor::DispatchEvent(Event* evt)
{
if (!IsVisible())
return true;
@ -71,18 +71,18 @@ bool Layer::DispatchEvent(Event* evt)
return Actor::DispatchEvent(evt);
}
void Layer::Render(RenderContext& ctx)
void LayerActor::Render(RenderContext& ctx)
{
ctx.PushLayer(area_);
ctx.PushLayer(layer_);
Actor::Render(ctx);
ctx.PopLayer();
}
bool Layer::CheckVisibility(RenderContext& ctx) const
bool LayerActor::CheckVisibility(RenderContext& ctx) const
{
// Do not need to render Layer
// Do not need to render LayerActor
return false;
}

View File

@ -20,12 +20,12 @@
#pragma once
#include <kiwano/2d/Actor.h>
#include <kiwano/render/LayerArea.h>
#include <kiwano/render/Layer.h>
#include <kiwano/render/RenderContext.h>
namespace kiwano
{
KGE_DECLARE_SMART_PTR(Layer);
KGE_DECLARE_SMART_PTR(LayerActor);
/**
* \addtogroup Actors
@ -36,16 +36,16 @@ KGE_DECLARE_SMART_PTR(Layer);
* \~chinese
* @brief
*/
class KGE_API Layer : public Actor
class KGE_API LayerActor : public Actor
{
public:
/// \~chinese
/// @brief 创建图层
static LayerPtr Create();
static LayerActorPtr Create();
Layer();
LayerActor();
virtual ~Layer();
virtual ~LayerActor();
/// \~chinese
/// @brief 是否开启消息吞没
@ -79,11 +79,11 @@ public:
/// \~chinese
/// @brief 设置图层区域
/// @param area 图层区域属性
void SetArea(LayerArea const& area);
void SetLayer(Layer const& layer);
/// \~chinese
/// @brief 获取图层区域
LayerArea const& GetArea() const;
Layer const& GetLayer() const;
bool DispatchEvent(Event* evt) override;
@ -93,29 +93,29 @@ protected:
bool CheckVisibility(RenderContext& ctx) const override;
private:
bool swallow_;
LayerArea area_;
bool swallow_;
Layer layer_;
};
/** @} */
inline bool Layer::IsSwallowEventsEnabled() const
inline bool LayerActor::IsSwallowEventsEnabled() const
{
return swallow_;
}
inline void Layer::SetSwallowEvents(bool enabled)
inline void LayerActor::SetSwallowEvents(bool enabled)
{
swallow_ = enabled;
}
inline void Layer::SetArea(LayerArea const& area)
inline void LayerActor::SetLayer(Layer const& layer)
{
area_ = area;
layer_ = layer;
}
inline LayerArea const& Layer::GetArea() const
inline Layer const& LayerActor::GetLayer() const
{
return area_;
return layer_;
}
} // namespace kiwano

View File

@ -62,12 +62,12 @@ void Transition::Init(StagePtr prev, StagePtr next)
if (in_stage_)
{
in_layer_.SetAreaRect(Rect{ Point(), window_size_ });
in_layer_.SetClipRect(Rect{ Point(), window_size_ });
}
if (out_stage_)
{
out_layer_.SetAreaRect(Rect{ Point(), window_size_ });
out_layer_.SetClipRect(Rect{ Point(), window_size_ });
}
}
@ -151,14 +151,14 @@ void BoxTransition::Update(Duration dt)
if (process_ < .5f)
{
out_layer_.SetAreaRect(Rect(window_size_.x * process_, window_size_.y * process_,
out_layer_.SetClipRect(Rect(window_size_.x * process_, window_size_.y * process_,
window_size_.x * (1 - process_), window_size_.y * (1 - process_)));
}
else
{
out_layer_.SetOpacity(0.f);
in_layer_.SetOpacity(1.f);
in_layer_.SetAreaRect(Rect(window_size_.x * (1 - process_), window_size_.y * (1 - process_),
in_layer_.SetClipRect(Rect(window_size_.x * (1 - process_), window_size_.y * (1 - process_),
window_size_.x * process_, window_size_.y * process_));
}
}

View File

@ -20,7 +20,7 @@
#pragma once
#include <kiwano/2d/Stage.h>
#include <kiwano/render/LayerArea.h>
#include <kiwano/render/Layer.h>
namespace kiwano
{
@ -102,8 +102,8 @@ protected:
Size window_size_;
StagePtr out_stage_;
StagePtr in_stage_;
LayerArea out_layer_;
LayerArea in_layer_;
Layer out_layer_;
Layer in_layer_;
};
/**

View File

@ -70,7 +70,7 @@
#include <kiwano/render/ShapeSink.h>
#include <kiwano/render/Texture.h>
#include <kiwano/render/GifImage.h>
#include <kiwano/render/LayerArea.h>
#include <kiwano/render/Layer.h>
#include <kiwano/render/TextLayout.h>
#include <kiwano/render/TextureCache.h>
#include <kiwano/render/Renderer.h>
@ -86,7 +86,7 @@
#include <kiwano/2d/Frame.h>
#include <kiwano/2d/FrameSequence.h>
#include <kiwano/2d/GifSprite.h>
#include <kiwano/2d/Layer.h>
#include <kiwano/2d/LayerActor.h>
#include <kiwano/2d/ShapeActor.h>
#include <kiwano/2d/Sprite.h>
#include <kiwano/2d/Stage.h>

View File

@ -330,7 +330,7 @@ void RenderContextImpl::PopClipRect()
render_target_->PopAxisAlignedClip();
}
void RenderContextImpl::PushLayer(LayerArea& layer)
void RenderContextImpl::PushLayer(Layer& layer)
{
KGE_ASSERT(render_target_ && "Render target has not been initialized!");
if (!layer.IsValid())
@ -356,7 +356,7 @@ void RenderContextImpl::PushLayer(LayerArea& layer)
mask = layer.GetMaskShape()->GetGeometry();
render_target_->PushLayer(
D2D1::LayerParameters(DX::ConvertToRectF(layer.GetAreaRect()), mask.get(),
D2D1::LayerParameters(DX::ConvertToRectF(layer.GetClipRect()), mask.get(),
antialias_ ? D2D1_ANTIALIAS_MODE_PER_PRIMITIVE : D2D1_ANTIALIAS_MODE_ALIASED,
DX::ConvertToMatrix3x2F(layer.GetMaskTransform()), layer.GetOpacity(), nullptr,
D2D1_LAYER_OPTIONS_NONE),

View File

@ -70,7 +70,7 @@ public:
void PopClipRect() override;
void PushLayer(LayerArea& layer) override;
void PushLayer(Layer& layer) override;
void PopLayer() override;

View File

@ -18,13 +18,13 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#include <kiwano/render/LayerArea.h>
#include <kiwano/render/Layer.h>
namespace kiwano
{
LayerArea::LayerArea()
Layer::Layer()
: opacity_(1.f)
, area_(Rect::Infinite())
, clip_rect_(Rect::Infinite())
{
}

View File

@ -33,18 +33,18 @@ namespace kiwano
* \~chinese
* @brief
*/
class KGE_API LayerArea
class KGE_API Layer
{
public:
LayerArea();
Layer();
/// \~chinese
/// @brief 是否有效
bool IsValid() const;
/// \~chinese
/// @brief 获取图层区域
Rect const& GetAreaRect() const;
/// @brief 获取图层裁剪区域
Rect const& GetClipRect() const;
/// \~chinese
/// @brief 获取图层透明度
@ -59,8 +59,8 @@ public:
Matrix3x2 const& GetMaskTransform() const;
/// \~chinese
/// @brief 设置图层区域
void SetAreaRect(Rect const& area);
/// @brief 设置图层裁剪区域
void SetClipRect(Rect const& rect);
/// \~chinese
/// @brief 设置图层透明度
@ -75,10 +75,10 @@ public:
void SetMaskTransform(Matrix3x2 const& matrix);
private:
Rect area_;
float opacity_;
ShapePtr mask_;
Matrix3x2 mask_transform_;
Rect clip_rect_;
float opacity_;
ShapePtr mask_;
Matrix3x2 mask_transform_;
#if defined(KGE_WIN32)
public:
@ -93,58 +93,58 @@ private:
/** @} */
inline bool LayerArea::IsValid() const
inline bool Layer::IsValid() const
{
return layer_ != nullptr;
}
inline Rect const& LayerArea::GetAreaRect() const
inline Rect const& Layer::GetClipRect() const
{
return area_;
return clip_rect_;
}
inline float LayerArea::GetOpacity() const
inline float Layer::GetOpacity() const
{
return opacity_;
}
inline ShapePtr LayerArea::GetMaskShape() const
inline ShapePtr Layer::GetMaskShape() const
{
return mask_;
}
inline Matrix3x2 const& LayerArea::GetMaskTransform() const
inline Matrix3x2 const& Layer::GetMaskTransform() const
{
return mask_transform_;
}
inline void LayerArea::SetAreaRect(Rect const& area)
inline void Layer::SetClipRect(Rect const& rect)
{
area_ = area;
clip_rect_ = rect;
}
inline void LayerArea::SetOpacity(float opacity)
inline void Layer::SetOpacity(float opacity)
{
opacity_ = opacity;
}
inline void LayerArea::SetMaskShape(ShapePtr mask)
inline void Layer::SetMaskShape(ShapePtr mask)
{
mask_ = mask;
}
inline void LayerArea::SetMaskTransform(Matrix3x2 const& matrix)
inline void Layer::SetMaskTransform(Matrix3x2 const& matrix)
{
mask_transform_ = matrix;
}
#if defined(KGE_WIN32)
inline ComPtr<ID2D1Layer> LayerArea::GetLayer() const
inline ComPtr<ID2D1Layer> Layer::GetLayer() const
{
return layer_;
}
inline void LayerArea::SetLayer(ComPtr<ID2D1Layer> layer)
inline void Layer::SetLayer(ComPtr<ID2D1Layer> layer)
{
layer_ = layer;
}

View File

@ -23,7 +23,7 @@
#include <kiwano/core/Time.h>
#include <kiwano/render/Brush.h>
#include <kiwano/render/Shape.h>
#include <kiwano/render/LayerArea.h>
#include <kiwano/render/Layer.h>
#include <kiwano/render/TextLayout.h>
#include <kiwano/render/Texture.h>
#include <kiwano/render/DirectX/TextRenderer.h>
@ -165,7 +165,7 @@ public:
/// \~chinese
/// @brief 设置图层区域
/// @param layer 图层区域
virtual void PushLayer(LayerArea& layer) = 0;
virtual void PushLayer(Layer& layer) = 0;
/// \~chinese
/// @brief 取消上一次设置的图层区域