~unity-team/unity/match-designed-sizings

« back to all changes in this revision

Viewing changes to src/PlacesGroup.cpp

Show the right expand button hint

Show diffs side-by-side

added added

removed removed

Lines of Context:
43
43
PlacesGroup::PlacesGroup (NUX_FILE_LINE_DECL)
44
44
: View (NUX_FILE_LINE_PARAM),
45
45
  _content_layout (NULL),
46
 
  _idle_id (0)
 
46
  _idle_id (0),
 
47
  _is_expanded (false),
 
48
  _n_visible_items_in_unexpand_mode (0),
 
49
  _n_total_items (0),
 
50
  _child_unexpand_height (0)
47
51
{
48
52
  _group_layout = new nux::VLayout ("", NUX_TRACKER_LOCATION);
49
53
 
63
67
  _expand_label = new nux::StaticCairoText ("Expand", NUX_TRACKER_LOCATION);
64
68
  _expand_label->SetTextEllipsize (nux::StaticCairoText::NUX_ELLIPSIZE_END);
65
69
  _expand_label->SetTextAlignment (nux::StaticCairoText::NUX_ALIGN_LEFT);
66
 
  _header_layout->AddView (_expand_label, 0, nux::MINOR_POSITION_TOP, nux::MINOR_SIZE_FULL);
 
70
  _header_layout->AddView (_expand_label, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FIX);
67
71
 
68
72
  SetLayout (_group_layout);
69
73
}
115
119
void
116
120
PlacesGroup::Refresh ()
117
121
{
118
 
#if 0
119
 
  char *result_string = NULL;
120
 
  result_string = g_strdup_printf (g_dngettext(NULL, "See %s less results",
121
 
                                                     "See one less result",
122
 
                                                       _total_items - _visible_items));
 
122
  char *result_string;
 
123
 
 
124
  if (_n_visible_items_in_unexpand_mode >= _n_total_items)
 
125
  {
 
126
    result_string = g_strdup ("");
 
127
  }
 
128
  else if (_is_expanded)
 
129
  {
 
130
    result_string = g_strdup (_("See fewer results"));
 
131
  }
 
132
  else
 
133
  {
 
134
    result_string = g_strdup_printf (g_dngettext (GETTEXT_PACKAGE,
 
135
                                           "See one more result",
 
136
                                           "See %d more results",
 
137
                                           _n_total_items - _n_visible_items_in_unexpand_mode),
 
138
                                     _n_total_items - _n_visible_items_in_unexpand_mode);
 
139
  }
123
140
 
124
141
  _expand_label->SetText (result_string);
 
142
  _expand_label->SetVisible (_n_visible_items_in_unexpand_mode < _n_total_items);
125
143
 
126
144
  ComputeChildLayout ();
127
145
  QueueDraw ();
128
146
  
129
147
  g_free ((result_string));
130
 
#endif
131
148
}
132
149
 
133
150
void
175
192
 
176
193
  GfxContext.PopClippingRectangle();
177
194
}
 
195
 
 
196
void
 
197
PlacesGroup::SetCounts (guint n_visible_items_in_unexpand_mode, guint n_total_items)
 
198
{
 
199
  _n_visible_items_in_unexpand_mode = n_visible_items_in_unexpand_mode;
 
200
  _n_total_items = n_total_items;
 
201
 
 
202
  Refresh ();
 
203
}
 
204
 
 
205
 
 
206
void
 
207
PlacesGroup::SetChildUnexpandHeight (guint height)
 
208
{
 
209
  if (_child_unexpand_height == height)
 
210
    return;
 
211
 
 
212
  _child_unexpand_height = height;
 
213
  Relayout ();
 
214
}