| 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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 #include "third_party/skia/include/core/SkPaint.h" | 47 #include "third_party/skia/include/core/SkPaint.h" |
| 48 #include "ui/accessibility/ax_view_state.h" | 48 #include "ui/accessibility/ax_view_state.h" |
| 49 #include "ui/base/l10n/l10n_util.h" | 49 #include "ui/base/l10n/l10n_util.h" |
| 50 #include "ui/base/layout.h" | 50 #include "ui/base/layout.h" |
| 51 #include "ui/base/material_design/material_design_controller.h" | 51 #include "ui/base/material_design/material_design_controller.h" |
| 52 #include "ui/base/resource/resource_bundle.h" | 52 #include "ui/base/resource/resource_bundle.h" |
| 53 #include "ui/gfx/canvas.h" | 53 #include "ui/gfx/canvas.h" |
| 54 #include "ui/gfx/font_list.h" | 54 #include "ui/gfx/font_list.h" |
| 55 #include "ui/gfx/image/image.h" | 55 #include "ui/gfx/image/image.h" |
| 56 #include "ui/gfx/image/image_skia_source.h" | 56 #include "ui/gfx/image/image_skia_source.h" |
| 57 #include "ui/gfx/scoped_canvas.h" |
| 57 #include "ui/gfx/skia_util.h" | 58 #include "ui/gfx/skia_util.h" |
| 58 #include "ui/gfx/text_utils.h" | 59 #include "ui/gfx/text_utils.h" |
| 59 #include "ui/views/background.h" | 60 #include "ui/views/background.h" |
| 60 #include "ui/views/controls/button/image_button.h" | 61 #include "ui/views/controls/button/image_button.h" |
| 61 #include "ui/views/controls/button/label_button.h" | 62 #include "ui/views/controls/button/label_button.h" |
| 62 #include "ui/views/controls/button/menu_button.h" | 63 #include "ui/views/controls/button/menu_button.h" |
| 63 #include "ui/views/controls/label.h" | 64 #include "ui/views/controls/label.h" |
| 64 #include "ui/views/controls/menu/menu_config.h" | 65 #include "ui/views/controls/menu/menu_config.h" |
| 65 #include "ui/views/controls/menu/menu_item_view.h" | 66 #include "ui/views/controls/menu/menu_item_view.h" |
| 66 #include "ui/views/controls/menu/menu_model_adapter.h" | 67 #include "ui/views/controls/menu/menu_model_adapter.h" |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 void Paint(gfx::Canvas* canvas, View* view) const override { | 156 void Paint(gfx::Canvas* canvas, View* view) const override { |
| 156 CustomButton* button = CustomButton::AsCustomButton(view); | 157 CustomButton* button = CustomButton::AsCustomButton(view); |
| 157 views::Button::ButtonState state = | 158 views::Button::ButtonState state = |
| 158 button ? button->state() : views::Button::STATE_NORMAL; | 159 button ? button->state() : views::Button::STATE_NORMAL; |
| 159 int h = view->height(); | 160 int h = view->height(); |
| 160 | 161 |
| 161 // Draw leading border where needed. This is along the left edge unless the | 162 // Draw leading border where needed. This is along the left edge unless the |
| 162 // layout is RTL and the button isn't mirroring itself. | 163 // layout is RTL and the button isn't mirroring itself. |
| 163 gfx::Rect bounds(view->GetLocalBounds()); | 164 gfx::Rect bounds(view->GetLocalBounds()); |
| 164 if (type_ == LEADING_BORDER) { | 165 if (type_ == LEADING_BORDER) { |
| 165 gfx::Rect rect = view->FlipCanvasOnPaintForRTLUI() | 166 gfx::ScopedRTLFlipCanvas scoped_canvas( |
| 166 ? gfx::Rect(0, 0, 1, h) | 167 canvas, view->width(), view->flip_canvas_on_paint_for_rtl_ui()); |
| 167 : gfx::Rect(view->GetMirroredXWithWidthInView(0, 1), 0, 1, h); | 168 canvas->FillRect(gfx::Rect(0, 0, 1, h), |
| 168 canvas->FillRect(rect, 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 |
| 177 private: | 178 private: |
| 178 static SkColor BorderColor(View* view, views::Button::ButtonState state) { | 179 static SkColor BorderColor(View* view, views::Button::ButtonState state) { |
| (...skipping 1070 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1249 0, | 1250 0, |
| 1250 BookmarkMenuDelegate::SHOW_PERMANENT_FOLDERS, | 1251 BookmarkMenuDelegate::SHOW_PERMANENT_FOLDERS, |
| 1251 BOOKMARK_LAUNCH_LOCATION_APP_MENU); | 1252 BOOKMARK_LAUNCH_LOCATION_APP_MENU); |
| 1252 } | 1253 } |
| 1253 | 1254 |
| 1254 int AppMenu::ModelIndexFromCommandId(int command_id) const { | 1255 int AppMenu::ModelIndexFromCommandId(int command_id) const { |
| 1255 CommandIDToEntry::const_iterator ix = command_id_to_entry_.find(command_id); | 1256 CommandIDToEntry::const_iterator ix = command_id_to_entry_.find(command_id); |
| 1256 DCHECK(ix != command_id_to_entry_.end()); | 1257 DCHECK(ix != command_id_to_entry_.end()); |
| 1257 return ix->second.second; | 1258 return ix->second.second; |
| 1258 } | 1259 } |
| OLD | NEW |