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

Side by Side Diff: ui/views/controls/button/custom_button.cc

Issue 1569113002: MacViews: Style BUTTON_STYLE buttons using the "modern" UI (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix desktop linux weirdness Created 4 years, 8 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/controls/button/custom_button.h" 5 #include "ui/views/controls/button/custom_button.h"
6 6
7 #include "ui/accessibility/ax_view_state.h" 7 #include "ui/accessibility/ax_view_state.h"
8 #include "ui/base/material_design/material_design_controller.h" 8 #include "ui/base/material_design/material_design_controller.h"
9 #include "ui/events/event.h" 9 #include "ui/events/event.h"
10 #include "ui/events/event_utils.h" 10 #include "ui/events/event_utils.h"
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 // CustomButton, public: 73 // CustomButton, public:
74 74
75 // static 75 // static
76 const char CustomButton::kViewClassName[] = "CustomButton"; 76 const char CustomButton::kViewClassName[] = "CustomButton";
77 77
78 // static 78 // static
79 const CustomButton* CustomButton::AsCustomButton(const views::View* view) { 79 const CustomButton* CustomButton::AsCustomButton(const views::View* view) {
80 return AsCustomButton(const_cast<views::View*>(view)); 80 return AsCustomButton(const_cast<views::View*>(view));
81 } 81 }
82 82
83 // static
83 CustomButton* CustomButton::AsCustomButton(views::View* view) { 84 CustomButton* CustomButton::AsCustomButton(views::View* view) {
84 if (view) { 85 if (view) {
85 const char* classname = view->GetClassName(); 86 const char* classname = view->GetClassName();
86 if (!strcmp(classname, Checkbox::kViewClassName) || 87 if (!strcmp(classname, Checkbox::kViewClassName) ||
87 !strcmp(classname, CustomButton::kViewClassName) || 88 !strcmp(classname, CustomButton::kViewClassName) ||
88 !strcmp(classname, ImageButton::kViewClassName) || 89 !strcmp(classname, ImageButton::kViewClassName) ||
89 !strcmp(classname, LabelButton::kViewClassName) || 90 !strcmp(classname, LabelButton::kViewClassName) ||
90 !strcmp(classname, RadioButton::kViewClassName) || 91 !strcmp(classname, RadioButton::kViewClassName) ||
91 !strcmp(classname, MenuButton::kViewClassName)) { 92 !strcmp(classname, MenuButton::kViewClassName)) {
92 return static_cast<CustomButton*>(view); 93 return static_cast<CustomButton*>(view);
93 } 94 }
94 } 95 }
95 return NULL; 96 return nullptr;
97 }
98
99 // static
100 const LabelButton* CustomButton::AsLabelButton(const views::View* view) {
101 return AsLabelButton(const_cast<views::View*>(view));
102 }
103
104 // static
105 LabelButton* CustomButton::AsLabelButton(views::View* view) {
106 if (view) {
107 const char* classname = view->GetClassName();
108 if (!strcmp(classname, Checkbox::kViewClassName) ||
Elly Fong-Jones 2016/04/05 16:43:25 This seems a little weird... if anyone adds anothe
tapted 2016/04/06 12:08:33 Yeah I agree. However, this is the typical approac
109 !strcmp(classname, LabelButton::kViewClassName) ||
110 !strcmp(classname, RadioButton::kViewClassName) ||
111 !strcmp(classname, MenuButton::kViewClassName)) {
112 return static_cast<LabelButton*>(view);
113 }
114 }
115 return nullptr;
96 } 116 }
97 117
98 CustomButton::~CustomButton() {} 118 CustomButton::~CustomButton() {}
99 119
100 void CustomButton::SetState(ButtonState state) { 120 void CustomButton::SetState(ButtonState state) {
101 if (state == state_) 121 if (state == state_)
102 return; 122 return;
103 123
104 if (animate_on_state_change_ && 124 if (animate_on_state_change_ &&
105 (!is_throbbing_ || !hover_animation_.is_animating())) { 125 (!is_throbbing_ || !hover_animation_.is_animating())) {
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 Button::NotifyClick(event); 518 Button::NotifyClick(event);
499 } 519 }
500 520
501 void CustomButton::OnClickCanceled(const ui::Event& event) { 521 void CustomButton::OnClickCanceled(const ui::Event& event) {
502 if (ink_drop_delegate()) 522 if (ink_drop_delegate())
503 ink_drop_delegate()->OnAction(views::InkDropState::HIDDEN); 523 ink_drop_delegate()->OnAction(views::InkDropState::HIDDEN);
504 Button::OnClickCanceled(event); 524 Button::OnClickCanceled(event);
505 } 525 }
506 526
507 } // namespace views 527 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698