| 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 "ui/views/test/test_views.h" | 5 #include "ui/views/test/test_views.h" |
| 6 | 6 |
| 7 #include "ui/events/event.h" | 7 #include "ui/events/event.h" |
| 8 #include "ui/views/widget/native_widget_private.h" | 8 #include "ui/views/widget/native_widget_private.h" |
| 9 #include "ui/views/widget/widget.h" | 9 #include "ui/views/widget/widget.h" |
| 10 | 10 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 | 28 |
| 29 gfx::Size StaticSizedView::GetMaximumSize() const { | 29 gfx::Size StaticSizedView::GetMaximumSize() const { |
| 30 return maximum_size_; | 30 return maximum_size_; |
| 31 } | 31 } |
| 32 | 32 |
| 33 ProportionallySizedView::ProportionallySizedView(int factor) | 33 ProportionallySizedView::ProportionallySizedView(int factor) |
| 34 : factor_(factor), preferred_width_(-1) {} | 34 : factor_(factor), preferred_width_(-1) {} |
| 35 | 35 |
| 36 ProportionallySizedView::~ProportionallySizedView() {} | 36 ProportionallySizedView::~ProportionallySizedView() {} |
| 37 | 37 |
| 38 void ProportionallySizedView::SetPreferredWidth(int width) { |
| 39 preferred_width_ = width; |
| 40 PreferredSizeChanged(); |
| 41 } |
| 42 |
| 38 int ProportionallySizedView::GetHeightForWidth(int w) const { | 43 int ProportionallySizedView::GetHeightForWidth(int w) const { |
| 39 return w * factor_; | 44 return w * factor_; |
| 40 } | 45 } |
| 41 | 46 |
| 42 gfx::Size ProportionallySizedView::GetPreferredSize() const { | 47 gfx::Size ProportionallySizedView::GetPreferredSize() const { |
| 43 if (preferred_width_ >= 0) | 48 if (preferred_width_ >= 0) |
| 44 return gfx::Size(preferred_width_, GetHeightForWidth(preferred_width_)); | 49 return gfx::Size(preferred_width_, GetHeightForWidth(preferred_width_)); |
| 45 return View::GetPreferredSize(); | 50 return View::GetPreferredSize(); |
| 46 } | 51 } |
| 47 | 52 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 } | 104 } |
| 100 | 105 |
| 101 void EventCountView::RecordEvent(ui::Event* event) { | 106 void EventCountView::RecordEvent(ui::Event* event) { |
| 102 ++event_count_[event->type()]; | 107 ++event_count_[event->type()]; |
| 103 last_flags_ = event->flags(); | 108 last_flags_ = event->flags(); |
| 104 if (handle_mode_ == CONSUME_EVENTS) | 109 if (handle_mode_ == CONSUME_EVENTS) |
| 105 event->SetHandled(); | 110 event->SetHandled(); |
| 106 } | 111 } |
| 107 | 112 |
| 108 } // namespace views | 113 } // namespace views |
| OLD | NEW |