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

Return-To-The-Roots / s25client / 17286335676

28 Aug 2025 05:05AM UTC coverage: 50.479% (-0.02%) from 50.502%
17286335676

push

github

Flow86
Test mouseover

22506 of 44585 relevant lines covered (50.48%)

33972.0 hits per line

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

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

5
#include "ctrlButton.h"
6
#include "CollisionDetection.h"
7
#include "driver/MouseCoords.h"
8
#include "drivers/VideoDriverWrapper.h"
9

10
ctrlButton::ctrlButton(Window* parent, unsigned id, const DrawPoint& pos, const Extent& size, TextureColor tc,
449✔
11
                       const std::string& tooltip)
449✔
12
    : Window(parent, id, pos, size), ctrlBaseTooltip(tooltip), tc(tc), state(ButtonState::Up), hasBorder(true),
13
      isChecked(false), isIlluminated(false), isEnabled(true)
449✔
14
{}
449✔
15

16
ctrlButton::~ctrlButton() = default;
449✔
17

18
void ctrlButton::SetEnabled(bool enable /*= true*/)
×
19
{
20
    isEnabled = enable;
×
21
    state = ButtonState::Up;
×
22
}
×
23

24
void ctrlButton::SetActive(bool activate)
1,054✔
25
{
26
    Window::SetActive(activate);
1,054✔
27
    if(!activate)
1,054✔
28
        state = ButtonState::Up;
922✔
29
    else if(IsMouseOver())
132✔
30
        state = ButtonState::Hover;
8✔
31
}
1,054✔
32

33
bool ctrlButton::Msg_MouseMove(const MouseCoords& mc)
113✔
34
{
35
    if(isEnabled && IsMouseOver(mc))
113✔
36
    {
37
        if(state != ButtonState::Pressed)
1✔
38
            state = ButtonState::Hover;
1✔
39

40
        ShowTooltip();
1✔
41
        return true;
1✔
42
    } else
43
    {
44
        state = ButtonState::Up;
112✔
45
        HideTooltip();
112✔
46
        return false;
112✔
47
    }
48
}
49

50
bool ctrlButton::Msg_LeftDown(const MouseCoords& mc)
8✔
51
{
52
    if(isEnabled && IsMouseOver(mc))
8✔
53
    {
54
        state = ButtonState::Pressed;
×
55
        return true;
×
56
    }
57

58
    return false;
8✔
59
}
60

61
bool ctrlButton::Msg_LeftUp(const MouseCoords& mc)
8✔
62
{
63
    if(state == ButtonState::Pressed)
8✔
64
    {
65
        if(isEnabled && IsMouseOver(mc))
×
66
        {
67
            state = ButtonState::Hover;
×
68
            GetParent()->Msg_ButtonClick(GetID());
×
69
            return true;
×
70
        } else
71
            state = ButtonState::Up;
×
72
    }
73

74
    return false;
8✔
75
}
76

77
/**
78
 *  zeichnet das Fenster.
79
 */
80
void ctrlButton::Draw_()
49✔
81
{
82
    if(GetSize().x == 0 || GetSize().y == 0)
49✔
83
        return;
×
84

85
    if(tc != TextureColor::Invisible)
49✔
86
    {
87
        unsigned color = isEnabled ? COLOR_WHITE : 0xFFBBBBBB;
49✔
88
        bool isCurIlluminated = isIlluminated || (!isEnabled && isChecked);
49✔
89
        bool isElevated = !isChecked && state != ButtonState::Pressed;
49✔
90
        bool isHighlighted = isEnabled && !isChecked && state == ButtonState::Hover;
49✔
91
        if(hasBorder)
49✔
92
            Draw3D(GetDrawRect(), tc, isElevated, isHighlighted, isCurIlluminated, color);
21✔
93
        else
94
            Draw3DContent(GetDrawRect(), tc, isElevated, isHighlighted, isCurIlluminated, color);
28✔
95
    }
96

97
    /// Inhalt malen (Text, Bilder usw.)
98
    DrawContent();
49✔
99
}
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