OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/libgtk2ui/native_theme_gtk2.h" | 5 #include "chrome/browser/ui/libgtk2ui/native_theme_gtk2.h" |
6 | 6 |
7 #include <gtk/gtk.h> | 7 #include <gtk/gtk.h> |
8 | 8 |
9 #include "chrome/browser/ui/libgtk2ui/chrome_gtk_frame.h" | 9 #include "chrome/browser/ui/libgtk2ui/chrome_gtk_frame.h" |
10 #include "chrome/browser/ui/libgtk2ui/chrome_gtk_menu_subclasses.h" | 10 #include "chrome/browser/ui/libgtk2ui/chrome_gtk_menu_subclasses.h" |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 } else { | 192 } else { |
193 canvas->drawColor(GetSystemColor(kColorId_MenuBackgroundColor), | 193 canvas->drawColor(GetSystemColor(kColorId_MenuBackgroundColor), |
194 SkXfermode::kSrc_Mode); | 194 SkXfermode::kSrc_Mode); |
195 } | 195 } |
196 } | 196 } |
197 | 197 |
198 void NativeThemeGtk2::PaintMenuItemBackground( | 198 void NativeThemeGtk2::PaintMenuItemBackground( |
199 SkCanvas* canvas, | 199 SkCanvas* canvas, |
200 State state, | 200 State state, |
201 const gfx::Rect& rect, | 201 const gfx::Rect& rect, |
202 const MenuListExtraParams& menu_list) const { | 202 const MenuItemExtraParams& menu_item) const { |
203 SkColor color; | 203 SkColor color; |
204 SkPaint paint; | 204 SkPaint paint; |
205 switch (state) { | 205 switch (state) { |
206 case NativeTheme::kNormal: | 206 case NativeTheme::kNormal: |
207 case NativeTheme::kDisabled: | 207 case NativeTheme::kDisabled: |
208 color = GetSystemColor(NativeTheme::kColorId_MenuBackgroundColor); | 208 color = GetSystemColor(NativeTheme::kColorId_MenuBackgroundColor); |
209 paint.setColor(color); | 209 paint.setColor(color); |
210 break; | 210 break; |
211 case NativeTheme::kHovered: | 211 case NativeTheme::kHovered: |
212 color = GetSystemColor( | 212 color = GetSystemColor( |
213 NativeTheme::kColorId_FocusedMenuItemBackgroundColor); | 213 NativeTheme::kColorId_FocusedMenuItemBackgroundColor); |
214 paint.setColor(color); | 214 paint.setColor(color); |
215 break; | 215 break; |
216 default: | 216 default: |
217 NOTREACHED() << "Invalid state " << state; | 217 NOTREACHED() << "Invalid state " << state; |
218 break; | 218 break; |
219 } | 219 } |
| 220 if (menu_item.corner_radius > 0) { |
| 221 const SkScalar radius = SkIntToScalar(menu_item.corner_radius); |
| 222 canvas->drawRoundRect(gfx::RectToSkRect(rect), radius, radius, paint); |
| 223 return; |
| 224 } |
220 canvas->drawRect(gfx::RectToSkRect(rect), paint); | 225 canvas->drawRect(gfx::RectToSkRect(rect), paint); |
221 } | 226 } |
222 | 227 |
223 SkColor NativeThemeGtk2::GetSystemColor(ColorId color_id) const { | 228 SkColor NativeThemeGtk2::GetSystemColor(ColorId color_id) const { |
224 const SkColor kPositiveTextColor = SkColorSetRGB(0x0b, 0x80, 0x43); | 229 const SkColor kPositiveTextColor = SkColorSetRGB(0x0b, 0x80, 0x43); |
225 const SkColor kNegativeTextColor = SkColorSetRGB(0xc5, 0x39, 0x29); | 230 const SkColor kNegativeTextColor = SkColorSetRGB(0xc5, 0x39, 0x29); |
226 | 231 |
227 switch (color_id) { | 232 switch (color_id) { |
228 // Windows | 233 // Windows |
229 case kColorId_WindowBackground: | 234 case kColorId_WindowBackground: |
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
568 | 573 |
569 if (!fake_menu_item) { | 574 if (!fake_menu_item) { |
570 fake_menu_item = gtk_custom_menu_item_new(); | 575 fake_menu_item = gtk_custom_menu_item_new(); |
571 gtk_menu_shell_append(GTK_MENU_SHELL(GetMenu()), fake_menu_item); | 576 gtk_menu_shell_append(GTK_MENU_SHELL(GetMenu()), fake_menu_item); |
572 } | 577 } |
573 | 578 |
574 return fake_menu_item; | 579 return fake_menu_item; |
575 } | 580 } |
576 | 581 |
577 } // namespace libgtk2ui | 582 } // namespace libgtk2ui |
OLD | NEW |