| OLD | NEW |
| 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 "chrome/browser/ui/views/toolbar/app_menu_button.h" | 5 #include "chrome/browser/ui/views/toolbar/app_menu_button.h" |
| 6 | 6 |
| 7 #include "base/location.h" | 7 #include "base/location.h" |
| 8 #include "base/single_thread_task_runner.h" | 8 #include "base/single_thread_task_runner.h" |
| 9 #include "base/thread_task_runner_handle.h" | 9 #include "base/thread_task_runner_handle.h" |
| 10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 | 180 |
| 181 UpdateThemedBorder(); | 181 UpdateThemedBorder(); |
| 182 | 182 |
| 183 const int inset = LabelButton::kFocusRectInset; | 183 const int inset = LabelButton::kFocusRectInset; |
| 184 SetFocusPainter(views::Painter::CreateDashedFocusPainterWithInsets( | 184 SetFocusPainter(views::Painter::CreateDashedFocusPainterWithInsets( |
| 185 gfx::Insets(inset, inset, inset, inset + margin))); | 185 gfx::Insets(inset, inset, inset, inset + margin))); |
| 186 InvalidateLayout(); | 186 InvalidateLayout(); |
| 187 } | 187 } |
| 188 | 188 |
| 189 void AppMenuButton::AddInkDropLayer(ui::Layer* ink_drop_layer) { | 189 void AppMenuButton::AddInkDropLayer(ui::Layer* ink_drop_layer) { |
| 190 SetPaintToLayer(true); | |
| 191 SetFillsBoundsOpaquely(false); | |
| 192 image()->SetPaintToLayer(true); | 190 image()->SetPaintToLayer(true); |
| 193 image()->SetFillsBoundsOpaquely(false); | 191 image()->SetFillsBoundsOpaquely(false); |
| 194 | 192 views::MenuButton::AddInkDropLayer(ink_drop_layer); |
| 195 layer()->Add(ink_drop_layer); | |
| 196 layer()->StackAtBottom(ink_drop_layer); | |
| 197 } | 193 } |
| 198 | 194 |
| 199 void AppMenuButton::RemoveInkDropLayer(ui::Layer* ink_drop_layer) { | 195 void AppMenuButton::RemoveInkDropLayer(ui::Layer* ink_drop_layer) { |
| 200 layer()->Remove(ink_drop_layer); | 196 views::MenuButton::RemoveInkDropLayer(ink_drop_layer); |
| 201 | |
| 202 image()->SetFillsBoundsOpaquely(true); | 197 image()->SetFillsBoundsOpaquely(true); |
| 203 image()->SetPaintToLayer(false); | 198 image()->SetPaintToLayer(false); |
| 204 SetPaintToLayer(false); | |
| 205 } | 199 } |
| 206 | 200 |
| 207 gfx::Point AppMenuButton::CalculateInkDropCenter() const { | 201 gfx::Point AppMenuButton::CalculateInkDropCenter() const { |
| 208 // ToolbarView extends the bounds of the app button to the right in maximized | 202 // ToolbarView extends the bounds of the app button to the right in maximized |
| 209 // mode. So instead of using the center point of local bounds, we use the | 203 // mode. So instead of using the center point of local bounds, we use the |
| 210 // center point (adjusted for RTL layouts) of the preferred size, which | 204 // center point (adjusted for RTL layouts) of the preferred size, which |
| 211 // doesn't change in maximized mode. | 205 // doesn't change in maximized mode. |
| 212 const int visible_width = GetPreferredSize().width(); | 206 const int visible_width = GetPreferredSize().width(); |
| 213 return gfx::Point( | 207 return gfx::Point( |
| 214 (GetMirroredXWithWidthInView(0, visible_width) + visible_width) / 2, | 208 (GetMirroredXWithWidthInView(0, visible_width) + visible_width) / 2, |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 293 views::MenuButton::OnPaint(canvas); | 287 views::MenuButton::OnPaint(canvas); |
| 294 if (ui::MaterialDesignController::IsModeMaterial()) | 288 if (ui::MaterialDesignController::IsModeMaterial()) |
| 295 return; | 289 return; |
| 296 // Use GetPreferredSize() to center the icon inside the visible bounds rather | 290 // Use GetPreferredSize() to center the icon inside the visible bounds rather |
| 297 // than the whole size() (which may refer to hit test region extended to the | 291 // than the whole size() (which may refer to hit test region extended to the |
| 298 // end of the toolbar in maximized mode). | 292 // end of the toolbar in maximized mode). |
| 299 icon_painter_->Paint(canvas, GetThemeProvider(), | 293 icon_painter_->Paint(canvas, GetThemeProvider(), |
| 300 gfx::Rect(GetPreferredSize()), | 294 gfx::Rect(GetPreferredSize()), |
| 301 AppMenuIconPainter::BEZEL_NONE); | 295 AppMenuIconPainter::BEZEL_NONE); |
| 302 } | 296 } |
| OLD | NEW |