| 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 gfx::Point AppMenuButton::GetInkDropCenter() const { | |
| 192 // ToolbarView extends the bounds of the app button to the right in maximized | |
| 193 // mode. So instead of using the center point of local bounds, we use the | |
| 194 // center point (adjusted for RTL layouts) of the preferred size, which | |
| 195 // doesn't change in maximized mode. | |
| 196 const int visible_width = GetPreferredSize().width(); | |
| 197 return gfx::Point( | |
| 198 (GetMirroredXWithWidthInView(0, visible_width) + visible_width) / 2, | |
| 199 height() / 2); | |
| 200 } | |
| 201 | |
| 202 const char* AppMenuButton::GetClassName() const { | 191 const char* AppMenuButton::GetClassName() const { |
| 203 return "AppMenuButton"; | 192 return "AppMenuButton"; |
| 204 } | 193 } |
| 205 | 194 |
| 206 scoped_ptr<views::LabelButtonBorder> AppMenuButton::CreateDefaultBorder() | 195 scoped_ptr<views::LabelButtonBorder> AppMenuButton::CreateDefaultBorder() |
| 207 const { | 196 const { |
| 208 scoped_ptr<views::LabelButtonBorder> border = | 197 scoped_ptr<views::LabelButtonBorder> border = |
| 209 MenuButton::CreateDefaultBorder(); | 198 MenuButton::CreateDefaultBorder(); |
| 210 | 199 |
| 211 // Adjust border insets to follow the margin change, | 200 // Adjust border insets to follow the margin change, |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 views::MenuButton::OnPaint(canvas); | 266 views::MenuButton::OnPaint(canvas); |
| 278 if (ui::MaterialDesignController::IsModeMaterial()) | 267 if (ui::MaterialDesignController::IsModeMaterial()) |
| 279 return; | 268 return; |
| 280 // Use GetPreferredSize() to center the icon inside the visible bounds rather | 269 // Use GetPreferredSize() to center the icon inside the visible bounds rather |
| 281 // than the whole size() (which may refer to hit test region extended to the | 270 // than the whole size() (which may refer to hit test region extended to the |
| 282 // end of the toolbar in maximized mode). | 271 // end of the toolbar in maximized mode). |
| 283 icon_painter_->Paint(canvas, GetThemeProvider(), | 272 icon_painter_->Paint(canvas, GetThemeProvider(), |
| 284 gfx::Rect(GetPreferredSize()), | 273 gfx::Rect(GetPreferredSize()), |
| 285 AppMenuIconPainter::BEZEL_NONE); | 274 AppMenuIconPainter::BEZEL_NONE); |
| 286 } | 275 } |
| OLD | NEW |