mirror of
https://github.com/hrydgard/ppsspp.git
synced 2024-11-23 05:19:56 +00:00
Rename Point to Point2D to avoid a cocoa name clash
This commit is contained in:
parent
7e7d1d587a
commit
455e28da6c
@ -2,19 +2,19 @@
|
|||||||
|
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
|
||||||
struct Point {
|
struct Point2D {
|
||||||
Point() : x(0.0f), y(0.0f) {}
|
Point2D() : x(0.0f), y(0.0f) {}
|
||||||
Point(float x_, float y_) : x(x_), y(y_) {}
|
Point2D(float x_, float y_) : x(x_), y(y_) {}
|
||||||
|
|
||||||
float x;
|
float x;
|
||||||
float y;
|
float y;
|
||||||
|
|
||||||
float distanceTo(const Point &other) const {
|
float distanceTo(const Point2D &other) const {
|
||||||
float dx = other.x - x, dy = other.y - y;
|
float dx = other.x - x, dy = other.y - y;
|
||||||
return sqrtf(dx*dx + dy*dy);
|
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;
|
return x == other.x && y == other.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,8 +60,8 @@ struct Bounds {
|
|||||||
float y2() const { return y + h; }
|
float y2() const { return y + h; }
|
||||||
float centerX() const { return x + w * 0.5f; }
|
float centerX() const { return x + w * 0.5f; }
|
||||||
float centerY() const { return y + h * 0.5f; }
|
float centerY() const { return y + h * 0.5f; }
|
||||||
Point Center() const {
|
Point2D Center() const {
|
||||||
return Point(centerX(), centerY());
|
return Point2D(centerX(), centerY());
|
||||||
}
|
}
|
||||||
Bounds Expand(float amount) const {
|
Bounds Expand(float amount) const {
|
||||||
return Bounds(x - amount, y - amount, w + amount * 2, h + amount * 2);
|
return Bounds(x - amount, y - amount, w + amount * 2, h + amount * 2);
|
||||||
|
@ -288,7 +288,7 @@ bool ScrollView::SubviewFocused(View *view) {
|
|||||||
return true;
|
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()) {
|
if (ContainsSubview(view) && views_[0]->IsViewGroup()) {
|
||||||
ViewGroup *vg = static_cast<ViewGroup *>(views_[0]);
|
ViewGroup *vg = static_cast<ViewGroup *>(views_[0]);
|
||||||
int found = -1;
|
int found = -1;
|
||||||
@ -315,7 +315,7 @@ NeighborResult ScrollView::FindScrollNeighbor(View *view, const Point &target, F
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Okay, now where is our ideal target?
|
// Okay, now where is our ideal target?
|
||||||
Point targetPos = view->GetBounds().Center();
|
Point2D targetPos = view->GetBounds().Center();
|
||||||
if (orientation_ == ORIENT_VERTICAL)
|
if (orientation_ == ORIENT_VERTICAL)
|
||||||
targetPos.y += mult * bounds_.h;
|
targetPos.y += mult * bounds_.h;
|
||||||
else
|
else
|
||||||
|
@ -44,7 +44,7 @@ public:
|
|||||||
alignOpposite_ = alignOpposite;
|
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:
|
private:
|
||||||
float HardClampedScrollPos(float pos) const;
|
float HardClampedScrollPos(float pos) const;
|
||||||
|
@ -67,7 +67,7 @@ void TweenBase<Value>::PersistData(PersistStatus status, std::string anonId, Per
|
|||||||
|
|
||||||
template void TweenBase<uint32_t>::PersistData(PersistStatus status, std::string anonId, PersistMap &storage);
|
template void TweenBase<uint32_t>::PersistData(PersistStatus status, std::string anonId, PersistMap &storage);
|
||||||
template void TweenBase<Visibility>::PersistData(PersistStatus status, std::string anonId, PersistMap &storage);
|
template void TweenBase<Visibility>::PersistData(PersistStatus status, std::string anonId, PersistMap &storage);
|
||||||
template void TweenBase<Point>::PersistData(PersistStatus status, std::string anonId, PersistMap &storage);
|
template void TweenBase<Point2D>::PersistData(PersistStatus status, std::string anonId, PersistMap &storage);
|
||||||
|
|
||||||
uint32_t ColorTween::Current(float pos) {
|
uint32_t ColorTween::Current(float pos) {
|
||||||
return colorBlend(to_, from_, pos);
|
return colorBlend(to_, from_, pos);
|
||||||
@ -99,7 +99,7 @@ Visibility VisibilityTween::Current(float p) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void AnchorTranslateTween::DoApply(View *view, float pos) {
|
void AnchorTranslateTween::DoApply(View *view, float pos) {
|
||||||
Point cur = Current(pos);
|
Point2D cur = Current(pos);
|
||||||
|
|
||||||
auto prev = view->GetLayoutParams()->As<AnchorLayoutParams>();
|
auto prev = view->GetLayoutParams()->As<AnchorLayoutParams>();
|
||||||
auto lp = new AnchorLayoutParams(prev ? *prev : AnchorLayoutParams(FILL_PARENT, FILL_PARENT));
|
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);
|
view->ReplaceLayoutParams(lp);
|
||||||
}
|
}
|
||||||
|
|
||||||
Point AnchorTranslateTween::Current(float p) {
|
Point2D AnchorTranslateTween::Current(float p) {
|
||||||
float inv = 1.0f - 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
|
} // namespace
|
||||||
|
@ -182,14 +182,14 @@ protected:
|
|||||||
Visibility Current(float pos) override;
|
Visibility Current(float pos) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
class AnchorTranslateTween : public TweenBase<Point> {
|
class AnchorTranslateTween : public TweenBase<Point2D> {
|
||||||
public:
|
public:
|
||||||
using TweenBase::TweenBase;
|
using TweenBase::TweenBase;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void DoApply(View *view, float pos) override;
|
void DoApply(View *view, float pos) override;
|
||||||
|
|
||||||
Point Current(float pos) override;
|
Point2D Current(float pos) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
@ -144,7 +144,7 @@ private:
|
|||||||
int finishFrame_ = -1;
|
int finishFrame_ = -1;
|
||||||
DialogResult finishResult_ = DR_CANCEL;
|
DialogResult finishResult_ = DR_CANCEL;
|
||||||
bool hasPopupOrigin_ = false;
|
bool hasPopupOrigin_ = false;
|
||||||
Point popupOrigin_;
|
Point2D popupOrigin_;
|
||||||
float offsetY_ = 0.0f;
|
float offsetY_ = 0.0f;
|
||||||
bool alignTop_ = false;
|
bool alignTop_ = false;
|
||||||
|
|
||||||
|
@ -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.
|
// The +2/-2 is some extra fudge factor to cover for views sitting right next to each other.
|
||||||
// Distance zero yields strange results otherwise.
|
// Distance zero yields strange results otherwise.
|
||||||
switch (dir) {
|
switch (dir) {
|
||||||
case FOCUS_LEFT: return Point(bounds_.x + 2, bounds_.centerY());
|
case FOCUS_LEFT: return Point2D(bounds_.x + 2, bounds_.centerY());
|
||||||
case FOCUS_RIGHT: return Point(bounds_.x2() - 2, bounds_.centerY());
|
case FOCUS_RIGHT: return Point2D(bounds_.x2() - 2, bounds_.centerY());
|
||||||
case FOCUS_UP: return Point(bounds_.centerX(), bounds_.y + 2);
|
case FOCUS_UP: return Point2D(bounds_.centerX(), bounds_.y + 2);
|
||||||
case FOCUS_DOWN: return Point(bounds_.centerX(), bounds_.y2() - 2);
|
case FOCUS_DOWN: return Point2D(bounds_.centerX(), bounds_.y2() - 2);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return bounds_.Center();
|
return bounds_.Center();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Point CollapsibleHeader::GetFocusPosition(FocusDirection dir) const {
|
Point2D CollapsibleHeader::GetFocusPosition(FocusDirection dir) const {
|
||||||
// Bias the focus position to the left.
|
// Bias the focus position to the left.
|
||||||
switch (dir) {
|
switch (dir) {
|
||||||
case FOCUS_UP: return Point(bounds_.x + 50, bounds_.y + 2);
|
case FOCUS_UP: return Point2D(bounds_.x + 50, bounds_.y + 2);
|
||||||
case FOCUS_DOWN: return Point(bounds_.x + 50, bounds_.y2() - 2);
|
case FOCUS_DOWN: return Point2D(bounds_.x + 50, bounds_.y2() - 2);
|
||||||
default:
|
default:
|
||||||
return View::GetFocusPosition(dir);
|
return View::GetFocusPosition(dir);
|
||||||
}
|
}
|
||||||
|
@ -468,7 +468,7 @@ public:
|
|||||||
virtual bool IsViewGroup() const { return false; }
|
virtual bool IsViewGroup() const { return false; }
|
||||||
virtual bool ContainsSubview(const View *view) 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 <class T>
|
template <class T>
|
||||||
T *AddTween(T *t) {
|
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 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;
|
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 SetHasSubitems(bool hasSubItems) { hasSubItems_ = hasSubItems; }
|
||||||
void SetOpenPtr(bool *open) {
|
void SetOpenPtr(bool *open) {
|
||||||
|
@ -284,7 +284,7 @@ static float VerticalOverlap(const Bounds &a, const Bounds &b) {
|
|||||||
return std::min(1.0f, overlap / minH);
|
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.
|
// Skip labels and things like that.
|
||||||
if (!destination->CanBeFocused())
|
if (!destination->CanBeFocused())
|
||||||
return 0.0f;
|
return 0.0f;
|
||||||
@ -293,7 +293,7 @@ float GetTargetScore(const Point &originPos, int originIndex, const View *origin
|
|||||||
if (destination->GetVisibility() != V_VISIBLE)
|
if (destination->GetVisibility() != V_VISIBLE)
|
||||||
return 0.0f;
|
return 0.0f;
|
||||||
|
|
||||||
Point destPos = destination->GetFocusPosition(Opposite(direction));
|
Point2D destPos = destination->GetFocusPosition(Opposite(direction));
|
||||||
|
|
||||||
float dx = destPos.x - originPos.x;
|
float dx = destPos.x - originPos.x;
|
||||||
float dy = destPos.y - originPos.y;
|
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) {
|
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);
|
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_PREV_PAGE:
|
||||||
case FOCUS_NEXT_PAGE:
|
case FOCUS_NEXT_PAGE:
|
||||||
return FindScrollNeighbor(view, Point(INFINITY, INFINITY), direction, result);
|
return FindScrollNeighbor(view, Point2D(INFINITY, INFINITY), direction, result);
|
||||||
case FOCUS_PREV:
|
case FOCUS_PREV:
|
||||||
// If view not found, no neighbor to find.
|
// If view not found, no neighbor to find.
|
||||||
if (num == -1)
|
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())
|
if (!IsEnabled())
|
||||||
return best;
|
return best;
|
||||||
if (GetVisibility() != V_VISIBLE)
|
if (GetVisibility() != V_VISIBLE)
|
||||||
@ -1015,21 +1015,21 @@ void TabHolder::SetCurrentTab(int tab, bool skipTween) {
|
|||||||
// Currently displayed, so let's reset it.
|
// Currently displayed, so let's reset it.
|
||||||
if (skipTween) {
|
if (skipTween) {
|
||||||
tabs_[currentTab_]->SetVisibility(V_GONE);
|
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]);
|
tabTweens_[tab]->Apply(tabs_[tab]);
|
||||||
} else {
|
} else {
|
||||||
tabTweens_[currentTab_]->Reset(Point(0.0f, 0.0f));
|
tabTweens_[currentTab_]->Reset(Point2D(0.0f, 0.0f));
|
||||||
|
|
||||||
if (orient == ORIENT_HORIZONTAL) {
|
if (orient == ORIENT_HORIZONTAL) {
|
||||||
tabTweens_[tab]->Reset(Point(bounds_.w * dir, 0.0f));
|
tabTweens_[tab]->Reset(Point2D(bounds_.w * dir, 0.0f));
|
||||||
tabTweens_[currentTab_]->Divert(Point(bounds_.w * -dir, 0.0f));
|
tabTweens_[currentTab_]->Divert(Point2D(bounds_.w * -dir, 0.0f));
|
||||||
} else {
|
} else {
|
||||||
tabTweens_[tab]->Reset(Point(0.0f, bounds_.h * dir));
|
tabTweens_[tab]->Reset(Point2D(0.0f, bounds_.h * dir));
|
||||||
tabTweens_[currentTab_]->Divert(Point(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.
|
// Actually move it to the initial position now, just to avoid any flicker.
|
||||||
tabTweens_[tab]->Apply(tabs_[tab]);
|
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);
|
tabs_[tab]->SetVisibility(V_VISIBLE);
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ public:
|
|||||||
|
|
||||||
// Assumes that layout has taken place.
|
// Assumes that layout has taken place.
|
||||||
NeighborResult FindNeighbor(View *view, FocusDirection direction, NeighborResult best);
|
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 CanBeFocused() const override { return false; }
|
||||||
bool IsViewGroup() const override { return true; }
|
bool IsViewGroup() const override { return true; }
|
||||||
|
@ -370,8 +370,8 @@ public:
|
|||||||
int mode_ = 0;
|
int mode_ = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
static Point ClampTo(const Point &p, const Bounds &b) {
|
static Point2D ClampTo(const Point2D &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));
|
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) {
|
bool ControlLayoutView::Touch(const TouchInput &touch) {
|
||||||
@ -393,7 +393,7 @@ bool ControlLayoutView::Touch(const TouchInput &touch) {
|
|||||||
//validRange.y += controlBounds.h * 0.5f;
|
//validRange.y += controlBounds.h * 0.5f;
|
||||||
//validRange.h -= controlBounds.h;
|
//validRange.h -= controlBounds.h;
|
||||||
|
|
||||||
Point newPos;
|
Point2D newPos;
|
||||||
newPos.x = startObjectX_ + (touch.x - startDragX_);
|
newPos.x = startObjectX_ + (touch.x - startDragX_);
|
||||||
newPos.y = startObjectY_ + (touch.y - startDragY_);
|
newPos.y = startObjectY_ + (touch.y - startDragY_);
|
||||||
if (g_Config.bTouchSnapToGrid) {
|
if (g_Config.bTouchSnapToGrid) {
|
||||||
|
Loading…
Reference in New Issue
Block a user