~macslow/unity/backported-remote-add-to-5.0

« back to all changes in this revision

Viewing changes to plugins/unityshell/src/HudView.cpp

Merging with upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
64
64
  , current_height_(0)
65
65
  , timeline_need_more_draw_(false)
66
66
  , selected_button_(0)
67
 
  , icon_state_(IconHideState::SHOW)
 
67
  , show_embedded_icon_(true)
68
68
  , activated_signal_sent_(false)
69
69
{
70
70
  renderer_.SetOwner(this);
127
127
 
128
128
View::~View()
129
129
{
130
 
  RemoveChild(search_bar_.GetPointer());
131
130
  for (auto button = buttons_.begin(); button != buttons_.end(); button++)
132
131
  {
133
132
    RemoveChild((*button).GetPointer());
272
271
void View::SetIcon(std::string icon_name)
273
272
{
274
273
  LOG_DEBUG(logger) << "Setting icon to " << icon_name;
275
 
  icon_->SetByIconName(icon_name.c_str(), icon_size);
 
274
  icon_->SetByIconName(icon_name, icon_size);
276
275
  QueueDraw();
277
276
}
278
277
 
279
 
void View::SetHideIcon(IconHideState hide_icon)
 
278
void View::ShowEmbeddedIcon(bool show)
280
279
{
281
280
  LOG_DEBUG(logger) << "Hide icon called";
282
 
  if (hide_icon == icon_state_)
 
281
  if (show == show_embedded_icon_)
283
282
    return;
284
283
 
285
 
  icon_state_ = hide_icon;
286
 
 
287
 
  if (icon_state_ == IconHideState::HIDE)
288
 
    layout_->RemoveChildObject(dynamic_cast<nux::Area*>(icon_layout_.GetPointer()));
 
284
  show_embedded_icon_ = show;
 
285
 
 
286
  if (show_embedded_icon_)
 
287
  {
 
288
    layout_->AddLayout(icon_layout_.GetPointer(), 0, nux::MINOR_POSITION_TOP,
 
289
                       nux::MINOR_SIZE_MATCHCONTENT, 100.0f, nux::LayoutPosition::NUX_LAYOUT_BEGIN);
 
290
 
 
291
    AddChild(icon_.GetPointer());
 
292
  }
289
293
  else
290
 
    layout_->AddLayout(icon_layout_.GetPointer(), 0, nux::MINOR_POSITION_TOP, nux::MINOR_SIZE_MATCHCONTENT, 100.0f, nux::LayoutPosition::NUX_LAYOUT_BEGIN);
 
294
  {
 
295
    layout_->RemoveChildObject(static_cast<nux::Area*>(icon_layout_.GetPointer()));
 
296
    RemoveChild(icon_.GetPointer());
 
297
  }
291
298
 
292
299
  Relayout();
293
300
}
303
310
  width = 1024;
304
311
  height = 276;
305
312
 
306
 
  if (icon_state_ == IconHideState::HIDE)
 
313
  if (!show_embedded_icon_)
307
314
  {
308
315
    width -= icon_layout_->GetGeometry().width;
309
316
  }
333
340
 
334
341
namespace
335
342
{
336
 
  const int top_spacing = 9;
 
343
  const int top_spacing = 11;
337
344
  const int content_width = 941;
338
345
  const int icon_vertical_margin = 5;
339
346
  const int spacing_between_icon_and_content = 8;
351
358
    icon_ = new Icon("", icon_size, true);
352
359
    icon_layout_ = new nux::VLayout();
353
360
    {
 
361
      AddChild(icon_.GetPointer());
354
362
      icon_layout_->SetVerticalExternalMargin(icon_vertical_margin);
355
363
      icon_layout_->AddView(icon_.GetPointer(), 0, nux::MINOR_POSITION_LEFT, nux::MINOR_SIZE_FULL);
356
364
      layout_->AddLayout(icon_layout_.GetPointer(), 0, nux::MINOR_POSITION_TOP, nux::MINOR_SIZE_MATCHCONTENT);
369
377
      content_layout_->AddLayout(new nux::SpaceLayout(top_spacing,top_spacing,top_spacing,top_spacing), 0);
370
378
 
371
379
      // add the search bar to the composite
372
 
      search_bar_ = new unity::SearchBar(content_width, true);
373
 
      search_bar_->disable_glow = true;
374
 
      search_bar_->SetMinimumHeight(style.GetSearchBarHeight() + style.SEARCH_BAR_EXTRA_PADDING * 2);
375
 
      search_bar_->SetMaximumHeight(style.GetSearchBarHeight() + style.SEARCH_BAR_EXTRA_PADDING * 2);
 
380
      search_bar_ = new unity::SearchBar(true);
 
381
      search_bar_->SetMinimumHeight(style.GetSearchBarHeight());
 
382
      search_bar_->SetMaximumHeight(style.GetSearchBarHeight());
376
383
      search_bar_->search_hint = default_text;
377
384
      search_bar_->search_changed.connect(sigc::mem_fun(this, &View::OnSearchChanged));
378
385
      AddChild(search_bar_.GetPointer());
491
498
{
492
499
  unsigned num_buttons = buttons_.size();
493
500
  variant::BuilderWrapper(builder)
 
501
    .add(GetGeometry())
494
502
    .add("selected_button", selected_button_)
495
503
    .add("num_buttons", num_buttons);
496
504
}