Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(236)

Side by Side Diff: views/controls/menu/menu_item_view_gtk.cc

Issue 6811025: Change status button menu implementation from Menu2 to MenuItemView. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Move NetworkMenuModel declaration into .cc. Created 9 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « views/controls/menu/menu_item_view.cc ('k') | views/controls/menu/menu_item_view_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "views/controls/menu/menu_item_view.h" 5 #include "views/controls/menu/menu_item_view.h"
6 6
7 #include "base/utf_string_conversions.h" 7 #include "base/utf_string_conversions.h"
8 #include "grit/app_resources.h" 8 #include "grit/app_resources.h"
9 #include "third_party/skia/include/effects/SkGradientShader.h" 9 #include "third_party/skia/include/effects/SkGradientShader.h"
10 #include "ui/base/resource/resource_bundle.h" 10 #include "ui/base/resource/resource_bundle.h"
11 #include "ui/gfx/canvas_skia.h" 11 #include "ui/gfx/canvas_skia.h"
12 #include "ui/gfx/favicon_size.h" 12 #include "ui/gfx/favicon_size.h"
13 #include "views/controls/button/text_button.h" 13 #include "views/controls/button/text_button.h"
14 #include "views/controls/menu/menu_config.h" 14 #include "views/controls/menu/menu_config.h"
15 #include "views/controls/menu/menu_image_util_gtk.h" 15 #include "views/controls/menu/menu_image_util_gtk.h"
16 #include "views/controls/menu/submenu_view.h" 16 #include "views/controls/menu/submenu_view.h"
17 17
18 namespace views { 18 namespace views {
19 19
20 // Background color when the menu item is selected. 20 // Background color when the menu item is selected.
21 #if defined(OS_CHROMEOS) 21 #if defined(OS_CHROMEOS)
22 static const SkColor kSelectedBackgroundColor = SkColorSetRGB(0xDC, 0xE4, 0xFA); 22 static const SkColor kSelectedBackgroundColor = SkColorSetRGB(0xDC, 0xE4, 0xFA);
23 #else 23 #else
24 static const SkColor kSelectedBackgroundColor = SkColorSetRGB(246, 249, 253); 24 static const SkColor kSelectedBackgroundColor = SkColorSetRGB(246, 249, 253);
25 #endif 25 #endif
26 26
27 gfx::Size MenuItemView::CalculatePreferredSize() { 27 gfx::Size MenuItemView::CalculatePreferredSize() {
28 const gfx::Font& font = MenuConfig::instance().font; 28 const gfx::Font& font = GetFont();
29 return gfx::Size( 29 return gfx::Size(
30 font.GetStringWidth(title_) + label_start_ + 30 font.GetStringWidth(title_) + label_start_ +
31 item_right_margin_ + GetChildPreferredWidth(), 31 item_right_margin_ + GetChildPreferredWidth(),
32 font.GetHeight() + GetBottomMargin() + GetTopMargin()); 32 font.GetHeight() + GetBottomMargin() + GetTopMargin());
33 } 33 }
34 34
35 void MenuItemView::PaintButton(gfx::Canvas* canvas, PaintButtonMode mode) { 35 void MenuItemView::PaintButton(gfx::Canvas* canvas, PaintButtonMode mode) {
36 const MenuConfig& config = MenuConfig::instance(); 36 const MenuConfig& config = MenuConfig::instance();
37 bool render_selection = 37 bool render_selection =
38 (mode == PB_NORMAL && IsSelected() && 38 (mode == PB_NORMAL && IsSelected() &&
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 } 76 }
77 77
78 // Render the foreground. 78 // Render the foreground.
79 #if defined(OS_CHROMEOS) 79 #if defined(OS_CHROMEOS)
80 SkColor fg_color = 80 SkColor fg_color =
81 IsEnabled() ? SK_ColorBLACK : SkColorSetRGB(0x80, 0x80, 0x80); 81 IsEnabled() ? SK_ColorBLACK : SkColorSetRGB(0x80, 0x80, 0x80);
82 #else 82 #else
83 SkColor fg_color = 83 SkColor fg_color =
84 IsEnabled() ? TextButton::kEnabledColor : TextButton::kDisabledColor; 84 IsEnabled() ? TextButton::kEnabledColor : TextButton::kDisabledColor;
85 #endif 85 #endif
86 const gfx::Font& font = MenuConfig::instance().font; 86 const gfx::Font& font = GetFont();
87 int accel_width = parent_menu_item_->GetSubmenu()->max_accelerator_width(); 87 int accel_width = parent_menu_item_->GetSubmenu()->max_accelerator_width();
88 int width = this->width() - item_right_margin_ - label_start_ - accel_width; 88 int width = this->width() - item_right_margin_ - label_start_ - accel_width;
89 gfx::Rect text_bounds(label_start_, top_margin + 89 gfx::Rect text_bounds(label_start_, top_margin +
90 (available_height - font.GetHeight()) / 2, width, 90 (available_height - font.GetHeight()) / 2, width,
91 font.GetHeight()); 91 font.GetHeight());
92 text_bounds.set_x(GetMirroredXForRect(text_bounds)); 92 text_bounds.set_x(GetMirroredXForRect(text_bounds));
93 canvas->DrawStringInt(WideToUTF16Hack(GetTitle()), font, fg_color, 93 canvas->DrawStringInt(WideToUTF16Hack(GetTitle()), font, fg_color,
94 text_bounds.x(), text_bounds.y(), text_bounds.width(), 94 text_bounds.x(), text_bounds.y(), text_bounds.width(),
95 text_bounds.height(), 95 text_bounds.height(),
96 GetRootMenuItem()->GetDrawStringFlags()); 96 GetRootMenuItem()->GetDrawStringFlags());
(...skipping 18 matching lines...) Expand all
115 top_margin + (available_height - 115 top_margin + (available_height -
116 config.arrow_width) / 2, 116 config.arrow_width) / 2,
117 config.arrow_width, height()); 117 config.arrow_width, height());
118 AdjustBoundsForRTLUI(&arrow_bounds); 118 AdjustBoundsForRTLUI(&arrow_bounds);
119 canvas->DrawBitmapInt(*GetSubmenuArrowImage(), 119 canvas->DrawBitmapInt(*GetSubmenuArrowImage(),
120 arrow_bounds.x(), arrow_bounds.y()); 120 arrow_bounds.x(), arrow_bounds.y());
121 } 121 }
122 } 122 }
123 123
124 } // namespace views 124 } // namespace views
OLDNEW
« no previous file with comments | « views/controls/menu/menu_item_view.cc ('k') | views/controls/menu/menu_item_view_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698