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

Return-To-The-Roots / s25client / 17208623929

25 Aug 2025 12:19PM UTC coverage: 50.497% (-0.005%) from 50.502%
17208623929

Pull #1794

github

web-flow
Merge 136f11398 into e99b7a27a
Pull Request #1794: Fix lags in right-click scrolling for SDL2

14 of 35 new or added lines in 8 files covered. (40.0%)

8 existing lines in 5 files now uncovered.

22514 of 44585 relevant lines covered (50.5%)

35961.31 hits per line

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

59.52
/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

UNCOV
20
bool ctrlCheck::Msg_LeftDown(const MouseCoords& mc)
×
21
{
22
    if(!readonly && IsPointInRect(mc.GetPos(), GetDrawRect()))
×
23
    {
24
        check = !check;
×
25
        GetParent()->Msg_CheckboxChange(GetID(), check);
×
26
        return true;
×
27
    }
28

29
    return false;
×
30
}
31

NEW
32
bool ctrlCheck::Msg_MouseMove(const MouseCoords& mc)
×
33
{
NEW
34
    if(IsMouseOver(mc.GetPos()))
×
35
    {
NEW
36
        ShowTooltip();
×
NEW
37
        return true;
×
38
    } else
39
    {
NEW
40
        HideTooltip();
×
NEW
41
        return false;
×
42
    }
43
}
44

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

63
    Draw3D(drawRect, tc, false);
3✔
64

65
    if(drawText)
3✔
66
    {
67
        int availableWidth = boxStartOffsetX - 4;
3✔
68
        if(availableWidth < 0)
3✔
69
            availableWidth = 0;
×
70
        font->Draw(drawRect.getOrigin() + DrawPoint(4, GetSize().y / 2), text, FontStyle::VCENTER,
6✔
71
                   (check ? COLOR_YELLOW : 0xFFBBBBBB), availableWidth);
3✔
72
    }
73

74
    DrawPoint boxPos = drawRect.getOrigin() + DrawPoint(boxStartOffsetX, spacing);
3✔
75

76
    if(!readonly)
3✔
77
        Draw3D(Rect(boxPos, Extent::all(boxSize)), tc, false);
3✔
78

79
    if(check)
3✔
80
        LOADER.GetImageN("io", 32)->DrawFull(boxPos + DrawPoint(boxSize, boxSize) / 2);
2✔
81
}
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