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

Return-To-The-Roots / s25client / 17188815231

24 Aug 2025 12:40PM UTC coverage: 50.482%. First build
17188815231

Pull #1794

github

web-flow
Merge ead0fca0a into 12df4a2d2
Pull Request #1794: Fix lags in right-click scrolling for SDL2

14 of 38 new or added lines in 8 files covered. (36.84%)

22509 of 44588 relevant lines covered (50.48%)

36888.05 hits per line

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

55.56
/libs/s25main/controls/ctrlCheck.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 "ctrlCheck.h"
6

7
#include "CollisionDetection.h"
8
#include "Loader.h"
9
#include "driver/MouseCoords.h"
10
#include "ogl/FontStyle.h"
11
#include "ogl/glArchivItem_Bitmap.h"
12
#include "ogl/glFont.h"
13
#include <utility>
14

15
ctrlCheck::ctrlCheck(Window* parent, unsigned id, const DrawPoint& pos, const Extent& size, TextureColor tc,
45✔
16
                     std::string text, const glFont* font, bool readonly)
45✔
17
    : Window(parent, id, pos, size), tc(tc), text(std::move(text)), font(font), check(false), readonly(readonly)
45✔
18
{}
45✔
19

NEW
20
ctrlCheck* ctrlCheck::setTooltip(std::string tooltip)
×
21
{
NEW
22
    tooltip_ = std::move(tooltip);
×
NEW
23
    return this;
×
24
}
25

26
bool ctrlCheck::Msg_LeftDown(const MouseCoords& mc)
×
27
{
28
    if(!readonly && IsPointInRect(mc.GetPos(), GetDrawRect()))
×
29
    {
30
        check = !check;
×
31
        GetParent()->Msg_CheckboxChange(GetID(), check);
×
32
        return true;
×
33
    }
34

35
    return false;
×
36
}
37

NEW
38
bool ctrlCheck::Msg_MouseMove(const MouseCoords& mc)
×
39
{
NEW
40
    if(IsMouseOver(mc.GetPos()))
×
41
    {
NEW
42
        ShowTooltip();
×
NEW
43
        return true;
×
44
    } else
45
    {
NEW
46
        HideTooltip();
×
NEW
47
        return false;
×
48
    }
49
}
50

51
void ctrlCheck::Draw_()
3✔
52
{
53
    const unsigned short boxSize = 20;
3✔
54
    short spacing = (GetSize().y - boxSize) / 2;
3✔
55
    if(spacing < 0)
3✔
56
        spacing = 0;
×
57
    Rect drawRect = GetDrawRect();
3✔
58
    const bool drawText = font && !text.empty();
3✔
59
    if(!drawText)
3✔
60
    {
61
        // If we draw only the check mark, draw surrounding box smaller and center checkbox
62
        drawRect.setSize(Extent(boxSize + 2 * spacing, drawRect.getSize().y));
×
63
        drawRect.move(DrawPoint((GetSize().x - drawRect.getSize().x) / 2, 0));
×
64
    }
65
    short boxStartOffsetX = drawRect.getSize().x - spacing - boxSize;
3✔
66
    if(boxStartOffsetX < 0)
3✔
67
        boxStartOffsetX = 0;
×
68

69
    Draw3D(drawRect, tc, false);
3✔
70

71
    if(drawText)
3✔
72
    {
73
        int availableWidth = boxStartOffsetX - 4;
3✔
74
        if(availableWidth < 0)
3✔
75
            availableWidth = 0;
×
76
        font->Draw(drawRect.getOrigin() + DrawPoint(4, GetSize().y / 2), text, FontStyle::VCENTER,
6✔
77
                   (check ? COLOR_YELLOW : 0xFFBBBBBB), availableWidth);
3✔
78
    }
79

80
    DrawPoint boxPos = drawRect.getOrigin() + DrawPoint(boxStartOffsetX, spacing);
3✔
81

82
    if(!readonly)
3✔
83
        Draw3D(Rect(boxPos, Extent::all(boxSize)), tc, false);
3✔
84

85
    if(check)
3✔
86
        LOADER.GetImageN("io", 32)->DrawFull(boxPos + DrawPoint(boxSize, boxSize) / 2);
2✔
87
}
3✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc