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

Unified Diff: chrome/browser/ui/views/toolbar/app_menu.cc

Issue 1661673004: Enables hot-tracking for overflow extension buttons in the app menu (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Restores hot-tracking of extension buttons in app menu with MD (comments) Created 4 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/views/toolbar/app_menu.cc
diff --git a/chrome/browser/ui/views/toolbar/app_menu.cc b/chrome/browser/ui/views/toolbar/app_menu.cc
index 916ebad4a9e117c7c565961293ed9e35dcf448b2..a492a0a087acd302260ac6e05687e6784448c762 100644
--- a/chrome/browser/ui/views/toolbar/app_menu.cc
+++ b/chrome/browser/ui/views/toolbar/app_menu.cc
@@ -46,6 +46,7 @@
#include "third_party/skia/include/core/SkPaint.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/layout.h"
+#include "ui/base/material_design/material_design_controller.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/gfx/canvas.h"
#include "ui/gfx/font_list.h"
@@ -130,6 +131,8 @@ class FullscreenButton : public ImageButton {
// paint the border.
class InMenuButtonBackground : public views::Background {
public:
+ const int kBackgroundCornerRadius = 2;
Peter Kasting 2016/02/16 21:36:15 This does not need to be class-scope; it can be fu
varkha 2016/02/17 17:52:00 Done.
+
enum ButtonType {
LEFT_BUTTON,
CENTER_BUTTON,
@@ -163,12 +166,13 @@ class InMenuButtonBackground : public views::Background {
// Normal buttons get a border drawn on the right side and the rest gets
// filled in. The left button however does not get a line to combine
// buttons.
+ gfx::Rect bounds(view->GetLocalBounds());
if (type_ != RIGHT_BUTTON) {
canvas->FillRect(gfx::Rect(0, 0, 1, h),
BorderColor(view, views::Button::STATE_NORMAL));
+ bounds.Inset(gfx::Insets(0, 1, 0, 0));
}
- gfx::Rect bounds(view->GetLocalBounds());
bounds.set_x(view->GetMirroredXForRect(bounds));
DrawBackground(canvas, view, bounds, state);
}
@@ -213,11 +217,14 @@ class InMenuButtonBackground : public views::Background {
views::Button::ButtonState state) const {
if (state == views::Button::STATE_HOVERED ||
state == views::Button::STATE_PRESSED) {
+ ui::NativeTheme::ExtraParams params = ui::NativeTheme::ExtraParams();
+ if (ui::MaterialDesignController::IsModeMaterial() &&
+ view->GetClassName() == views::MenuButton::kViewClassName) {
+ params.menu_item.corner_radius = kBackgroundCornerRadius;
+ }
view->GetNativeTheme()->Paint(canvas->sk_canvas(),
ui::NativeTheme::kMenuItemBackground,
- ui::NativeTheme::kHovered,
- bounds,
- ui::NativeTheme::ExtraParams());
+ ui::NativeTheme::kHovered, bounds, params);
}
}
@@ -1135,13 +1142,24 @@ void AppMenu::PopulateMenu(MenuItemView* parent, MenuModel* model) {
switch (model->GetCommandIdAt(i)) {
case IDC_EXTENSIONS_OVERFLOW_MENU: {
+ extension_toolbar_ = nullptr;
Peter Kasting 2016/02/16 21:36:15 Nit: I would probably put this inside the ShouldSh
varkha 2016/02/17 17:52:00 Done.
scoped_ptr<ExtensionToolbarMenuView> extension_toolbar(
new ExtensionToolbarMenuView(browser_, this));
- extension_toolbar_ = extension_toolbar.get();
- if (extension_toolbar->ShouldShow())
- item->AddChildView(extension_toolbar.release());
- else
+ if (!extension_toolbar->ShouldShow()) {
item->SetVisible(false);
+ break;
+ }
+ if (ui::MaterialDesignController::IsModeMaterial()) {
+ for (int i = 0; i < extension_toolbar->contents()->child_count();
+ ++i) {
+ View* action_view = extension_toolbar->contents()->child_at(i);
+ action_view->set_background(new InMenuButtonBackground(
+ InMenuButtonBackground::RIGHT_BUTTON));
+ DCHECK(action_view->IsFocusable());
+ }
+ }
+ extension_toolbar_ = extension_toolbar.get();
+ item->AddChildView(extension_toolbar.release());
break;
}

Powered by Google App Engine
This is Rietveld 408576698