GCC Code Coverage Report
Directory: src/ Exec Total Coverage
File: src/gui/fonts/textchunksmall.cpp Lines: 25 35 71.4 %
Date: 2017-11-29 Branches: 15 18 83.3 %

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

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