summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ui/views/controls/menu/menu_config_linux.cc25
-rw-r--r--ui/views/controls/menu/menu_config_views.cc (renamed from ui/views/controls/menu/menu_config_aura.cc)0
-rw-r--r--ui/views/controls/menu/menu_item_view_aura.cc107
-rw-r--r--ui/views/controls/menu/menu_item_view_views.cc (renamed from ui/views/controls/menu/menu_item_view_linux.cc)0
-rw-r--r--ui/views/controls/menu/menu_separator_linux.cc24
-rw-r--r--ui/views/controls/menu/menu_separator_views.cc (renamed from ui/views/controls/menu/menu_separator_aura.cc)0
-rw-r--r--ui/views/views.gyp20
7 files changed, 11 insertions, 165 deletions
diff --git a/ui/views/controls/menu/menu_config_linux.cc b/ui/views/controls/menu/menu_config_linux.cc
deleted file mode 100644
index 31c4203..0000000
--- a/ui/views/controls/menu/menu_config_linux.cc
+++ /dev/null
@@ -1,25 +0,0 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "ui/views/controls/menu/menu_config.h"
-
-#include "grit/ui_resources.h"
-#include "third_party/skia/include/core/SkBitmap.h"
-#include "ui/base/resource/resource_bundle.h"
-
-namespace views {
-
-// static
-MenuConfig* MenuConfig::Create() {
- MenuConfig* config = new MenuConfig();
- ResourceBundle& rb = ResourceBundle::GetSharedInstance();
- config->font = rb.GetFont(ResourceBundle::BaseFont);
- config->arrow_width = rb.GetBitmapNamed(IDR_MENU_ARROW)->width();
- // Add 4 to force some padding between check and label.
- config->check_width = rb.GetBitmapNamed(IDR_MENU_CHECK)->width() + 4;
- config->check_height = rb.GetBitmapNamed(IDR_MENU_CHECK)->height();
- return config;
-}
-
-} // namespace views
diff --git a/ui/views/controls/menu/menu_config_aura.cc b/ui/views/controls/menu/menu_config_views.cc
index 31c4203..31c4203 100644
--- a/ui/views/controls/menu/menu_config_aura.cc
+++ b/ui/views/controls/menu/menu_config_views.cc
diff --git a/ui/views/controls/menu/menu_item_view_aura.cc b/ui/views/controls/menu/menu_item_view_aura.cc
deleted file mode 100644
index 7a3df3e..0000000
--- a/ui/views/controls/menu/menu_item_view_aura.cc
+++ /dev/null
@@ -1,107 +0,0 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "ui/views/controls/menu/menu_item_view.h"
-
-#include "base/utf_string_conversions.h"
-#include "grit/ui_resources.h"
-#include "third_party/skia/include/effects/SkGradientShader.h"
-#include "ui/base/resource/resource_bundle.h"
-#include "ui/gfx/canvas_skia.h"
-#include "ui/gfx/favicon_size.h"
-#include "ui/views/controls/button/text_button.h"
-#include "ui/views/controls/menu/menu_config.h"
-#include "ui/views/controls/menu/menu_image_util.h"
-#include "ui/views/controls/menu/submenu_view.h"
-
-namespace views {
-
-// Background color when the menu item is selected.
-static const SkColor kSelectedBackgroundColor = SkColorSetRGB(246, 249, 253);
-
-void MenuItemView::PaintButton(gfx::Canvas* canvas, PaintButtonMode mode) {
- const MenuConfig& config = MenuConfig::instance();
- bool render_selection =
- (mode == PB_NORMAL && IsSelected() &&
- parent_menu_item_->GetSubmenu()->GetShowSelection(this) &&
- !has_children());
-
- int icon_x = config.item_left_margin;
- int top_margin = GetTopMargin();
- int bottom_margin = GetBottomMargin();
- int icon_y = top_margin + (height() - config.item_top_margin -
- bottom_margin - config.check_height) / 2;
- int icon_height = config.check_height;
- int available_height = height() - top_margin - bottom_margin;
-
- // Render the background. As MenuScrollViewContainer draws the background, we
- // only need the background when we want it to look different, as when we're
- // selected.
- if (render_selection)
- canvas->GetSkCanvas()->drawColor(kSelectedBackgroundColor,
- SkXfermode::kSrc_Mode);
-
- // Render the check.
- if (type_ == CHECKBOX && GetDelegate()->IsItemChecked(GetCommand())) {
- ResourceBundle& rb = ResourceBundle::GetSharedInstance();
- SkBitmap* check = rb.GetBitmapNamed(IDR_MENU_CHECK);
- // Don't use config.check_width here as it's padded to force more padding.
- gfx::Rect check_bounds(icon_x, icon_y, check->width(), icon_height);
- AdjustBoundsForRTLUI(&check_bounds);
- canvas->DrawBitmapInt(*check, check_bounds.x(), check_bounds.y());
- } else if (type_ == RADIO) {
- const SkBitmap* image =
- GetRadioButtonImage(GetDelegate()->IsItemChecked(GetCommand()));
- gfx::Rect radio_bounds(icon_x,
- top_margin +
- (height() - top_margin - bottom_margin -
- image->height()) / 2,
- image->width(),
- image->height());
- AdjustBoundsForRTLUI(&radio_bounds);
- canvas->DrawBitmapInt(*image, radio_bounds.x(), radio_bounds.y());
- }
-
- // Render the foreground.
- SkColor fg_color = enabled() ? TextButton::kEnabledColor
- : TextButton::kDisabledColor;
- const gfx::Font& font = GetFont();
- int accel_width = parent_menu_item_->GetSubmenu()->max_accelerator_width();
- int width = this->width() - item_right_margin_ - label_start_ - accel_width;
- gfx::Rect text_bounds(label_start_, top_margin +
- (available_height - font.GetHeight()) / 2, width,
- font.GetHeight());
- text_bounds.set_x(GetMirroredXForRect(text_bounds));
- canvas->DrawStringInt(title(), font, fg_color,
- text_bounds.x(), text_bounds.y(), text_bounds.width(),
- text_bounds.height(),
- GetRootMenuItem()->GetDrawStringFlags());
-
- PaintAccelerator(canvas);
-
- // Render the icon.
- if (icon_.width() > 0) {
- gfx::Rect icon_bounds(config.item_left_margin,
- top_margin + (height() - top_margin -
- bottom_margin - icon_.height()) / 2,
- icon_.width(),
- icon_.height());
- icon_bounds.set_x(GetMirroredXForRect(icon_bounds));
- canvas->DrawBitmapInt(icon_, icon_bounds.x(), icon_bounds.y());
- }
-
- // Render the submenu indicator (arrow).
- if (HasSubmenu()) {
- gfx::Rect arrow_bounds(this->width() - item_right_margin_ +
- config.label_to_arrow_padding,
- top_margin + (available_height -
- config.arrow_width) / 2,
- config.arrow_width, height());
- AdjustBoundsForRTLUI(&arrow_bounds);
- canvas->DrawBitmapInt(*GetSubmenuArrowImage(),
- arrow_bounds.x(), arrow_bounds.y());
- }
-}
-
-} // namespace views
diff --git a/ui/views/controls/menu/menu_item_view_linux.cc b/ui/views/controls/menu/menu_item_view_views.cc
index 1b77e27..1b77e27 100644
--- a/ui/views/controls/menu/menu_item_view_linux.cc
+++ b/ui/views/controls/menu/menu_item_view_views.cc
diff --git a/ui/views/controls/menu/menu_separator_linux.cc b/ui/views/controls/menu/menu_separator_linux.cc
deleted file mode 100644
index 0b914cf..0000000
--- a/ui/views/controls/menu/menu_separator_linux.cc
+++ /dev/null
@@ -1,24 +0,0 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "ui/views/controls/menu/menu_separator.h"
-
-#include "third_party/skia/include/core/SkColor.h"
-#include "ui/gfx/canvas.h"
-#include "ui/views/controls/menu/menu_config.h"
-
-namespace views {
-
-static const SkColor kSeparatorColor = SkColorSetARGB(50, 00, 00, 00);
-
-void MenuSeparator::OnPaint(gfx::Canvas* canvas) {
- canvas->DrawLineInt(kSeparatorColor, 0, height() / 2, width(), height() / 2);
-}
-
-gfx::Size MenuSeparator::GetPreferredSize() {
- return gfx::Size(10, // Just in case we're the only item in a menu.
- MenuConfig::instance().separator_height);
-}
-
-} // namespace views
diff --git a/ui/views/controls/menu/menu_separator_aura.cc b/ui/views/controls/menu/menu_separator_views.cc
index 0b914cf..0b914cf 100644
--- a/ui/views/controls/menu/menu_separator_aura.cc
+++ b/ui/views/controls/menu/menu_separator_views.cc
diff --git a/ui/views/views.gyp b/ui/views/views.gyp
index c57fb38..84a3119 100644
--- a/ui/views/views.gyp
+++ b/ui/views/views.gyp
@@ -105,8 +105,7 @@
'controls/menu/menu_2.h',
'controls/menu/menu_config.cc',
'controls/menu/menu_config.h',
- 'controls/menu/menu_config_aura.cc',
- 'controls/menu/menu_config_linux.cc',
+ 'controls/menu/menu_config_views.cc',
'controls/menu/menu_config_win.cc',
'controls/menu/menu_controller.cc',
'controls/menu/menu_controller.h',
@@ -121,8 +120,7 @@
'controls/menu/menu_host_root_view.h',
'controls/menu/menu_item_view.cc',
'controls/menu/menu_item_view.h',
- 'controls/menu/menu_item_view_aura.cc',
- 'controls/menu/menu_item_view_linux.cc',
+ 'controls/menu/menu_item_view_views.cc',
'controls/menu/menu_item_view_win.cc',
'controls/menu/menu_listener.h',
'controls/menu/menu_model_adapter.cc',
@@ -132,8 +130,7 @@
'controls/menu/menu_scroll_view_container.cc',
'controls/menu/menu_scroll_view_container.h',
'controls/menu/menu_separator.h',
- 'controls/menu/menu_separator_aura.cc',
- 'controls/menu/menu_separator_linux.cc',
+ 'controls/menu/menu_separator_views.cc',
'controls/menu/menu_separator_win.cc',
'controls/menu/menu_win.cc',
'controls/menu/menu_win.h',
@@ -396,9 +393,6 @@
['exclude', 'controls/menu/menu_2.*'],
],
'sources!': [
- 'controls/menu/menu_config_linux.cc',
- 'controls/menu/menu_item_view_linux.cc',
- 'controls/menu/menu_separator_linux.cc',
'controls/native_control.cc',
'controls/native_control.h',
'controls/scrollbar/bitmap_scroll_bar.cc',
@@ -450,6 +444,14 @@
'widget/tooltip_manager_views.cc',
],
}],
+ # For these we still use platform code instead of Views code on Windows.
+ ['use_aura==0 and OS=="win"', {
+ 'sources!': [
+ 'controls/menu/menu_config_views.cc',
+ 'controls/menu/menu_item_view_views.cc',
+ 'controls/menu/menu_separator_views.cc',
+ ],
+ }],
['OS=="win"', {
'dependencies': [
# For accessibility