Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(239)

Side by Side Diff: ash/launcher/launcher_view.cc

Issue 9590001: Launch panels as popup windows in Aura, and add separate launcher icon logic for panels. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: . Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ash/launcher/launcher_view.h" 5 #include "ash/launcher/launcher_view.h"
6 6
7 #include "ash/launcher/app_launcher_button.h" 7 #include "ash/launcher/app_launcher_button.h"
8 #include "ash/launcher/launcher_delegate.h" 8 #include "ash/launcher/launcher_delegate.h"
9 #include "ash/launcher/launcher_model.h" 9 #include "ash/launcher/launcher_model.h"
10 #include "ash/launcher/launcher_window_cycler.h" 10 #include "ash/launcher/launcher_window_cycler.h"
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 views::View* view = NULL; 302 views::View* view = NULL;
303 switch (item.type) { 303 switch (item.type) {
304 case TYPE_TABBED: { 304 case TYPE_TABBED: {
305 TabbedLauncherButton* button = new TabbedLauncherButton(this, this); 305 TabbedLauncherButton* button = new TabbedLauncherButton(this, this);
306 button->SetTabImage(item.image, item.num_tabs); 306 button->SetTabImage(item.image, item.num_tabs);
307 button->set_context_menu_controller(this); 307 button->set_context_menu_controller(this);
308 view = button; 308 view = button;
309 break; 309 break;
310 } 310 }
311 311
312 case TYPE_APP: { 312 case TYPE_APP:
313 case TYPE_PANEL: {
313 AppLauncherButton* button = new AppLauncherButton(this, this); 314 AppLauncherButton* button = new AppLauncherButton(this, this);
314 button->SetAppImage(item.image); 315 button->SetAppImage(item.image);
315 view = button; 316 view = button;
316 button->set_context_menu_controller(this); 317 button->set_context_menu_controller(this);
317 break; 318 break;
318 } 319 }
319 320
320 case TYPE_APP_LIST: { 321 case TYPE_APP_LIST: {
321 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); 322 ResourceBundle& rb = ResourceBundle::GetSharedInstance();
322 views::ImageButton* button = new AppLauncherButton(this, this); 323 views::ImageButton* button = new AppLauncherButton(this, this);
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 } 411 }
411 412
412 void LauncherView::GetOverflowItems(std::vector<LauncherItem>* items) { 413 void LauncherView::GetOverflowItems(std::vector<LauncherItem>* items) {
413 int index = 0; 414 int index = 0;
414 while (index < view_model_->view_size() && 415 while (index < view_model_->view_size() &&
415 view_model_->view_at(index)->visible()) { 416 view_model_->view_at(index)->visible()) {
416 index++; 417 index++;
417 } 418 }
418 while (index < view_model_->view_size()) { 419 while (index < view_model_->view_size()) {
419 const LauncherItem& item = model_->items()[index]; 420 const LauncherItem& item = model_->items()[index];
420 if (item.type == TYPE_TABBED || item.type == TYPE_APP) 421 if (item.type == TYPE_TABBED ||
422 item.type == TYPE_APP ||
423 item.type == TYPE_PANEL)
421 items->push_back(item); 424 items->push_back(item);
422 index++; 425 index++;
423 } 426 }
424 } 427 }
425 428
426 void LauncherView::ShowOverflowMenu() { 429 void LauncherView::ShowOverflowMenu() {
427 #if !defined(OS_MACOSX) 430 #if !defined(OS_MACOSX)
428 if (!delegate_) 431 if (!delegate_)
429 return; 432 return;
430 433
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
553 TabbedLauncherButton* button = static_cast<TabbedLauncherButton*>(view); 556 TabbedLauncherButton* button = static_cast<TabbedLauncherButton*>(view);
554 gfx::Size pref = button->GetPreferredSize(); 557 gfx::Size pref = button->GetPreferredSize();
555 button->SetTabImage(item.image, item.num_tabs); 558 button->SetTabImage(item.image, item.num_tabs);
556 if (pref != button->GetPreferredSize()) 559 if (pref != button->GetPreferredSize())
557 AnimateToIdealBounds(); 560 AnimateToIdealBounds();
558 else 561 else
559 button->SchedulePaint(); 562 button->SchedulePaint();
560 break; 563 break;
561 } 564 }
562 565
563 case TYPE_APP: { 566 case TYPE_APP:
567 case TYPE_PANEL: {
564 AppLauncherButton* button = static_cast<AppLauncherButton*>(view); 568 AppLauncherButton* button = static_cast<AppLauncherButton*>(view);
565 button->SetAppImage(item.image); 569 button->SetAppImage(item.image);
566 button->SchedulePaint(); 570 button->SchedulePaint();
567 break; 571 break;
568 } 572 }
569 573
570 default: 574 default:
571 break; 575 break;
572 } 576 }
573 } 577 }
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
623 if (!delegate_) 627 if (!delegate_)
624 return string16(); 628 return string16();
625 int view_index = view_model_->GetIndexOfView(view); 629 int view_index = view_model_->GetIndexOfView(view);
626 // May be -1 while in the process of animating closed. 630 // May be -1 while in the process of animating closed.
627 if (view_index == -1) 631 if (view_index == -1)
628 return string16(); 632 return string16();
629 633
630 switch (model_->items()[view_index].type) { 634 switch (model_->items()[view_index].type) {
631 case TYPE_TABBED: 635 case TYPE_TABBED:
632 case TYPE_APP: 636 case TYPE_APP:
637 case TYPE_PANEL:
633 return delegate_->GetTitle(model_->items()[view_index]); 638 return delegate_->GetTitle(model_->items()[view_index]);
634 639
635 case TYPE_APP_LIST: 640 case TYPE_APP_LIST:
636 return l10n_util::GetStringUTF16(IDS_AURA_APP_LIST_TITLE); 641 return l10n_util::GetStringUTF16(IDS_AURA_APP_LIST_TITLE);
637 642
638 case TYPE_BROWSER_SHORTCUT: 643 case TYPE_BROWSER_SHORTCUT:
639 return l10n_util::GetStringUTF16(IDS_AURA_CYCLER_TITLE); 644 return l10n_util::GetStringUTF16(IDS_AURA_CYCLER_TITLE);
640 } 645 }
641 return string16(); 646 return string16();
642 } 647 }
643 648
644 void LauncherView::ButtonPressed(views::Button* sender, 649 void LauncherView::ButtonPressed(views::Button* sender,
645 const views::Event& event) { 650 const views::Event& event) {
646 if (sender == overflow_button_) 651 if (sender == overflow_button_)
647 ShowOverflowMenu(); 652 ShowOverflowMenu();
648 653
649 if (!delegate_) 654 if (!delegate_)
650 return; 655 return;
651 int view_index = view_model_->GetIndexOfView(sender); 656 int view_index = view_model_->GetIndexOfView(sender);
652 // May be -1 while in the process of animating closed. 657 // May be -1 while in the process of animating closed.
653 if (view_index == -1) 658 if (view_index == -1)
654 return; 659 return;
655 660
656 switch (model_->items()[view_index].type) { 661 switch (model_->items()[view_index].type) {
657 case TYPE_TABBED: 662 case TYPE_TABBED:
658 case TYPE_APP: 663 case TYPE_APP:
664 case TYPE_PANEL:
659 delegate_->ItemClicked(model_->items()[view_index]); 665 delegate_->ItemClicked(model_->items()[view_index]);
660 break; 666 break;
661 667
662 case TYPE_APP_LIST: 668 case TYPE_APP_LIST:
663 Shell::GetInstance()->ToggleAppList(); 669 Shell::GetInstance()->ToggleAppList();
664 break; 670 break;
665 671
666 case TYPE_BROWSER_SHORTCUT: 672 case TYPE_BROWSER_SHORTCUT:
667 cycler_->Cycle(); 673 cycler_->Cycle();
668 break; 674 break;
(...skipping 25 matching lines...) Expand all
694 // code. 700 // code.
695 if (launcher_menu_runner_->RunMenuAt( 701 if (launcher_menu_runner_->RunMenuAt(
696 source->GetWidget(), NULL, gfx::Rect(p, gfx::Size()), 702 source->GetWidget(), NULL, gfx::Rect(p, gfx::Size()),
697 views::MenuItemView::TOPLEFT, 0) == views::MenuRunner::MENU_DELETED) 703 views::MenuItemView::TOPLEFT, 0) == views::MenuRunner::MENU_DELETED)
698 return; 704 return;
699 #endif 705 #endif
700 } 706 }
701 707
702 } // namespace internal 708 } // namespace internal
703 } // namespace ash 709 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698