diff options
author | crupest <crupest@outlook.com> | 2018-11-13 22:36:40 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2018-11-13 22:37:08 +0800 |
commit | 6d0a44597eb6e35993b46642ebf85abd94bca2d7 (patch) | |
tree | 98719593d5854f2162ea8d87b7fecdc3472968bc /CruUI-Generate/cru_ui.cpp | |
parent | 38a523be0085a9b529043bddc61e4aee04a6768d (diff) | |
download | cru-6d0a44597eb6e35993b46642ebf85abd94bca2d7.tar.gz cru-6d0a44597eb6e35993b46642ebf85abd94bca2d7.tar.bz2 cru-6d0a44597eb6e35993b46642ebf85abd94bca2d7.zip |
Add check for IsBordered.
Diffstat (limited to 'CruUI-Generate/cru_ui.cpp')
-rw-r--r-- | CruUI-Generate/cru_ui.cpp | 49 |
1 files changed, 35 insertions, 14 deletions
diff --git a/CruUI-Generate/cru_ui.cpp b/CruUI-Generate/cru_ui.cpp index 418d2498..252dfd9a 100644 --- a/CruUI-Generate/cru_ui.cpp +++ b/CruUI-Generate/cru_ui.cpp @@ -982,11 +982,20 @@ namespace cru::ui { if (border_geometry_ != nullptr) { - BOOL contains; - border_geometry_->FillContainsPoint(Convert(point), D2D1::Matrix3x2F::Identity(), &contains); - if (!contains) - border_geometry_->StrokeContainsPoint(Convert(point), GetBorderProperty().GetStrokeWidth(), nullptr, D2D1::Matrix3x2F::Identity(), &contains); - return contains != 0; + if (IsBordered()) + { + BOOL contains; + border_geometry_->FillContainsPoint(Convert(point), D2D1::Matrix3x2F::Identity(), &contains); + if (!contains) + border_geometry_->StrokeContainsPoint(Convert(point), GetBorderProperty().GetStrokeWidth(), nullptr, D2D1::Matrix3x2F::Identity(), &contains); + return contains != 0; + } + else + { + BOOL contains; + border_geometry_->FillContainsPoint(Convert(point), D2D1::Matrix3x2F::Identity(), &contains); + return contains != 0; + } } return false; } @@ -1306,16 +1315,28 @@ namespace cru::ui void Control::RegenerateBorderGeometry() { - const auto bound_rect = GetRect(RectRange::HalfBorder); - const auto bound_rounded_rect = D2D1::RoundedRect(Convert(bound_rect), - GetBorderProperty().GetRadiusX(), - GetBorderProperty().GetRadiusY()); + if (IsBordered()) + { + const auto bound_rect = GetRect(RectRange::HalfBorder); + const auto bound_rounded_rect = D2D1::RoundedRect(Convert(bound_rect), + GetBorderProperty().GetRadiusX(), + GetBorderProperty().GetRadiusY()); - Microsoft::WRL::ComPtr<ID2D1RoundedRectangleGeometry> geometry; - ThrowIfFailed( - graph::GraphManager::GetInstance()->GetD2D1Factory()->CreateRoundedRectangleGeometry(bound_rounded_rect, &geometry) - ); - border_geometry_ = std::move(geometry); + Microsoft::WRL::ComPtr<ID2D1RoundedRectangleGeometry> geometry; + ThrowIfFailed( + graph::GraphManager::GetInstance()->GetD2D1Factory()->CreateRoundedRectangleGeometry(bound_rounded_rect, &geometry) + ); + border_geometry_ = std::move(geometry); + } + else + { + const auto bound_rect = GetRect(RectRange::Padding); + Microsoft::WRL::ComPtr<ID2D1RectangleGeometry> geometry; + ThrowIfFailed( + graph::GraphManager::GetInstance()->GetD2D1Factory()->CreateRectangleGeometry(Convert(bound_rect), &geometry) + ); + border_geometry_ = std::move(geometry); + } } void Control::OnMouseEnter(MouseEventArgs & args) |