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

Side by Side Diff: ui/views/examples/throbber_example.cc

Issue 2343603003: [Chrome OS MD] Implement accessibility detailed view for the MD Ash system menu (Closed)
Patch Set: address comments Created 4 years, 2 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
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/views/examples/throbber_example.h" 5 #include "ui/views/examples/throbber_example.h"
6 6
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "ui/views/controls/throbber.h" 8 #include "ui/views/controls/throbber.h"
9 #include "ui/views/layout/fill_layout.h" 9 #include "ui/views/layout/fill_layout.h"
10 #include "ui/views/view.h" 10 #include "ui/views/view.h"
11 11
12 namespace views { 12 namespace views {
13 namespace examples { 13 namespace examples {
14 14
15 namespace { 15 namespace {
16 16
17 class ThrobberView : public View { 17 class ThrobberView : public View {
18 public: 18 public:
19 ThrobberView() : throbber_(new Throbber()) { 19 ThrobberView() : throbber_(new Throbber()), is_checked_(false) {
20 AddChildView(throbber_); 20 AddChildView(throbber_);
21 throbber_->Start(); 21 throbber_->Start();
22 } 22 }
23 23
24 // View::
24 gfx::Size GetPreferredSize() const override { 25 gfx::Size GetPreferredSize() const override {
25 return gfx::Size(width(), height()); 26 return gfx::Size(width(), height());
26 } 27 }
27 28
28 void Layout() override { 29 void Layout() override {
29 int diameter = 64; 30 int diameter = 16;
30 throbber_->SetBounds((width() - diameter) / 2, 31 throbber_->SetBounds((width() - diameter) / 2,
31 (height() - diameter) / 2, 32 (height() - diameter) / 2,
32 diameter, diameter); 33 diameter, diameter);
33 SizeToPreferredSize(); 34 SizeToPreferredSize();
34 } 35 }
35 36
37 bool OnMousePressed(const ui::MouseEvent& event) override {
38 if (GetEventHandlerForPoint(event.location()) == throbber_) {
39
40 if (is_checked_)
41 throbber_->Start();
42 else
43 throbber_->Stop();
44 throbber_->SetChecked(!is_checked_);
45 is_checked_ = !is_checked_;
46 return true;
47 }
48 return false;
49 }
50
36 private: 51 private:
37 Throbber* throbber_; 52 Throbber* throbber_;
53 bool is_checked_;
38 54
39 DISALLOW_COPY_AND_ASSIGN(ThrobberView); 55 DISALLOW_COPY_AND_ASSIGN(ThrobberView);
40 }; 56 };
41 57
42 } // namespace 58 } // namespace
43 59
44 ThrobberExample::ThrobberExample() : ExampleBase("Throbber") { 60 ThrobberExample::ThrobberExample() : ExampleBase("Throbber") {
45 } 61 }
46 62
47 ThrobberExample::~ThrobberExample() { 63 ThrobberExample::~ThrobberExample() {
48 } 64 }
49 65
50 void ThrobberExample::CreateExampleView(View* container) { 66 void ThrobberExample::CreateExampleView(View* container) {
51 container->SetLayoutManager(new FillLayout()); 67 container->SetLayoutManager(new FillLayout());
52 container->AddChildView(new ThrobberView()); 68 container->AddChildView(new ThrobberView());
53 } 69 }
54 70
55 } // namespace examples 71 } // namespace examples
56 } // namespace views 72 } // namespace views
OLDNEW
« ash/common/system/tray_accessibility.cc ('K') | « ui/gfx/vector_icons/check_circle.1x.icon ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698