| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ash/shelf/shelf_view.h" | 5 #include "ash/shelf/shelf_view.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "ash/ash_constants.h" | 9 #include "ash/ash_constants.h" |
| 10 #include "ash/ash_switches.h" | 10 #include "ash/ash_switches.h" |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 | 121 |
| 122 namespace { | 122 namespace { |
| 123 | 123 |
| 124 // The MenuModelAdapter gets slightly changed to adapt the menu appearance to | 124 // The MenuModelAdapter gets slightly changed to adapt the menu appearance to |
| 125 // our requirements. | 125 // our requirements. |
| 126 class ShelfMenuModelAdapter : public views::MenuModelAdapter { | 126 class ShelfMenuModelAdapter : public views::MenuModelAdapter { |
| 127 public: | 127 public: |
| 128 explicit ShelfMenuModelAdapter(ShelfMenuModel* menu_model); | 128 explicit ShelfMenuModelAdapter(ShelfMenuModel* menu_model); |
| 129 | 129 |
| 130 // views::MenuModelAdapter: | 130 // views::MenuModelAdapter: |
| 131 virtual const gfx::Font* GetLabelFont(int command_id) const OVERRIDE; | 131 virtual const gfx::FontList* GetLabelFontList(int command_id) const OVERRIDE; |
| 132 virtual bool IsCommandEnabled(int id) const OVERRIDE; | 132 virtual bool IsCommandEnabled(int id) const OVERRIDE; |
| 133 virtual void GetHorizontalIconMargins(int id, | 133 virtual void GetHorizontalIconMargins(int id, |
| 134 int icon_size, | 134 int icon_size, |
| 135 int* left_margin, | 135 int* left_margin, |
| 136 int* right_margin) const OVERRIDE; | 136 int* right_margin) const OVERRIDE; |
| 137 virtual bool GetForegroundColor(int command_id, | 137 virtual bool GetForegroundColor(int command_id, |
| 138 bool is_hovered, | 138 bool is_hovered, |
| 139 SkColor* override_color) const OVERRIDE; | 139 SkColor* override_color) const OVERRIDE; |
| 140 virtual bool GetBackgroundColor(int command_id, | 140 virtual bool GetBackgroundColor(int command_id, |
| 141 bool is_hovered, | 141 bool is_hovered, |
| 142 SkColor* override_color) const OVERRIDE; | 142 SkColor* override_color) const OVERRIDE; |
| 143 virtual int GetMaxWidthForMenu(views::MenuItemView* menu) OVERRIDE; | 143 virtual int GetMaxWidthForMenu(views::MenuItemView* menu) OVERRIDE; |
| 144 virtual bool ShouldReserveSpaceForSubmenuIndicator() const OVERRIDE; | 144 virtual bool ShouldReserveSpaceForSubmenuIndicator() const OVERRIDE; |
| 145 | 145 |
| 146 private: | 146 private: |
| 147 ShelfMenuModel* menu_model_; | 147 ShelfMenuModel* menu_model_; |
| 148 | 148 |
| 149 DISALLOW_COPY_AND_ASSIGN(ShelfMenuModelAdapter); | 149 DISALLOW_COPY_AND_ASSIGN(ShelfMenuModelAdapter); |
| 150 }; | 150 }; |
| 151 | 151 |
| 152 ShelfMenuModelAdapter::ShelfMenuModelAdapter(ShelfMenuModel* menu_model) | 152 ShelfMenuModelAdapter::ShelfMenuModelAdapter(ShelfMenuModel* menu_model) |
| 153 : MenuModelAdapter(menu_model), | 153 : MenuModelAdapter(menu_model), |
| 154 menu_model_(menu_model) { | 154 menu_model_(menu_model) { |
| 155 } | 155 } |
| 156 | 156 |
| 157 const gfx::Font* ShelfMenuModelAdapter::GetLabelFont(int command_id) const { | 157 const gfx::FontList* ShelfMenuModelAdapter::GetLabelFontList( |
| 158 int command_id) const { |
| 158 if (command_id != kCommandIdOfMenuName) | 159 if (command_id != kCommandIdOfMenuName) |
| 159 return MenuModelAdapter::GetLabelFont(command_id); | 160 return MenuModelAdapter::GetLabelFontList(command_id); |
| 160 | 161 |
| 161 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 162 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
| 162 return &rb.GetFont(ui::ResourceBundle::BoldFont); | 163 return &rb.GetFontList(ui::ResourceBundle::BoldFont); |
| 163 } | 164 } |
| 164 | 165 |
| 165 bool ShelfMenuModelAdapter::IsCommandEnabled(int id) const { | 166 bool ShelfMenuModelAdapter::IsCommandEnabled(int id) const { |
| 166 return id != kCommandIdOfMenuName; | 167 return id != kCommandIdOfMenuName; |
| 167 } | 168 } |
| 168 | 169 |
| 169 bool ShelfMenuModelAdapter::GetForegroundColor(int command_id, | 170 bool ShelfMenuModelAdapter::GetForegroundColor(int command_id, |
| 170 bool is_hovered, | 171 bool is_hovered, |
| 171 SkColor* override_color) const { | 172 SkColor* override_color) const { |
| 172 if (command_id != kCommandIdOfMenuName) | 173 if (command_id != kCommandIdOfMenuName) |
| (...skipping 1845 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2018 break; | 2019 break; |
| 2019 case ash::SHELF_ALIGNMENT_TOP: | 2020 case ash::SHELF_ALIGNMENT_TOP: |
| 2020 distance = coordinate.y() - bounds.bottom(); | 2021 distance = coordinate.y() - bounds.bottom(); |
| 2021 break; | 2022 break; |
| 2022 } | 2023 } |
| 2023 return distance > 0 ? distance : 0; | 2024 return distance > 0 ? distance : 0; |
| 2024 } | 2025 } |
| 2025 | 2026 |
| 2026 } // namespace internal | 2027 } // namespace internal |
| 2027 } // namespace ash | 2028 } // namespace ash |
| OLD | NEW |