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

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

Issue 641683003: C++11 override style change for athena (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: Created 6 years, 1 month 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
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/athena_start_page_view.h" 5 #include "athena/home/athena_start_page_view.h"
6 6
7 #include "athena/home/home_card_constants.h" 7 #include "athena/home/home_card_constants.h"
8 #include "athena/system/public/system_ui.h" 8 #include "athena/system/public/system_ui.h"
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 canvas.DrawCircle( 65 canvas.DrawCircle(
66 gfx::Point(kIconSize / 2, kIconSize / 2), kIconSize / 2, paint); 66 gfx::Point(kIconSize / 2, kIconSize / 2), kIconSize / 2, paint);
67 67
68 scoped_ptr<gfx::ImageSkia> image( 68 scoped_ptr<gfx::ImageSkia> image(
69 new gfx::ImageSkia(canvas.ExtractImageRep())); 69 new gfx::ImageSkia(canvas.ExtractImageRep()));
70 SetImage(STATE_NORMAL, image.get()); 70 SetImage(STATE_NORMAL, image.get());
71 } 71 }
72 72
73 private: 73 private:
74 // views::ButtonListener: 74 // views::ButtonListener:
75 virtual void ButtonPressed(views::Button* sender, 75 void ButtonPressed(views::Button* sender,
76 const ui::Event& event) override { 76 const ui::Event& event) override {
77 // Do nothing: remove these place holders. 77 // Do nothing: remove these place holders.
78 } 78 }
79 79
80 DISALLOW_COPY_AND_ASSIGN(PlaceHolderButton); 80 DISALLOW_COPY_AND_ASSIGN(PlaceHolderButton);
81 }; 81 };
82 82
83 class AppIconButton : public views::ImageButton, 83 class AppIconButton : public views::ImageButton,
84 public views::ButtonListener { 84 public views::ButtonListener {
85 public: 85 public:
86 explicit AppIconButton(app_list::AppListItem* item) 86 explicit AppIconButton(app_list::AppListItem* item)
87 : ImageButton(this), item_(nullptr) { 87 : ImageButton(this), item_(nullptr) {
88 SetItem(item); 88 SetItem(item);
89 } 89 }
90 90
91 void SetItem(app_list::AppListItem* item) { 91 void SetItem(app_list::AppListItem* item) {
92 item_ = item; 92 item_ = item;
93 // TODO(mukai): icon should be resized. 93 // TODO(mukai): icon should be resized.
94 SetImage(STATE_NORMAL, &item->icon()); 94 SetImage(STATE_NORMAL, &item->icon());
95 } 95 }
96 96
97 private: 97 private:
98 // views::ButtonListener: 98 // views::ButtonListener:
99 virtual void ButtonPressed(views::Button* sender, 99 void ButtonPressed(views::Button* sender,
100 const ui::Event& event) override { 100 const ui::Event& event) override {
101 DCHECK_EQ(sender, this); 101 DCHECK_EQ(sender, this);
102 item_->Activate(event.flags()); 102 item_->Activate(event.flags());
103 } 103 }
104 104
105 app_list::AppListItem* item_; 105 app_list::AppListItem* item_;
106 106
107 DISALLOW_COPY_AND_ASSIGN(AppIconButton); 107 DISALLOW_COPY_AND_ASSIGN(AppIconButton);
108 }; 108 };
109 109
110 // The background to paint the round rectangle of the view area. 110 // The background to paint the round rectangle of the view area.
111 class RoundRectBackground : public views::Background { 111 class RoundRectBackground : public views::Background {
112 public: 112 public:
113 RoundRectBackground(SkColor color, int corner_radius) 113 RoundRectBackground(SkColor color, int corner_radius)
114 : color_(color), 114 : color_(color),
115 corner_radius_(corner_radius) {} 115 corner_radius_(corner_radius) {}
116 virtual ~RoundRectBackground() {} 116 ~RoundRectBackground() override {}
117 117
118 private: 118 private:
119 // views::Background: 119 // views::Background:
120 virtual void Paint(gfx::Canvas* canvas, views::View* view) const override { 120 void Paint(gfx::Canvas* canvas, views::View* view) const override {
121 SkPaint paint; 121 SkPaint paint;
122 paint.setStyle(SkPaint::kFill_Style); 122 paint.setStyle(SkPaint::kFill_Style);
123 paint.setColor(color_); 123 paint.setColor(color_);
124 canvas->DrawRoundRect(view->GetContentsBounds(), corner_radius_, paint); 124 canvas->DrawRoundRect(view->GetContentsBounds(), corner_radius_, paint);
125 } 125 }
126 126
127 SkColor color_; 127 SkColor color_;
128 int corner_radius_; 128 int corner_radius_;
129 129
130 DISALLOW_COPY_AND_ASSIGN(RoundRectBackground); 130 DISALLOW_COPY_AND_ASSIGN(RoundRectBackground);
131 }; 131 };
132 132
133 class SearchBoxContainer : public views::View { 133 class SearchBoxContainer : public views::View {
134 public: 134 public:
135 explicit SearchBoxContainer(app_list::SearchBoxView* search_box) 135 explicit SearchBoxContainer(app_list::SearchBoxView* search_box)
136 : search_box_(search_box) { 136 : search_box_(search_box) {
137 search_box->set_background( 137 search_box->set_background(
138 new RoundRectBackground(SK_ColorWHITE, kSearchBoxCornerRadius)); 138 new RoundRectBackground(SK_ColorWHITE, kSearchBoxCornerRadius));
139 search_box->SetBorder(views::Border::CreateBorderPainter( 139 search_box->SetBorder(views::Border::CreateBorderPainter(
140 new views::RoundRectPainter(SK_ColorGRAY, kSearchBoxCornerRadius), 140 new views::RoundRectPainter(SK_ColorGRAY, kSearchBoxCornerRadius),
141 gfx::Insets(kSearchBoxBorderWidth, kSearchBoxBorderWidth, 141 gfx::Insets(kSearchBoxBorderWidth, kSearchBoxBorderWidth,
142 kSearchBoxBorderWidth, kSearchBoxBorderWidth))); 142 kSearchBoxBorderWidth, kSearchBoxBorderWidth)));
143 SetLayoutManager(new views::FillLayout()); 143 SetLayoutManager(new views::FillLayout());
144 AddChildView(search_box_); 144 AddChildView(search_box_);
145 } 145 }
146 virtual ~SearchBoxContainer() {} 146 ~SearchBoxContainer() override {}
147 147
148 private: 148 private:
149 // views::View: 149 // views::View:
150 virtual gfx::Size GetPreferredSize() const override { 150 gfx::Size GetPreferredSize() const override {
151 return gfx::Size(kSearchBoxWidth, kSearchBoxHeight); 151 return gfx::Size(kSearchBoxWidth, kSearchBoxHeight);
152 } 152 }
153 153
154 // Owned by the views hierarchy. 154 // Owned by the views hierarchy.
155 app_list::SearchBoxView* search_box_; 155 app_list::SearchBoxView* search_box_;
156 156
157 DISALLOW_COPY_AND_ASSIGN(SearchBoxContainer); 157 DISALLOW_COPY_AND_ASSIGN(SearchBoxContainer);
158 }; 158 };
159 159
160 } // namespace 160 } // namespace
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after
486 app_list::AppListItem* item) { 486 app_list::AppListItem* item) {
487 UpdateAppIcons(); 487 UpdateAppIcons();
488 } 488 }
489 489
490 // static 490 // static
491 size_t AthenaStartPageView::GetMaxIconNumForTest() { 491 size_t AthenaStartPageView::GetMaxIconNumForTest() {
492 return kMaxIconNum; 492 return kMaxIconNum;
493 } 493 }
494 494
495 } // namespace athena 495 } // namespace athena
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698