20 const float M_PI = 3.141593f;
32 recalculateTime(_widget);
47 while ((keyFocus !=
nullptr) && (_widget != keyFocus))
49 while ((mouseFocus !=
nullptr) && (_widget != mouseFocus))
53 bool haveFocus = ((keyFocus !=
nullptr) || (mouseFocus !=
nullptr)) || (_widget->
getVisible() ==
false);
55 mElapsedTime += haveFocus ? -_time : _time;
57 if (mElapsedTime >= mTime)
61 if (mElapsedTime <= 0)
67 float k = std::sin(
M_PI * mElapsedTime / mTime -
M_PI / 2);
68 if (k < 0) k = (-std::pow(-k, 0.7f) + 1) / 2;
69 else k = (std::pow(k, 0.7f) + 1) / 2;
73 if (coord != mLastCoord)
79 recalculateTime(_widget);
82 bool nearBorder =
false;
86 coord.
left = - int(
float(coord.
width - mRemainPixels - mShadowSize) * k);
91 coord.
top = - int(
float(coord.
height - mRemainPixels - mShadowSize) * k);
96 coord.
left = int(
float(view_size.
width - 1) -
float(mRemainPixels) * k -
float(coord.
width) * (1.f - k));
101 coord.
top = int(
float(view_size.
height - 1) -
float(mRemainPixels) * k -
float(coord.
height) * (1.f - k));
123 setTime(utility::parseValue<float>(_value));
124 else if (_key ==
"RemainPixels")
126 else if (_key ==
"ShadowSize")
130 void ControllerEdgeHide::recalculateTime(
Widget* _widget)
139 k = - (float) coord.
left / (coord.
width - mRemainPixels - mShadowSize);
141 else if ((coord.
top <= 0) && !(coord.
bottom() >= view_size.
height - 1))
143 k = - (float)coord.
top / (coord.
height - mRemainPixels - mShadowSize);
145 else if ((coord.
right() >= view_size.
width - 1) && !(coord.
left <= 0))
147 k = (float)(coord.
right() - view_size.
width + 1 ) / (coord.
width - mRemainPixels);
149 else if ((coord.
bottom() >= view_size.
height - 1) && !(coord.
top <= 0))
157 mElapsedTime = (std::asin( std::pow( 2 * k - 1, 1 / 0.7f)) /
M_PI + 1.f / 2) * mTime;
159 mElapsedTime = (std::asin(-std::pow(-2 * k + 1, 1 / 0.7f)) /
M_PI + 1.f / 2) * mTime;
169 mRemainPixels = _value;
174 mShadowSize = _value;
void setRemainPixels(int _value)
void setProperty(const std::string &_key, const std::string &_value) override
void setShadowSize(int _value)
void setTime(float _value)
bool addTime(Widget *_widget, float _time) override
void prepareItem(Widget *_widget) override
EventPairAddParameter< EventHandle_WidgetPtr, EventHandle_WidgetPtrControllerItemPtr > eventPreAction
EventPairAddParameter< EventHandle_WidgetPtr, EventHandle_WidgetPtrControllerItemPtr > eventUpdateAction
const IntCoord & getCoord() const