| 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.h" | 5 #include "chrome/browser/ui/views/toolbar/app_menu.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <cmath> | 10 #include <cmath> |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 | 151 |
| 152 explicit InMenuButtonBackground(ButtonType type) : type_(type) {} | 152 explicit InMenuButtonBackground(ButtonType type) : type_(type) {} |
| 153 | 153 |
| 154 // Overridden from views::Background. | 154 // Overridden from views::Background. |
| 155 void Paint(gfx::Canvas* canvas, View* view) const override { | 155 void Paint(gfx::Canvas* canvas, View* view) const override { |
| 156 CustomButton* button = CustomButton::AsCustomButton(view); | 156 CustomButton* button = CustomButton::AsCustomButton(view); |
| 157 views::Button::ButtonState state = | 157 views::Button::ButtonState state = |
| 158 button ? button->state() : views::Button::STATE_NORMAL; | 158 button ? button->state() : views::Button::STATE_NORMAL; |
| 159 int h = view->height(); | 159 int h = view->height(); |
| 160 | 160 |
| 161 // Draw leading border where needed. This is along the left edge unless the | 161 // Draw leading border if desired. |
| 162 // layout is RTL and the button isn't mirroring itself. | |
| 163 gfx::Rect bounds(view->GetLocalBounds()); | 162 gfx::Rect bounds(view->GetLocalBounds()); |
| 164 if (type_ == LEADING_BORDER) { | 163 if (type_ == LEADING_BORDER) { |
| 164 // We need to flip the canvas for RTL iff the button is not auto-flipping |
| 165 // already, so we end up flipping exactly once. |
| 165 gfx::ScopedRTLFlipCanvas scoped_canvas( | 166 gfx::ScopedRTLFlipCanvas scoped_canvas( |
| 166 canvas, view->width(), view->flip_canvas_on_paint_for_rtl_ui()); | 167 canvas, view->width(), !view->flip_canvas_on_paint_for_rtl_ui()); |
| 167 canvas->FillRect(gfx::Rect(0, 0, 1, h), | 168 canvas->FillRect(gfx::Rect(0, 0, 1, h), |
| 168 BorderColor(view, views::Button::STATE_NORMAL)); | 169 BorderColor(view, views::Button::STATE_NORMAL)); |
| 169 bounds.Inset(gfx::Insets(0, 1, 0, 0)); | 170 bounds.Inset(gfx::Insets(0, 1, 0, 0)); |
| 170 } | 171 } |
| 171 | 172 |
| 172 // Fill in background for state. | 173 // Fill in background for state. |
| 173 bounds.set_x(view->GetMirroredXForRect(bounds)); | 174 bounds.set_x(view->GetMirroredXForRect(bounds)); |
| 174 DrawBackground(canvas, view, bounds, state); | 175 DrawBackground(canvas, view, bounds, state); |
| 175 } | 176 } |
| 176 | 177 |
| (...skipping 1056 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1233 0, | 1234 0, |
| 1234 BookmarkMenuDelegate::SHOW_PERMANENT_FOLDERS, | 1235 BookmarkMenuDelegate::SHOW_PERMANENT_FOLDERS, |
| 1235 BOOKMARK_LAUNCH_LOCATION_APP_MENU); | 1236 BOOKMARK_LAUNCH_LOCATION_APP_MENU); |
| 1236 } | 1237 } |
| 1237 | 1238 |
| 1238 int AppMenu::ModelIndexFromCommandId(int command_id) const { | 1239 int AppMenu::ModelIndexFromCommandId(int command_id) const { |
| 1239 CommandIDToEntry::const_iterator ix = command_id_to_entry_.find(command_id); | 1240 CommandIDToEntry::const_iterator ix = command_id_to_entry_.find(command_id); |
| 1240 DCHECK(ix != command_id_to_entry_.end()); | 1241 DCHECK(ix != command_id_to_entry_.end()); |
| 1241 return ix->second.second; | 1242 return ix->second.second; |
| 1242 } | 1243 } |
| OLD | NEW |