| OLD | NEW |
| 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/menu_button.h" | 5 #include "ui/views/controls/button/menu_button.h" |
| 6 | 6 |
| 7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
| 8 #include "ui/accessibility/ax_view_state.h" | 8 #include "ui/accessibility/ax_view_state.h" |
| 9 #include "ui/base/dragdrop/drag_drop_types.h" | 9 #include "ui/base/dragdrop/drag_drop_types.h" |
| 10 #include "ui/base/l10n/l10n_util.h" | 10 #include "ui/base/l10n/l10n_util.h" |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 menu_closed_time_ = TimeTicks::Now(); | 138 menu_closed_time_ = TimeTicks::Now(); |
| 139 | 139 |
| 140 // We must return false here so that the RootView does not get stuck | 140 // We must return false here so that the RootView does not get stuck |
| 141 // sending all mouse pressed events to us instead of the appropriate | 141 // sending all mouse pressed events to us instead of the appropriate |
| 142 // target. | 142 // target. |
| 143 return false; | 143 return false; |
| 144 } | 144 } |
| 145 return true; | 145 return true; |
| 146 } | 146 } |
| 147 | 147 |
| 148 void MenuButton::WillNotActivate() { |
| 149 if (listener_) { |
| 150 listener_->OnMenuButtonReleasedWithoutClick(this); |
| 151 } |
| 152 } |
| 153 |
| 148 void MenuButton::OnPaint(gfx::Canvas* canvas) { | 154 void MenuButton::OnPaint(gfx::Canvas* canvas) { |
| 149 LabelButton::OnPaint(canvas); | 155 LabelButton::OnPaint(canvas); |
| 150 | 156 |
| 151 if (show_menu_marker_) | 157 if (show_menu_marker_) |
| 152 PaintMenuMarker(canvas); | 158 PaintMenuMarker(canvas); |
| 153 } | 159 } |
| 154 | 160 |
| 155 //////////////////////////////////////////////////////////////////////////////// | 161 //////////////////////////////////////////////////////////////////////////////// |
| 156 // | 162 // |
| 157 // MenuButton - Events | 163 // MenuButton - Events |
| (...skipping 24 matching lines...) Expand all Loading... |
| 182 return Activate(); | 188 return Activate(); |
| 183 } | 189 } |
| 184 return true; | 190 return true; |
| 185 } | 191 } |
| 186 | 192 |
| 187 void MenuButton::OnMouseReleased(const ui::MouseEvent& event) { | 193 void MenuButton::OnMouseReleased(const ui::MouseEvent& event) { |
| 188 if (state() != STATE_DISABLED && ShouldEnterPushedState(event) && | 194 if (state() != STATE_DISABLED && ShouldEnterPushedState(event) && |
| 189 HitTestPoint(event.location()) && !InDrag()) { | 195 HitTestPoint(event.location()) && !InDrag()) { |
| 190 Activate(); | 196 Activate(); |
| 191 } else { | 197 } else { |
| 198 WillNotActivate(); |
| 192 LabelButton::OnMouseReleased(event); | 199 LabelButton::OnMouseReleased(event); |
| 193 } | 200 } |
| 194 } | 201 } |
| 195 | 202 |
| 196 void MenuButton::OnMouseEntered(const ui::MouseEvent& event) { | 203 void MenuButton::OnMouseEntered(const ui::MouseEvent& event) { |
| 197 if (pressed_lock_count_ == 0) // Ignore mouse movement if state is locked. | 204 if (pressed_lock_count_ == 0) // Ignore mouse movement if state is locked. |
| 198 LabelButton::OnMouseEntered(event); | 205 LabelButton::OnMouseEntered(event); |
| 199 } | 206 } |
| 200 | 207 |
| 201 void MenuButton::OnMouseExited(const ui::MouseEvent& event) { | 208 void MenuButton::OnMouseExited(const ui::MouseEvent& event) { |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 351 if (!GetWidget()) { | 358 if (!GetWidget()) { |
| 352 NOTREACHED(); | 359 NOTREACHED(); |
| 353 return 0; | 360 return 0; |
| 354 } | 361 } |
| 355 | 362 |
| 356 gfx::Rect monitor_bounds = GetWidget()->GetWorkAreaBoundsInScreen(); | 363 gfx::Rect monitor_bounds = GetWidget()->GetWorkAreaBoundsInScreen(); |
| 357 return monitor_bounds.right() - 1; | 364 return monitor_bounds.right() - 1; |
| 358 } | 365 } |
| 359 | 366 |
| 360 } // namespace views | 367 } // namespace views |
| OLD | NEW |