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

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

Issue 298813002: views: Move MenuButton from TextButton to LabelButton. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Disable DragDirectlyToSecondWindow. 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"
43 #include "ui/views/controls/resize_area.h" 44 #include "ui/views/controls/resize_area.h"
44 #include "ui/views/metrics.h" 45 #include "ui/views/metrics.h"
45 #include "ui/views/painter.h" 46 #include "ui/views/painter.h"
46 #include "ui/views/widget/widget.h" 47 #include "ui/views/widget/widget.h"
47 48
48 using extensions::Extension; 49 using extensions::Extension;
49 50
50 namespace { 51 namespace {
51 52
52 // Horizontal spacing between most items in the container, as well as after the 53 // Horizontal spacing between most items in the container, as well as after the
53 // last item or chevron (if visible). 54 // last item or chevron (if visible).
54 const int kItemSpacing = ToolbarView::kStandardSpacing; 55 const int kItemSpacing = ToolbarView::kStandardSpacing;
55 56
56 // Horizontal spacing before the chevron (if visible). 57 // Horizontal spacing before the chevron (if visible).
57 const int kChevronSpacing = kItemSpacing - 2; 58 const int kChevronSpacing = kItemSpacing - 2;
58 59
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
59 } // namespace 89 } // namespace
60 90
61 // static 91 // static
62 bool BrowserActionsContainer::disable_animations_during_testing_ = false; 92 bool BrowserActionsContainer::disable_animations_during_testing_ = false;
63 93
64 //////////////////////////////////////////////////////////////////////////////// 94 ////////////////////////////////////////////////////////////////////////////////
65 // BrowserActionsContainer 95 // BrowserActionsContainer
66 96
67 BrowserActionsContainer::BrowserActionsContainer(Browser* browser, 97 BrowserActionsContainer::BrowserActionsContainer(Browser* browser,
68 View* owner_view) 98 View* owner_view)
(...skipping 21 matching lines...) Expand all
90 extension_keybinding_registry_.reset(new ExtensionKeybindingRegistryViews( 120 extension_keybinding_registry_.reset(new ExtensionKeybindingRegistryViews(
91 browser->profile(), 121 browser->profile(),
92 owner_view->GetFocusManager(), 122 owner_view->GetFocusManager(),
93 extensions::ExtensionKeybindingRegistry::ALL_EXTENSIONS, 123 extensions::ExtensionKeybindingRegistry::ALL_EXTENSIONS,
94 this)); 124 this));
95 125
96 resize_animation_.reset(new gfx::SlideAnimation(this)); 126 resize_animation_.reset(new gfx::SlideAnimation(this));
97 resize_area_ = new views::ResizeArea(this); 127 resize_area_ = new views::ResizeArea(this);
98 AddChildView(resize_area_); 128 AddChildView(resize_area_);
99 129
100 chevron_ = new views::MenuButton(NULL, base::string16(), this, false); 130 chevron_ = new ChevronMenuButton(NULL, base::string16(), this, false);
101 chevron_->SetBorder(views::Border::NullBorder());
102 chevron_->EnableCanvasFlippingForRTLUI(true); 131 chevron_->EnableCanvasFlippingForRTLUI(true);
103 chevron_->SetAccessibleName( 132 chevron_->SetAccessibleName(
104 l10n_util::GetStringUTF16(IDS_ACCNAME_EXTENSIONS_CHEVRON)); 133 l10n_util::GetStringUTF16(IDS_ACCNAME_EXTENSIONS_CHEVRON));
105 chevron_->SetVisible(false); 134 chevron_->SetVisible(false);
106 AddChildView(chevron_); 135 AddChildView(chevron_);
107 } 136 }
108 137
109 BrowserActionsContainer::~BrowserActionsContainer() { 138 BrowserActionsContainer::~BrowserActionsContainer() {
110 FOR_EACH_OBSERVER(BrowserActionsContainerObserver, 139 FOR_EACH_OBSERVER(BrowserActionsContainerObserver,
111 observers_, 140 observers_,
(...skipping 663 matching lines...) Expand 10 before | Expand all | Expand 10 after
775 // we delete and recreate everything here, but that's how it's done in 804 // we delete and recreate everything here, but that's how it's done in
776 // BrowserActionMoved(), too. If we want to optimize it, we could move the 805 // BrowserActionMoved(), too. If we want to optimize it, we could move the
777 // existing icons, instead of deleting it all. 806 // existing icons, instead of deleting it all.
778 DeleteBrowserActionViews(); 807 DeleteBrowserActionViews();
779 CreateBrowserActionViews(); 808 CreateBrowserActionViews();
780 SaveDesiredSizeAndAnimate(gfx::Tween::LINEAR, browser_action_views_.size()); 809 SaveDesiredSizeAndAnimate(gfx::Tween::LINEAR, browser_action_views_.size());
781 } 810 }
782 811
783 void BrowserActionsContainer::LoadImages() { 812 void BrowserActionsContainer::LoadImages() {
784 ui::ThemeProvider* tp = GetThemeProvider(); 813 ui::ThemeProvider* tp = GetThemeProvider();
785 chevron_->SetIcon(*tp->GetImageSkiaNamed(IDR_BROWSER_ACTIONS_OVERFLOW)); 814 chevron_->SetImage(views::Button::STATE_NORMAL,
786 chevron_->SetHoverIcon(*tp->GetImageSkiaNamed( 815 *tp->GetImageSkiaNamed(IDR_BROWSER_ACTIONS_OVERFLOW));
787 IDR_BROWSER_ACTIONS_OVERFLOW_H));
788 chevron_->SetPushedIcon(*tp->GetImageSkiaNamed(
789 IDR_BROWSER_ACTIONS_OVERFLOW_P));
790 816
791 const int kImages[] = IMAGE_GRID(IDR_DEVELOPER_MODE_HIGHLIGHT); 817 const int kImages[] = IMAGE_GRID(IDR_DEVELOPER_MODE_HIGHLIGHT);
792 highlight_painter_.reset(views::Painter::CreateImageGridPainter(kImages)); 818 highlight_painter_.reset(views::Painter::CreateImageGridPainter(kImages));
793 } 819 }
794 820
795 void BrowserActionsContainer::SetContainerWidth() { 821 void BrowserActionsContainer::SetContainerWidth() {
796 int visible_actions = model_->GetVisibleIconCount(); 822 int visible_actions = model_->GetVisibleIconCount();
797 if (visible_actions < 0) // All icons should be visible. 823 if (visible_actions < 0) // All icons should be visible.
798 visible_actions = model_->toolbar_items().size(); 824 visible_actions = model_->toolbar_items().size();
799 chevron_->SetVisible( 825 chevron_->SetVisible(
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
932 views::BubbleBorder::TOP_RIGHT, 958 views::BubbleBorder::TOP_RIGHT,
933 show_action); 959 show_action);
934 popup_->GetWidget()->AddObserver(this); 960 popup_->GetWidget()->AddObserver(this);
935 popup_button_ = button; 961 popup_button_ = button;
936 962
937 // Only set button as pushed if it was triggered by a user click. 963 // Only set button as pushed if it was triggered by a user click.
938 if (should_grant) 964 if (should_grant)
939 popup_button_->SetButtonPushed(); 965 popup_button_->SetButtonPushed();
940 return true; 966 return true;
941 } 967 }
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