MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / GetButton

Method GetButton

src/network/network_gui.cpp:1412–1420  ·  view source on GitHub ↗

* Get the button at a given point on the line. * @param r Rect of line. * @param pt Point of interest. * @return Button at point, or \c nullptr if button isn't pressed. */

Source from the content-addressed store, hash-verified

1410 * @return Button at point, or \c nullptr if button isn't pressed.
1411 */
1412 ButtonCommon *GetButton(Rect r, const Point &pt) const
1413 {
1414 bool rtl = _current_text_dir == TD_RTL;
1415 for (auto &button : this->buttons) {
1416 if (r.WithWidth(button->width, !rtl).Contains(pt)) return button.get();
1417 r = r.Indent(button->width + WidgetDimensions::scaled.hsep_normal, !rtl);
1418 }
1419 return nullptr;
1420 }
1421
1422 /**
1423 * Get tooptip for a given point on the line.

Callers 2

GetTooltipMethod · 0.95
OnClickMethod · 0.45

Calls 4

WithWidthMethod · 0.80
IndentMethod · 0.80
ContainsMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected