GCC Code Coverage Report
Directory: src/ Exec Total Coverage
File: src/gui/fonts/textchunksmall.cpp Lines: 25 35 71.4 %
Date: 2021-03-17 Branches: 15 24 62.5 %

Line Branch Exec Source
1
/*
2
 *  The ManaPlus Client
3
 *  Copyright (C) 2011-2019  The ManaPlus Developers
4
 *  Copyright (C) 2019-2021  Andrei Karas
5
 *
6
 *  This file is part of The ManaPlus Client.
7
 *
8
 *  This program is free software; you can redistribute it and/or modify
9
 *  it under the terms of the GNU General Public License as published by
10
 *  the Free Software Foundation; either version 2 of the License, or
11
 *  any later version.
12
 *
13
 *  This program is distributed in the hope that it will be useful,
14
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
 *  GNU General Public License for more details.
17
 *
18
 *  You should have received a copy of the GNU General Public License
19
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
20
 */
21
22
#include "gui/fonts/textchunksmall.h"
23
24
#include "gui/fonts/font.h"
25
26
#include "debug.h"
27
28
677
TextChunkSmall::TextChunkSmall(const std::string &text0,
29
                               const Color &color0,
30
677
                               const Color &color1) :
31
    text(text0),
32
    color(color0),
33
1354
    color2(color1)
34
{
35
677
}
36
37
242
TextChunkSmall::TextChunkSmall(const TextChunkSmall &old) :
38
    text(old.text),
39
    color(old.color),
40
484
    color2(old.color2)
41
{
42
242
}
43
44
TextChunkSmall &TextChunkSmall::operator=(const TextChunkSmall &chunk)
45
{
46
    text = chunk.text;
47
    color = chunk.color;
48
    color2 = chunk.color2;
49
    return *this;
50
}
51
52
bool TextChunkSmall::operator==(const TextChunkSmall &chunk) const
53
{
54
    return chunk.text == text &&
55
        chunk.color == color &&
56
        chunk.color2 == color2;
57
}
58
59
324
bool TextChunkSmall::operator<(const TextChunkSmall &chunk) const
60
{
61
648
    if (chunk.text != text)
62
456
        return chunk.text > text;
63
64
96
    const Color &restrict c = chunk.color;
65
96
    if (c.r != color.r)
66
14
        return c.r > color.r;
67
82
    if (c.g != color.g)
68
2
        return c.g > color.g;
69
80
    if (c.b != color.b)
70
11
        return c.b > color.b;
71
72
69
    const Color &restrict c2 = chunk.color2;
73
69
    if (c2.r != color2.r)
74
2
        return c2.r > color2.r;
75
67
    if (c2.g != color2.g)
76
2
        return c2.g > color2.g;
77
65
    if (c2.b != color2.b)
78
23
        return c2.b > color2.b;
79
80

42
    if (c.a != color.a && Font::mSoftMode)
81
        return c.a > color.a;
82
83
    return false;
84
}