Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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 #ifndef UI_VIEWS_CONTROLS_NATIVE_NATIVE_VIEW_HOST_H_ | 5 #ifndef UI_VIEWS_CONTROLS_NATIVE_NATIVE_VIEW_HOST_H_ |
| 6 #define UI_VIEWS_CONTROLS_NATIVE_NATIVE_VIEW_HOST_H_ | 6 #define UI_VIEWS_CONTROLS_NATIVE_NATIVE_VIEW_HOST_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "ui/gfx/native_widget_types.h" | 10 #include "ui/gfx/native_widget_types.h" |
| 11 #include "ui/views/view.h" | 11 #include "ui/views/view.h" |
| 12 | 12 |
| 13 namespace views { | 13 namespace views { |
| 14 | 14 |
| 15 class NativeViewHostAuraTest; | 15 class NativeViewHostAuraTest; |
| 16 class NativeViewHostWrapper; | 16 class NativeViewHostWrapper; |
| 17 | 17 |
| 18 // When performing fast resizes the contents is not actually resized, but | |
| 19 // instead the contents is positioned and clipped to give the impression of | |
| 20 // resizing. Gravity indicates the positioning of the content relative to the | |
| 21 // clipping. The default value, northwest, indicates that the top left corner of | |
| 22 // the clip and the content should align, so the bottom and left sides of the | |
|
sky
2013/09/24 20:23:25
left -> right
rharrison
2013/09/26 20:36:48
Done.
| |
| 23 // content will be clipped. For a value like south the bottom edges will align | |
| 24 // at their respective middles, thus the full vertical resize will be reflected | |
| 25 // on the top, but half of the horizontal resize will be reflected on the left | |
| 26 // and right sides. The following list is the gravity values and their alignment | |
| 27 // points for reference, coordinates relative to the respective system for the | |
| 28 // clip or contents: | |
| 29 // NorthWest (0, 0) | |
| 30 // North (width/2, 0) | |
| 31 // NorthEast (width, 0) | |
| 32 // East (width, height/2) | |
| 33 // SouthEast (width, height) | |
| 34 // South (width/2, height) | |
| 35 // SouthWest (0, height) | |
| 36 // West (0, height/2) | |
| 37 // Center (width/2, height/2) | |
| 38 enum FastResizeGravity { | |
|
sky
2013/09/24 20:23:25
I'm not opposed to all of these, but do we really
sky
2013/09/24 20:23:25
Could you also make this a member of NativeViewHos
rharrison
2013/09/26 20:36:48
The default is NW and I would need a southern one
rharrison
2013/09/26 20:36:48
Done.
| |
| 39 FAST_RESIZE_GRAVITY_NORTHWEST, | |
| 40 FAST_RESIZE_GRAVITY_NORTH, | |
| 41 FAST_RESIZE_GRAVITY_NORTHEAST, | |
| 42 FAST_RESIZE_GRAVITY_EAST, | |
| 43 FAST_RESIZE_GRAVITY_SOUTHEAST, | |
| 44 FAST_RESIZE_GRAVITY_SOUTH, | |
| 45 FAST_RESIZE_GRAVITY_SOUTHWEST, | |
| 46 FAST_RESIZE_GRAVITY_WEST, | |
| 47 FAST_RESIZE_GRAVITY_CENTER, | |
| 48 }; | |
| 49 | |
| 18 // If a NativeViewHost's native view is a Widget, this native window | 50 // If a NativeViewHost's native view is a Widget, this native window |
| 19 // property is set on the widget, pointing to the owning NativeViewHost. | 51 // property is set on the widget, pointing to the owning NativeViewHost. |
| 20 extern const char kWidgetNativeViewHostKey[]; | 52 extern const char kWidgetNativeViewHostKey[]; |
| 21 | 53 |
| 22 // A View type that hosts a gfx::NativeView. The bounds of the native view are | 54 // A View type that hosts a gfx::NativeView. The bounds of the native view are |
| 23 // kept in sync with the bounds of this view as it is moved and sized. | 55 // kept in sync with the bounds of this view as it is moved and sized. |
| 24 // Under the hood, a platform-specific NativeViewHostWrapper implementation does | 56 // Under the hood, a platform-specific NativeViewHostWrapper implementation does |
| 25 // the platform-specific work of manipulating the underlying OS widget type. | 57 // the platform-specific work of manipulating the underlying OS widget type. |
| 26 class VIEWS_EXPORT NativeViewHost : public View { | 58 class VIEWS_EXPORT NativeViewHost : public View { |
| 27 public: | 59 public: |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 67 // and don't care about accuracy. Make sure you do a real resize at the | 99 // and don't care about accuracy. Make sure you do a real resize at the |
| 68 // end. USE WITH CAUTION. | 100 // end. USE WITH CAUTION. |
| 69 void set_fast_resize(bool fast_resize) { fast_resize_ = fast_resize; } | 101 void set_fast_resize(bool fast_resize) { fast_resize_ = fast_resize; } |
| 70 bool fast_resize() const { return fast_resize_; } | 102 bool fast_resize() const { return fast_resize_; } |
| 71 | 103 |
| 72 // Value of fast_resize() the last time Layout() was invoked. | 104 // Value of fast_resize() the last time Layout() was invoked. |
| 73 bool fast_resize_at_last_layout() const { | 105 bool fast_resize_at_last_layout() const { |
| 74 return fast_resize_at_last_layout_; | 106 return fast_resize_at_last_layout_; |
| 75 } | 107 } |
| 76 | 108 |
| 109 // Gravity controls how the clip is positioned relative to the native | |
| 110 // view. The specifics of this are discussed in the comment above the related | |
| 111 // enum. This call only sets the value being used, but does not cause a | |
| 112 // re-layout, so ShowWidget, via Layout, must be called before the new gravity | |
| 113 // will have an effect. | |
| 114 void set_fast_resize_gravity(FastResizeGravity gravity) { | |
| 115 fast_resize_gravity_ = gravity; | |
| 116 } | |
| 117 FastResizeGravity fast_resize_gravity() { | |
| 118 return fast_resize_gravity_; | |
| 119 } | |
| 120 | |
| 77 // Accessor for |native_view_|. | 121 // Accessor for |native_view_|. |
| 78 gfx::NativeView native_view() const { return native_view_; } | 122 gfx::NativeView native_view() const { return native_view_; } |
| 79 | 123 |
| 80 void NativeViewDestroyed(); | 124 void NativeViewDestroyed(); |
| 81 | 125 |
| 82 // Overridden from View: | 126 // Overridden from View: |
| 83 virtual gfx::Size GetPreferredSize() OVERRIDE; | 127 virtual gfx::Size GetPreferredSize() OVERRIDE; |
| 84 virtual void Layout() OVERRIDE; | 128 virtual void Layout() OVERRIDE; |
| 85 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; | 129 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; |
| 86 virtual void VisibilityChanged(View* starting_from, bool is_visible) OVERRIDE; | 130 virtual void VisibilityChanged(View* starting_from, bool is_visible) OVERRIDE; |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 116 // The preferred size of this View | 160 // The preferred size of this View |
| 117 gfx::Size preferred_size_; | 161 gfx::Size preferred_size_; |
| 118 | 162 |
| 119 // True if the native view is being resized using the fast method described | 163 // True if the native view is being resized using the fast method described |
| 120 // in the setter/accessor above. | 164 // in the setter/accessor above. |
| 121 bool fast_resize_; | 165 bool fast_resize_; |
| 122 | 166 |
| 123 // Value of |fast_resize_| during the last call to Layout. | 167 // Value of |fast_resize_| during the last call to Layout. |
| 124 bool fast_resize_at_last_layout_; | 168 bool fast_resize_at_last_layout_; |
| 125 | 169 |
| 170 // gravity value to be used on the next call to ShowWidget. | |
| 171 FastResizeGravity fast_resize_gravity_; | |
| 172 | |
| 126 // The view that should be given focus when this NativeViewHost is focused. | 173 // The view that should be given focus when this NativeViewHost is focused. |
| 127 View* focus_view_; | 174 View* focus_view_; |
| 128 | 175 |
| 129 DISALLOW_COPY_AND_ASSIGN(NativeViewHost); | 176 DISALLOW_COPY_AND_ASSIGN(NativeViewHost); |
| 130 }; | 177 }; |
| 131 | 178 |
| 132 } // namespace views | 179 } // namespace views |
| 133 | 180 |
| 134 #endif // UI_VIEWS_CONTROLS_NATIVE_NATIVE_VIEW_HOST_H_ | 181 #endif // UI_VIEWS_CONTROLS_NATIVE_NATIVE_VIEW_HOST_H_ |
| OLD | NEW |