1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
/*
* Copyright 2014 Canonical Ltd.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License version 3, as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the applicable version of the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of both the GNU Lesser General Public
* License version 3 along with this program. If not, see
* <http://www.gnu.org/licenses/>
*
* Authored by: Marco Trevisan <marco.trevisan@canonical.com>
*
*/
#include "FilterRatingsButton.h"
namespace
{
const int STAR_SIZE = 28;
const int STAR_GAP = 10;
}
namespace unity
{
namespace dash
{
NUX_IMPLEMENT_OBJECT_TYPE(FilterRatingsButton);
FilterRatingsButton::FilterRatingsButton(NUX_FILE_LINE_DECL)
: RatingsButton(STAR_SIZE, STAR_GAP, NUX_FILE_LINE_PARAM)
{}
void FilterRatingsButton::SetFilter(Filter::Ptr const& filter)
{
filter_ = std::static_pointer_cast<RatingsFilter>(filter);
filter_->rating.changed.connect(sigc::mem_fun(this, &FilterRatingsButton::SetRating));
QueueDraw();
}
RatingsFilter::Ptr FilterRatingsButton::GetFilter() const
{
return filter_;
}
std::string FilterRatingsButton::GetFilterType()
{
return "FilterRatingsButton";
}
std::string FilterRatingsButton::GetName() const
{
return "FilterRatingsButton";
}
void FilterRatingsButton::SetRating(float rating)
{
if (filter_)
filter_->rating = rating;
QueueDraw();
}
float FilterRatingsButton::GetRating() const
{
return (filter_ && filter_->filtering) ? filter_->rating : 0;
}
} // namespace dash
} // namespace unity
|