From 455e28da6c94fe1bee53645ed04f987ae65eaefc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Fri, 24 May 2024 22:51:50 +0200 Subject: [PATCH] Rename Point to Point2D to avoid a cocoa name clash --- Common/Math/geom2d.h | 14 +++++++------- Common/UI/ScrollView.cpp | 4 ++-- Common/UI/ScrollView.h | 2 +- Common/UI/Tween.cpp | 8 ++++---- Common/UI/Tween.h | 4 ++-- Common/UI/UIScreen.h | 2 +- Common/UI/View.cpp | 16 ++++++++-------- Common/UI/View.h | 4 ++-- Common/UI/ViewGroup.cpp | 24 ++++++++++++------------ Common/UI/ViewGroup.h | 2 +- UI/TouchControlLayoutScreen.cpp | 6 +++--- 11 files changed, 43 insertions(+), 43 deletions(-) diff --git a/Common/Math/geom2d.h b/Common/Math/geom2d.h index f319d7c79d..bfbe950c83 100644 --- a/Common/Math/geom2d.h +++ b/Common/Math/geom2d.h @@ -2,19 +2,19 @@ #include -struct Point { - Point() : x(0.0f), y(0.0f) {} - Point(float x_, float y_) : x(x_), y(y_) {} +struct Point2D { + Point2D() : x(0.0f), y(0.0f) {} + Point2D(float x_, float y_) : x(x_), y(y_) {} float x; float y; - float distanceTo(const Point &other) const { + float distanceTo(const Point2D &other) const { float dx = other.x - x, dy = other.y - y; return sqrtf(dx*dx + dy*dy); } - bool operator ==(const Point &other) const { + bool operator ==(const Point2D &other) const { return x == other.x && y == other.y; } @@ -60,8 +60,8 @@ struct Bounds { float y2() const { return y + h; } float centerX() const { return x + w * 0.5f; } float centerY() const { return y + h * 0.5f; } - Point Center() const { - return Point(centerX(), centerY()); + Point2D Center() const { + return Point2D(centerX(), centerY()); } Bounds Expand(float amount) const { return Bounds(x - amount, y - amount, w + amount * 2, h + amount * 2); diff --git a/Common/UI/ScrollView.cpp b/Common/UI/ScrollView.cpp index 728bbc7278..c18566d518 100644 --- a/Common/UI/ScrollView.cpp +++ b/Common/UI/ScrollView.cpp @@ -288,7 +288,7 @@ bool ScrollView::SubviewFocused(View *view) { return true; } -NeighborResult ScrollView::FindScrollNeighbor(View *view, const Point &target, FocusDirection direction, NeighborResult best) { +NeighborResult ScrollView::FindScrollNeighbor(View *view, const Point2D &target, FocusDirection direction, NeighborResult best) { if (ContainsSubview(view) && views_[0]->IsViewGroup()) { ViewGroup *vg = static_cast(views_[0]); int found = -1; @@ -315,7 +315,7 @@ NeighborResult ScrollView::FindScrollNeighbor(View *view, const Point &target, F } // Okay, now where is our ideal target? - Point targetPos = view->GetBounds().Center(); + Point2D targetPos = view->GetBounds().Center(); if (orientation_ == ORIENT_VERTICAL) targetPos.y += mult * bounds_.h; else diff --git a/Common/UI/ScrollView.h b/Common/UI/ScrollView.h index a5c31a2feb..99c7304e56 100644 --- a/Common/UI/ScrollView.h +++ b/Common/UI/ScrollView.h @@ -44,7 +44,7 @@ public: alignOpposite_ = alignOpposite; } - NeighborResult FindScrollNeighbor(View *view, const Point &target, FocusDirection direction, NeighborResult best) override; + NeighborResult FindScrollNeighbor(View *view, const Point2D &target, FocusDirection direction, NeighborResult best) override; private: float HardClampedScrollPos(float pos) const; diff --git a/Common/UI/Tween.cpp b/Common/UI/Tween.cpp index bbe819e915..bf7e29026e 100644 --- a/Common/UI/Tween.cpp +++ b/Common/UI/Tween.cpp @@ -67,7 +67,7 @@ void TweenBase::PersistData(PersistStatus status, std::string anonId, Per template void TweenBase::PersistData(PersistStatus status, std::string anonId, PersistMap &storage); template void TweenBase::PersistData(PersistStatus status, std::string anonId, PersistMap &storage); -template void TweenBase::PersistData(PersistStatus status, std::string anonId, PersistMap &storage); +template void TweenBase::PersistData(PersistStatus status, std::string anonId, PersistMap &storage); uint32_t ColorTween::Current(float pos) { return colorBlend(to_, from_, pos); @@ -99,7 +99,7 @@ Visibility VisibilityTween::Current(float p) { } void AnchorTranslateTween::DoApply(View *view, float pos) { - Point cur = Current(pos); + Point2D cur = Current(pos); auto prev = view->GetLayoutParams()->As(); auto lp = new AnchorLayoutParams(prev ? *prev : AnchorLayoutParams(FILL_PARENT, FILL_PARENT)); @@ -108,9 +108,9 @@ void AnchorTranslateTween::DoApply(View *view, float pos) { view->ReplaceLayoutParams(lp); } -Point AnchorTranslateTween::Current(float p) { +Point2D AnchorTranslateTween::Current(float p) { float inv = 1.0f - p; - return Point(from_.x * inv + to_.x * p, from_.y * inv + to_.y * p); + return Point2D(from_.x * inv + to_.x * p, from_.y * inv + to_.y * p); } } // namespace diff --git a/Common/UI/Tween.h b/Common/UI/Tween.h index 2786963d55..c3e4c1181e 100644 --- a/Common/UI/Tween.h +++ b/Common/UI/Tween.h @@ -182,14 +182,14 @@ protected: Visibility Current(float pos) override; }; -class AnchorTranslateTween : public TweenBase { +class AnchorTranslateTween : public TweenBase { public: using TweenBase::TweenBase; protected: void DoApply(View *view, float pos) override; - Point Current(float pos) override; + Point2D Current(float pos) override; }; } // namespace diff --git a/Common/UI/UIScreen.h b/Common/UI/UIScreen.h index 701fe4e42d..2918d2676e 100644 --- a/Common/UI/UIScreen.h +++ b/Common/UI/UIScreen.h @@ -144,7 +144,7 @@ private: int finishFrame_ = -1; DialogResult finishResult_ = DR_CANCEL; bool hasPopupOrigin_ = false; - Point popupOrigin_; + Point2D popupOrigin_; float offsetY_ = 0.0f; bool alignTop_ = false; diff --git a/Common/UI/View.cpp b/Common/UI/View.cpp index 8333c514bf..d6f8e27490 100644 --- a/Common/UI/View.cpp +++ b/Common/UI/View.cpp @@ -168,25 +168,25 @@ void View::PersistData(PersistStatus status, std::string anonId, PersistMap &sto } } -Point View::GetFocusPosition(FocusDirection dir) const { +Point2D View::GetFocusPosition(FocusDirection dir) const { // The +2/-2 is some extra fudge factor to cover for views sitting right next to each other. // Distance zero yields strange results otherwise. switch (dir) { - case FOCUS_LEFT: return Point(bounds_.x + 2, bounds_.centerY()); - case FOCUS_RIGHT: return Point(bounds_.x2() - 2, bounds_.centerY()); - case FOCUS_UP: return Point(bounds_.centerX(), bounds_.y + 2); - case FOCUS_DOWN: return Point(bounds_.centerX(), bounds_.y2() - 2); + case FOCUS_LEFT: return Point2D(bounds_.x + 2, bounds_.centerY()); + case FOCUS_RIGHT: return Point2D(bounds_.x2() - 2, bounds_.centerY()); + case FOCUS_UP: return Point2D(bounds_.centerX(), bounds_.y + 2); + case FOCUS_DOWN: return Point2D(bounds_.centerX(), bounds_.y2() - 2); default: return bounds_.Center(); } } -Point CollapsibleHeader::GetFocusPosition(FocusDirection dir) const { +Point2D CollapsibleHeader::GetFocusPosition(FocusDirection dir) const { // Bias the focus position to the left. switch (dir) { - case FOCUS_UP: return Point(bounds_.x + 50, bounds_.y + 2); - case FOCUS_DOWN: return Point(bounds_.x + 50, bounds_.y2() - 2); + case FOCUS_UP: return Point2D(bounds_.x + 50, bounds_.y + 2); + case FOCUS_DOWN: return Point2D(bounds_.x + 50, bounds_.y2() - 2); default: return View::GetFocusPosition(dir); } diff --git a/Common/UI/View.h b/Common/UI/View.h index 97923f2819..c75b96fcfe 100644 --- a/Common/UI/View.h +++ b/Common/UI/View.h @@ -468,7 +468,7 @@ public: virtual bool IsViewGroup() const { return false; } virtual bool ContainsSubview(const View *view) const { return false; } - virtual Point GetFocusPosition(FocusDirection dir) const; + virtual Point2D GetFocusPosition(FocusDirection dir) const; template T *AddTween(T *t) { @@ -904,7 +904,7 @@ public: void GetContentDimensionsBySpec(const UIContext &dc, MeasureSpec horiz, MeasureSpec vert, float &w, float &h) const override; void GetContentDimensions(const UIContext &dc, float &w, float &h) const override; - Point GetFocusPosition(FocusDirection dir) const override; + Point2D GetFocusPosition(FocusDirection dir) const override; void SetHasSubitems(bool hasSubItems) { hasSubItems_ = hasSubItems; } void SetOpenPtr(bool *open) { diff --git a/Common/UI/ViewGroup.cpp b/Common/UI/ViewGroup.cpp index 0120f87419..fd7881ea39 100644 --- a/Common/UI/ViewGroup.cpp +++ b/Common/UI/ViewGroup.cpp @@ -284,7 +284,7 @@ static float VerticalOverlap(const Bounds &a, const Bounds &b) { return std::min(1.0f, overlap / minH); } -float GetTargetScore(const Point &originPos, int originIndex, const View *origin, const View *destination, FocusDirection direction) { +float GetTargetScore(const Point2D &originPos, int originIndex, const View *origin, const View *destination, FocusDirection direction) { // Skip labels and things like that. if (!destination->CanBeFocused()) return 0.0f; @@ -293,7 +293,7 @@ float GetTargetScore(const Point &originPos, int originIndex, const View *origin if (destination->GetVisibility() != V_VISIBLE) return 0.0f; - Point destPos = destination->GetFocusPosition(Opposite(direction)); + Point2D destPos = destination->GetFocusPosition(Opposite(direction)); float dx = destPos.x - originPos.x; float dy = destPos.y - originPos.y; @@ -385,7 +385,7 @@ float GetTargetScore(const Point &originPos, int originIndex, const View *origin } static float GetDirectionScore(int originIndex, const View *origin, View *destination, FocusDirection direction) { - Point originPos = origin->GetFocusPosition(direction); + Point2D originPos = origin->GetFocusPosition(direction); return GetTargetScore(originPos, originIndex, origin, destination, direction); } @@ -444,7 +444,7 @@ NeighborResult ViewGroup::FindNeighbor(View *view, FocusDirection direction, Nei } case FOCUS_PREV_PAGE: case FOCUS_NEXT_PAGE: - return FindScrollNeighbor(view, Point(INFINITY, INFINITY), direction, result); + return FindScrollNeighbor(view, Point2D(INFINITY, INFINITY), direction, result); case FOCUS_PREV: // If view not found, no neighbor to find. if (num == -1) @@ -462,7 +462,7 @@ NeighborResult ViewGroup::FindNeighbor(View *view, FocusDirection direction, Nei } } -NeighborResult ViewGroup::FindScrollNeighbor(View *view, const Point &target, FocusDirection direction, NeighborResult best) { +NeighborResult ViewGroup::FindScrollNeighbor(View *view, const Point2D &target, FocusDirection direction, NeighborResult best) { if (!IsEnabled()) return best; if (GetVisibility() != V_VISIBLE) @@ -1015,21 +1015,21 @@ void TabHolder::SetCurrentTab(int tab, bool skipTween) { // Currently displayed, so let's reset it. if (skipTween) { tabs_[currentTab_]->SetVisibility(V_GONE); - tabTweens_[tab]->Reset(Point(0.0f, 0.0f)); + tabTweens_[tab]->Reset(Point2D(0.0f, 0.0f)); tabTweens_[tab]->Apply(tabs_[tab]); } else { - tabTweens_[currentTab_]->Reset(Point(0.0f, 0.0f)); + tabTweens_[currentTab_]->Reset(Point2D(0.0f, 0.0f)); if (orient == ORIENT_HORIZONTAL) { - tabTweens_[tab]->Reset(Point(bounds_.w * dir, 0.0f)); - tabTweens_[currentTab_]->Divert(Point(bounds_.w * -dir, 0.0f)); + tabTweens_[tab]->Reset(Point2D(bounds_.w * dir, 0.0f)); + tabTweens_[currentTab_]->Divert(Point2D(bounds_.w * -dir, 0.0f)); } else { - tabTweens_[tab]->Reset(Point(0.0f, bounds_.h * dir)); - tabTweens_[currentTab_]->Divert(Point(0.0f, bounds_.h * -dir)); + tabTweens_[tab]->Reset(Point2D(0.0f, bounds_.h * dir)); + tabTweens_[currentTab_]->Divert(Point2D(0.0f, bounds_.h * -dir)); } // Actually move it to the initial position now, just to avoid any flicker. tabTweens_[tab]->Apply(tabs_[tab]); - tabTweens_[tab]->Divert(Point(0.0f, 0.0f)); + tabTweens_[tab]->Divert(Point2D(0.0f, 0.0f)); } tabs_[tab]->SetVisibility(V_VISIBLE); diff --git a/Common/UI/ViewGroup.h b/Common/UI/ViewGroup.h index d54b59a754..9ccde20aec 100644 --- a/Common/UI/ViewGroup.h +++ b/Common/UI/ViewGroup.h @@ -60,7 +60,7 @@ public: // Assumes that layout has taken place. NeighborResult FindNeighbor(View *view, FocusDirection direction, NeighborResult best); - virtual NeighborResult FindScrollNeighbor(View *view, const Point &target, FocusDirection direction, NeighborResult best); + virtual NeighborResult FindScrollNeighbor(View *view, const Point2D &target, FocusDirection direction, NeighborResult best); bool CanBeFocused() const override { return false; } bool IsViewGroup() const override { return true; } diff --git a/UI/TouchControlLayoutScreen.cpp b/UI/TouchControlLayoutScreen.cpp index 0f66931b2e..367fee910d 100644 --- a/UI/TouchControlLayoutScreen.cpp +++ b/UI/TouchControlLayoutScreen.cpp @@ -370,8 +370,8 @@ public: int mode_ = 0; }; -static Point ClampTo(const Point &p, const Bounds &b) { - return Point(clamp_value(p.x, b.x, b.x + b.w), clamp_value(p.y, b.y, b.y + b.h)); +static Point2D ClampTo(const Point2D &p, const Bounds &b) { + return Point2D(clamp_value(p.x, b.x, b.x + b.w), clamp_value(p.y, b.y, b.y + b.h)); } bool ControlLayoutView::Touch(const TouchInput &touch) { @@ -393,7 +393,7 @@ bool ControlLayoutView::Touch(const TouchInput &touch) { //validRange.y += controlBounds.h * 0.5f; //validRange.h -= controlBounds.h; - Point newPos; + Point2D newPos; newPos.x = startObjectX_ + (touch.x - startDragX_); newPos.y = startObjectY_ + (touch.y - startDragY_); if (g_Config.bTouchSnapToGrid) {