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

Side by Side Diff: ash/common/shelf/shelf_window_watcher_item_delegate.cc

Issue 2558963002: Move shelf item tooltip flag from delegate to item. (Closed)
Patch Set: Cleanup Created 4 years 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/common/shelf/shelf_window_watcher_item_delegate.h" 5 #include "ash/common/shelf/shelf_window_watcher_item_delegate.h"
6 6
7 #include "ash/common/shelf/shelf_controller.h" 7 #include "ash/common/shelf/shelf_controller.h"
8 #include "ash/common/shelf/shelf_model.h" 8 #include "ash/common/shelf/shelf_model.h"
9 #include "ash/common/wm/window_state.h" 9 #include "ash/common/wm/window_state.h"
10 #include "ash/common/wm_shell.h" 10 #include "ash/common/wm_shell.h"
11 #include "ash/common/wm_window.h" 11 #include "ash/common/wm_window.h"
12 #include "ash/common/wm_window_property.h"
12 #include "ui/events/event.h" 13 #include "ui/events/event.h"
13 14
14 namespace ash { 15 namespace ash {
15 16
16 namespace { 17 namespace {
17 18
18 ShelfItemType GetShelfItemType(ShelfID id) { 19 ShelfItemType GetShelfItemType(ShelfID id) {
19 ShelfModel* model = WmShell::Get()->shelf_controller()->model(); 20 ShelfModel* model = WmShell::Get()->shelf_controller()->model();
20 ShelfItems::const_iterator item = model->ItemByID(id); 21 ShelfItems::const_iterator item = model->ItemByID(id);
21 return item == model->items().end() ? TYPE_UNDEFINED : item->type; 22 return item == model->items().end() ? TYPE_UNDEFINED : item->type;
22 } 23 }
23 24
24 } // namespace 25 } // namespace
25 26
26 ShelfWindowWatcherItemDelegate::ShelfWindowWatcherItemDelegate(ShelfID id, 27 ShelfWindowWatcherItemDelegate::ShelfWindowWatcherItemDelegate(ShelfID id,
27 WmWindow* window) 28 WmWindow* window)
28 : id_(id), window_(window) { 29 : id_(id), window_(window) {
29 DCHECK_NE(kInvalidShelfID, id_); 30 DCHECK_NE(kInvalidShelfID, id_);
30 DCHECK(window_); 31 DCHECK(window_);
31 } 32 }
32 33
33 ShelfWindowWatcherItemDelegate::~ShelfWindowWatcherItemDelegate() {} 34 ShelfWindowWatcherItemDelegate::~ShelfWindowWatcherItemDelegate() {}
34 35
35 ShelfItemDelegate::PerformedAction ShelfWindowWatcherItemDelegate::ItemSelected( 36 ShelfItemDelegate::PerformedAction ShelfWindowWatcherItemDelegate::ItemSelected(
36 const ui::Event& event) { 37 const ui::Event& event) {
37 // Move panels attached on another display to the current display. 38 // Move panels attached on another display to the current display.
38 if (GetShelfItemType(id_) == TYPE_APP_PANEL && 39 if (GetShelfItemType(id_) == TYPE_APP_PANEL &&
39 window_->GetWindowState()->panel_attached() && 40 window_->GetBoolProperty(WmWindowProperty::PANEL_ATTACHED) &&
40 window_->MoveToEventRoot(event)) { 41 window_->MoveToEventRoot(event)) {
41 window_->Activate(); 42 window_->Activate();
42 return kExistingWindowActivated; 43 return kExistingWindowActivated;
43 } 44 }
44 45
45 if (window_->IsActive()) { 46 if (window_->IsActive()) {
46 if (event.type() & ui::ET_KEY_RELEASED) { 47 if (event.type() & ui::ET_KEY_RELEASED) {
47 window_->Animate(::wm::WINDOW_ANIMATION_TYPE_BOUNCE); 48 window_->Animate(::wm::WINDOW_ANIMATION_TYPE_BOUNCE);
48 return kNoAction; 49 return kNoAction;
49 } 50 }
(...skipping 14 matching lines...) Expand all
64 } 65 }
65 66
66 bool ShelfWindowWatcherItemDelegate::IsDraggable() { 67 bool ShelfWindowWatcherItemDelegate::IsDraggable() {
67 return true; 68 return true;
68 } 69 }
69 70
70 bool ShelfWindowWatcherItemDelegate::CanPin() const { 71 bool ShelfWindowWatcherItemDelegate::CanPin() const {
71 return GetShelfItemType(id_) != TYPE_APP_PANEL; 72 return GetShelfItemType(id_) != TYPE_APP_PANEL;
72 } 73 }
73 74
74 bool ShelfWindowWatcherItemDelegate::ShouldShowTooltip() {
75 // Do not show tooltips for visible attached app panel windows.
76 return GetShelfItemType(id_) != TYPE_APP_PANEL || !window_->IsVisible() ||
77 !window_->GetWindowState()->panel_attached();
78 }
79
80 void ShelfWindowWatcherItemDelegate::Close() { 75 void ShelfWindowWatcherItemDelegate::Close() {
81 window_->CloseWidget(); 76 window_->CloseWidget();
82 } 77 }
83 78
84 } // namespace ash 79 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698