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

Side by Side Diff: ui/aura_shell/launcher/launcher_view.cc

Issue 8873036: Create a visible shelf and constrain window movement (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Cleanup Created 9 years 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "ui/aura_shell/launcher/launcher_view.h" 5 #include "ui/aura_shell/launcher/launcher_view.h"
6 6
7 #include "base/utf_string_conversions.h" 7 #include "base/utf_string_conversions.h"
8 #include "grit/ui_resources.h" 8 #include "grit/ui_resources.h"
9 #include "ui/aura/window.h" 9 #include "ui/aura/window.h"
10 #include "ui/aura_shell/launcher/app_launcher_button.h" 10 #include "ui/aura_shell/launcher/app_launcher_button.h"
11 #include "ui/aura_shell/launcher/launcher_model.h" 11 #include "ui/aura_shell/launcher/launcher_model.h"
12 #include "ui/aura_shell/launcher/tabbed_launcher_button.h" 12 #include "ui/aura_shell/launcher/tabbed_launcher_button.h"
13 #include "ui/aura_shell/launcher/view_model.h" 13 #include "ui/aura_shell/launcher/view_model.h"
14 #include "ui/aura_shell/launcher/view_model_utils.h" 14 #include "ui/aura_shell/launcher/view_model_utils.h"
15 #include "ui/aura_shell/shelf_layout_manager.h"
15 #include "ui/aura_shell/shell.h" 16 #include "ui/aura_shell/shell.h"
16 #include "ui/aura_shell/shell_delegate.h" 17 #include "ui/aura_shell/shell_delegate.h"
17 #include "ui/base/animation/animation.h" 18 #include "ui/base/animation/animation.h"
18 #include "ui/base/animation/throb_animation.h" 19 #include "ui/base/animation/throb_animation.h"
19 #include "ui/base/models/simple_menu_model.h" 20 #include "ui/base/models/simple_menu_model.h"
20 #include "ui/base/resource/resource_bundle.h" 21 #include "ui/base/resource/resource_bundle.h"
22 #include "ui/gfx/canvas.h"
21 #include "ui/gfx/compositor/layer.h" 23 #include "ui/gfx/compositor/layer.h"
22 #include "ui/gfx/image/image.h" 24 #include "ui/gfx/image/image.h"
23 #include "ui/views/animation/bounds_animator.h" 25 #include "ui/views/animation/bounds_animator.h"
24 #include "ui/views/controls/button/image_button.h" 26 #include "ui/views/controls/button/image_button.h"
25 #include "ui/views/controls/menu/menu_model_adapter.h" 27 #include "ui/views/controls/menu/menu_model_adapter.h"
26 #include "ui/views/controls/menu/menu_runner.h" 28 #include "ui/views/controls/menu/menu_runner.h"
29 #include "ui/views/painter.h"
27 #include "ui/views/widget/widget.h" 30 #include "ui/views/widget/widget.h"
28 31
29 using ui::Animation; 32 using ui::Animation;
30 using views::View; 33 using views::View;
31 34
32 namespace aura_shell { 35 namespace aura_shell {
33 namespace internal { 36 namespace internal {
34 37
35 // Padding between each view. 38 // Padding between each view.
36 static const int kHorizontalPadding = 12; 39 static const int kHorizontalPadding = 12;
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 view_->layer()->SetOpacity(1.0f); 163 view_->layer()->SetOpacity(1.0f);
161 view_->layer()->ScheduleDraw(); 164 view_->layer()->ScheduleDraw();
162 } 165 }
163 166
164 private: 167 private:
165 views::View* view_; 168 views::View* view_;
166 169
167 DISALLOW_COPY_AND_ASSIGN(FadeInAnimationDelegate); 170 DISALLOW_COPY_AND_ASSIGN(FadeInAnimationDelegate);
168 }; 171 };
169 172
173 // Used to draw the background of the shelf.
174 class ShelfPainter : public views::Painter {
175 public:
176 ShelfPainter() {
177 ResourceBundle& rb = ResourceBundle::GetSharedInstance();
178 image_ = *rb.GetImageNamed(IDR_AURA_LAUNCHER_BACKGROUND).ToSkBitmap();
179 }
180
181 virtual void Paint(int w, int h, gfx::Canvas* canvas) {
sky 2011/12/14 06:23:05 PVERRODE
DaveMoore 2011/12/14 17:03:19 Done.
182 canvas->TileImageInt(image_, 0, 0, w, h);
183 }
184
185 private:
186 SkBitmap image_;
187
188 DISALLOW_COPY_AND_ASSIGN(ShelfPainter);
189 };
190
191
170 } // namespace 192 } // namespace
171 193
172 // AnimationDelegate used when inserting a new item. This steadily decreased the 194 // AnimationDelegate used when inserting a new item. This steadily decreased the
173 // opacity of the layer as the animation progress. 195 // opacity of the layer as the animation progress.
174 class LauncherView::FadeOutAnimationDelegate : 196 class LauncherView::FadeOutAnimationDelegate :
175 public views::BoundsAnimator::OwnedAnimationDelegate { 197 public views::BoundsAnimator::OwnedAnimationDelegate {
176 public: 198 public:
177 FadeOutAnimationDelegate(LauncherView* host, views::View* view) 199 FadeOutAnimationDelegate(LauncherView* host, views::View* view)
178 : launcher_view_(host), 200 : launcher_view_(host),
179 view_(view) {} 201 view_(view) {}
180 virtual ~FadeOutAnimationDelegate() {} 202 virtual ~FadeOutAnimationDelegate() {}
181 203
182 // AnimationDelegate overrides: 204 // AnimationDelegate overrides:
183 virtual void AnimationProgressed(const Animation* animation) OVERRIDE { 205 virtual void AnimationProgressed(const Animation* animation) OVERRIDE {
184 view_->layer()->SetOpacity(1 - animation->GetCurrentValue()); 206 view_->layer()->SetOpacity(1 - animation->GetCurrentValue());
185 view_->layer()->ScheduleDraw(); 207 view_->layer()->ScheduleDraw();
186 } 208 }
187 virtual void AnimationEnded(const Animation* animation) OVERRIDE { 209 virtual void AnimationEnded(const Animation* animation) OVERRIDE {
188 launcher_view_->AnimateToIdealBounds(); 210 launcher_view_->AnimateToIdealBounds();
189 } 211 }
190 virtual void AnimationCanceled(const Animation* animation) OVERRIDE { 212 virtual void AnimationCanceled(const Animation* animation) OVERRIDE {
191 } 213 }
192 214
193 private: 215 private:
194 LauncherView* launcher_view_; 216 LauncherView* launcher_view_;
195 scoped_ptr<views::View> view_; 217 scoped_ptr<views::View> view_;
196 218
197 DISALLOW_COPY_AND_ASSIGN(FadeOutAnimationDelegate); 219 DISALLOW_COPY_AND_ASSIGN(FadeOutAnimationDelegate);
198 }; 220 };
199 221
sky 2011/12/14 06:23:05 remove this line
DaveMoore 2011/12/14 17:03:19 Done.
222
200 // AnimationDelegate used to trigger fading an element in. When an item is 223 // AnimationDelegate used to trigger fading an element in. When an item is
201 // inserted this delegate is attached to the animation that expands the size of 224 // inserted this delegate is attached to the animation that expands the size of
202 // the item. When done it kicks off another animation to fade the item in. 225 // the item. When done it kicks off another animation to fade the item in.
203 class LauncherView::StartFadeAnimationDelegate : 226 class LauncherView::StartFadeAnimationDelegate :
204 public views::BoundsAnimator::OwnedAnimationDelegate { 227 public views::BoundsAnimator::OwnedAnimationDelegate {
205 public: 228 public:
206 StartFadeAnimationDelegate(LauncherView* host, 229 StartFadeAnimationDelegate(LauncherView* host,
207 views::View* view) 230 views::View* view)
208 : launcher_view_(host), 231 : launcher_view_(host),
209 view_(view) {} 232 view_(view) {}
(...skipping 29 matching lines...) Expand all
239 bounds_animator_.reset(new views::BoundsAnimator(this)); 262 bounds_animator_.reset(new views::BoundsAnimator(this));
240 } 263 }
241 264
242 LauncherView::~LauncherView() { 265 LauncherView::~LauncherView() {
243 model_->RemoveObserver(this); 266 model_->RemoveObserver(this);
244 } 267 }
245 268
246 void LauncherView::Init() { 269 void LauncherView::Init() {
247 model_->AddObserver(this); 270 model_->AddObserver(this);
248 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); 271 ResourceBundle& rb = ResourceBundle::GetSharedInstance();
272
273 set_background(
274 views::Background::CreateBackgroundPainter(true, new ShelfPainter()));
249 new_browser_button_ = new FadeButton(this); 275 new_browser_button_ = new FadeButton(this);
250 new_browser_button_->SetImage( 276 new_browser_button_->SetImage(
251 views::CustomButton::BS_NORMAL, 277 views::CustomButton::BS_NORMAL,
252 rb.GetImageNamed(IDR_AURA_LAUNCHER_ICON_CHROME).ToSkBitmap()); 278 rb.GetImageNamed(IDR_AURA_LAUNCHER_ICON_CHROME).ToSkBitmap());
253 ConfigureChildView(new_browser_button_); 279 ConfigureChildView(new_browser_button_);
254 AddChildView(new_browser_button_); 280 AddChildView(new_browser_button_);
255 281
256 const LauncherItems& items(model_->items()); 282 const LauncherItems& items(model_->items());
257 for (LauncherItems::const_iterator i = items.begin(); i != items.end(); ++i) { 283 for (LauncherItems::const_iterator i = items.begin(); i != items.end(); ++i) {
258 views::View* child = CreateViewForItem(*i); 284 views::View* child = CreateViewForItem(*i);
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after
604 } else { 630 } else {
605 int view_index = view_model_->GetIndexOfView(sender); 631 int view_index = view_model_->GetIndexOfView(sender);
606 // May be -1 while in the process of animating closed. 632 // May be -1 while in the process of animating closed.
607 if (view_index != -1) 633 if (view_index != -1)
608 delegate->LauncherItemClicked(model_->items()[view_index]); 634 delegate->LauncherItemClicked(model_->items()[view_index]);
609 } 635 }
610 } 636 }
611 637
612 } // namespace internal 638 } // namespace internal
613 } // namespace aura_shell 639 } // namespace aura_shell
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698