~unity-team/unity/trusty-1237132

« back to all changes in this revision

Viewing changes to dash/FilterGenreWidget.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:
35
35
{
36
36
namespace dash
37
37
{
 
38
namespace
 
39
{
 
40
const RawPixel CHILDREN_SPACE = 12_em;
 
41
const RawPixel CHILDREN_SPACE_SMALLER = 10_em;
 
42
}
38
43
 
39
44
NUX_IMPLEMENT_OBJECT_TYPE(FilterGenre);
40
45
 
42
47
: FilterExpanderLabel(_("Categories"), NUX_FILE_LINE_PARAM)
43
48
, all_button_(nullptr)
44
49
{
45
 
  dash::Style& style = dash::Style::Instance();
46
 
 
47
50
  InitTheme();
48
51
 
49
 
 
50
52
  genre_layout_ = new nux::GridHLayout(NUX_TRACKER_LOCATION);
51
53
  genre_layout_->ForceChildrenSize(true);
52
54
  genre_layout_->MatchContentSize(true);
53
 
  genre_layout_->SetTopAndBottomPadding(style.GetSpaceBetweenFilterWidgets() - style.GetFilterHighlightPadding(), style.GetFilterHighlightPadding());
54
55
  genre_layout_->EnablePartialVisibility(false);
55
56
 
 
57
  UpdateSize(columns);
 
58
  SetContents(genre_layout_);
 
59
 
 
60
  scale.changed.connect([this, columns] (double scale) {
 
61
    if (all_button_) all_button_->scale = scale;
 
62
 
 
63
    for (auto* button : buttons_)
 
64
      button->scale = scale;
 
65
 
 
66
    UpdateSize(columns);
 
67
  });
 
68
}
 
69
 
 
70
void FilterGenre::UpdateSize(int columns)
 
71
{
 
72
  auto& style = dash::Style::Instance();
 
73
  genre_layout_->SetTopAndBottomPadding(style.GetSpaceBetweenFilterWidgets().CP(scale) - style.GetFilterHighlightPadding().CP(scale), style.GetFilterHighlightPadding().CP(scale));
 
74
 
56
75
  if (columns == 3)
57
76
  {
58
 
    genre_layout_->SetChildrenSize((style.GetFilterBarWidth() - 12 * 2) / 3, style.GetFilterButtonHeight());
59
 
    genre_layout_->SetSpaceBetweenChildren (12, 12);
 
77
    genre_layout_->SetChildrenSize((style.GetFilterBarWidth().CP(scale) - CHILDREN_SPACE.CP(scale) * 2) / 3, style.GetFilterButtonHeight().CP(scale));
 
78
    genre_layout_->SetSpaceBetweenChildren(CHILDREN_SPACE.CP(scale), CHILDREN_SPACE.CP(scale));
60
79
  }
61
80
  else
62
81
  {
63
 
    genre_layout_->SetChildrenSize((style.GetFilterBarWidth() - 10 ) / 2, style.GetFilterButtonHeight());
64
 
    genre_layout_->SetSpaceBetweenChildren (10, 12);
 
82
    genre_layout_->SetChildrenSize((style.GetFilterBarWidth().CP(scale) - CHILDREN_SPACE_SMALLER.CP(scale)) / 2, style.GetFilterButtonHeight().CP(scale));
 
83
    genre_layout_->SetSpaceBetweenChildren(CHILDREN_SPACE_SMALLER.CP(scale), CHILDREN_SPACE.CP(scale));
65
84
  }
66
 
 
67
 
  SetContents(genre_layout_);
68
 
}
69
 
 
70
 
FilterGenre::~FilterGenre()
71
 
{
72
85
}
73
86
 
74
87
void FilterGenre::SetFilter(Filter::Ptr const& filter)
81
94
    all_button_ = show_all_button ? new FilterAllButton(NUX_TRACKER_LOCATION) : nullptr;
82
95
    SetRightHandView(all_button_);
83
96
    if (all_button_)
 
97
    {
 
98
      all_button_->scale = scale();
84
99
      all_button_->SetFilter(filter_);
 
100
    }
85
101
  };
86
102
  show_button_func(filter_->show_all_button);
87
103
  filter_->show_all_button.changed.connect(show_button_func);
88
 
  
 
104
 
89
105
  expanded = !filter_->collapsed();
90
106
 
91
107
  filter_->option_added.connect(sigc::mem_fun(this, &FilterGenre::OnOptionAdded));
106
122
  std::string label(escape.Value());
107
123
 
108
124
  FilterGenreButton* button = new FilterGenreButton(label, NUX_TRACKER_LOCATION);
 
125
  button->scale = scale();
109
126
  button->SetFilter(new_filter);
110
127
  genre_layout_->AddView(button, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL);
111
128
  buttons_.push_back(button);
121
138
    {
122
139
      genre_layout_->RemoveChildObject(*it);
123
140
      buttons_.erase(it);
124
 
      
 
141
 
125
142
      QueueRelayout();
126
143
      break;
127
144
    }