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

Function AddKey

src/osk_gui.cpp:228–242  ·  view source on GitHub ↗

* Add a key widget to a row of the keyboard. * @param hor Row container to add key widget to. * @param pad_y Vertical padding of the key (all keys in a row should have equal padding). * @param num_half Number of 1/2 key widths that this key has. * @param widtype Widget type of the key. Must be either \c NWID_SPACER for an invisible key, or a \c WWT_* widget. * @param widnum Widget numb

Source from the content-addressed store, hash-verified

226 * @note Key width is measured in 1/2 keys to allow for 1/2 key shifting between rows.
227 */
228static void AddKey(std::unique_ptr<NWidgetHorizontal> &hor, int pad_y, int num_half, WidgetType widtype, WidgetID widnum, const WidgetData &widdata)
229{
230 int key_width = HALF_KEY_WIDTH + (INTER_KEY_SPACE + HALF_KEY_WIDTH) * (num_half - 1);
231
232 if (widtype == NWID_SPACER) {
233 auto spc = std::make_unique<NWidgetSpacer>(key_width, 0);
234 spc->SetMinimalTextLines(1, pad_y, FS_NORMAL);
235 hor->Add(std::move(spc));
236 } else {
237 auto leaf = std::make_unique<NWidgetLeaf>(widtype, COLOUR_GREY, widnum, widdata, STR_NULL);
238 leaf->SetMinimalSize(key_width, 0);
239 leaf->SetMinimalTextLines(1, pad_y, FS_NORMAL);
240 hor->Add(std::move(leaf));
241 }
242}
243
244/** Construct the top row keys (cancel, ok, backspace). */
245static std::unique_ptr<NWidgetBase> MakeTopKeys()

Callers 6

MakeTopKeysFunction · 0.85
MakeNumberKeysFunction · 0.85
MakeQwertyKeysFunction · 0.85
MakeAsdfgKeysFunction · 0.85
MakeZxcvbKeysFunction · 0.85
MakeSpacebarKeysFunction · 0.85

Calls 3

SetMinimalTextLinesMethod · 0.80
SetMinimalSizeMethod · 0.80
AddMethod · 0.45

Tested by

no test coverage detected