~macslow/unity/unity.fix-870284

« back to all changes in this revision

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

  • Committer: Mirco Müller
  • Date: 2012-02-28 15:06:52 UTC
  • mfrom: (1976.1.59 unity)
  • Revision ID: mirco.mueller@canonical.com-20120228150652-wephnfgkwn1fzykn
Re-merged with trunk... solved merge-conflicts... grrrrr... hope nothing breaks

Show diffs side-by-side

added added

removed removed

Lines of Context:
43
43
#include "DashStyle.h"
44
44
#include "ubus-server.h"
45
45
#include "UBusMessages.h"
 
46
 #include "Introspectable.h"
46
47
 
47
48
namespace unity
48
49
{
69
70
  HeaderView(NUX_FILE_LINE_DECL)
70
71
   : nux::View(NUX_FILE_LINE_PARAM)
71
72
  {
 
73
    SetAcceptKeyNavFocusOnMouseDown(false);
 
74
    SetAcceptKeyNavFocusOnMouseEnter(true);
72
75
  }
73
76
 
74
77
protected:
84
87
 
85
88
  bool AcceptKeyNavFocus()
86
89
  {
87
 
    return false;
 
90
    return true;
 
91
  }
 
92
 
 
93
  nux::Area* FindAreaUnderMouse(const nux::Point& mouse_position, nux::NuxEventType event_type)
 
94
  {
 
95
    bool mouse_inside = TestMousePointerInclusionFilterMouseWheel(mouse_position, event_type);
 
96
 
 
97
    if (mouse_inside == false)
 
98
      return nullptr;
 
99
 
 
100
    return this;
88
101
  }
89
102
};
90
103
 
102
115
    _n_total_items(0),
103
116
    _draw_sep(true)
104
117
{
 
118
  SetAcceptKeyNavFocusOnMouseDown(false);
 
119
  SetAcceptKeyNavFocusOnMouseEnter(false);
 
120
 
105
121
  nux::BaseTexture* arrow = dash::Style::Instance().GetGroupUnexpandIcon();
106
122
 
107
123
  _cached_name = NULL;
151
167
  SetLayout(_group_layout);
152
168
 
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));
 
177
 
 
178
  key_nav_focus_change.connect([&](nux::Area* area, bool has_focus, nux::KeyNavDirection direction)
 
179
  {
 
180
    if (!has_focus)
 
181
      return;
 
182
 
 
183
    if(direction == nux::KEY_NAV_UP)
 
184
      nux::GetWindowCompositor().SetKeyFocusArea(_child_view, direction);
 
185
    else
 
186
      nux::GetWindowCompositor().SetKeyFocusArea(GetHeaderFocusableView(), direction);
 
187
  });
174
188
}
175
189
 
176
190
PlacesGroup::~PlacesGroup()
193
207
void
194
208
PlacesGroup::OnLabelFocusChanged(nux::Area* label, bool has_focus, nux::KeyNavDirection direction)
195
209
{
196
 
  _ubus.SendMessage(UBUS_RESULT_VIEW_KEYNAV_CHANGED,
197
 
                    g_variant_new("(iiii)", 0, -30, 0, -30));
 
210
  if (HeaderHasKeyFocus())
 
211
  {
 
212
    _ubus.SendMessage(UBUS_RESULT_VIEW_KEYNAV_CHANGED,
 
213
                      g_variant_new("(iiii)", 0, 0, 0, 0));
 
214
  }
198
215
 
199
216
  QueueDraw();
200
217
}
239
256
void
240
257
PlacesGroup::SetChildView(nux::View* view)
241
258
{
 
259
  debug::Introspectable *i = dynamic_cast<debug::Introspectable*>(view);
 
260
  if (i)
 
261
    AddChild(i);
242
262
  _child_view = view;
243
263
  _group_layout->AddView(_child_view, 1);
244
264
  QueueDraw();
291
311
  _expand_label->SetText(final);
292
312
  _expand_label->SetVisible(_n_visible_items_in_unexpand_mode < _n_total_items);
293
313
 
294
 
  _icon->SetAcceptKeyNavFocus(false);
295
 
  _name->SetAcceptKeyNavFocus(false);
296
 
  _expand_label->SetAcceptKeyNavFocus(false);
297
 
  _expand_icon->SetAcceptKeyNavFocus(false);
298
 
 
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);
307
 
 
308
314
  QueueDraw();
309
315
 
310
316
  g_free((result_string));
492
498
 
493
499
bool PlacesGroup::HeaderHasKeyFocus() const
494
500
{
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());
 
502
}
 
503
 
 
504
bool PlacesGroup::HeaderIsFocusable() const
 
505
{
 
506
  return (_header_view != nullptr);
 
507
}
 
508
 
 
509
nux::View* PlacesGroup::GetHeaderFocusableView() const
 
510
{
 
511
  return _header_view;
499
512
}
500
513
 
501
514
bool PlacesGroup::ShouldBeHighlighted() const
502
515
{
503
 
  return (_header_view && _header_view->IsMousePointerInside()) ||
504
 
          HeaderHasKeyFocus();
 
516
  return HeaderHasKeyFocus();
505
517
}
506
518
 
507
519
//
510
522
bool
511
523
PlacesGroup::AcceptKeyNavFocus()
512
524
{
513
 
  return false;
 
525
  return true;
514
526
}
515
527
 
516
528
//
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());
534
549
}
535
550
 
536
551
} // namespace unity