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

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

Issue 7825024: For Touch: remove some menu items for experimentation, adjust sizes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 3 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
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/ui_resources.h" 8 #include "grit/ui_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_linux.h" 15 #include "views/controls/menu/menu_image_util_linux.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 #if defined(TOUCH_UI) 27 #if defined(TOUCH_UI)
28 const int kMinTouchHeight = 46; 28 const int kMinTouchHeight = 40;
29 #endif 29 #endif
30 30
31 gfx::Size MenuItemView::CalculatePreferredSize() { 31 gfx::Size MenuItemView::CalculatePreferredSize() {
32 gfx::Size child_size = GetChildPreferredSize(); 32 gfx::Size child_size = GetChildPreferredSize();
33 if (child_count() == 1 && title_.size() == 0) { 33 if (child_count() == 1 && title_.size() == 0) {
34 return gfx::Size( 34 return gfx::Size(
35 child_size.width(), 35 child_size.width(),
36 child_size.height() + GetBottomMargin() + GetTopMargin()); 36 child_size.height() + GetBottomMargin() + GetTopMargin());
37 } 37 }
38 38
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 int accel_width = parent_menu_item_->GetSubmenu()->max_accelerator_width(); 104 int accel_width = parent_menu_item_->GetSubmenu()->max_accelerator_width();
105 int width = this->width() - item_right_margin_ - label_start_ - accel_width; 105 int width = this->width() - item_right_margin_ - label_start_ - accel_width;
106 gfx::Rect text_bounds(label_start_, top_margin + 106 gfx::Rect text_bounds(label_start_, top_margin +
107 (available_height - font.GetHeight()) / 2, width, 107 (available_height - font.GetHeight()) / 2, width,
108 font.GetHeight()); 108 font.GetHeight());
109 text_bounds.set_x(GetMirroredXForRect(text_bounds)); 109 text_bounds.set_x(GetMirroredXForRect(text_bounds));
110 canvas->DrawStringInt(WideToUTF16Hack(GetTitle()), font, fg_color, 110 canvas->DrawStringInt(WideToUTF16Hack(GetTitle()), font, fg_color,
111 text_bounds.x(), text_bounds.y(), text_bounds.width(), 111 text_bounds.x(), text_bounds.y(), text_bounds.width(),
112 text_bounds.height(), 112 text_bounds.height(),
113 GetRootMenuItem()->GetDrawStringFlags()); 113 GetRootMenuItem()->GetDrawStringFlags());
114 114 #if !defined(TOUCH_UI)
115 PaintAccelerator(canvas); 115 PaintAccelerator(canvas);
116 #endif
116 117
117 // Render the icon. 118 // Render the icon.
118 if (icon_.width() > 0) { 119 if (icon_.width() > 0) {
119 gfx::Rect icon_bounds(config.item_left_margin, 120 gfx::Rect icon_bounds(config.item_left_margin,
120 top_margin + (height() - top_margin - 121 top_margin + (height() - top_margin -
121 bottom_margin - icon_.height()) / 2, 122 bottom_margin - icon_.height()) / 2,
122 icon_.width(), 123 icon_.width(),
123 icon_.height()); 124 icon_.height());
124 icon_bounds.set_x(GetMirroredXForRect(icon_bounds)); 125 icon_bounds.set_x(GetMirroredXForRect(icon_bounds));
125 canvas->DrawBitmapInt(icon_, icon_bounds.x(), icon_bounds.y()); 126 canvas->DrawBitmapInt(icon_, icon_bounds.x(), icon_bounds.y());
126 } 127 }
127 128
128 // Render the submenu indicator (arrow). 129 // Render the submenu indicator (arrow).
129 if (HasSubmenu()) { 130 if (HasSubmenu()) {
130 gfx::Rect arrow_bounds(this->width() - item_right_margin_ + 131 gfx::Rect arrow_bounds(this->width() - item_right_margin_ +
131 config.label_to_arrow_padding, 132 config.label_to_arrow_padding,
132 top_margin + (available_height - 133 top_margin + (available_height -
133 config.arrow_width) / 2, 134 config.arrow_width) / 2,
134 config.arrow_width, height()); 135 config.arrow_width, height());
135 AdjustBoundsForRTLUI(&arrow_bounds); 136 AdjustBoundsForRTLUI(&arrow_bounds);
136 canvas->DrawBitmapInt(*GetSubmenuArrowImage(), 137 canvas->DrawBitmapInt(*GetSubmenuArrowImage(),
137 arrow_bounds.x(), arrow_bounds.y()); 138 arrow_bounds.x(), arrow_bounds.y());
138 } 139 }
139 } 140 }
140 141
141 } // namespace views 142 } // namespace views
OLDNEW
« views/controls/menu/menu_item_view.cc ('K') | « views/controls/menu/menu_item_view.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698