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

Side by Side Diff: athena/home/minimized_home.cc

Issue 464213006: Redesign the minimized home to follow the latest mock. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 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 | « athena/home/home_card_impl.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "athena/home/minimized_home.h" 5 #include "athena/home/minimized_home.h"
6 6
7 #include "athena/wm/public/window_manager.h" 7 #include "athena/wm/public/window_manager.h"
8 #include "ui/gfx/canvas.h"
8 #include "ui/views/background.h" 9 #include "ui/views/background.h"
9 #include "ui/views/layout/box_layout.h"
10 #include "ui/views/view.h" 10 #include "ui/views/view.h"
11 #include "ui/views/widget/widget.h"
12 11
13 namespace { 12 namespace {
14 13
15 const SkColor kDragHandleColorNormal = SK_ColorGRAY; 14 const int kDragHandleWidth = 112;
16 const SkColor kDragHandleColorHot = SK_ColorWHITE; 15 const int kDragHandleHeight = 2;
17 16
18 // The small white bar in the middle of the minimized view. Does not reach to 17 class MinimizedHomeBackground : public views::Background {
19 // events.
20 class SmallBarView : public views::View {
21 public: 18 public:
22 SmallBarView() : color_(SK_ColorTRANSPARENT) { 19 MinimizedHomeBackground() {}
23 SetColor(kDragHandleColorNormal); 20 virtual ~MinimizedHomeBackground() {}
21
22 private:
23 virtual void Paint(gfx::Canvas* canvas, views::View* view) const OVERRIDE {
24 gfx::Rect bounds = view->GetLocalBounds();
25 canvas->FillRect(bounds, SK_ColorBLACK);
26 canvas->FillRect(gfx::Rect((bounds.width() - kDragHandleWidth) / 2,
27 bounds.bottom() - kDragHandleHeight,
28 kDragHandleWidth,
29 kDragHandleHeight),
30 SK_ColorWHITE);
24 } 31 }
25 32
26 virtual ~SmallBarView() {} 33 DISALLOW_COPY_AND_ASSIGN(MinimizedHomeBackground);
27
28 void SetActive(bool active) {
29 SetColor(active ? kDragHandleColorHot : kDragHandleColorNormal);
30 }
31
32 private:
33 void SetColor(SkColor color) {
34 if (color_ == color)
35 return;
36 color_ = color;
37 set_background(views::Background::CreateSolidBackground(color_));
38 SchedulePaint();
39 }
40
41 // views::View
42 virtual gfx::Size GetPreferredSize() const OVERRIDE {
43 const int kDragHandleWidth = 80;
44 const int kDragHandleHeight = 4;
45 return gfx::Size(kDragHandleWidth, kDragHandleHeight);
46 }
47
48 SkColor color_;
49
50 DISALLOW_COPY_AND_ASSIGN(SmallBarView);
51 }; 34 };
52 35
53 // This View shows an instance of SmallBarView in the middle, and reacts to 36 // This View shows an instance of SmallBarView in the middle, and reacts to
54 // mouse and touch-gesture events. 37 // mouse and touch-gesture events.
55 class MinimizedHomeView : public views::View { 38 class MinimizedHomeView : public views::View {
56 public: 39 public:
57 MinimizedHomeView() 40 MinimizedHomeView() {
58 : bar_(new SmallBarView) { 41 set_background(new MinimizedHomeBackground());
59 set_background(views::Background::CreateSolidBackground(SK_ColorBLACK));
60 views::BoxLayout* layout =
61 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 2, 0);
62 layout->set_main_axis_alignment(
63 views::BoxLayout::MAIN_AXIS_ALIGNMENT_CENTER);
64 SetLayoutManager(layout);
65
66 AddChildView(bar_);
67 } 42 }
68 virtual ~MinimizedHomeView() {} 43 virtual ~MinimizedHomeView() {}
69 44
70 private: 45 private:
71 // TODO(mukai): unify mouse event handling to the HomeCardGestureManager.
72 // views::View: 46 // views::View:
73 virtual bool OnMousePressed(const ui::MouseEvent& event) OVERRIDE { 47 virtual bool OnMousePressed(const ui::MouseEvent& event) OVERRIDE {
74 if (event.IsLeftMouseButton() && event.GetClickCount() == 1) { 48 if (event.IsLeftMouseButton() && event.GetClickCount() == 1) {
75 bar_->SetActive(false);
76 athena::WindowManager::GetInstance()->ToggleOverview(); 49 athena::WindowManager::GetInstance()->ToggleOverview();
77 return true; 50 return true;
78 } 51 }
79 return false; 52 return false;
80 } 53 }
81 54
82 virtual void OnMouseEntered(const ui::MouseEvent& event) OVERRIDE {
83 bar_->SetActive(true);
84 }
85
86 virtual void OnMouseExited(const ui::MouseEvent& event) OVERRIDE {
87 bar_->SetActive(false);
88 }
89
90 SmallBarView* bar_;
91
92 DISALLOW_COPY_AND_ASSIGN(MinimizedHomeView); 55 DISALLOW_COPY_AND_ASSIGN(MinimizedHomeView);
93 }; 56 };
94 57
95 } // namespace 58 } // namespace
96 59
97 namespace athena { 60 namespace athena {
98 61
99 views::View* CreateMinimizedHome() { 62 views::View* CreateMinimizedHome() {
100 return new MinimizedHomeView(); 63 return new MinimizedHomeView();
101 } 64 }
102 65
103 } // namespace athena 66 } // namespace athena
OLDNEW
« no previous file with comments | « athena/home/home_card_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698