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/wrench_menu.h" | 5 #include "chrome/browser/ui/views/toolbar/wrench_menu.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 #include <set> | 9 #include <set> |
10 | 10 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 #include "ui/views/controls/button/menu_button.h" | 50 #include "ui/views/controls/button/menu_button.h" |
51 #include "ui/views/controls/label.h" | 51 #include "ui/views/controls/label.h" |
52 #include "ui/views/controls/menu/menu_config.h" | 52 #include "ui/views/controls/menu/menu_config.h" |
53 #include "ui/views/controls/menu/menu_item_view.h" | 53 #include "ui/views/controls/menu/menu_item_view.h" |
54 #include "ui/views/controls/menu/menu_model_adapter.h" | 54 #include "ui/views/controls/menu/menu_model_adapter.h" |
55 #include "ui/views/controls/menu/menu_runner.h" | 55 #include "ui/views/controls/menu/menu_runner.h" |
56 #include "ui/views/controls/menu/menu_scroll_view_container.h" | 56 #include "ui/views/controls/menu/menu_scroll_view_container.h" |
57 #include "ui/views/controls/menu/submenu_view.h" | 57 #include "ui/views/controls/menu/submenu_view.h" |
58 #include "ui/views/widget/widget.h" | 58 #include "ui/views/widget/widget.h" |
59 | 59 |
60 #if defined(USE_AURA) | |
61 #include "ui/native_theme/native_theme_aura.h" | |
62 #endif | |
63 | |
64 using base::UserMetricsAction; | 60 using base::UserMetricsAction; |
65 using content::HostZoomMap; | 61 using content::HostZoomMap; |
66 using content::WebContents; | 62 using content::WebContents; |
67 using ui::MenuModel; | 63 using ui::MenuModel; |
68 using views::CustomButton; | 64 using views::CustomButton; |
69 using views::ImageButton; | 65 using views::ImageButton; |
70 using views::Label; | 66 using views::Label; |
71 using views::LabelButton; | 67 using views::LabelButton; |
72 using views::MenuConfig; | 68 using views::MenuConfig; |
73 using views::MenuItemView; | 69 using views::MenuItemView; |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 } | 176 } |
181 } | 177 } |
182 | 178 |
183 // Overridden from views::Background. | 179 // Overridden from views::Background. |
184 virtual void Paint(gfx::Canvas* canvas, View* view) const OVERRIDE { | 180 virtual void Paint(gfx::Canvas* canvas, View* view) const OVERRIDE { |
185 CustomButton* button = CustomButton::AsCustomButton(view); | 181 CustomButton* button = CustomButton::AsCustomButton(view); |
186 views::Button::ButtonState state = | 182 views::Button::ButtonState state = |
187 button ? button->state() : views::Button::STATE_NORMAL; | 183 button ? button->state() : views::Button::STATE_NORMAL; |
188 int w = view->width(); | 184 int w = view->width(); |
189 int h = view->height(); | 185 int h = view->height(); |
190 #if defined(USE_AURA) | |
191 // Normal buttons get a border drawn on the right side and the rest gets | |
192 // filled in. The left button however does not get a line to combine | |
193 // buttons. | |
194 int border = 0; | |
195 if (type_ != RIGHT_BUTTON) { | |
196 border = 1; | |
197 canvas->FillRect(gfx::Rect(0, 0, border, h), | |
198 BorderColor(view, views::Button::STATE_NORMAL)); | |
199 } | |
200 if (use_new_menu_) { | 186 if (use_new_menu_) { |
| 187 // Normal buttons get a border drawn on the right side and the rest gets |
| 188 // filled in. The left button however does not get a line to combine |
| 189 // buttons. |
| 190 if (type_ != RIGHT_BUTTON) { |
| 191 canvas->FillRect(gfx::Rect(0, 0, 1, h), |
| 192 BorderColor(view, views::Button::STATE_NORMAL)); |
| 193 } |
201 gfx::Rect bounds(view->GetLocalBounds()); | 194 gfx::Rect bounds(view->GetLocalBounds()); |
202 bounds.set_x(view->GetMirroredXForRect(bounds)); | 195 bounds.set_x(view->GetMirroredXForRect(bounds)); |
203 DrawBackground(canvas, view, bounds, state); | 196 DrawBackground(canvas, view, bounds, state); |
204 return; | 197 return; |
205 } | 198 } |
206 #endif | |
207 const SkColor border_color = BorderColor(view, state); | 199 const SkColor border_color = BorderColor(view, state); |
208 switch (TypeAdjustedForRTL()) { | 200 switch (TypeAdjustedForRTL()) { |
209 // TODO(pkasting): Why don't all the following use SkPaths with rounded | 201 // TODO(pkasting): Why don't all the following use SkPaths with rounded |
210 // corners? | 202 // corners? |
211 case LEFT_BUTTON: | 203 case LEFT_BUTTON: |
212 DrawBackground(canvas, view, gfx::Rect(1, 1, w, h - 2), state); | 204 DrawBackground(canvas, view, gfx::Rect(1, 1, w, h - 2), state); |
213 canvas->FillRect(gfx::Rect(2, 0, w, 1), border_color); | 205 canvas->FillRect(gfx::Rect(2, 0, w, 1), border_color); |
214 canvas->FillRect(gfx::Rect(1, 1, 1, 1), border_color); | 206 canvas->FillRect(gfx::Rect(1, 1, 1, 1), border_color); |
215 canvas->FillRect(gfx::Rect(0, 2, 1, h - 4), border_color); | 207 canvas->FillRect(gfx::Rect(0, 2, 1, h - 4), border_color); |
216 canvas->FillRect(gfx::Rect(1, h - 2, 1, 1), border_color); | 208 canvas->FillRect(gfx::Rect(1, h - 2, 1, 1), border_color); |
(...skipping 1149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1366 0, | 1358 0, |
1367 BookmarkMenuDelegate::SHOW_PERMANENT_FOLDERS, | 1359 BookmarkMenuDelegate::SHOW_PERMANENT_FOLDERS, |
1368 BOOKMARK_LAUNCH_LOCATION_WRENCH_MENU); | 1360 BOOKMARK_LAUNCH_LOCATION_WRENCH_MENU); |
1369 } | 1361 } |
1370 | 1362 |
1371 int WrenchMenu::ModelIndexFromCommandId(int command_id) const { | 1363 int WrenchMenu::ModelIndexFromCommandId(int command_id) const { |
1372 CommandIDToEntry::const_iterator ix = command_id_to_entry_.find(command_id); | 1364 CommandIDToEntry::const_iterator ix = command_id_to_entry_.find(command_id); |
1373 DCHECK(ix != command_id_to_entry_.end()); | 1365 DCHECK(ix != command_id_to_entry_.end()); |
1374 return ix->second.second; | 1366 return ix->second.second; |
1375 } | 1367 } |
OLD | NEW |