Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(672)

Side by Side Diff: ui/views/controls/native/native_view_host.h

Issue 30993004: Reland: Implement features in NativeViewHostAura for scroll end effect (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed outstanding issues from original CL Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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"
(...skipping 13 matching lines...) Expand all
24 // Under the hood, a platform-specific NativeViewHostWrapper implementation does 24 // Under the hood, a platform-specific NativeViewHostWrapper implementation does
25 // the platform-specific work of manipulating the underlying OS widget type. 25 // the platform-specific work of manipulating the underlying OS widget type.
26 class VIEWS_EXPORT NativeViewHost : public View { 26 class VIEWS_EXPORT NativeViewHost : public View {
27 public: 27 public:
28 // The NativeViewHost's class name. 28 // The NativeViewHost's class name.
29 static const char kViewClassName[]; 29 static const char kViewClassName[];
30 30
31 // Should views render the focus when on native controls? 31 // Should views render the focus when on native controls?
32 static const bool kRenderNativeControlFocus; 32 static const bool kRenderNativeControlFocus;
33 33
34 NativeViewHost(); 34 // When performing fast resizes the contents is not actually resized, but
35 // instead the contents is positioned and clipped to give the impression of
36 // resizing. Gravity indicates the positioning of the content relative to the
37 // clipping. The default value, northwest, indicates that the top left corner
38 // of the clip and the content should align, so the bottom and right sides of
39 // the content will be clipped. For a value like south the bottom edges will
40 // align at their respective middles, thus the full vertical resize will be
41 // reflected on the top, but half of the horizontal resize will be reflected
42 // on the left and right sides. The following list is the gravity values and
43 // their alignment points for reference, coordinates relative to the
44 // respective system for the clip or contents:
45 // NorthWest (0, 0)
46 // North (width/2, 0)
47 // NorthEast (width, 0)
48 // East (width, height/2)
49 // SouthEast (width, height)
50 // South (width/2, height)
51 // SouthWest (0, height)
52 // West (0, height/2)
53 // Center (width/2, height/2)
54 enum Gravity {
55 GRAVITY_NORTHWEST,
56 GRAVITY_NORTH,
57 GRAVITY_NORTHEAST,
58 GRAVITY_EAST,
59 GRAVITY_SOUTHEAST,
60 GRAVITY_SOUTH,
61 GRAVITY_SOUTHWEST,
62 GRAVITY_WEST,
63 GRAVITY_CENTER,
64 };
65
66 NativeViewHost();
35 virtual ~NativeViewHost(); 67 virtual ~NativeViewHost();
36 68
37 // Attach a gfx::NativeView to this View. Its bounds will be kept in sync 69 // Attach a gfx::NativeView to this View. Its bounds will be kept in sync
38 // with the bounds of this View until Detach is called. 70 // with the bounds of this View until Detach is called.
39 // 71 //
40 // Because native views are positioned in the coordinates of their parent 72 // Because native views are positioned in the coordinates of their parent
41 // native view, this function should only be called after this View has been 73 // native view, this function should only be called after this View has been
42 // added to a View hierarchy hosted within a valid Widget. 74 // added to a View hierarchy hosted within a valid Widget.
43 void Attach(gfx::NativeView native_view); 75 void Attach(gfx::NativeView native_view);
44 76
(...skipping 22 matching lines...) Expand all
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(Gravity gravity) {
115 fast_resize_gravity_ = gravity;
116 }
117 Gravity fast_resize_gravity() const {
118 return fast_resize_gravity_;
119 }
120
121 // Returns the appropriate, as in the comment above discussing gravity,
122 // scaling factor for the current gravity.
123 float GetWidthScaleFactor() const;
124 float GetHeightScaleFactor() const;
125
77 // Accessor for |native_view_|. 126 // Accessor for |native_view_|.
78 gfx::NativeView native_view() const { return native_view_; } 127 gfx::NativeView native_view() const { return native_view_; }
79 128
80 void NativeViewDestroyed(); 129 void NativeViewDestroyed();
81 130
82 // Overridden from View: 131 // Overridden from View:
83 virtual gfx::Size GetPreferredSize() OVERRIDE; 132 virtual gfx::Size GetPreferredSize() OVERRIDE;
84 virtual void Layout() OVERRIDE; 133 virtual void Layout() OVERRIDE;
85 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; 134 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE;
86 virtual void VisibilityChanged(View* starting_from, bool is_visible) OVERRIDE; 135 virtual void VisibilityChanged(View* starting_from, bool is_visible) OVERRIDE;
(...skipping 29 matching lines...) Expand all
116 // The preferred size of this View 165 // The preferred size of this View
117 gfx::Size preferred_size_; 166 gfx::Size preferred_size_;
118 167
119 // True if the native view is being resized using the fast method described 168 // True if the native view is being resized using the fast method described
120 // in the setter/accessor above. 169 // in the setter/accessor above.
121 bool fast_resize_; 170 bool fast_resize_;
122 171
123 // Value of |fast_resize_| during the last call to Layout. 172 // Value of |fast_resize_| during the last call to Layout.
124 bool fast_resize_at_last_layout_; 173 bool fast_resize_at_last_layout_;
125 174
175 // Gravity value to be used on the next call to ShowWidget.
176 Gravity fast_resize_gravity_;
177
126 // The view that should be given focus when this NativeViewHost is focused. 178 // The view that should be given focus when this NativeViewHost is focused.
127 View* focus_view_; 179 View* focus_view_;
128 180
129 DISALLOW_COPY_AND_ASSIGN(NativeViewHost); 181 DISALLOW_COPY_AND_ASSIGN(NativeViewHost);
130 }; 182 };
131 183
132 } // namespace views 184 } // namespace views
133 185
134 #endif // UI_VIEWS_CONTROLS_NATIVE_NATIVE_VIEW_HOST_H_ 186 #endif // UI_VIEWS_CONTROLS_NATIVE_NATIVE_VIEW_HOST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698