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 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 | 134 |
135 // Overridden from views::Border. | 135 // Overridden from views::Border. |
136 virtual void Paint(const View& view, gfx::Canvas* canvas) OVERRIDE { | 136 virtual void Paint(const View& view, gfx::Canvas* canvas) OVERRIDE { |
137 // Painting of border is done in MenuButtonBackground. | 137 // Painting of border is done in MenuButtonBackground. |
138 } | 138 } |
139 | 139 |
140 virtual gfx::Insets GetInsets() const OVERRIDE { | 140 virtual gfx::Insets GetInsets() const OVERRIDE { |
141 return insets_; | 141 return insets_; |
142 } | 142 } |
143 | 143 |
| 144 virtual gfx::Size GetMinimumSize() const OVERRIDE { |
| 145 // This size is sufficient for MenuButtonBackground::Paint() to draw any of |
| 146 // the button types. |
| 147 return gfx::Size(4, 4); |
| 148 } |
| 149 |
144 private: | 150 private: |
145 // The horizontal padding dependent on the layout. | 151 // The horizontal padding dependent on the layout. |
146 const int horizontal_padding_; | 152 const int horizontal_padding_; |
147 | 153 |
148 const gfx::Insets insets_; | 154 const gfx::Insets insets_; |
149 | 155 |
150 DISALLOW_COPY_AND_ASSIGN(MenuButtonBorder); | 156 DISALLOW_COPY_AND_ASSIGN(MenuButtonBorder); |
151 }; | 157 }; |
152 | 158 |
153 // Combination border/background for the buttons contained in the menu. The | 159 // Combination border/background for the buttons contained in the menu. The |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 BorderColor(view, CustomButton::STATE_NORMAL)); | 206 BorderColor(view, CustomButton::STATE_NORMAL)); |
201 } | 207 } |
202 canvas->FillRect(gfx::Rect(border, 0, w - border, h), | 208 canvas->FillRect(gfx::Rect(border, 0, w - border, h), |
203 touch_background_color(state)); | 209 touch_background_color(state)); |
204 return; | 210 return; |
205 } | 211 } |
206 #endif | 212 #endif |
207 const SkColor background = BackgroundColor(view, state); | 213 const SkColor background = BackgroundColor(view, state); |
208 const SkColor border = BorderColor(view, state); | 214 const SkColor border = BorderColor(view, state); |
209 switch (TypeAdjustedForRTL()) { | 215 switch (TypeAdjustedForRTL()) { |
| 216 // TODO(pkasting): Why don't all the following use SkPaths with rounded |
| 217 // corners? |
210 case LEFT_BUTTON: | 218 case LEFT_BUTTON: |
211 canvas->FillRect(gfx::Rect(1, 1, w, h - 2), background); | 219 canvas->FillRect(gfx::Rect(1, 1, w, h - 2), background); |
212 canvas->FillRect(gfx::Rect(2, 0, w, 1), border); | 220 canvas->FillRect(gfx::Rect(2, 0, w, 1), border); |
213 canvas->FillRect(gfx::Rect(1, 1, 1, 1), border); | 221 canvas->FillRect(gfx::Rect(1, 1, 1, 1), border); |
214 canvas->FillRect(gfx::Rect(0, 2, 1, h - 4), border); | 222 canvas->FillRect(gfx::Rect(0, 2, 1, h - 4), border); |
215 canvas->FillRect(gfx::Rect(1, h - 2, 1, 1), border); | 223 canvas->FillRect(gfx::Rect(1, h - 2, 1, 1), border); |
216 canvas->FillRect(gfx::Rect(2, h - 1, w, 1), border); | 224 canvas->FillRect(gfx::Rect(2, h - 1, w, 1), border); |
217 break; | 225 break; |
218 | 226 |
219 case CENTER_BUTTON: { | 227 case CENTER_BUTTON: { |
(...skipping 1083 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1303 0, | 1311 0, |
1304 BookmarkMenuDelegate::SHOW_PERMANENT_FOLDERS, | 1312 BookmarkMenuDelegate::SHOW_PERMANENT_FOLDERS, |
1305 BOOKMARK_LAUNCH_LOCATION_WRENCH_MENU); | 1313 BOOKMARK_LAUNCH_LOCATION_WRENCH_MENU); |
1306 } | 1314 } |
1307 | 1315 |
1308 int WrenchMenu::ModelIndexFromCommandId(int command_id) const { | 1316 int WrenchMenu::ModelIndexFromCommandId(int command_id) const { |
1309 CommandIDToEntry::const_iterator ix = command_id_to_entry_.find(command_id); | 1317 CommandIDToEntry::const_iterator ix = command_id_to_entry_.find(command_id); |
1310 DCHECK(ix != command_id_to_entry_.end()); | 1318 DCHECK(ix != command_id_to_entry_.end()); |
1311 return ix->second.second; | 1319 return ix->second.second; |
1312 } | 1320 } |
OLD | NEW |