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

Method updateTrack

MyGUIEngine/src/MyGUI_ScrollBar.cpp:104–185  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

102 }
103
104 void ScrollBar::updateTrack()
105 {
106 if (mWidgetTrack == nullptr)
107 return;
108
109 _forcePick(mWidgetTrack);
110 // размер диапазана в пикселях
111 int pos = getLineSize();
112
113 if (mVerticalAlignment)
114 {
115 // скрываем если диапазан маленький или места мало
116 if ((mScrollRange < 2) || (pos <= mWidgetTrack->getHeight()))
117 {
118 mWidgetTrack->setVisible(false);
119 if (nullptr != mWidgetFirstPart)
120 mWidgetFirstPart->setSize(mWidgetFirstPart->getWidth(), pos / 2);
121 if (nullptr != mWidgetSecondPart)
122 mWidgetSecondPart->setCoord(
123 mWidgetSecondPart->getLeft(),
124 pos / 2 + (int)mSkinRangeStart,
125 mWidgetSecondPart->getWidth(),
126 pos - pos / 2);
127 return;
128 }
129 // если скрыт то покажем
130 if (!mWidgetTrack->getVisible())
131 mWidgetTrack->setVisible(true);
132
133 // и обновляем позицию
134 pos = (int)(((size_t)(pos - getTrackSize()) * mScrollPosition) / (mScrollRange - 1) + mSkinRangeStart);
135
136 mWidgetTrack->setPosition(mWidgetTrack->getLeft(), pos);
137 if (nullptr != mWidgetFirstPart)
138 {
139 int height = pos - mWidgetFirstPart->getTop();
140 mWidgetFirstPart->setSize(mWidgetFirstPart->getWidth(), height);
141 }
142 if (nullptr != mWidgetSecondPart)
143 {
144 int top = pos + mWidgetTrack->getHeight();
145 int height = getTrackPlaceLength() - top;
146 mWidgetSecondPart->setCoord(mWidgetSecondPart->getLeft(), top, mWidgetSecondPart->getWidth(), height);
147 }
148 }
149 else
150 {
151 // скрываем если диапазан маленький или места мало
152 if ((mScrollRange < 2) || (pos <= mWidgetTrack->getWidth()))
153 {
154 mWidgetTrack->setVisible(false);
155 if (nullptr != mWidgetFirstPart)
156 mWidgetFirstPart->setSize(pos / 2, mWidgetFirstPart->getHeight());
157 if (nullptr != mWidgetSecondPart)
158 mWidgetSecondPart->setCoord(
159 pos / 2 + (int)mSkinRangeStart,
160 mWidgetSecondPart->getTop(),
161 pos - pos / 2,

Callers

nothing calls this directly

Calls 9

getLeftMethod · 0.80
getTopMethod · 0.80
getHeightMethod · 0.45
setVisibleMethod · 0.45
setSizeMethod · 0.45
getWidthMethod · 0.45
setCoordMethod · 0.45
getVisibleMethod · 0.45
setPositionMethod · 0.45

Tested by

no test coverage detected