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

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

Issue 1998933002: Update shelf spacing in Chrome OS according to the MD specs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: merge Created 4 years, 6 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
« no previous file with comments | « ash/root_window_controller_unittest.cc ('k') | ash/shelf/overflow_bubble_view.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/shelf/app_list_button.h" 5 #include "ash/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/shelf_item_types.h" 9 #include "ash/common/shelf/shelf_item_types.h"
10 #include "ash/common/shelf/shelf_types.h"
11 #include "ash/common/shelf/wm_shelf_util.h"
10 #include "ash/shelf/shelf_layout_manager.h" 12 #include "ash/shelf/shelf_layout_manager.h"
11 #include "ash/shelf/shelf_view.h" 13 #include "ash/shelf/shelf_view.h"
12 #include "ash/shelf/shelf_widget.h" 14 #include "ash/shelf/shelf_widget.h"
13 #include "ash/shell.h" 15 #include "ash/shell.h"
14 #include "base/command_line.h" 16 #include "base/command_line.h"
15 #include "grit/ash_resources.h" 17 #include "grit/ash_resources.h"
16 #include "grit/ash_strings.h" 18 #include "grit/ash_strings.h"
17 #include "ui/accessibility/ax_view_state.h" 19 #include "ui/accessibility/ax_view_state.h"
18 #include "ui/app_list/app_list_switches.h" 20 #include "ui/app_list/app_list_switches.h"
19 #include "ui/base/l10n/l10n_util.h" 21 #include "ui/base/l10n/l10n_util.h"
20 #include "ui/base/resource/resource_bundle.h" 22 #include "ui/base/resource/resource_bundle.h"
21 #include "ui/base/ui_base_switches_util.h" 23 #include "ui/base/ui_base_switches_util.h"
22 #include "ui/gfx/canvas.h" 24 #include "ui/gfx/canvas.h"
23 #include "ui/gfx/paint_vector_icon.h" 25 #include "ui/gfx/paint_vector_icon.h"
24 #include "ui/gfx/vector_icons_public.h" 26 #include "ui/gfx/vector_icons_public.h"
25 #include "ui/views/painter.h" 27 #include "ui/views/painter.h"
26 28
27 namespace ash { 29 namespace ash {
28 30
29 AppListButton::AppListButton(ShelfView* shelf_view) 31 AppListButton::AppListButton(ShelfView* shelf_view)
30 : views::ImageButton(shelf_view), 32 : views::ImageButton(shelf_view),
31 draw_background_as_active_(false), 33 draw_background_as_active_(false),
32 shelf_view_(shelf_view) { 34 shelf_view_(shelf_view) {
33 SetAccessibleName( 35 SetAccessibleName(
34 app_list::switches::IsExperimentalAppListEnabled() 36 app_list::switches::IsExperimentalAppListEnabled()
35 ? l10n_util::GetStringUTF16(IDS_ASH_SHELF_APP_LIST_LAUNCHER_TITLE) 37 ? l10n_util::GetStringUTF16(IDS_ASH_SHELF_APP_LIST_LAUNCHER_TITLE)
36 : l10n_util::GetStringUTF16(IDS_ASH_SHELF_APP_LIST_TITLE)); 38 : l10n_util::GetStringUTF16(IDS_ASH_SHELF_APP_LIST_TITLE));
37 SetSize(gfx::Size(kShelfSize, kShelfSize)); 39 SetSize(
40 gfx::Size(GetShelfConstant(SHELF_SIZE), GetShelfConstant(SHELF_SIZE)));
38 SetFocusPainter(views::Painter::CreateSolidFocusPainter( 41 SetFocusPainter(views::Painter::CreateSolidFocusPainter(
39 kFocusBorderColor, gfx::Insets(1, 1, 1, 1))); 42 kFocusBorderColor, gfx::Insets(1, 1, 1, 1)));
40 set_notify_action(CustomButton::NOTIFY_ON_PRESS); 43 set_notify_action(CustomButton::NOTIFY_ON_PRESS);
41 } 44 }
42 45
43 AppListButton::~AppListButton() {} 46 AppListButton::~AppListButton() {}
44 47
45 bool AppListButton::OnMousePressed(const ui::MouseEvent& event) { 48 bool AppListButton::OnMousePressed(const ui::MouseEvent& event) {
46 ImageButton::OnMousePressed(event); 49 ImageButton::OnMousePressed(event);
47 shelf_view_->PointerPressedOnButton(this, ShelfView::MOUSE, event); 50 shelf_view_->PointerPressedOnButton(this, ShelfView::MOUSE, event);
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 const gfx::ImageSkia& foreground_image = 122 const gfx::ImageSkia& foreground_image =
120 MaterialDesignController::IsShelfMaterial() 123 MaterialDesignController::IsShelfMaterial()
121 ? CreateVectorIcon(gfx::VectorIconId::SHELF_APPLIST, kShelfIconColor) 124 ? CreateVectorIcon(gfx::VectorIconId::SHELF_APPLIST, kShelfIconColor)
122 : *rb.GetImageNamed(IDR_ASH_SHELF_ICON_APPLIST).ToImageSkia(); 125 : *rb.GetImageNamed(IDR_ASH_SHELF_ICON_APPLIST).ToImageSkia();
123 126
124 gfx::Rect contents_bounds = GetContentsBounds(); 127 gfx::Rect contents_bounds = GetContentsBounds();
125 gfx::Rect background_bounds, foreground_bounds; 128 gfx::Rect background_bounds, foreground_bounds;
126 129
127 ShelfAlignment alignment = shelf_view_->shelf()->alignment(); 130 ShelfAlignment alignment = shelf_view_->shelf()->alignment();
128 background_bounds.set_size(background_image->size()); 131 background_bounds.set_size(background_image->size());
129 if (alignment == SHELF_ALIGNMENT_LEFT) { 132
130 background_bounds.set_x(contents_bounds.width() - 133 if (MaterialDesignController::IsShelfMaterial()) {
131 ShelfLayoutManager::kShelfItemInset - background_image->width()); 134 if (shelf_view_->shelf()->IsHorizontalAlignment()) {
132 background_bounds.set_y(contents_bounds.y() + 135 background_bounds.set_x(
133 (contents_bounds.height() - background_image->height()) / 2); 136 contents_bounds.x() +
134 } else if (alignment == SHELF_ALIGNMENT_RIGHT) { 137 (contents_bounds.width() - background_image->width()) / 2);
135 background_bounds.set_x(ShelfLayoutManager::kShelfItemInset); 138 background_bounds.set_y(
136 background_bounds.set_y(contents_bounds.y() + 139 (contents_bounds.height() - background_image->height()) / 2);
137 (contents_bounds.height() - background_image->height()) / 2); 140 } else {
141 background_bounds.set_x(
142 (contents_bounds.height() - background_image->height()) / 2);
143 background_bounds.set_y(
144 contents_bounds.y() +
145 (contents_bounds.width() - background_image->width()) / 2);
146 }
138 } else { 147 } else {
139 background_bounds.set_y(ShelfLayoutManager::kShelfItemInset); 148 if (alignment == SHELF_ALIGNMENT_LEFT) {
140 background_bounds.set_x(contents_bounds.x() + 149 background_bounds.set_x(contents_bounds.width() - kShelfItemInset -
141 (contents_bounds.width() - background_image->width()) / 2); 150 background_image->width());
151 background_bounds.set_y(
152 contents_bounds.y() +
153 (contents_bounds.height() - background_image->height()) / 2);
154 } else if (alignment == SHELF_ALIGNMENT_RIGHT) {
155 background_bounds.set_x(kShelfItemInset);
156 background_bounds.set_y(
157 contents_bounds.y() +
158 (contents_bounds.height() - background_image->height()) / 2);
159 } else { // SHELF_ALIGNMENT_BOTTOM
160 background_bounds.set_y(kShelfItemInset);
161 background_bounds.set_x(
162 contents_bounds.x() +
163 (contents_bounds.width() - background_image->width()) / 2);
164 }
142 } 165 }
143 166
144 foreground_bounds.set_size(foreground_image.size()); 167 foreground_bounds.set_size(foreground_image.size());
145 168
146 foreground_bounds.set_x(background_bounds.x() + 169 foreground_bounds.set_x(background_bounds.x() +
147 std::max(0, 170 std::max(0,
148 (background_bounds.width() - foreground_bounds.width()) / 2)); 171 (background_bounds.width() - foreground_bounds.width()) / 2));
149 foreground_bounds.set_y(background_bounds.y() + 172 foreground_bounds.set_y(background_bounds.y() +
150 std::max(0, 173 std::max(0,
151 (background_bounds.height() - foreground_bounds.height()) / 2)); 174 (background_bounds.height() - foreground_bounds.height()) / 2));
(...skipping 15 matching lines...) Expand all
167 190
168 void AppListButton::SetDrawBackgroundAsActive( 191 void AppListButton::SetDrawBackgroundAsActive(
169 bool draw_background_as_active) { 192 bool draw_background_as_active) {
170 if (draw_background_as_active_ == draw_background_as_active) 193 if (draw_background_as_active_ == draw_background_as_active)
171 return; 194 return;
172 draw_background_as_active_ = draw_background_as_active; 195 draw_background_as_active_ = draw_background_as_active;
173 SchedulePaint(); 196 SchedulePaint();
174 } 197 }
175 198
176 } // namespace ash 199 } // namespace ash
OLDNEW
« no previous file with comments | « ash/root_window_controller_unittest.cc ('k') | ash/shelf/overflow_bubble_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698