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

Side by Side Diff: ui/views_core/bridged_view_mac.h

Issue 187483005: Extending the Views-on-Mac experiment: whole app list grid. Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: still compiles r263560 + crrev/195793005 Created 6 years, 8 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
« no previous file with comments | « ui/views_core/bridged_view_impl_mac.mm ('k') | ui/views_core/bridged_view_mac.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef UI_VIEWS_CORE_BRIDGED_VIEW_MAC_H_
6 #define UI_VIEWS_CORE_BRIDGED_VIEW_MAC_H_
7
8 #include <stddef.h>
9
10 #include "base/mac/scoped_nsobject.h"
11 #include "ui/views/views_export.h"
12
13 @class BridgedViewImpl;
14 @class NSView;
15
16 namespace views {
17
18 class View;
19
20 // Represents a toolkit-view that has been bridged so that it can be painted
21 // using an NSView. This is the non-templatized base.
22 class VIEWS_EXPORT BridgedViewBase {
23 typedef base::scoped_nsobject<BridgedViewImpl> BridgedViewBase::*Testable;
24
25 public:
26 // Allow bool-conversion, returning the private pointer-to-member trick to
27 // avoid returning something that easily converts to int.
28 operator Testable() const {
29 return bridged_view_.get() ? &BridgedViewBase::bridged_view_ : NULL;
30 }
31
32 // Returns the NSView side of the bridge, or nil.
33 NSView* GetNSView();
34
35 // Returns the views::View side of the bridge, or NULL.
36 View* GetView();
37
38 protected:
39 BridgedViewBase();
40 explicit BridgedViewBase(View* view);
41 ~BridgedViewBase();
42
43 void ResetView(View* view);
44
45 private:
46 base::scoped_nsobject<BridgedViewImpl> bridged_view_;
47 };
48
49 // Templatized scoped_ptr-style class for representing a bridged views::View.
50 // Members of the views::View subtype are accessed via the strongly typed
51 // operator->(). When a BridgedView goes out of scope, the owned |view| is
52 // removed from the hosting NSView superview and immediately destroyed. The
53 // NSView is released, but it is reference counted so could still hang around
54 // for a while.
55 template <class T>
56 class BridgedView : public BridgedViewBase {
57 public:
58 // Construct with an initially NULL bridge.
59 BridgedView() : BridgedViewBase() {}
60
61 // Takes ownership of |view|.
62 explicit BridgedView(T* view) : BridgedViewBase(view) {}
63
64 // Takes ownership of |view|.
65 void reset(T* view = NULL) { ResetView(view); }
66
67 T* get() { return static_cast<T*>(GetView()); }
68 const T* get() const { return static_cast<const T*>(GetView()); }
69 T* operator->() { return get(); }
70 const T* operator->() const { return get(); }
71 };
72
73 } // namespace views
74
75 #endif // UI_VIEWS_CORE_BRIDGED_VIEW_MAC_H_
OLDNEW
« no previous file with comments | « ui/views_core/bridged_view_impl_mac.mm ('k') | ui/views_core/bridged_view_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698