OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "views/controls/native_control_wayland.h" |
| 6 |
| 7 #include "base/logging.h" |
| 8 #include "ui/base/accessibility/accessibility_types.h" |
| 9 #include "ui/wayland/wayland_widget.h" |
| 10 #include "views/focus/focus_manager.h" |
| 11 #include "views/widget/widget.h" |
| 12 |
| 13 |
| 14 namespace views { |
| 15 |
| 16 #if defined(TOUCH_UI) |
| 17 void NativeControlWayland::FakeNativeMouseEvent(const MouseEvent& mouseev) { |
| 18 NOTIMPLEMENTED(); |
| 19 } |
| 20 #endif // defined(TOUCH_UI) |
| 21 |
| 22 NativeControlWayland::NativeControlWayland() { |
| 23 } |
| 24 |
| 25 NativeControlWayland::~NativeControlWayland() { |
| 26 } |
| 27 |
| 28 //////////////////////////////////////////////////////////////////////////////// |
| 29 // NativeControlWayland, View overrides: |
| 30 |
| 31 void NativeControlWayland::OnEnabledChanged() { |
| 32 View::OnEnabledChanged(); |
| 33 NOTIMPLEMENTED(); |
| 34 } |
| 35 |
| 36 void NativeControlWayland::ViewHierarchyChanged(bool is_add, View* parent, |
| 37 View* child) { |
| 38 // Call the base class to hide the view if we're being removed. |
| 39 NativeViewHost::ViewHierarchyChanged(is_add, parent, child); |
| 40 |
| 41 if (!is_add && child == this && native_view()) { |
| 42 Detach(); |
| 43 } else if (is_add && GetWidget() && !native_view()) { |
| 44 // Create the widget when we're added to a valid Widget. Many |
| 45 // controls need a parent widget to function properly. |
| 46 CreateNativeControl(); |
| 47 } |
| 48 } |
| 49 |
| 50 void NativeControlWayland::VisibilityChanged(View* starting_from, |
| 51 bool is_visible) { |
| 52 if (!is_visible) { |
| 53 if (native_view()) { |
| 54 // We destroy the child widget when we become invisible because of the |
| 55 // performance cost of maintaining widgets that aren't currently needed. |
| 56 Detach(); |
| 57 // Make sure that Detach destroyed the widget. |
| 58 DCHECK(!native_view()); |
| 59 } |
| 60 } else if (!native_view()) { |
| 61 if (GetWidget()) |
| 62 CreateNativeControl(); |
| 63 } else { |
| 64 // The view becomes visible after native control is created. |
| 65 // Layout now. |
| 66 Layout(); |
| 67 } |
| 68 } |
| 69 |
| 70 void NativeControlWayland::OnFocus() { |
| 71 DCHECK(native_view()); |
| 72 NOTIMPLEMENTED(); |
| 73 } |
| 74 |
| 75 #if defined(TOUCH_UI) |
| 76 bool NativeControlWayland::OnMousePressed(const MouseEvent& mouseev) { |
| 77 FakeNativeMouseEvent(mouseev); |
| 78 return true; |
| 79 } |
| 80 |
| 81 void NativeControlWayland::OnMouseReleased(const MouseEvent& mouseev) { |
| 82 FakeNativeMouseEvent(mouseev); |
| 83 } |
| 84 |
| 85 void NativeControlWayland::OnMouseMoved(const MouseEvent& mouseev) { |
| 86 FakeNativeMouseEvent(mouseev); |
| 87 } |
| 88 |
| 89 void NativeControlWayland::OnMouseEntered(const MouseEvent& mouseev) { |
| 90 FakeNativeMouseEvent(mouseev); |
| 91 } |
| 92 |
| 93 void NativeControlWayland::OnMouseExited(const MouseEvent& mouseev) { |
| 94 FakeNativeMouseEvent(mouseev); |
| 95 } |
| 96 #endif // defined(TOUCH_UI) |
| 97 |
| 98 void NativeControlWayland::NativeControlCreated( |
| 99 ui::WaylandWidget* native_control) { |
| 100 NOTIMPLEMENTED(); |
| 101 } |
| 102 |
| 103 } // namespace views |
OLD | NEW |