~bilalakhtar/unity/sd-card-stop-device-960910

« back to all changes in this revision

Viewing changes to launcher/QuicklistView.cpp

  • Committer: Bilal Akhtar
  • Date: 2012-08-21 17:50:55 UTC
  • mfrom: (2540.2.61 unity)
  • Revision ID: bilalakhtar@ubuntu.com-20120821175055-2nyk2ne624tcd247
Merge from trunk and resolve conflicts

Show diffs side-by-side

added added

removed removed

Lines of Context:
147
147
    if (menu_item)
148
148
    {
149
149
      target_item = index;
150
 
      menu_item->_prelight = true;
 
150
      menu_item->Select();
151
151
    }
152
152
  }
153
153
 
448
448
      _item_layout->AddView(item, 1, nux::eCenter, nux::eFull);
449
449
    }
450
450
 
451
 
    int  textWidth  = 0;
452
 
    int  textHeight = 0;
453
 
    item->GetTextExtents(textWidth, textHeight);
454
 
    textHeight += QuicklistMenuItem::ITEM_MARGIN * 2;
455
 
 
456
 
    MaxItemWidth = std::max(MaxItemWidth, textWidth);
457
 
    TotalItemHeight += textHeight;
 
451
    nux::Size const& text_extents = item->GetTextExtents();
 
452
    MaxItemWidth = std::max(MaxItemWidth, text_extents.width);
 
453
    TotalItemHeight += text_extents.height;
458
454
  }
459
455
 
460
456
  if (TotalItemHeight < _anchor_height)
510
506
  // only after MaxItemWidth is computed in QuicklistView::PreLayoutManagement.
511
507
  // The setting of the separator width is done here after the Layout cycle for this widget is over. The width of the separator
512
508
  // has bee set correctly during the layout cycle, but the cairo rendering still need to be adjusted.
513
 
  int separator_width = _item_layout->GetBaseWidth();
 
509
  unsigned separator_width = _item_layout->GetBaseWidth();
514
510
 
515
511
  for (auto item : _item_list)
516
512
  {
517
 
    if (item->GetVisible() && item->CairoSurfaceWidth() != separator_width)
 
513
    if (item->GetVisible() && item->GetCairoSurfaceWidth() != separator_width)
518
514
    {
519
515
      // Compute textures of the item.
520
516
      item->UpdateTexture();
567
563
 
568
564
void QuicklistView::ActivateItem(QuicklistMenuItem* item)
569
565
{
570
 
  if (item && item->_menuItem)
571
 
  {
572
 
    ubus_server_send_message(ubus_server_get_default(),
573
 
                             UBUS_PLACE_VIEW_CLOSE_REQUEST,
574
 
                             NULL);
 
566
  if (!item)
 
567
    return;
575
568
 
576
 
    dbusmenu_menuitem_handle_event(item->_menuItem, "clicked", NULL, 0);
577
 
  }
 
569
  item->Activate();
578
570
}
579
571
 
580
572
void QuicklistView::RecvItemMouseRelease(QuicklistMenuItem* item, int x, int y)
595
587
{
596
588
  for (auto item : _item_list)
597
589
  {
598
 
    item->_prelight = false;
 
590
    item->Select(false);
599
591
  }
600
592
}
601
593
 
760
752
  if (item)
761
753
    return item->GetItemType();
762
754
 
763
 
  return MENUITEM_TYPE_UNKNOWN;
 
755
  return QuicklistMenuItemType::UNKNOWN;
764
756
}
765
757
 
766
758
std::list<QuicklistMenuItem*> QuicklistView::GetChildren()
1310
1302
  UpdateTexture();
1311
1303
}
1312
1304
 
1313
 
void QuicklistView::TestMenuItems(DbusmenuMenuitem* root)
1314
 
{
1315
 
  RemoveAllMenuItem();
1316
 
 
1317
 
  if (root == 0)
1318
 
    return;
1319
 
 
1320
 
  GList* child = NULL;
1321
 
  for (child = dbusmenu_menuitem_get_children(root); child != NULL; child = g_list_next(child))
1322
 
  {
1323
 
    const gchar* type = dbusmenu_menuitem_property_get((DbusmenuMenuitem*)child->data, DBUSMENU_MENUITEM_PROP_TYPE);
1324
 
    const gchar* toggle_type = dbusmenu_menuitem_property_get((DbusmenuMenuitem*)child->data, DBUSMENU_MENUITEM_PROP_TOGGLE_TYPE);
1325
 
 
1326
 
    if (g_strcmp0(type, DBUSMENU_CLIENT_TYPES_SEPARATOR) == 0)
1327
 
    {
1328
 
      QuicklistMenuItemSeparator* item = new QuicklistMenuItemSeparator((DbusmenuMenuitem*)child->data, NUX_TRACKER_LOCATION);
1329
 
      AddMenuItem(item);
1330
 
    }
1331
 
    else if (g_strcmp0(toggle_type, DBUSMENU_MENUITEM_TOGGLE_CHECK) == 0)
1332
 
    {
1333
 
      QuicklistMenuItemCheckmark* item = new QuicklistMenuItemCheckmark((DbusmenuMenuitem*)child->data, NUX_TRACKER_LOCATION);
1334
 
      AddMenuItem(item);
1335
 
    }
1336
 
    else if (g_strcmp0(toggle_type, DBUSMENU_MENUITEM_TOGGLE_RADIO) == 0)
1337
 
    {
1338
 
      QuicklistMenuItemRadio* item = new QuicklistMenuItemRadio((DbusmenuMenuitem*)child->data, NUX_TRACKER_LOCATION);
1339
 
      AddMenuItem(item);
1340
 
    }
1341
 
    else //if (g_strcmp0 (type, DBUSMENU_MENUITEM_PROP_LABEL) == 0)
1342
 
    {
1343
 
      QuicklistMenuItemLabel* item = new QuicklistMenuItemLabel((DbusmenuMenuitem*)child->data, NUX_TRACKER_LOCATION);
1344
 
      AddMenuItem(item);
1345
 
    }
1346
 
  }
1347
 
}
1348
 
 
1349
1305
// Introspection
1350
1306
 
1351
1307
std::string QuicklistView::GetName() const