Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "chrome/browser/ui/views/toolbar/toolbar_button.h" | 5 #include "chrome/browser/ui/views/toolbar/toolbar_button.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/location.h" | 8 #include "base/location.h" |
| 9 #include "base/single_thread_task_runner.h" | 9 #include "base/single_thread_task_runner.h" |
| 10 #include "base/thread_task_runner_handle.h" | 10 #include "base/thread_task_runner_handle.h" |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 144 if (IsTriggerableEvent(event)) | 144 if (IsTriggerableEvent(event)) |
| 145 show_menu_factory_.InvalidateWeakPtrs(); | 145 show_menu_factory_.InvalidateWeakPtrs(); |
| 146 | 146 |
| 147 if (!HitTestPoint(event.location())) | 147 if (!HitTestPoint(event.location())) |
| 148 ink_drop_animation_controller_->AnimateToState(views::InkDropState::HIDDEN); | 148 ink_drop_animation_controller_->AnimateToState(views::InkDropState::HIDDEN); |
| 149 } | 149 } |
| 150 | 150 |
| 151 void ToolbarButton::OnMouseCaptureLost() { | 151 void ToolbarButton::OnMouseCaptureLost() { |
| 152 } | 152 } |
| 153 | 153 |
| 154 void ToolbarButton::OnMouseEntered(const ui::MouseEvent& event) { | |
| 155 UpdateInkDropHoverState(); | |
| 156 } | |
| 157 | |
| 158 void ToolbarButton::OnMouseMoved(const ui::MouseEvent& event) { | |
| 159 UpdateInkDropHoverState(); | |
|
sadrul
2015/11/04 19:58:10
Is it not sufficient to update the state from ente
bruthig
2015/11/11 21:48:44
Removed.
| |
| 160 } | |
| 161 | |
| 154 void ToolbarButton::OnMouseExited(const ui::MouseEvent& event) { | 162 void ToolbarButton::OnMouseExited(const ui::MouseEvent& event) { |
| 163 UpdateInkDropHoverState(); | |
| 164 | |
| 155 // Starting a drag results in a MouseExited, we need to ignore it. | 165 // Starting a drag results in a MouseExited, we need to ignore it. |
| 156 // A right click release triggers an exit event. We want to | 166 // A right click release triggers an exit event. We want to |
| 157 // remain in a PUSHED state until the drop down menu closes. | 167 // remain in a PUSHED state until the drop down menu closes. |
| 158 if (state_ != STATE_DISABLED && !InDrag() && state_ != STATE_PRESSED) | 168 if (state_ != STATE_DISABLED && !InDrag() && state_ != STATE_PRESSED) |
| 159 SetState(STATE_NORMAL); | 169 SetState(STATE_NORMAL); |
| 160 } | 170 } |
| 161 | 171 |
| 162 void ToolbarButton::OnGestureEvent(ui::GestureEvent* event) { | 172 void ToolbarButton::OnGestureEvent(ui::GestureEvent* event) { |
| 163 if (menu_showing_) { | 173 if (menu_showing_) { |
| 164 // While dropdown menu is showing the button should not handle gestures. | 174 // While dropdown menu is showing the button should not handle gestures. |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 207 scoped_ptr<views::LabelButtonBorder> border = | 217 scoped_ptr<views::LabelButtonBorder> border = |
| 208 views::LabelButton::CreateDefaultBorder(); | 218 views::LabelButton::CreateDefaultBorder(); |
| 209 | 219 |
| 210 ui::ThemeProvider* provider = GetThemeProvider(); | 220 ui::ThemeProvider* provider = GetThemeProvider(); |
| 211 if (provider && provider->UsingSystemTheme()) | 221 if (provider && provider->UsingSystemTheme()) |
| 212 border->set_insets(GetLayoutInsets(TOOLBAR_BUTTON)); | 222 border->set_insets(GetLayoutInsets(TOOLBAR_BUTTON)); |
| 213 | 223 |
| 214 return border.Pass(); | 224 return border.Pass(); |
| 215 } | 225 } |
| 216 | 226 |
| 227 void ToolbarButton::OnEnabledChanged() { | |
| 228 UpdateInkDropHoverState(); | |
| 229 } | |
| 230 | |
| 217 void ToolbarButton::ShowContextMenuForView(View* source, | 231 void ToolbarButton::ShowContextMenuForView(View* source, |
| 218 const gfx::Point& point, | 232 const gfx::Point& point, |
| 219 ui::MenuSourceType source_type) { | 233 ui::MenuSourceType source_type) { |
| 220 if (!enabled()) | 234 if (!enabled()) |
| 221 return; | 235 return; |
| 222 | 236 |
| 223 show_menu_factory_.InvalidateWeakPtrs(); | 237 show_menu_factory_.InvalidateWeakPtrs(); |
| 224 ShowDropDownMenu(source_type); | 238 ShowDropDownMenu(source_type); |
| 225 } | 239 } |
| 226 | 240 |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 339 | 353 |
| 340 // Set the state back to normal after the drop down menu is closed. | 354 // Set the state back to normal after the drop down menu is closed. |
| 341 if (state_ != STATE_DISABLED) | 355 if (state_ != STATE_DISABLED) |
| 342 SetState(STATE_NORMAL); | 356 SetState(STATE_NORMAL); |
| 343 } | 357 } |
| 344 | 358 |
| 345 gfx::Point ToolbarButton::CalculateInkDropCenter() const { | 359 gfx::Point ToolbarButton::CalculateInkDropCenter() const { |
| 346 return GetLocalBounds().CenterPoint(); | 360 return GetLocalBounds().CenterPoint(); |
| 347 } | 361 } |
| 348 | 362 |
| 363 void ToolbarButton::UpdateInkDropHoverState() { | |
| 364 ink_drop_animation_controller_->SetHovered(enabled() && IsMouseHovered()); | |
| 365 } | |
| 366 | |
| 349 const char* ToolbarButton::GetClassName() const { | 367 const char* ToolbarButton::GetClassName() const { |
| 350 return "ToolbarButton"; | 368 return "ToolbarButton"; |
| 351 } | 369 } |
| OLD | NEW |