From a96dfc829944e7801e35bec68d2730e5883724b5 Mon Sep 17 00:00:00 2001 From: Nomango Date: Mon, 10 Feb 2020 18:03:35 +0800 Subject: [PATCH] Layer rename to LayerActor & LayerArea rename to Layer --- projects/kiwano/kiwano.vcxproj | 8 ++-- projects/kiwano/kiwano.vcxproj.filters | 24 +++++----- src/kiwano-imgui/ImGuiLayer.h | 2 +- src/kiwano/2d/Canvas.cpp | 6 +-- src/kiwano/2d/Canvas.h | 6 +-- src/kiwano/2d/{Layer.cpp => LayerActor.cpp} | 36 +++++++-------- src/kiwano/2d/{Layer.h => LayerActor.h} | 32 ++++++------- src/kiwano/2d/Transition.cpp | 8 ++-- src/kiwano/2d/Transition.h | 6 +-- src/kiwano/kiwano.h | 4 +- .../render/DirectX/RenderContextImpl.cpp | 4 +- src/kiwano/render/DirectX/RenderContextImpl.h | 2 +- .../render/{LayerArea.cpp => Layer.cpp} | 6 +-- src/kiwano/render/{LayerArea.h => Layer.h} | 46 +++++++++---------- src/kiwano/render/RenderContext.h | 4 +- 15 files changed, 97 insertions(+), 97 deletions(-) rename src/kiwano/2d/{Layer.cpp => LayerActor.cpp} (68%) rename src/kiwano/2d/{Layer.h => LayerActor.h} (82%) rename src/kiwano/render/{LayerArea.cpp => Layer.cpp} (92%) rename src/kiwano/render/{LayerArea.h => Layer.h} (72%) diff --git a/projects/kiwano/kiwano.vcxproj b/projects/kiwano/kiwano.vcxproj index 4270463a..28f90319 100644 --- a/projects/kiwano/kiwano.vcxproj +++ b/projects/kiwano/kiwano.vcxproj @@ -31,7 +31,7 @@ - + @@ -81,7 +81,7 @@ - + @@ -109,7 +109,7 @@ - + @@ -154,7 +154,7 @@ - + diff --git a/projects/kiwano/kiwano.vcxproj.filters b/projects/kiwano/kiwano.vcxproj.filters index 4fd95326..9e3b3736 100644 --- a/projects/kiwano/kiwano.vcxproj.filters +++ b/projects/kiwano/kiwano.vcxproj.filters @@ -36,9 +36,6 @@ 2d - - 2d - 2d @@ -216,9 +213,6 @@ render - - render - render @@ -303,14 +297,17 @@ core + + 2d + + + render + 2d - - 2d - 2d @@ -458,9 +455,6 @@ render - - render - render @@ -515,5 +509,11 @@ core + + 2d + + + render + \ No newline at end of file diff --git a/src/kiwano-imgui/ImGuiLayer.h b/src/kiwano-imgui/ImGuiLayer.h index ffd83774..474382cf 100644 --- a/src/kiwano-imgui/ImGuiLayer.h +++ b/src/kiwano-imgui/ImGuiLayer.h @@ -35,7 +35,7 @@ using ImGuiPipeline = Function; * \~chinese * @brief ImGui图层 */ -class ImGuiLayer : public Layer +class ImGuiLayer : public LayerActor { public: /// \~chinese diff --git a/src/kiwano/2d/Canvas.cpp b/src/kiwano/2d/Canvas.cpp index 305c2e4d..09c9e911 100644 --- a/src/kiwano/2d/Canvas.cpp +++ b/src/kiwano/2d/Canvas.cpp @@ -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(); diff --git a/src/kiwano/2d/Canvas.h b/src/kiwano/2d/Canvas.h index 06d31ed4..b08696b8 100644 --- a/src/kiwano/2d/Canvas.h +++ b/src/kiwano/2d/Canvas.h @@ -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 添加一个裁剪区域 diff --git a/src/kiwano/2d/Layer.cpp b/src/kiwano/2d/LayerActor.cpp similarity index 68% rename from src/kiwano/2d/Layer.cpp rename to src/kiwano/2d/LayerActor.cpp index f49a6fec..8d433348 100644 --- a/src/kiwano/2d/Layer.cpp +++ b/src/kiwano/2d/LayerActor.cpp @@ -19,47 +19,47 @@ // THE SOFTWARE. #pragma once -#include +#include #include 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; } diff --git a/src/kiwano/2d/Layer.h b/src/kiwano/2d/LayerActor.h similarity index 82% rename from src/kiwano/2d/Layer.h rename to src/kiwano/2d/LayerActor.h index 6b2d10ae..9dd61745 100644 --- a/src/kiwano/2d/Layer.h +++ b/src/kiwano/2d/LayerActor.h @@ -20,12 +20,12 @@ #pragma once #include -#include +#include #include 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 diff --git a/src/kiwano/2d/Transition.cpp b/src/kiwano/2d/Transition.cpp index 19c5fee1..1b8e3df9 100644 --- a/src/kiwano/2d/Transition.cpp +++ b/src/kiwano/2d/Transition.cpp @@ -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_)); } } diff --git a/src/kiwano/2d/Transition.h b/src/kiwano/2d/Transition.h index c6f1e0d7..7ab74b45 100644 --- a/src/kiwano/2d/Transition.h +++ b/src/kiwano/2d/Transition.h @@ -20,7 +20,7 @@ #pragma once #include -#include +#include 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_; }; /** diff --git a/src/kiwano/kiwano.h b/src/kiwano/kiwano.h index af1bf455..38953e4f 100644 --- a/src/kiwano/kiwano.h +++ b/src/kiwano/kiwano.h @@ -70,7 +70,7 @@ #include #include #include -#include +#include #include #include #include @@ -86,7 +86,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/kiwano/render/DirectX/RenderContextImpl.cpp b/src/kiwano/render/DirectX/RenderContextImpl.cpp index 8db2df29..b478dcb6 100644 --- a/src/kiwano/render/DirectX/RenderContextImpl.cpp +++ b/src/kiwano/render/DirectX/RenderContextImpl.cpp @@ -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), diff --git a/src/kiwano/render/DirectX/RenderContextImpl.h b/src/kiwano/render/DirectX/RenderContextImpl.h index 92d6a95d..f8d95404 100644 --- a/src/kiwano/render/DirectX/RenderContextImpl.h +++ b/src/kiwano/render/DirectX/RenderContextImpl.h @@ -70,7 +70,7 @@ public: void PopClipRect() override; - void PushLayer(LayerArea& layer) override; + void PushLayer(Layer& layer) override; void PopLayer() override; diff --git a/src/kiwano/render/LayerArea.cpp b/src/kiwano/render/Layer.cpp similarity index 92% rename from src/kiwano/render/LayerArea.cpp rename to src/kiwano/render/Layer.cpp index 0af86f26..4217070e 100644 --- a/src/kiwano/render/LayerArea.cpp +++ b/src/kiwano/render/Layer.cpp @@ -18,13 +18,13 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -#include +#include namespace kiwano { -LayerArea::LayerArea() +Layer::Layer() : opacity_(1.f) - , area_(Rect::Infinite()) + , clip_rect_(Rect::Infinite()) { } diff --git a/src/kiwano/render/LayerArea.h b/src/kiwano/render/Layer.h similarity index 72% rename from src/kiwano/render/LayerArea.h rename to src/kiwano/render/Layer.h index 92a28020..c0911040 100644 --- a/src/kiwano/render/LayerArea.h +++ b/src/kiwano/render/Layer.h @@ -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 LayerArea::GetLayer() const +inline ComPtr Layer::GetLayer() const { return layer_; } -inline void LayerArea::SetLayer(ComPtr layer) +inline void Layer::SetLayer(ComPtr layer) { layer_ = layer; } diff --git a/src/kiwano/render/RenderContext.h b/src/kiwano/render/RenderContext.h index 55f5d292..f70e51db 100644 --- a/src/kiwano/render/RenderContext.h +++ b/src/kiwano/render/RenderContext.h @@ -23,7 +23,7 @@ #include #include #include -#include +#include #include #include #include @@ -165,7 +165,7 @@ public: /// \~chinese /// @brief 设置图层区域 /// @param layer 图层区域 - virtual void PushLayer(LayerArea& layer) = 0; + virtual void PushLayer(Layer& layer) = 0; /// \~chinese /// @brief 取消上一次设置的图层区域