• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Return-To-The-Roots / s25client / 44076625557

17 Nov 2026 11:43AM UTC coverage: 51.803% (-0.002%) from 51.805%
44076625557

push

github

web-flow
Merge pull request #2018 from Return-To-The-Roots/refactor/lowerCamelCase-methods

Rename Msg_* handlers to lowerCamelCase

8121 of 16693 new or added lines in 565 files covered. (48.65%)

323 existing lines in 133 files now uncovered.

24236 of 46785 relevant lines covered (51.8%)

49647.74 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

91.3
/libs/s25main/controls/ctrlTextButton.cpp
1
// Copyright (C) 2005 - 2021 Settlers Freaks (sf-team at siedler25.org)
2
//
3
// SPDX-License-Identifier: GPL-2.0-or-later
4

5
#include "ctrlTextButton.h"
6
#include "ogl/FontStyle.h"
7
#include "ogl/glFont.h"
8

9
/// Offset of text to origin of the button
10
static constexpr unsigned contentOffset = 2;
11

12
ctrlTextButton::ctrlTextButton(Window* parent, unsigned id, const DrawPoint& pos, const Extent& size,
238 ✔
13
                               const TextureColor tc, const std::string& text, const glFont* font,
14
                               const std::string& tooltip)
238 ✔
15
    : ctrlButton(parent, id, pos, size, tc, tooltip), ctrlBaseText(text, COLOR_YELLOW, font)
238 ✔
16
{}
238 ✔
17

18
void ctrlTextButton::resizeForMaxChars(unsigned numChars)
2 ✔
19
{
20
    const auto maxTextWidth = font->getDx() * numChars;
2 ✔
21
    resize(Extent(maxTextWidth + contentOffset * 2, getSize().y));
2 ✔
22
}
2 ✔
23

24
void ctrlTextButton::drawContent() const
11 ✔
25
{
26
    const bool isPressed = state == ButtonState::Pressed || isChecked;
11 ✔
27
    unsigned color;
28
    if(this->color_ == COLOR_YELLOW && isPressed)
11 ✔
29
        color = 0xFFFFAA00;
1 ✔
30
    else if(!isEnabled)
10 ✔
31
        color = 0xFF818993;
×
32
    else
33
        color = this->color_;
10 ✔
34

35
    const unsigned short maxTextWidth = getSize().x - contentOffset * 2; // reduced by border
11 ✔
36

37
    if(getTooltip().empty() && state == ButtonState::Hover)
11 ✔
38
    {
39
        unsigned maxNumChars;
40
        font->getWidth(text, maxTextWidth, &maxNumChars);
1 ✔
41
        if(maxNumChars < text.length())
1 ✔
NEW
42
            showTooltip(text);
×
43
    }
44

45
    const unsigned short offset = isPressed ? contentOffset : 0;
11 ✔
46
    font->draw(getDrawPos() + getSize() / 2u + DrawPoint(offset, offset), text, FontStyle::CENTER | FontStyle::VCENTER,
11 ✔
47
               color, maxTextWidth);
48
}
11 ✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc