~unity-team/unity/trusty-1332509

« back to all changes in this revision

Viewing changes to dash/FilterRatingsWidget.cpp

  • Committer: CI bot
  • Author(s): Stephen M. Webb, Marco Trevisan (Treviño), Andrea Azzarone, Pawel Szubert, Chris Townsend, Andrea Azzarone, Eleni Maria Stea
  • Date: 2014-08-26 13:48:28 UTC
  • mfrom: (3800.1.24 prepare-7.2.3-SRU)
  • Revision ID: ps-jenkins@lists.canonical.com-20140826134828-fkev1oisyfl9kbt3
Prepare fixes for upstream micro-release 7.2.3. Fixes: 1283415, 1292391, 1306211, 1312107, 1320051, 1320071, 1324114, 1339629, 1340171, 1340394, 1340477, 1340992, 1340996, 1342208, 1342731, 1347735

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
#include "FilterRatingsButton.h"
34
34
#include "FilterRatingsWidget.h"
35
35
 
36
 
namespace
37
 
{
38
 
const int star_size      = 28;
39
 
}
40
 
 
41
36
namespace unity
42
37
{
43
38
namespace dash
44
39
{
 
40
namespace
 
41
{
 
42
const RawPixel STAR_SIZE = 28_em;
 
43
}
45
44
 
46
45
NUX_IMPLEMENT_OBJECT_TYPE(FilterRatingsWidget);
47
46
 
49
48
: FilterExpanderLabel(_("Rating"), NUX_FILE_LINE_PARAM)
50
49
, all_button_(nullptr)
51
50
{
52
 
  dash::Style& style = dash::Style::Instance();
53
 
  const int top_padding    = style.GetSpaceBetweenFilterWidgets() - style.GetFilterHighlightPadding() - 1; // -1 (PNGs have an 1px top padding)
54
 
  const int bottom_padding = style.GetFilterHighlightPadding();
55
 
 
56
51
  nux::VLayout* layout = new nux::VLayout(NUX_TRACKER_LOCATION);
57
 
  layout->SetTopAndBottomPadding(top_padding, bottom_padding);
58
52
  ratings_ = new FilterRatingsButton(NUX_TRACKER_LOCATION);
59
 
  ratings_->SetMinimumHeight(star_size);
60
53
 
61
54
  layout->AddView(ratings_);
62
55
 
 
56
  UpdateSize();
63
57
  SetContents(layout);
 
58
 
 
59
  scale.changed.connect([this] (double scale) {
 
60
    if (all_button_) all_button_->scale = scale;
 
61
    UpdateSize();
 
62
  });
64
63
}
65
64
 
66
 
FilterRatingsWidget::~FilterRatingsWidget()
 
65
void FilterRatingsWidget::UpdateSize()
67
66
{
 
67
  dash::Style& style = dash::Style::Instance();
 
68
  int top_padding = style.GetSpaceBetweenFilterWidgets().CP(scale) - style.GetFilterHighlightPadding().CP(scale) - (1_em).CP(scale); // -1 (PNGs have an 1px top padding)
 
69
  int bottom_padding = style.GetFilterHighlightPadding().CP(scale);
 
70
  static_cast<nux::VLayout*>(GetLayout())->SetTopAndBottomPadding(top_padding, bottom_padding);
 
71
 
 
72
  ratings_->scale = scale();
 
73
  ratings_->SetMinimumHeight(STAR_SIZE.CP(scale));
 
74
  ratings_->ApplyMinHeight();
68
75
}
69
76
 
70
77
void FilterRatingsWidget::SetFilter(Filter::Ptr const& filter)
77
84
    all_button_ = show_all_button ? new FilterAllButton(NUX_TRACKER_LOCATION) : nullptr;
78
85
    SetRightHandView(all_button_);
79
86
    if (all_button_)
 
87
    {
 
88
      all_button_->scale = scale();
80
89
      all_button_->SetFilter(filter_);
 
90
    }
81
91
  };
82
92
  show_button_func(filter_->show_all_button);
83
93
  filter_->show_all_button.changed.connect(show_button_func);