| 1367 | } |
| 1368 | |
| 1369 | static void drawSearchBox(Window& self, Gfx::DrawingContext& drawingCtx) |
| 1370 | { |
| 1371 | char* textBuffer = (char*)StringManager::getString(StringIds::buffer_2039); |
| 1372 | strncpy(textBuffer, inputSession.buffer.c_str(), 256); |
| 1373 | |
| 1374 | auto& widget = _widgets[widx::searchBox]; |
| 1375 | auto clipped = Gfx::clipRenderTarget(drawingCtx.currentRenderTarget(), Ui::Rect(self.x + widget.left, widget.top + 1 + self.y, widget.width() - 2, widget.height() - 2)); |
| 1376 | if (!clipped) |
| 1377 | { |
| 1378 | return; |
| 1379 | } |
| 1380 | |
| 1381 | drawingCtx.pushRenderTarget(*clipped); |
| 1382 | |
| 1383 | auto tr = Gfx::TextRenderer(drawingCtx); |
| 1384 | |
| 1385 | // Draw search box input buffer |
| 1386 | FormatArguments args{}; |
| 1387 | args.push(StringIds::buffer_2039); |
| 1388 | |
| 1389 | Ui::Point position = { inputSession.xOffset, 1 }; |
| 1390 | tr.drawStringLeft(position, Colour::black, StringIds::black_stringid, args); |
| 1391 | |
| 1392 | // Draw search box cursor, blinking |
| 1393 | if (Input::isFocused(self.type, self.number, widx::searchBox) && (inputSession.cursorFrame % 32) < 16) |
| 1394 | { |
| 1395 | // We draw the string again to figure out where the cursor should go; position.x will be adjusted |
| 1396 | textBuffer[inputSession.cursorPosition] = '\0'; |
| 1397 | position = { inputSession.xOffset, 1 }; |
| 1398 | position = tr.drawStringLeft(position, Colour::black, StringIds::black_stringid, args); |
| 1399 | drawingCtx.fillRect(position.x, position.y, position.x, position.y + 9, Colours::getShade(self.getColour(WindowColour::secondary).c(), 9), Gfx::RectFlags::none); |
| 1400 | } |
| 1401 | |
| 1402 | drawingCtx.popRenderTarget(); |
| 1403 | } |
| 1404 | |
| 1405 | // 0x4C2F23 |
| 1406 | static void draw(Ui::Window& self, Gfx::DrawingContext& drawingCtx) |
no test coverage detected