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

Side by Side Diff: chrome/browser/ui/views/toolbar/browser_actions_container.cc

Issue 340003002: Revert of views: Move MenuButton from TextButton to LabelButton. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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 | Annotate | Revision Log
OLDNEW
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/browser_actions_container.h" 5 #include "chrome/browser/ui/views/toolbar/browser_actions_container.h"
6 6
7 #include "base/compiler_specific.h" 7 #include "base/compiler_specific.h"
8 #include "base/prefs/pref_service.h" 8 #include "base/prefs/pref_service.h"
9 #include "base/stl_util.h" 9 #include "base/stl_util.h"
10 #include "chrome/browser/extensions/extension_service.h" 10 #include "chrome/browser/extensions/extension_service.h"
(...skipping 22 matching lines...) Expand all
33 #include "third_party/skia/include/core/SkColor.h" 33 #include "third_party/skia/include/core/SkColor.h"
34 #include "ui/accessibility/ax_view_state.h" 34 #include "ui/accessibility/ax_view_state.h"
35 #include "ui/base/dragdrop/drag_utils.h" 35 #include "ui/base/dragdrop/drag_utils.h"
36 #include "ui/base/l10n/l10n_util.h" 36 #include "ui/base/l10n/l10n_util.h"
37 #include "ui/base/nine_image_painter_factory.h" 37 #include "ui/base/nine_image_painter_factory.h"
38 #include "ui/base/resource/resource_bundle.h" 38 #include "ui/base/resource/resource_bundle.h"
39 #include "ui/base/theme_provider.h" 39 #include "ui/base/theme_provider.h"
40 #include "ui/gfx/animation/slide_animation.h" 40 #include "ui/gfx/animation/slide_animation.h"
41 #include "ui/gfx/canvas.h" 41 #include "ui/gfx/canvas.h"
42 #include "ui/gfx/geometry/rect.h" 42 #include "ui/gfx/geometry/rect.h"
43 #include "ui/views/controls/button/label_button_border.h"
44 #include "ui/views/controls/resize_area.h" 43 #include "ui/views/controls/resize_area.h"
45 #include "ui/views/metrics.h" 44 #include "ui/views/metrics.h"
46 #include "ui/views/painter.h" 45 #include "ui/views/painter.h"
47 #include "ui/views/widget/widget.h" 46 #include "ui/views/widget/widget.h"
48 47
49 using extensions::Extension; 48 using extensions::Extension;
50 49
51 namespace { 50 namespace {
52 51
53 // Horizontal spacing between most items in the container, as well as after the 52 // Horizontal spacing between most items in the container, as well as after the
54 // last item or chevron (if visible). 53 // last item or chevron (if visible).
55 const int kItemSpacing = ToolbarView::kStandardSpacing; 54 const int kItemSpacing = ToolbarView::kStandardSpacing;
56 55
57 // Horizontal spacing before the chevron (if visible). 56 // Horizontal spacing before the chevron (if visible).
58 const int kChevronSpacing = kItemSpacing - 2; 57 const int kChevronSpacing = kItemSpacing - 2;
59 58
60 // A version of MenuButton with almost empty insets to fit properly on the
61 // toolbar.
62 class ChevronMenuButton : public views::MenuButton {
63 public:
64 ChevronMenuButton(views::ButtonListener* listener,
65 const base::string16& text,
66 views::MenuButtonListener* menu_button_listener,
67 bool show_menu_marker)
68 : views::MenuButton(listener,
69 text,
70 menu_button_listener,
71 show_menu_marker) {
72 }
73
74 virtual ~ChevronMenuButton() {}
75
76 virtual scoped_ptr<views::LabelButtonBorder> CreateDefaultBorder() const
77 OVERRIDE {
78 // The chevron resource was designed to not have any insets.
79 scoped_ptr<views::LabelButtonBorder> border =
80 views::MenuButton::CreateDefaultBorder();
81 border->set_insets(gfx::Insets());
82 return border.Pass();
83 }
84
85 private:
86 DISALLOW_COPY_AND_ASSIGN(ChevronMenuButton);
87 };
88
89 } // namespace 59 } // namespace
90 60
91 // static 61 // static
92 bool BrowserActionsContainer::disable_animations_during_testing_ = false; 62 bool BrowserActionsContainer::disable_animations_during_testing_ = false;
93 63
94 //////////////////////////////////////////////////////////////////////////////// 64 ////////////////////////////////////////////////////////////////////////////////
95 // BrowserActionsContainer 65 // BrowserActionsContainer
96 66
97 BrowserActionsContainer::BrowserActionsContainer(Browser* browser, 67 BrowserActionsContainer::BrowserActionsContainer(Browser* browser,
98 View* owner_view) 68 View* owner_view)
(...skipping 21 matching lines...) Expand all
120 extension_keybinding_registry_.reset(new ExtensionKeybindingRegistryViews( 90 extension_keybinding_registry_.reset(new ExtensionKeybindingRegistryViews(
121 browser->profile(), 91 browser->profile(),
122 owner_view->GetFocusManager(), 92 owner_view->GetFocusManager(),
123 extensions::ExtensionKeybindingRegistry::ALL_EXTENSIONS, 93 extensions::ExtensionKeybindingRegistry::ALL_EXTENSIONS,
124 this)); 94 this));
125 95
126 resize_animation_.reset(new gfx::SlideAnimation(this)); 96 resize_animation_.reset(new gfx::SlideAnimation(this));
127 resize_area_ = new views::ResizeArea(this); 97 resize_area_ = new views::ResizeArea(this);
128 AddChildView(resize_area_); 98 AddChildView(resize_area_);
129 99
130 chevron_ = new ChevronMenuButton(NULL, base::string16(), this, false); 100 chevron_ = new views::MenuButton(NULL, base::string16(), this, false);
101 chevron_->SetBorder(views::Border::NullBorder());
131 chevron_->EnableCanvasFlippingForRTLUI(true); 102 chevron_->EnableCanvasFlippingForRTLUI(true);
132 chevron_->SetAccessibleName( 103 chevron_->SetAccessibleName(
133 l10n_util::GetStringUTF16(IDS_ACCNAME_EXTENSIONS_CHEVRON)); 104 l10n_util::GetStringUTF16(IDS_ACCNAME_EXTENSIONS_CHEVRON));
134 chevron_->SetVisible(false); 105 chevron_->SetVisible(false);
135 AddChildView(chevron_); 106 AddChildView(chevron_);
136 } 107 }
137 108
138 BrowserActionsContainer::~BrowserActionsContainer() { 109 BrowserActionsContainer::~BrowserActionsContainer() {
139 FOR_EACH_OBSERVER(BrowserActionsContainerObserver, 110 FOR_EACH_OBSERVER(BrowserActionsContainerObserver,
140 observers_, 111 observers_,
(...skipping 663 matching lines...) Expand 10 before | Expand all | Expand 10 after
804 // we delete and recreate everything here, but that's how it's done in 775 // we delete and recreate everything here, but that's how it's done in
805 // BrowserActionMoved(), too. If we want to optimize it, we could move the 776 // BrowserActionMoved(), too. If we want to optimize it, we could move the
806 // existing icons, instead of deleting it all. 777 // existing icons, instead of deleting it all.
807 DeleteBrowserActionViews(); 778 DeleteBrowserActionViews();
808 CreateBrowserActionViews(); 779 CreateBrowserActionViews();
809 SaveDesiredSizeAndAnimate(gfx::Tween::LINEAR, browser_action_views_.size()); 780 SaveDesiredSizeAndAnimate(gfx::Tween::LINEAR, browser_action_views_.size());
810 } 781 }
811 782
812 void BrowserActionsContainer::LoadImages() { 783 void BrowserActionsContainer::LoadImages() {
813 ui::ThemeProvider* tp = GetThemeProvider(); 784 ui::ThemeProvider* tp = GetThemeProvider();
814 chevron_->SetImage(views::Button::STATE_NORMAL, 785 chevron_->SetIcon(*tp->GetImageSkiaNamed(IDR_BROWSER_ACTIONS_OVERFLOW));
815 *tp->GetImageSkiaNamed(IDR_BROWSER_ACTIONS_OVERFLOW)); 786 chevron_->SetHoverIcon(*tp->GetImageSkiaNamed(
787 IDR_BROWSER_ACTIONS_OVERFLOW_H));
788 chevron_->SetPushedIcon(*tp->GetImageSkiaNamed(
789 IDR_BROWSER_ACTIONS_OVERFLOW_P));
816 790
817 const int kImages[] = IMAGE_GRID(IDR_DEVELOPER_MODE_HIGHLIGHT); 791 const int kImages[] = IMAGE_GRID(IDR_DEVELOPER_MODE_HIGHLIGHT);
818 highlight_painter_.reset(views::Painter::CreateImageGridPainter(kImages)); 792 highlight_painter_.reset(views::Painter::CreateImageGridPainter(kImages));
819 } 793 }
820 794
821 void BrowserActionsContainer::SetContainerWidth() { 795 void BrowserActionsContainer::SetContainerWidth() {
822 int visible_actions = model_->GetVisibleIconCount(); 796 int visible_actions = model_->GetVisibleIconCount();
823 if (visible_actions < 0) // All icons should be visible. 797 if (visible_actions < 0) // All icons should be visible.
824 visible_actions = model_->toolbar_items().size(); 798 visible_actions = model_->toolbar_items().size();
825 chevron_->SetVisible( 799 chevron_->SetVisible(
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
958 views::BubbleBorder::TOP_RIGHT, 932 views::BubbleBorder::TOP_RIGHT,
959 show_action); 933 show_action);
960 popup_->GetWidget()->AddObserver(this); 934 popup_->GetWidget()->AddObserver(this);
961 popup_button_ = button; 935 popup_button_ = button;
962 936
963 // Only set button as pushed if it was triggered by a user click. 937 // Only set button as pushed if it was triggered by a user click.
964 if (should_grant) 938 if (should_grant)
965 popup_button_->SetButtonPushed(); 939 popup_button_->SetButtonPushed();
966 return true; 940 return true;
967 } 941 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/toolbar/browser_action_view.cc ('k') | chrome/browser/ui/views/toolbar/wrench_toolbar_button.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698