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

Method OnClick

src/newgrf_badge_gui.cpp:288–298  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

286 }
287
288 int OnClick(const Rect &r, const Point &pt) const override
289 {
290 bool rtl = (_current_text_dir == TD_RTL);
291 int w = SETTING_BUTTON_WIDTH;
292
293 Rect br = r.WithWidth(w, TEnd ^ rtl).CentreToHeight(SETTING_BUTTON_HEIGHT);
294 if (br.WithWidth(w / 2, rtl).Contains(pt)) return this->click_up;
295 if (br.WithWidth(w / 2, !rtl).Contains(pt)) return this->click_down;
296
297 return this->TBase::OnClick(r.Indent(w + WidgetDimensions::scaled.hsep_wide, TEnd ^ rtl), pt);
298 }
299
300 void Draw(const Rect &full, const Rect &r, bool sel, int click_result, Colours bg_colour) const override
301 {

Callers

nothing calls this directly

Calls 4

CentreToHeightMethod · 0.80
WithWidthMethod · 0.80
IndentMethod · 0.80
ContainsMethod · 0.45

Tested by

no test coverage detected