MCPcopy Create free account
hub / github.com/OpenRCT2/OpenRCT2 / widgetScrollGetPart

Function widgetScrollGetPart

src/openrct2-ui/interface/Widget.cpp:961–1069  ·  view source on GitHub ↗

* * rct2: 0x006E9F92 * eax: x / output_x * ebx: y / output_y * ecx: output_scroll_area * edx: scroll_id * esi: w * edi: widget */

Source from the content-addressed store, hash-verified

959 * edi: widget
960 */
961 void widgetScrollGetPart(
962 WindowBase& w, const Widget* widget, const ScreenCoordsXY& screenCoords, ScreenCoordsXY& retScreenCoords,
963 int32_t* output_scroll_area, int32_t* scroll_id)
964 {
965 *scroll_id = 0;
966 auto itLast = std::find_if(
967 w.widgets.begin(), w.widgets.end(), [&](auto& otherWidget) { return &otherWidget == widget; });
968 for (auto it = w.widgets.begin(); it != itLast; it++)
969 {
970 if (it->type == WidgetType::scroll)
971 {
972 *scroll_id += 1;
973 }
974 }
975
976 const auto& scroll = w.scrolls[*scroll_id];
977 if ((scroll.flags & HSCROLLBAR_VISIBLE) && scroll.contentWidth > (widget->width() - 1)
978 && screenCoords.y >= (w.windowPos.y + widget->bottom - (kScrollBarWidth + 1)))
979 {
980 // horizontal scrollbar
981 int32_t rightOffset = 0;
982 int32_t iteratorLeft = widget->left + w.windowPos.x + kScrollBarWidth;
983 int32_t iteratorRight = widget->right + w.windowPos.x - kScrollBarWidth;
984 if (!(scroll.flags & VSCROLLBAR_VISIBLE))
985 {
986 rightOffset = kScrollBarWidth + 1;
987 }
988
989 if (screenCoords.x <= iteratorLeft)
990 {
991 *output_scroll_area = SCROLL_PART_HSCROLLBAR_LEFT;
992 }
993 else if (screenCoords.x >= iteratorRight + rightOffset)
994 {
995 *output_scroll_area = SCROLL_PART_NONE;
996 }
997 else if (screenCoords.x >= iteratorRight + rightOffset - kScrollBarWidth)
998 {
999 *output_scroll_area = SCROLL_PART_HSCROLLBAR_RIGHT;
1000 }
1001 else if (screenCoords.x < (widget->left + w.windowPos.x + scroll.hThumbLeft))
1002 {
1003 *output_scroll_area = SCROLL_PART_HSCROLLBAR_LEFT_TROUGH;
1004 }
1005 else if (screenCoords.x > (widget->left + w.windowPos.x + scroll.hThumbRight))
1006 {
1007 *output_scroll_area = SCROLL_PART_HSCROLLBAR_RIGHT_TROUGH;
1008 }
1009 else
1010 {
1011 *output_scroll_area = SCROLL_PART_HSCROLLBAR_THUMB;
1012 }
1013 }
1014 else if (
1015 (scroll.flags & VSCROLLBAR_VISIBLE) && scroll.contentHeight > widget->height() - 1
1016 && (screenCoords.x >= w.windowPos.x + widget->right - (kScrollBarWidth + 1)))
1017 {
1018 // vertical scrollbar

Callers 6

onPeriodicUpdateMethod · 0.85
GetResearchItemAtMethod · 0.85
InputScrollBeginFunction · 0.85
InputScrollContinueFunction · 0.85
InputWidgetOverFunction · 0.85
ProcessMouseOverFunction · 0.85

Calls 4

widthMethod · 0.80
heightMethod · 0.80
endMethod · 0.65
beginMethod · 0.45

Tested by

no test coverage detected