20 const float M_PI = 3.141593f;
24 recalculateTime(_widget);
39 while ((keyFocus !=
nullptr) && (_widget != keyFocus))
41 while ((mouseFocus !=
nullptr) && (_widget != mouseFocus))
45 bool haveFocus = ((keyFocus !=
nullptr) || (mouseFocus !=
nullptr)) || (!_widget->
getVisible());
47 mElapsedTime += haveFocus ? -_time : _time;
49 if (mElapsedTime >= mTime)
53 if (mElapsedTime <= 0)
59 float k = std::sin(
M_PI * mElapsedTime / mTime -
M_PI / 2);
61 k = (-std::pow(-k, 0.7f) + 1) / 2;
63 k = (std::pow(k, 0.7f) + 1) / 2;
67 if (coord != mLastCoord)
72 recalculateTime(_widget);
75 bool nearBorder =
false;
77 bool behindLeft = coord.
left <= 0;
78 bool behindRight = coord.
right() >= view_size.
width - 1;
79 bool behindTop = coord.
top <= 0;
80 bool behindBottom = coord.
bottom() >= view_size.
height - 1;
81 if (behindLeft && !behindRight)
83 coord.
left = -int(
float(coord.
width - mRemainPixels - mShadowSize) * k);
86 if (behindTop && !behindBottom)
88 coord.
top = -int(
float(coord.
height - mRemainPixels - mShadowSize) * k);
91 if (behindRight && !behindLeft)
93 coord.
left = int(
float(view_size.
width - 1) -
float(mRemainPixels) * k -
float(coord.
width) * (1.f - k));
96 if (behindBottom && !behindTop)
98 coord.
top = int(
float(view_size.
height - 1) -
float(mRemainPixels) * k -
float(coord.
height) * (1.f - k));
121 else if (_key ==
"RemainPixels")
123 else if (_key ==
"ShadowSize")
127 void ControllerEdgeHide::recalculateTime(
Widget* _widget)
133 bool behindLeft = coord.
left <= 0;
134 bool behindRight = coord.
right() >= view_size.
width - 1;
135 bool behindTop = coord.
top <= 0;
136 bool behindBottom = coord.
bottom() >= view_size.
height - 1;
138 if (behindLeft && !behindRight)
140 k = -(float)coord.
left / (coord.
width - mRemainPixels - mShadowSize);
142 else if (behindTop && !behindBottom)
144 k = -(float)coord.
top / (coord.
height - mRemainPixels - mShadowSize);
146 else if (behindRight && !behindLeft)
148 k = (float)(coord.
right() - view_size.
width + 1) / (coord.
width - mRemainPixels);
150 else if (behindBottom && !behindTop)
158 mElapsedTime = (std::asin(std::pow(2 * k - 1, 1 / 0.7f)) /
M_PI + 1.f / 2) * mTime;
160 mElapsedTime = (std::asin(-std::pow(-2 * k + 1, 1 / 0.7f)) /
M_PI + 1.f / 2) * mTime;
170 mRemainPixels = _value;
175 mShadowSize = _value;
void setRemainPixels(int _value)
void setShadowSize(int _value)
void setTime(float _value)
bool addTime(Widget *_widget, float _time) override
void prepareItem(Widget *_widget) override
void setProperty(std::string_view _key, std::string_view _value) override
EventPairAddParameter< EventHandle_WidgetPtr, EventHandle_WidgetPtrControllerItemPtr > eventPreAction
EventPairAddParameter< EventHandle_WidgetPtr, EventHandle_WidgetPtrControllerItemPtr > eventUpdateAction
const IntCoord & getCoord() const
T parseValue(std::string_view _value)
types::TCoord< int > IntCoord
types::TSize< int > IntSize