OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 #if !defined(__has_feature) || !__has_feature(objc_arc) | 5 #if !defined(__has_feature) || !__has_feature(objc_arc) |
6 #error "This file requires ARC support." | 6 #error "This file requires ARC support." |
7 #endif | 7 #endif |
8 | 8 |
9 #import "remoting/client/ios/app/host_view_controller.h" | 9 #import "remoting/client/ios/app/host_view_controller.h" |
10 | 10 |
| 11 #include <memory> |
| 12 |
11 #import <GLKit/GLKit.h> | 13 #import <GLKit/GLKit.h> |
12 | 14 |
13 #import "ios/third_party/material_components_ios/src/components/Buttons/src/Mate
rialButtons.h" | 15 #import "ios/third_party/material_components_ios/src/components/Buttons/src/Mate
rialButtons.h" |
14 #import "remoting/client/ios/display/gl_display_handler.h" | 16 #import "remoting/client/ios/client_gestures.h" |
15 #import "remoting/client/ios/session/remoting_client.h" | 17 #import "remoting/client/ios/session/remoting_client.h" |
16 | 18 |
| 19 #include "remoting/client/gesture_interpreter.h" |
| 20 |
17 static const CGFloat kFabInset = 15.f; | 21 static const CGFloat kFabInset = 15.f; |
18 | 22 |
19 @interface HostViewController () { | 23 @interface HostViewController () { |
20 RemotingClient* _client; | 24 RemotingClient* _client; |
21 MDCFloatingButton* _floatingButton; | 25 MDCFloatingButton* _floatingButton; |
| 26 |
| 27 ClientGestures* _clientGestures; |
22 } | 28 } |
23 @end | 29 @end |
24 | 30 |
25 @implementation HostViewController | 31 @implementation HostViewController |
26 | 32 |
27 - (id)initWithClient:(RemotingClient*)client { | 33 - (id)initWithClient:(RemotingClient*)client { |
28 self = [super init]; | 34 self = [super init]; |
29 if (self) { | 35 if (self) { |
30 _client = client; | 36 _client = client; |
31 } | 37 } |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 | 70 |
65 - (void)viewDidAppear:(BOOL)animated { | 71 - (void)viewDidAppear:(BOOL)animated { |
66 [super viewDidAppear:animated]; | 72 [super viewDidAppear:animated]; |
67 GLKView* glView = (GLKView*)self.view; | 73 GLKView* glView = (GLKView*)self.view; |
68 glView.context = [_client.displayHandler GetEAGLContext]; | 74 glView.context = [_client.displayHandler GetEAGLContext]; |
69 [_client.displayHandler onSurfaceCreated:glView]; | 75 [_client.displayHandler onSurfaceCreated:glView]; |
70 | 76 |
71 // viewDidLayoutSubviews may be called before viewDidAppear, in which case | 77 // viewDidLayoutSubviews may be called before viewDidAppear, in which case |
72 // the surface is not ready and onSurfaceChanged will be no-op. | 78 // the surface is not ready and onSurfaceChanged will be no-op. |
73 // Call onSurfaceChanged here to cover that case. | 79 // Call onSurfaceChanged here to cover that case. |
74 [_client.displayHandler onSurfaceChanged:glView.frame]; | 80 [_client surfaceChanged:self.view.frame]; |
75 } | 81 } |
76 | 82 |
77 - (void)viewWillAppear:(BOOL)animated { | 83 - (void)viewWillAppear:(BOOL)animated { |
78 [super viewWillAppear:animated]; | 84 [super viewWillAppear:animated]; |
79 ((GLKView*)self.view).enableSetNeedsDisplay = true; | 85 |
| 86 _clientGestures = |
| 87 [[ClientGestures alloc] initWithView:self.view client:_client]; |
80 } | 88 } |
81 | 89 |
82 - (void)viewWillDisappear:(BOOL)animated { | 90 - (void)viewWillDisappear:(BOOL)animated { |
83 [super viewWillDisappear:animated]; | 91 [super viewWillDisappear:animated]; |
| 92 |
| 93 _clientGestures = nil; |
84 } | 94 } |
85 | 95 |
86 - (void)viewDidLayoutSubviews { | 96 - (void)viewDidLayoutSubviews { |
87 [super viewDidLayoutSubviews]; | 97 [super viewDidLayoutSubviews]; |
88 | 98 |
89 [_client.displayHandler onSurfaceChanged:((GLKView*)self.view).frame]; | 99 [_client surfaceChanged:self.view.frame]; |
90 | 100 |
91 const CGSize& btnSize = _floatingButton.frame.size; | 101 CGSize btnSize = _floatingButton.frame.size; |
92 _floatingButton.frame = | 102 _floatingButton.frame = |
93 CGRectMake(self.view.frame.size.width - btnSize.width - kFabInset, | 103 CGRectMake(self.view.frame.size.width - btnSize.width - kFabInset, |
94 self.view.frame.size.height - btnSize.height - kFabInset, | 104 self.view.frame.size.height - btnSize.height - kFabInset, |
95 btnSize.width, btnSize.height); | 105 btnSize.width, btnSize.height); |
96 } | 106 } |
97 | 107 |
98 #pragma mark - Private | 108 #pragma mark - Private |
99 | 109 |
100 - (void)didTap:(id)sender { | 110 - (void)didTap:(id)sender { |
101 // TODO(nicholss): The FAB is being used to close the window at the moment | 111 // TODO(nicholss): The FAB is being used to close the window at the moment |
102 // just as a demo as the integration continues. This will not be the case | 112 // just as a demo as the integration continues. This will not be the case |
103 // in the final app. | 113 // in the final app. |
104 [self dismissViewControllerAnimated:YES completion:nil]; | 114 [self dismissViewControllerAnimated:YES completion:nil]; |
105 } | 115 } |
106 | 116 |
107 @end | 117 @end |
OLD | NEW |