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

Unified Diff: ash/system/tray/tray_background_view.cc

Issue 198063003: Revert of Shelf Cleanup (- binary files) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 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/system/tray/system_tray.cc ('k') | ash/system/tray/tray_constants.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/system/tray/tray_background_view.cc
diff --git a/ash/system/tray/tray_background_view.cc b/ash/system/tray/tray_background_view.cc
index 1c307bad93f610d077a3de4f7010532061f0fa80..c610ee4ace6882ca80b3eaf327b73e00424d9f33 100644
--- a/ash/system/tray/tray_background_view.cc
+++ b/ash/system/tray/tray_background_view.cc
@@ -37,6 +37,12 @@
const int kTrayBackgroundHoverAlpha = 150;
const SkColor kTrayBackgroundPressedColor = SkColorSetRGB(66, 129, 244);
+// Adjust the size of TrayContainer with additional padding.
+const int kTrayContainerVerticalPaddingBottomAlignment = 1;
+const int kTrayContainerHorizontalPaddingBottomAlignment = 1;
+const int kTrayContainerVerticalPaddingVerticalAlignment = 1;
+const int kTrayContainerHorizontalPaddingVerticalAlignment = 1;
+
const int kAnimationDurationForPopupMS = 200;
} // namespace
@@ -148,8 +154,7 @@
status_area_widget()->GetNativeWindow())->shelf();
}
- // Overridden from views::Background.
- virtual void Paint(gfx::Canvas* canvas, views::View* view) const OVERRIDE {
+ void PaintForAlternateShelf(gfx::Canvas* canvas, views::View* view) const {
int orientation = kImageHorizontal;
ShelfWidget* shelf_widget = GetShelfWidget();
if (shelf_widget &&
@@ -205,6 +210,23 @@
middle_bounds.height());
}
+ // Overridden from views::Background.
+ virtual void Paint(gfx::Canvas* canvas, views::View* view) const OVERRIDE {
+ if (ash::switches::UseAlternateShelfLayout()) {
+ PaintForAlternateShelf(canvas, view);
+ } else {
+ SkPaint paint;
+ paint.setAntiAlias(true);
+ paint.setStyle(SkPaint::kFill_Style);
+ paint.setColor(color_);
+ SkPath path;
+ gfx::Rect bounds(view->GetLocalBounds());
+ SkScalar radius = SkIntToScalar(kTrayRoundedBorderRadius);
+ path.addRoundRect(gfx::RectToSkRect(bounds), radius, radius);
+ canvas->DrawPath(path, paint);
+ }
+ }
+
SkColor color_;
// Reference to the TrayBackgroundView for which this is a background.
TrayBackgroundView* tray_background_view_;
@@ -256,22 +278,32 @@
// empty border.
if (alignment_ == SHELF_ALIGNMENT_BOTTOM ||
alignment_ == SHELF_ALIGNMENT_TOP) {
- SetBorder(views::Border::CreateEmptyBorder(
- kPaddingFromEdgeOfShelf,
- kPaddingFromEdgeOfShelf,
- kPaddingFromEdgeOfShelf,
- kPaddingFromEdgeOfShelf));
+ int vertical_padding = kTrayContainerVerticalPaddingBottomAlignment;
+ int horizontal_padding = kTrayContainerHorizontalPaddingBottomAlignment;
+ if (ash::switches::UseAlternateShelfLayout()) {
+ vertical_padding = kPaddingFromEdgeOfShelf;
+ horizontal_padding = kPaddingFromEdgeOfShelf;
+ }
+ SetBorder(views::Border::CreateEmptyBorder(vertical_padding,
+ horizontal_padding,
+ vertical_padding,
+ horizontal_padding));
views::BoxLayout* layout =
new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0);
layout->set_spread_blank_space(true);
views::View::SetLayoutManager(layout);
} else {
- SetBorder(views::Border::CreateEmptyBorder(
- kPaddingFromEdgeOfShelf,
- kPaddingFromEdgeOfShelf,
- kPaddingFromEdgeOfShelf,
- kPaddingFromEdgeOfShelf));
+ int vertical_padding = kTrayContainerVerticalPaddingVerticalAlignment;
+ int horizontal_padding = kTrayContainerHorizontalPaddingVerticalAlignment;
+ if (ash::switches::UseAlternateShelfLayout()) {
+ vertical_padding = kPaddingFromEdgeOfShelf;
+ horizontal_padding = kPaddingFromEdgeOfShelf;
+ }
+ SetBorder(views::Border::CreateEmptyBorder(vertical_padding,
+ horizontal_padding,
+ vertical_padding,
+ horizontal_padding));
views::BoxLayout* layout =
new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0);
@@ -325,10 +357,20 @@
void TrayBackgroundView::OnMouseEntered(const ui::MouseEvent& event) {
hovered_ = true;
+ if (!background_ || draw_background_as_active_ ||
+ ash::switches::UseAlternateShelfLayout())
+ return;
+ hover_background_animator_.SetPaintsBackground(
+ true, BACKGROUND_CHANGE_ANIMATE);
}
void TrayBackgroundView::OnMouseExited(const ui::MouseEvent& event) {
hovered_ = false;
+ if (!background_ || draw_background_as_active_ ||
+ ash::switches::UseAlternateShelfLayout())
+ return;
+ hover_background_animator_.SetPaintsBackground(
+ false, BACKGROUND_CHANGE_ANIMATE);
}
void TrayBackgroundView::ChildPreferredSizeChanged(views::View* child) {
@@ -362,6 +404,7 @@
// The animator should never fire when the alternate shelf layout is used.
if (!background_ || draw_background_as_active_)
return;
+ DCHECK(!ash::switches::UseAlternateShelfLayout());
background_->set_alpha(hide_background_animator_.alpha() +
hover_background_animator_.alpha());
SchedulePaint();
@@ -374,6 +417,7 @@
void TrayBackgroundView::SetPaintsBackground(
bool value, BackgroundAnimatorChangeType change_type) {
+ DCHECK(!ash::switches::UseAlternateShelfLayout());
hide_background_animator_.SetPaintsBackground(value, change_type);
}
@@ -397,24 +441,51 @@
// Tray views are laid out right-to-left or bottom-to-top
bool on_edge = (this == parent->child_at(0));
int left_edge, top_edge, right_edge, bottom_edge;
- if (shelf_alignment() == SHELF_ALIGNMENT_BOTTOM) {
- top_edge = ShelfLayoutManager::kShelfItemInset;
- left_edge = 0;
- bottom_edge = kShelfSize -
- ShelfLayoutManager::kShelfItemInset - ash::kShelfItemHeight;
- right_edge = on_edge ? kPaddingFromEdgeOfShelf : 0;
- } else if (shelf_alignment() == SHELF_ALIGNMENT_LEFT) {
- top_edge = 0;
- left_edge = kShelfSize -
- ShelfLayoutManager::kShelfItemInset - ash::kShelfItemHeight;
- bottom_edge = on_edge ? kPaddingFromEdgeOfShelf : 0;
- right_edge = ShelfLayoutManager::kShelfItemInset;
- } else { // SHELF_ALIGNMENT_RIGHT
- top_edge = 0;
- left_edge = ShelfLayoutManager::kShelfItemInset;
- bottom_edge = on_edge ? kPaddingFromEdgeOfShelf : 0;
- right_edge = kShelfSize -
- ShelfLayoutManager::kShelfItemInset - ash::kShelfItemHeight;
+ if (ash::switches::UseAlternateShelfLayout()) {
+ if (shelf_alignment() == SHELF_ALIGNMENT_BOTTOM) {
+ top_edge = ShelfLayoutManager::kShelfItemInset;
+ left_edge = 0;
+ bottom_edge = ShelfLayoutManager::GetPreferredShelfSize() -
+ ShelfLayoutManager::kShelfItemInset - GetShelfItemHeight();
+ right_edge = on_edge ? kPaddingFromEdgeOfShelf : 0;
+ } else if (shelf_alignment() == SHELF_ALIGNMENT_LEFT) {
+ top_edge = 0;
+ left_edge = ShelfLayoutManager::GetPreferredShelfSize() -
+ ShelfLayoutManager::kShelfItemInset - GetShelfItemHeight();
+ bottom_edge = on_edge ? kPaddingFromEdgeOfShelf : 0;
+ right_edge = ShelfLayoutManager::kShelfItemInset;
+ } else { // SHELF_ALIGNMENT_RIGHT
+ top_edge = 0;
+ left_edge = ShelfLayoutManager::kShelfItemInset;
+ bottom_edge = on_edge ? kPaddingFromEdgeOfShelf : 0;
+ right_edge = ShelfLayoutManager::GetPreferredShelfSize() -
+ ShelfLayoutManager::kShelfItemInset - GetShelfItemHeight();
+ }
+ } else {
+ // Change the border padding for different shelf alignment.
+ if (shelf_alignment() == SHELF_ALIGNMENT_BOTTOM) {
+ top_edge = 0;
+ left_edge = 0;
+ bottom_edge = on_edge ? kPaddingFromBottomOfScreenBottomAlignment :
+ kPaddingFromBottomOfScreenBottomAlignment - 1;
+ right_edge = on_edge ? kPaddingFromRightEdgeOfScreenBottomAlignment : 0;
+ } else if (shelf_alignment() == SHELF_ALIGNMENT_TOP) {
+ top_edge = on_edge ? kPaddingFromBottomOfScreenBottomAlignment :
+ kPaddingFromBottomOfScreenBottomAlignment - 1;
+ left_edge = 0;
+ bottom_edge = 0;
+ right_edge = on_edge ? kPaddingFromRightEdgeOfScreenBottomAlignment : 0;
+ } else if (shelf_alignment() == SHELF_ALIGNMENT_LEFT) {
+ top_edge = 0;
+ left_edge = kPaddingFromOuterEdgeOfLauncherVerticalAlignment;
+ bottom_edge = on_edge ? kPaddingFromBottomOfScreenVerticalAlignment : 0;
+ right_edge = kPaddingFromInnerEdgeOfLauncherVerticalAlignment;
+ } else {
+ top_edge = 0;
+ left_edge = kPaddingFromInnerEdgeOfLauncherVerticalAlignment;
+ bottom_edge = on_edge ? kPaddingFromBottomOfScreenVerticalAlignment : 0;
+ right_edge = kPaddingFromOuterEdgeOfLauncherVerticalAlignment;
+ }
}
SetBorder(views::Border::CreateEmptyBorder(
top_edge, left_edge, bottom_edge, right_edge));
@@ -449,22 +520,46 @@
if (anchor_type == TrayBubbleView::ANCHOR_TYPE_TRAY) {
if (anchor_alignment == TrayBubbleView::ANCHOR_ALIGNMENT_BOTTOM) {
bool rtl = base::i18n::IsRTL();
- rect.Inset(
- rtl ? kBubblePaddingHorizontalSide : 0,
- kBubblePaddingHorizontalBottom,
- rtl ? 0 : kBubblePaddingHorizontalSide,
- 0);
+ if (!ash::switches::UseAlternateShelfLayout()) {
+ rect.Inset(
+ rtl ? kPaddingFromRightEdgeOfScreenBottomAlignment : 0,
+ kTrayBubbleAnchorTopInsetBottomAnchor,
+ rtl ? 0 : kPaddingFromRightEdgeOfScreenBottomAlignment,
+ kPaddingFromBottomOfScreenBottomAlignment);
+ } else {
+ rect.Inset(
+ rtl ? kAlternateLayoutBubblePaddingHorizontalSide : 0,
+ kAlternateLayoutBubblePaddingHorizontalBottom,
+ rtl ? 0 : kAlternateLayoutBubblePaddingHorizontalSide,
+ 0);
+ }
} else if (anchor_alignment == TrayBubbleView::ANCHOR_ALIGNMENT_LEFT) {
- rect.Inset(0, 0, kBubblePaddingVerticalSide + 4,
- kBubblePaddingVerticalBottom);
+ if (!ash::switches::UseAlternateShelfLayout()) {
+ rect.Inset(0, 0, kPaddingFromInnerEdgeOfLauncherVerticalAlignment + 5,
+ kPaddingFromBottomOfScreenVerticalAlignment);
+ } else {
+ rect.Inset(0, 0, kAlternateLayoutBubblePaddingVerticalSide + 4,
+ kAlternateLayoutBubblePaddingVerticalBottom);
+ }
} else {
- rect.Inset(kBubblePaddingVerticalSide, 0, 0,
- kBubblePaddingVerticalBottom);
+ if (!ash::switches::UseAlternateShelfLayout()) {
+ rect.Inset(kPaddingFromInnerEdgeOfLauncherVerticalAlignment + 1,
+ 0, 0, kPaddingFromBottomOfScreenVerticalAlignment);
+ } else {
+ rect.Inset(kAlternateLayoutBubblePaddingVerticalSide, 0, 0,
+ kAlternateLayoutBubblePaddingVerticalBottom);
+ }
}
} else if (anchor_type == TrayBubbleView::ANCHOR_TYPE_BUBBLE) {
// Invert the offsets to align with the bubble below.
- int vertical_alignment = 0;
- int horizontal_alignment = kBubblePaddingVerticalBottom;
+ // Note that with the alternate shelf layout the tips are not shown and
+ // the offsets for left and right alignment do not need to be applied.
+ int vertical_alignment = ash::switches::UseAlternateShelfLayout() ?
+ 0 :
+ kPaddingFromInnerEdgeOfLauncherVerticalAlignment;
+ int horizontal_alignment = ash::switches::UseAlternateShelfLayout() ?
+ kAlternateLayoutBubblePaddingVerticalBottom :
+ kPaddingFromBottomOfScreenVerticalAlignment;
if (anchor_alignment == TrayBubbleView::ANCHOR_ALIGNMENT_LEFT)
rect.Inset(vertical_alignment, 0, 0, horizontal_alignment);
else if (anchor_alignment == TrayBubbleView::ANCHOR_ALIGNMENT_RIGHT)
@@ -505,7 +600,7 @@
void TrayBackgroundView::SetDrawBackgroundAsActive(bool visible) {
draw_background_as_active_ = visible;
- if (!background_)
+ if (!background_ || !switches::UseAlternateShelfLayout())
return;
// Do not change gradually, changing color between grey and blue is weird.
@@ -520,6 +615,17 @@
void TrayBackgroundView::UpdateBubbleViewArrow(
views::TrayBubbleView* bubble_view) {
+ if (switches::UseAlternateShelfLayout())
+ return;
+
+ aura::Window* root_window =
+ bubble_view->GetWidget()->GetNativeView()->GetRootWindow();
+ ash::internal::ShelfLayoutManager* shelf =
+ ShelfLayoutManager::ForShelf(root_window);
+ bubble_view->SetArrowPaintType(
+ (shelf && shelf->IsVisible()) ?
+ views::BubbleBorder::PAINT_NORMAL :
+ views::BubbleBorder::PAINT_TRANSPARENT);
}
} // namespace internal
« no previous file with comments | « ash/system/tray/system_tray.cc ('k') | ash/system/tray/tray_constants.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698