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

Side by Side Diff: ash/shelf/overflow_button.cc

Issue 229453005: Shelf Cleanup AlternateShelfLayout P1 Attempt 3 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 8 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
« no previous file with comments | « ash/shelf/overflow_bubble_view.cc ('k') | ash/shelf/shelf_button.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "ash/shelf/overflow_button.h" 5 #include "ash/shelf/overflow_button.h"
6 6
7 #include "ash/ash_switches.h" 7 #include "ash/ash_switches.h"
8 #include "ash/shelf/shelf_layout_manager.h" 8 #include "ash/shelf/shelf_layout_manager.h"
9 #include "ash/shelf/shelf_widget.h" 9 #include "ash/shelf/shelf_widget.h"
10 #include "grit/ash_resources.h" 10 #include "grit/ash_resources.h"
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 path.addRoundRect(gfx::RectToSkRect(rect), radius, radius); 81 path.addRoundRect(gfx::RectToSkRect(rect), radius, radius);
82 canvas->DrawPath(path, paint); 82 canvas->DrawPath(path, paint);
83 } 83 }
84 84
85 void OverflowButton::OnPaint(gfx::Canvas* canvas) { 85 void OverflowButton::OnPaint(gfx::Canvas* canvas) {
86 ShelfLayoutManager* layout_manager = 86 ShelfLayoutManager* layout_manager =
87 ShelfLayoutManager::ForShelf(GetWidget()->GetNativeView()); 87 ShelfLayoutManager::ForShelf(GetWidget()->GetNativeView());
88 ShelfAlignment alignment = layout_manager->GetAlignment(); 88 ShelfAlignment alignment = layout_manager->GetAlignment();
89 89
90 gfx::Rect bounds(GetContentsBounds()); 90 gfx::Rect bounds(GetContentsBounds());
91 if (ash::switches::UseAlternateShelfLayout()) { 91 ResourceBundle& rb = ResourceBundle::GetSharedInstance();
92 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); 92 int background_image_id = 0;
93 int background_image_id = 0; 93 if (layout_manager->shelf_widget()->shelf()->IsShowingOverflowBubble())
94 if (layout_manager->shelf_widget()->shelf()->IsShowingOverflowBubble()) 94 background_image_id = IDR_AURA_NOTIFICATION_BACKGROUND_PRESSED;
95 background_image_id = IDR_AURA_NOTIFICATION_BACKGROUND_PRESSED; 95 else if(layout_manager->shelf_widget()->GetDimsShelf())
96 else if(layout_manager->shelf_widget()->GetDimsShelf()) 96 background_image_id = IDR_AURA_NOTIFICATION_BACKGROUND_ON_BLACK;
97 background_image_id = IDR_AURA_NOTIFICATION_BACKGROUND_ON_BLACK; 97 else
98 else 98 background_image_id = IDR_AURA_NOTIFICATION_BACKGROUND_NORMAL;
99 background_image_id = IDR_AURA_NOTIFICATION_BACKGROUND_NORMAL;
100 99
101 const gfx::ImageSkia* background = 100 const gfx::ImageSkia* background =
102 rb.GetImageNamed(background_image_id).ToImageSkia(); 101 rb.GetImageNamed(background_image_id).ToImageSkia();
103 if (alignment == SHELF_ALIGNMENT_LEFT) { 102 if (alignment == SHELF_ALIGNMENT_LEFT) {
104 bounds = gfx::Rect( 103 bounds = gfx::Rect(
105 bounds.right() - background->width() - 104 bounds.right() - background->width() -
106 ShelfLayoutManager::kShelfItemInset, 105 ShelfLayoutManager::kShelfItemInset,
107 bounds.y() + (bounds.height() - background->height()) / 2, 106 bounds.y() + (bounds.height() - background->height()) / 2,
108 background->width(), background->height()); 107 background->width(), background->height());
109 } else if (alignment == SHELF_ALIGNMENT_RIGHT) { 108 } else if (alignment == SHELF_ALIGNMENT_RIGHT) {
110 bounds = gfx::Rect( 109 bounds = gfx::Rect(
111 bounds.x() + ShelfLayoutManager::kShelfItemInset, 110 bounds.x() + ShelfLayoutManager::kShelfItemInset,
112 bounds.y() + (bounds.height() - background->height()) / 2, 111 bounds.y() + (bounds.height() - background->height()) / 2,
113 background->width(), background->height()); 112 background->width(), background->height());
114 } else {
115 bounds = gfx::Rect(
116 bounds.x() + (bounds.width() - background->width()) / 2,
117 bounds.y() + ShelfLayoutManager::kShelfItemInset,
118 background->width(), background->height());
119 }
120 canvas->DrawImageInt(*background, bounds.x(), bounds.y());
121 } else { 113 } else {
122 if (alignment == SHELF_ALIGNMENT_BOTTOM) { 114 bounds = gfx::Rect(
123 bounds = gfx::Rect( 115 bounds.x() + (bounds.width() - background->width()) / 2,
124 bounds.x() + ((bounds.width() - kButtonHoverSize) / 2) - 1, 116 bounds.y() + ShelfLayoutManager::kShelfItemInset,
125 bounds.y() + kBackgroundOffset - 1, 117 background->width(), background->height());
126 kButtonHoverSize, kButtonHoverSize);
127 } else {
128 bounds = gfx::Rect(
129 bounds.x() + kBackgroundOffset -1,
130 bounds.y() + ((bounds.height() - kButtonHoverSize) / 2) -1,
131 kButtonHoverSize, kButtonHoverSize);
132 }
133 if (hover_animation_->is_animating()) {
134 PaintBackground(
135 canvas,
136 kButtonHoverAlpha * hover_animation_->GetCurrentValue());
137 } else if (state() == STATE_HOVERED || state() == STATE_PRESSED) {
138 PaintBackground(canvas, kButtonHoverAlpha);
139 }
140 } 118 }
119 canvas->DrawImageInt(*background, bounds.x(), bounds.y());
141 120
142 if (height() < kButtonHoverSize) 121 if (height() < kButtonHoverSize)
143 return; 122 return;
144 123
145 const gfx::ImageSkia* image = NULL; 124 const gfx::ImageSkia* image = NULL;
146 125
147 switch(alignment) { 126 switch(alignment) {
148 case SHELF_ALIGNMENT_LEFT: 127 case SHELF_ALIGNMENT_LEFT:
149 if (left_image_.isNull()) { 128 if (left_image_.isNull()) {
150 left_image_ = gfx::ImageSkiaOperations::CreateRotatedImage( 129 left_image_ = gfx::ImageSkiaOperations::CreateRotatedImage(
(...skipping 12 matching lines...) Expand all
163 image = bottom_image_; 142 image = bottom_image_;
164 break; 143 break;
165 } 144 }
166 145
167 canvas->DrawImageInt(*image, 146 canvas->DrawImageInt(*image,
168 bounds.x() + ((bounds.width() - image->width()) / 2), 147 bounds.x() + ((bounds.width() - image->width()) / 2),
169 bounds.y() + ((bounds.height() - image->height()) / 2)); 148 bounds.y() + ((bounds.height() - image->height()) / 2));
170 } 149 }
171 150
172 } // namespace ash 151 } // namespace ash
OLDNEW
« no previous file with comments | « ash/shelf/overflow_bubble_view.cc ('k') | ash/shelf/shelf_button.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698