151
167
SetLayout(_group_layout);
153
169
// don't need to disconnect these signals as they are disconnected when this object destroys the contents
154
_header_view->mouse_enter.connect(sigc::mem_fun(this, &PlacesGroup::RecvMouseEnter));
155
_header_view->mouse_leave.connect(sigc::mem_fun(this, &PlacesGroup::RecvMouseLeave));
156
170
_header_view->mouse_click.connect(sigc::mem_fun(this, &PlacesGroup::RecvMouseClick));
171
_header_view->key_nav_focus_change.connect(sigc::mem_fun(this, &PlacesGroup::OnLabelFocusChanged));
172
_header_view->key_nav_focus_activate.connect(sigc::mem_fun(this, &PlacesGroup::OnLabelActivated));
157
173
_icon->mouse_click.connect(sigc::mem_fun(this, &PlacesGroup::RecvMouseClick));
158
_icon->mouse_enter.connect(sigc::mem_fun(this, &PlacesGroup::RecvMouseEnter));
159
_icon->mouse_leave.connect(sigc::mem_fun(this, &PlacesGroup::RecvMouseLeave));
160
_icon->key_nav_focus_change.connect(sigc::mem_fun(this, &PlacesGroup::OnLabelFocusChanged));
161
174
_name->mouse_click.connect(sigc::mem_fun(this, &PlacesGroup::RecvMouseClick));
162
_name->mouse_enter.connect(sigc::mem_fun(this, &PlacesGroup::RecvMouseEnter));
163
_name->mouse_leave.connect(sigc::mem_fun(this, &PlacesGroup::RecvMouseLeave));
164
_name->key_nav_focus_change.connect(sigc::mem_fun(this, &PlacesGroup::OnLabelFocusChanged));
165
175
_expand_label->mouse_click.connect(sigc::mem_fun(this, &PlacesGroup::RecvMouseClick));
166
_expand_label->mouse_enter.connect(sigc::mem_fun(this, &PlacesGroup::RecvMouseEnter));
167
_expand_label->mouse_leave.connect(sigc::mem_fun(this, &PlacesGroup::RecvMouseLeave));
168
_expand_label->key_nav_focus_activate.connect(sigc::mem_fun(this, &PlacesGroup::OnLabelActivated));
169
_expand_label->key_nav_focus_change.connect(sigc::mem_fun(this, &PlacesGroup::OnLabelFocusChanged));
170
176
_expand_icon->mouse_click.connect(sigc::mem_fun(this, &PlacesGroup::RecvMouseClick));
171
_expand_icon->mouse_enter.connect(sigc::mem_fun(this, &PlacesGroup::RecvMouseEnter));
172
_expand_icon->mouse_leave.connect(sigc::mem_fun(this, &PlacesGroup::RecvMouseLeave));
173
_expand_icon->key_nav_focus_change.connect(sigc::mem_fun(this, &PlacesGroup::OnLabelFocusChanged));
178
key_nav_focus_change.connect([&](nux::Area* area, bool has_focus, nux::KeyNavDirection direction)
183
if(direction == nux::KEY_NAV_UP)
184
nux::GetWindowCompositor().SetKeyFocusArea(_child_view, direction);
186
nux::GetWindowCompositor().SetKeyFocusArea(GetHeaderFocusableView(), direction);
176
190
PlacesGroup::~PlacesGroup()
194
208
PlacesGroup::OnLabelFocusChanged(nux::Area* label, bool has_focus, nux::KeyNavDirection direction)
196
_ubus.SendMessage(UBUS_RESULT_VIEW_KEYNAV_CHANGED,
197
g_variant_new("(iiii)", 0, -30, 0, -30));
210
if (HeaderHasKeyFocus())
212
_ubus.SendMessage(UBUS_RESULT_VIEW_KEYNAV_CHANGED,
213
g_variant_new("(iiii)", 0, 0, 0, 0));
291
311
_expand_label->SetText(final);
292
312
_expand_label->SetVisible(_n_visible_items_in_unexpand_mode < _n_total_items);
294
_icon->SetAcceptKeyNavFocus(false);
295
_name->SetAcceptKeyNavFocus(false);
296
_expand_label->SetAcceptKeyNavFocus(false);
297
_expand_icon->SetAcceptKeyNavFocus(false);
299
if (_expand_label->IsVisible())
300
_expand_label->SetAcceptKeyNavFocus(true);
301
else if (_expand_icon->IsVisible())
302
_expand_icon->SetAcceptKeyNavFocus(true);
303
else if (_name->IsVisible())
304
_name->SetAcceptKeyNavFocus(true);
305
else if (_icon->IsVisible())
306
_icon->SetAcceptKeyNavFocus(true);
310
316
g_free((result_string));
493
499
bool PlacesGroup::HeaderHasKeyFocus() const
495
return (_icon && _icon->HasKeyFocus()) ||
496
(_name && _name->HasKeyFocus()) ||
497
(_expand_label && _expand_label->HasKeyFocus()) ||
498
(_expand_icon && _expand_icon->HasKeyFocus());
501
return (_header_view && _header_view->HasKeyFocus());
504
bool PlacesGroup::HeaderIsFocusable() const
506
return (_header_view != nullptr);
509
nux::View* PlacesGroup::GetHeaderFocusableView() const
501
514
bool PlacesGroup::ShouldBeHighlighted() const
503
return (_header_view && _header_view->IsMousePointerInside()) ||
516
return HeaderHasKeyFocus();
531
543
wrapper.add("header-height", _header_view->GetAbsoluteHeight());
532
544
wrapper.add("header-has-keyfocus", HeaderHasKeyFocus());
533
545
wrapper.add("header-is-highlighted", ShouldBeHighlighted());
546
wrapper.add("name", _name->GetText());
547
wrapper.add("is-visible", IsVisible());
548
wrapper.add("is-expanded", GetExpanded());
536
551
} // namespace unity