| 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/toolbar_button.h" | 5 #include "chrome/browser/ui/views/toolbar/toolbar_button.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" | 8 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" |
| 9 #include "grit/theme_resources.h" | 9 #include "grit/theme_resources.h" |
| 10 #include "grit/ui_strings.h" | 10 #include "grit/ui_strings.h" |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 } | 33 } |
| 34 | 34 |
| 35 void ToolbarButton::Init() { | 35 void ToolbarButton::Init() { |
| 36 SetFocusable(false); | 36 SetFocusable(false); |
| 37 SetAccessibilityFocusable(true); | 37 SetAccessibilityFocusable(true); |
| 38 image()->EnableCanvasFlippingForRTLUI(true); | 38 image()->EnableCanvasFlippingForRTLUI(true); |
| 39 | 39 |
| 40 // Provides the hover/pressed style used by buttons in the toolbar. | 40 // Provides the hover/pressed style used by buttons in the toolbar. |
| 41 views::LabelButtonBorder* border = | 41 views::LabelButtonBorder* border = |
| 42 new views::LabelButtonBorder(views::Button::STYLE_TEXTBUTTON); | 42 new views::LabelButtonBorder(views::Button::STYLE_TEXTBUTTON); |
| 43 const int kHoverImages[] = IMAGE_GRID(IDR_TOOLBAR_BUTTON_HOVER); | |
| 44 border->SetPainter(false, views::Button::STATE_HOVERED, | |
| 45 views::Painter::CreateImageGridPainter( | |
| 46 kHoverImages)); | |
| 47 const int kPressedImages[] = IMAGE_GRID(IDR_TOOLBAR_BUTTON_PRESSED); | |
| 48 border->SetPainter(false, views::Button::STATE_PRESSED, | |
| 49 views::Painter::CreateImageGridPainter( | |
| 50 kPressedImages)); | |
| 51 set_border(border); | 43 set_border(border); |
| 52 } | 44 } |
| 53 | 45 |
| 54 void ToolbarButton::ClearPendingMenu() { | 46 void ToolbarButton::ClearPendingMenu() { |
| 55 show_menu_factory_.InvalidateWeakPtrs(); | 47 show_menu_factory_.InvalidateWeakPtrs(); |
| 56 } | 48 } |
| 57 | 49 |
| 58 bool ToolbarButton::IsMenuShowing() const { | 50 bool ToolbarButton::IsMenuShowing() const { |
| 59 return menu_showing_; | 51 return menu_showing_; |
| 60 } | 52 } |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 | 224 |
| 233 // Need to explicitly clear mouse handler so that events get sent | 225 // Need to explicitly clear mouse handler so that events get sent |
| 234 // properly after the menu finishes running. If we don't do this, then | 226 // properly after the menu finishes running. If we don't do this, then |
| 235 // the first click to other parts of the UI is eaten. | 227 // the first click to other parts of the UI is eaten. |
| 236 SetMouseHandler(NULL); | 228 SetMouseHandler(NULL); |
| 237 | 229 |
| 238 // Set the state back to normal after the drop down menu is closed. | 230 // Set the state back to normal after the drop down menu is closed. |
| 239 if (state_ != STATE_DISABLED) | 231 if (state_ != STATE_DISABLED) |
| 240 SetState(STATE_NORMAL); | 232 SetState(STATE_NORMAL); |
| 241 } | 233 } |
| OLD | NEW |