MCPcopy Create free account
hub / github.com/MyGUI/mygui / addTime

Method addTime

MyGUIEngine/src/MyGUI_ControllerEdgeHide.cpp:29–115  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

27 }
28
29 bool ControllerEdgeHide::addTime(Widget* _widget, float _time)
30 {
31 const IntSize& view_size = _widget->getParentSize();
32 // do nothing if we have minimized window
33 if (view_size.width <= 1 && view_size.height <= 1)
34 return true;
35
36 Widget* keyFocus = InputManager::getInstance().getKeyFocusWidget();
37 Widget* mouseFocus = InputManager::getInstance().getMouseFocusWidget();
38
39 while ((keyFocus != nullptr) && (_widget != keyFocus))
40 keyFocus = keyFocus->getParent();
41 while ((mouseFocus != nullptr) && (_widget != mouseFocus))
42 mouseFocus = mouseFocus->getParent();
43
44 // if our widget or its children have focus
45 bool haveFocus = ((keyFocus != nullptr) || (mouseFocus != nullptr)) || (!_widget->getVisible());
46
47 mElapsedTime += haveFocus ? -_time : _time;
48
49 if (mElapsedTime >= mTime)
50 {
51 mElapsedTime = mTime;
52 }
53 if (mElapsedTime <= 0)
54 {
55 mElapsedTime = 0.0f;
56 return true;
57 }
58
59 float k = std::sin(M_PI * mElapsedTime / mTime - M_PI / 2);
60 if (k < 0)
61 k = (-std::pow(-k, 0.7f) + 1) / 2;
62 else
63 k = (std::pow(k, 0.7f) + 1) / 2;
64
65 MyGUI::IntCoord coord = _widget->getCoord();
66 // if widget was moved
67 if (coord != mLastCoord)
68 {
69 // if still moving - leave it alone
70 if (haveFocus)
71 return true;
72 recalculateTime(_widget);
73 }
74
75 bool nearBorder = false;
76
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)
82 {
83 coord.left = -int(float(coord.width - mRemainPixels - mShadowSize) * k);
84 nearBorder = true;
85 }
86 if (behindTop && !behindBottom)

Callers 2

frameEnteredMethod · 0.45
frameEnteredMethod · 0.45

Calls 8

getParentSizeMethod · 0.80
getKeyFocusWidgetMethod · 0.80
getMouseFocusWidgetMethod · 0.80
rightMethod · 0.80
bottomMethod · 0.80
getParentMethod · 0.45
getVisibleMethod · 0.45
setCoordMethod · 0.45

Tested by

no test coverage detected