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

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

Issue 2534953006: Fix shelf auto-hide calculation for app-list visibility. (Closed)
Patch Set: Address comments. 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
« no previous file with comments | « ash/common/shelf/app_list_button.h ('k') | ash/common/shelf/shelf_layout_manager.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/app_list_button.h" 5 #include "ash/common/shelf/app_list_button.h"
6 6
7 #include "ash/common/ash_constants.h" 7 #include "ash/common/ash_constants.h"
8 #include "ash/common/material_design/material_design_controller.h" 8 #include "ash/common/material_design/material_design_controller.h"
9 #include "ash/common/shelf/ink_drop_button_listener.h" 9 #include "ash/common/shelf/ink_drop_button_listener.h"
10 #include "ash/common/shelf/shelf_constants.h" 10 #include "ash/common/shelf/shelf_constants.h"
(...skipping 15 matching lines...) Expand all
26 #include "ui/views/animation/ink_drop_impl.h" 26 #include "ui/views/animation/ink_drop_impl.h"
27 #include "ui/views/animation/ink_drop_mask.h" 27 #include "ui/views/animation/ink_drop_mask.h"
28 #include "ui/views/painter.h" 28 #include "ui/views/painter.h"
29 29
30 namespace ash { 30 namespace ash {
31 31
32 AppListButton::AppListButton(InkDropButtonListener* listener, 32 AppListButton::AppListButton(InkDropButtonListener* listener,
33 ShelfView* shelf_view, 33 ShelfView* shelf_view,
34 WmShelf* wm_shelf) 34 WmShelf* wm_shelf)
35 : views::ImageButton(nullptr), 35 : views::ImageButton(nullptr),
36 is_showing_app_list_(false),
36 draw_background_as_active_(false), 37 draw_background_as_active_(false),
37 background_alpha_(0), 38 background_alpha_(0),
38 listener_(listener), 39 listener_(listener),
39 shelf_view_(shelf_view), 40 shelf_view_(shelf_view),
40 wm_shelf_(wm_shelf) { 41 wm_shelf_(wm_shelf) {
41 DCHECK(listener_); 42 DCHECK(listener_);
42 DCHECK(shelf_view_); 43 DCHECK(shelf_view_);
43 DCHECK(wm_shelf_); 44 DCHECK(wm_shelf_);
44 if (ash::MaterialDesignController::IsShelfMaterial()) { 45 if (ash::MaterialDesignController::IsShelfMaterial()) {
45 SetInkDropMode(InkDropMode::ON_NO_GESTURE_HANDLER); 46 SetInkDropMode(InkDropMode::ON_NO_GESTURE_HANDLER);
46 set_ink_drop_base_color(kShelfInkDropBaseColor); 47 set_ink_drop_base_color(kShelfInkDropBaseColor);
47 set_ink_drop_visible_opacity(kShelfInkDropVisibleOpacity); 48 set_ink_drop_visible_opacity(kShelfInkDropVisibleOpacity);
48 } 49 }
49 SetAccessibleName( 50 SetAccessibleName(
50 l10n_util::GetStringUTF16(IDS_ASH_SHELF_APP_LIST_LAUNCHER_TITLE)); 51 l10n_util::GetStringUTF16(IDS_ASH_SHELF_APP_LIST_LAUNCHER_TITLE));
51 SetSize( 52 SetSize(
52 gfx::Size(GetShelfConstant(SHELF_SIZE), GetShelfConstant(SHELF_SIZE))); 53 gfx::Size(GetShelfConstant(SHELF_SIZE), GetShelfConstant(SHELF_SIZE)));
53 SetFocusPainter(views::Painter::CreateSolidFocusPainter( 54 SetFocusPainter(views::Painter::CreateSolidFocusPainter(
54 kFocusBorderColor, gfx::Insets(1, 1, 1, 1))); 55 kFocusBorderColor, gfx::Insets(1, 1, 1, 1)));
55 set_notify_action(CustomButton::NOTIFY_ON_PRESS); 56 set_notify_action(CustomButton::NOTIFY_ON_PRESS);
56 } 57 }
57 58
58 AppListButton::~AppListButton() {} 59 AppListButton::~AppListButton() {}
59 60
60 void AppListButton::OnAppListShown() { 61 void AppListButton::OnAppListShown() {
61 if (ash::MaterialDesignController::IsShelfMaterial()) 62 if (ash::MaterialDesignController::IsShelfMaterial())
62 AnimateInkDrop(views::InkDropState::ACTIVATED, nullptr); 63 AnimateInkDrop(views::InkDropState::ACTIVATED, nullptr);
63 else 64 else
64 SchedulePaint(); 65 SchedulePaint();
66 is_showing_app_list_ = true;
67 wm_shelf_->UpdateAutoHideState();
65 } 68 }
66 69
67 void AppListButton::OnAppListDismissed() { 70 void AppListButton::OnAppListDismissed() {
68 if (ash::MaterialDesignController::IsShelfMaterial()) 71 if (ash::MaterialDesignController::IsShelfMaterial())
69 AnimateInkDrop(views::InkDropState::DEACTIVATED, nullptr); 72 AnimateInkDrop(views::InkDropState::DEACTIVATED, nullptr);
70 else 73 else
71 SchedulePaint(); 74 SchedulePaint();
75 is_showing_app_list_ = false;
76 wm_shelf_->UpdateAutoHideState();
72 } 77 }
73 78
74 void AppListButton::SetBackgroundAlpha(int alpha) { 79 void AppListButton::SetBackgroundAlpha(int alpha) {
75 background_alpha_ = alpha; 80 background_alpha_ = alpha;
76 SchedulePaint(); 81 SchedulePaint();
77 } 82 }
78 83
79 bool AppListButton::OnMousePressed(const ui::MouseEvent& event) { 84 bool AppListButton::OnMousePressed(const ui::MouseEvent& event) {
80 ImageButton::OnMousePressed(event); 85 ImageButton::OnMousePressed(event);
81 shelf_view_->PointerPressedOnButton(this, ShelfView::MOUSE, event); 86 shelf_view_->PointerPressedOnButton(this, ShelfView::MOUSE, event);
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 int center = std::max(width(), height()) / 2.f; 295 int center = std::max(width(), height()) / 2.f;
291 gfx::Point centroid(center, center); 296 gfx::Point centroid(center, center);
292 // For the left shelf alignment, we need to right-justify. For other shelf 297 // For the left shelf alignment, we need to right-justify. For other shelf
293 // alignments, left/top justification (i.e. no adjustments are necessary). 298 // alignments, left/top justification (i.e. no adjustments are necessary).
294 if (SHELF_ALIGNMENT_LEFT == wm_shelf_->GetAlignment()) 299 if (SHELF_ALIGNMENT_LEFT == wm_shelf_->GetAlignment())
295 centroid.set_x(width() - center); 300 centroid.set_x(width() - center);
296 return centroid; 301 return centroid;
297 } 302 }
298 303
299 } // namespace ash 304 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/shelf/app_list_button.h ('k') | ash/common/shelf/shelf_layout_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698