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

Unified 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, 3 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 side-by-side diff with in-line comments
Download patch
Index: ui/views/examples/throbber_example.cc
diff --git a/ui/views/examples/throbber_example.cc b/ui/views/examples/throbber_example.cc
index 5a1981219c1403c449b40365149ab680ebf0d232..5fda5921c20c7269981d91f2bd03881cc0473719 100644
--- a/ui/views/examples/throbber_example.cc
+++ b/ui/views/examples/throbber_example.cc
@@ -16,25 +16,43 @@ namespace {
class ThrobberView : public View {
public:
- ThrobberView() : throbber_(new Throbber()) {
+ ThrobberView() : throbber_(new Throbber()), is_checked_(false) {
AddChildView(throbber_);
throbber_->Start();
}
+ // View implementation.
tdanderson 2016/09/19 23:32:27 nit: Just "// View:"
yiyix 2016/09/21 17:10:48 Done.
gfx::Size GetPreferredSize() const override {
return gfx::Size(width(), height());
}
void Layout() override {
- int diameter = 64;
+ int diameter = 16;
throbber_->SetBounds((width() - diameter) / 2,
(height() - diameter) / 2,
diameter, diameter);
SizeToPreferredSize();
}
+ bool OnMousePressed(const ui::MouseEvent& event) override {
+ if (GetEventHandlerForPoint(event.location()) == throbber_) {
+ if (is_checked_) {
+ throbber_->Start();
+ throbber_->SetChecked(false);
+ is_checked_ = false;
+ } else {
+ throbber_->Stop();
+ throbber_->SetChecked(true);
+ is_checked_ = true;
tdanderson 2016/09/19 23:32:27 You can avoid duplicated code with: throbber->Set
yiyix 2016/09/21 17:10:48 Thanks, I thought about it, then i don't know how
+ }
+ return true;
+ }
+ return false;
+ }
+
private:
Throbber* throbber_;
+ bool is_checked_;
DISALLOW_COPY_AND_ASSIGN(ThrobberView);
};
« ui/gfx/vector_icons/check_circle.1x.icon ('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