33 const float M_PI = 3.141593f;
48 void ControllerEdgeHide::prepareItem(
Widget* _widget)
50 recalculateTime(_widget);
55 bool ControllerEdgeHide::addTime(Widget* _widget,
float _time)
57 const IntSize& view_size = _widget->getParentSize();
59 if (view_size.width <= 1 && view_size.height <= 1)
65 while ((keyFocus !=
nullptr) && (_widget != keyFocus))
67 while ((mouseFocus !=
nullptr) && (_widget != mouseFocus))
71 bool haveFocus = ((keyFocus !=
nullptr) || (mouseFocus !=
nullptr)) || (_widget->getVisible() ==
false);
73 mElapsedTime += haveFocus ? -_time : _time;
75 if (mElapsedTime >= mTime)
79 if (mElapsedTime <= 0)
85 float k = sin(
M_PI * mElapsedTime / mTime -
M_PI / 2);
86 if (k < 0) k = (-pow(-k, 0.7f) + 1) / 2;
87 else k = (pow(k, 0.7f) + 1) / 2;
91 if (coord != mLastCoord)
97 recalculateTime(_widget);
100 bool nearBorder =
false;
102 if ((coord.
left <= 0) && !(coord.
right() >= view_size.width - 1))
104 coord.
left = - int(
float(coord.
width - mRemainPixels - mShadowSize) * k);
107 if ((coord.
top <= 0) && !(coord.
bottom() >= view_size.height - 1))
109 coord.
top = - int(
float(coord.
height - mRemainPixels - mShadowSize) * k);
112 if ((coord.
right() >= view_size.width - 1) && !(coord.
left <= 0))
114 coord.
left = int(
float(view_size.width - 1) -
float(mRemainPixels) * k -
float(coord.
width) * (1.f - k));
117 if ((coord.
bottom() >= view_size.height - 1) && !(coord.
top <= 0))
119 coord.
top = int(
float(view_size.height - 1) -
float(mRemainPixels) * k -
float(coord.
height) * (1.f - k));
125 _widget->setCoord(coord);
141 setTime(utility::parseValue<float>(_value));
142 else if (_key ==
"RemainPixels")
144 else if (_key ==
"ShadowSize")
148 void ControllerEdgeHide::recalculateTime(
Widget* _widget)
157 k = - (float) coord.
left / (coord.
width - mRemainPixels - mShadowSize);
159 else if ((coord.
top <= 0) && !(coord.
bottom() >= view_size.
height - 1))
161 k = - (float)coord.
top / (coord.
height - mRemainPixels - mShadowSize);
163 else if ((coord.
right() >= view_size.
width - 1) && !(coord.
left <= 0))
165 k = (float)(coord.
right() - view_size.
width + 1 ) / (coord.
width - mRemainPixels);
167 else if ((coord.
bottom() >= view_size.
height - 1) && !(coord.
top <= 0))
175 mElapsedTime = (asin( pow( 2 * k - 1, 1 / 0.7f)) /
M_PI + 1.f / 2) * mTime;
177 mElapsedTime = (asin(-pow(-2 * k + 1, 1 / 0.7f)) /
M_PI + 1.f / 2) * mTime;
187 mRemainPixels = _value;
192 mShadowSize = _value;
delegates::CMultiDelegate1< Widget * > eventUpdateAction
const IntCoord & getCoord() const
types::TSize< int > IntSize
static InputManager & getInstance()
virtual void setProperty(const std::string &_key, const std::string &_value)
void setShadowSize(int _value)
void setTime(float _value)
virtual ~ControllerEdgeHide()
delegates::CMultiDelegate1< Widget * > eventPreAction
void setRemainPixels(int _value)