* 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
| 226 | * @note Key width is measured in 1/2 keys to allow for 1/2 key shifting between rows. |
| 227 | */ |
| 228 | static 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). */ |
| 245 | static std::unique_ptr<NWidgetBase> MakeTopKeys() |
no test coverage detected