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

Unified Diff: ash/common/shelf/overflow_button.cc

Issue 2714853004: Remove non-MD code from overflow button and bubble (Closed)
Patch Set: Rebased Created 3 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
« no previous file with comments | « ash/common/shelf/overflow_button.h ('k') | ash/resources/ash_resources.grd » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/common/shelf/overflow_button.cc
diff --git a/ash/common/shelf/overflow_button.cc b/ash/common/shelf/overflow_button.cc
index 3d57ca0a8650608f6aeaaab483bd896e03ea2fb7..6db7e08c6375e12842736c31ea7274ea71a6f701 100644
--- a/ash/common/shelf/overflow_button.cc
+++ b/ash/common/shelf/overflow_button.cc
@@ -4,26 +4,17 @@
#include "ash/common/shelf/overflow_button.h"
-#include "ash/common/ash_constants.h"
-#include "ash/common/material_design/material_design_controller.h"
-#include "ash/common/shelf/ink_drop_button_listener.h"
#include "ash/common/shelf/shelf_constants.h"
#include "ash/common/shelf/shelf_view.h"
#include "ash/common/shelf/wm_shelf.h"
-#include "ash/common/shelf/wm_shelf_util.h"
#include "ash/common/strings/grit/ash_strings.h"
-#include "ash/resources/grit/ash_resources.h"
#include "ash/resources/vector_icons/vector_icons.h"
#include "base/memory/ptr_util.h"
-#include "third_party/skia/include/core/SkPath.h"
#include "ui/base/l10n/l10n_util.h"
-#include "ui/base/resource/resource_bundle.h"
#include "ui/gfx/canvas.h"
#include "ui/gfx/image/image_skia_operations.h"
#include "ui/gfx/paint_vector_icon.h"
#include "ui/gfx/skbitmap_operations.h"
-#include "ui/gfx/skia_util.h"
-#include "ui/gfx/transform.h"
#include "ui/views/animation/flood_fill_ink_drop_ripple.h"
#include "ui/views/animation/ink_drop_impl.h"
#include "ui/views/animation/ink_drop_mask.h"
@@ -32,22 +23,16 @@ namespace ash {
OverflowButton::OverflowButton(ShelfView* shelf_view, WmShelf* wm_shelf)
: CustomButton(nullptr),
- bottom_image_(nullptr),
shelf_view_(shelf_view),
wm_shelf_(wm_shelf),
background_color_(kShelfDefaultBaseColor) {
DCHECK(shelf_view_);
- if (MaterialDesignController::IsShelfMaterial()) {
- SetInkDropMode(InkDropMode::ON);
- set_ink_drop_base_color(kShelfInkDropBaseColor);
- set_ink_drop_visible_opacity(kShelfInkDropVisibleOpacity);
- set_hide_ink_drop_when_showing_context_menu(false);
- bottom_image_md_ = CreateVectorIcon(kShelfOverflowIcon, kShelfIconColor);
- bottom_image_ = &bottom_image_md_;
- } else {
- bottom_image_ = ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed(
- IDR_ASH_SHELF_OVERFLOW);
- }
+
+ SetInkDropMode(InkDropMode::ON);
+ set_ink_drop_base_color(kShelfInkDropBaseColor);
+ set_ink_drop_visible_opacity(kShelfInkDropVisibleOpacity);
+ set_hide_ink_drop_when_showing_context_menu(false);
+ bottom_image_ = gfx::CreateVectorIcon(kShelfOverflowIcon, kShelfIconColor);
SetFocusBehavior(FocusBehavior::ACCESSIBLE_ONLY);
SetAccessibleName(l10n_util::GetStringUTF16(IDS_ASH_SHELF_OVERFLOW_NAME));
@@ -61,14 +46,10 @@ void OverflowButton::OnShelfAlignmentChanged() {
void OverflowButton::OnOverflowBubbleShown() {
AnimateInkDrop(views::InkDropState::ACTIVATED, nullptr);
- if (!ash::MaterialDesignController::IsShelfMaterial())
- SchedulePaint();
}
void OverflowButton::OnOverflowBubbleHidden() {
AnimateInkDrop(views::InkDropState::DEACTIVATED, nullptr);
- if (!ash::MaterialDesignController::IsShelfMaterial())
- SchedulePaint();
}
void OverflowButton::UpdateShelfItemBackground(SkColor color) {
@@ -118,17 +99,10 @@ std::unique_ptr<views::InkDropMask> OverflowButton::CreateInkDropMask() const {
void OverflowButton::PaintBackground(gfx::Canvas* canvas,
const gfx::Rect& bounds) {
- if (MaterialDesignController::IsShelfMaterial()) {
- cc::PaintFlags flags;
- flags.setFlags(cc::PaintFlags::kAntiAlias_Flag);
- flags.setColor(background_color_);
- canvas->DrawRoundRect(bounds, kOverflowButtonCornerRadius, flags);
- } else {
- ResourceBundle& rb = ResourceBundle::GetSharedInstance();
- const gfx::ImageSkia* background =
- rb.GetImageNamed(NonMaterialBackgroundImageId()).ToImageSkia();
- canvas->DrawImageInt(*background, bounds.x(), bounds.y());
- }
+ cc::PaintFlags flags;
+ flags.setFlags(cc::PaintFlags::kAntiAlias_Flag);
+ flags.setColor(background_color_);
+ canvas->DrawRoundRect(bounds, kOverflowButtonCornerRadius, flags);
}
void OverflowButton::PaintForeground(gfx::Canvas* canvas,
@@ -139,19 +113,19 @@ void OverflowButton::PaintForeground(gfx::Canvas* canvas,
case SHELF_ALIGNMENT_LEFT:
if (left_image_.isNull()) {
left_image_ = gfx::ImageSkiaOperations::CreateRotatedImage(
- *bottom_image_, SkBitmapOperations::ROTATION_90_CW);
+ bottom_image_, SkBitmapOperations::ROTATION_90_CW);
}
image = &left_image_;
break;
case SHELF_ALIGNMENT_RIGHT:
if (right_image_.isNull()) {
right_image_ = gfx::ImageSkiaOperations::CreateRotatedImage(
- *bottom_image_, SkBitmapOperations::ROTATION_270_CW);
+ bottom_image_, SkBitmapOperations::ROTATION_270_CW);
}
image = &right_image_;
break;
default:
- image = bottom_image_;
+ image = &bottom_image_;
break;
}
@@ -160,46 +134,17 @@ void OverflowButton::PaintForeground(gfx::Canvas* canvas,
bounds.y() + ((bounds.height() - image->height()) / 2));
}
-int OverflowButton::NonMaterialBackgroundImageId() const {
- if (shelf_view_->IsShowingOverflowBubble())
- return IDR_AURA_NOTIFICATION_BACKGROUND_PRESSED;
- return IDR_AURA_NOTIFICATION_BACKGROUND_NORMAL;
-}
-
gfx::Rect OverflowButton::CalculateButtonBounds() const {
ShelfAlignment alignment = wm_shelf_->GetAlignment();
- gfx::Rect bounds(GetContentsBounds());
- if (MaterialDesignController::IsShelfMaterial()) {
- // Align the button to the top of a bottom-aligned shelf, to the right edge
- // a left-aligned shelf, and to the left edge of a right-aligned shelf.
- const int inset = (GetShelfConstant(SHELF_SIZE) - kOverflowButtonSize) / 2;
- const int x = alignment == SHELF_ALIGNMENT_LEFT
- ? bounds.right() - inset - kOverflowButtonSize
- : bounds.x() + inset;
- bounds = gfx::Rect(x, bounds.y() + inset, kOverflowButtonSize,
- kOverflowButtonSize);
- } else {
- ResourceBundle& rb = ResourceBundle::GetSharedInstance();
- const gfx::ImageSkia* background =
- rb.GetImageNamed(NonMaterialBackgroundImageId()).ToImageSkia();
- if (alignment == SHELF_ALIGNMENT_LEFT) {
- bounds =
- gfx::Rect(bounds.right() - background->width() - kShelfItemInset,
- bounds.y() + (bounds.height() - background->height()) / 2,
- background->width(), background->height());
- } else if (alignment == SHELF_ALIGNMENT_RIGHT) {
- bounds =
- gfx::Rect(bounds.x() + kShelfItemInset,
- bounds.y() + (bounds.height() - background->height()) / 2,
- background->width(), background->height());
- } else {
- bounds =
- gfx::Rect(bounds.x() + (bounds.width() - background->width()) / 2,
- bounds.y() + kShelfItemInset, background->width(),
- background->height());
- }
- }
- return bounds;
+ gfx::Rect content_bounds = GetContentsBounds();
+ // Align the button to the top of a bottom-aligned shelf, to the right edge
+ // a left-aligned shelf, and to the left edge of a right-aligned shelf.
+ const int inset = (GetShelfConstant(SHELF_SIZE) - kOverflowButtonSize) / 2;
+ const int x = alignment == SHELF_ALIGNMENT_LEFT
+ ? content_bounds.right() - inset - kOverflowButtonSize
+ : content_bounds.x() + inset;
+ return gfx::Rect(x, content_bounds.y() + inset, kOverflowButtonSize,
+ kOverflowButtonSize);
}
} // namespace ash
« no previous file with comments | « ash/common/shelf/overflow_button.h ('k') | ash/resources/ash_resources.grd » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698