Chromium Code Reviews| 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/metrics/histogram_macros.h" | 8 #include "base/metrics/histogram_macros.h" |
| 9 #include "base/single_thread_task_runner.h" | 9 #include "base/single_thread_task_runner.h" |
| 10 #include "base/thread_task_runner_handle.h" | 10 #include "base/thread_task_runner_handle.h" |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 181 margin_trailing_ = margin; | 181 margin_trailing_ = margin; |
| 182 | 182 |
| 183 UpdateThemedBorder(); | 183 UpdateThemedBorder(); |
| 184 | 184 |
| 185 const int inset = LabelButton::kFocusRectInset; | 185 const int inset = LabelButton::kFocusRectInset; |
| 186 SetFocusPainter(views::Painter::CreateDashedFocusPainterWithInsets( | 186 SetFocusPainter(views::Painter::CreateDashedFocusPainterWithInsets( |
| 187 gfx::Insets(inset, inset, inset, inset + margin))); | 187 gfx::Insets(inset, inset, inset, inset + margin))); |
| 188 InvalidateLayout(); | 188 InvalidateLayout(); |
| 189 } | 189 } |
| 190 | 190 |
| 191 void AppMenuButton::AddInkDropLayer(ui::Layer* ink_drop_layer) { | |
|
Evan Stade
2016/03/01 00:23:37
these are no longer necessary because MenuButton i
| |
| 192 image()->SetPaintToLayer(true); | |
| 193 image()->SetFillsBoundsOpaquely(false); | |
| 194 views::MenuButton::AddInkDropLayer(ink_drop_layer); | |
| 195 } | |
| 196 | |
| 197 void AppMenuButton::RemoveInkDropLayer(ui::Layer* ink_drop_layer) { | |
| 198 views::MenuButton::RemoveInkDropLayer(ink_drop_layer); | |
| 199 image()->SetPaintToLayer(false); | |
| 200 } | |
| 201 | |
| 202 gfx::Point AppMenuButton::GetInkDropCenter() const { | 191 gfx::Point AppMenuButton::GetInkDropCenter() const { |
| 203 // ToolbarView extends the bounds of the app button to the right in maximized | 192 // ToolbarView extends the bounds of the app button to the right in maximized |
| 204 // mode. So instead of using the center point of local bounds, we use the | 193 // mode. So instead of using the center point of local bounds, we use the |
| 205 // center point (adjusted for RTL layouts) of the preferred size, which | 194 // center point (adjusted for RTL layouts) of the preferred size, which |
| 206 // doesn't change in maximized mode. | 195 // doesn't change in maximized mode. |
| 207 const int visible_width = GetPreferredSize().width(); | 196 const int visible_width = GetPreferredSize().width(); |
| 208 return gfx::Point( | 197 return gfx::Point( |
| 209 (GetMirroredXWithWidthInView(0, visible_width) + visible_width) / 2, | 198 (GetMirroredXWithWidthInView(0, visible_width) + visible_width) / 2, |
| 210 height() / 2); | 199 height() / 2); |
| 211 } | 200 } |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 288 views::MenuButton::OnPaint(canvas); | 277 views::MenuButton::OnPaint(canvas); |
| 289 if (ui::MaterialDesignController::IsModeMaterial()) | 278 if (ui::MaterialDesignController::IsModeMaterial()) |
| 290 return; | 279 return; |
| 291 // Use GetPreferredSize() to center the icon inside the visible bounds rather | 280 // Use GetPreferredSize() to center the icon inside the visible bounds rather |
| 292 // than the whole size() (which may refer to hit test region extended to the | 281 // than the whole size() (which may refer to hit test region extended to the |
| 293 // end of the toolbar in maximized mode). | 282 // end of the toolbar in maximized mode). |
| 294 icon_painter_->Paint(canvas, GetThemeProvider(), | 283 icon_painter_->Paint(canvas, GetThemeProvider(), |
| 295 gfx::Rect(GetPreferredSize()), | 284 gfx::Rect(GetPreferredSize()), |
| 296 AppMenuIconPainter::BEZEL_NONE); | 285 AppMenuIconPainter::BEZEL_NONE); |
| 297 } | 286 } |
| OLD | NEW |