Chromium Code Reviews| 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 |
| 15 #include "remoting/client/gesture_interpreter.h" | |
| 16 | |
| 13 #import "ios/third_party/material_components_ios/src/components/Buttons/src/Mate rialButtons.h" | 17 #import "ios/third_party/material_components_ios/src/components/Buttons/src/Mate rialButtons.h" |
| 14 #import "remoting/client/ios/display/gl_display_handler.h" | 18 #import "remoting/client/ios/client_gestures.h" |
| 15 #import "remoting/client/ios/session/remoting_client.h" | 19 #import "remoting/client/ios/session/remoting_client.h" |
| 16 | 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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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.displayHandler onSurfaceChanged:glView.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 _client.displayHandler.delegate = self; | |
| 87 | |
| 88 _clientGestures = | |
| 89 [[ClientGestures alloc] initWithView:self.view client:_client]; | |
| 80 } | 90 } |
| 81 | 91 |
| 82 - (void)viewWillDisappear:(BOOL)animated { | 92 - (void)viewWillDisappear:(BOOL)animated { |
| 83 [super viewWillDisappear:animated]; | 93 [super viewWillDisappear:animated]; |
| 94 | |
| 95 _clientGestures = nil; | |
| 84 } | 96 } |
| 85 | 97 |
| 86 - (void)viewDidLayoutSubviews { | 98 - (void)viewDidLayoutSubviews { |
| 87 [super viewDidLayoutSubviews]; | 99 [super viewDidLayoutSubviews]; |
| 88 | 100 |
| 89 [_client.displayHandler onSurfaceChanged:((GLKView*)self.view).frame]; | 101 CGRect surfaceFrame = self.view.frame; |
| 102 [_client.displayHandler onSurfaceChanged:surfaceFrame]; | |
|
nicholss
2017/05/03 22:47:35
Maybe we could tell the client that the surface ch
Yuwei
2017/05/04 00:28:07
Done.
| |
| 103 _client.gestureInterpreter->OnSurfaceSizeChanged(surfaceFrame.size.width, | |
| 104 surfaceFrame.size.height); | |
| 90 | 105 |
| 91 const CGSize& btnSize = _floatingButton.frame.size; | 106 CGSize btnSize = _floatingButton.frame.size; |
| 92 _floatingButton.frame = | 107 _floatingButton.frame = |
| 93 CGRectMake(self.view.frame.size.width - btnSize.width - kFabInset, | 108 CGRectMake(self.view.frame.size.width - btnSize.width - kFabInset, |
| 94 self.view.frame.size.height - btnSize.height - kFabInset, | 109 self.view.frame.size.height - btnSize.height - kFabInset, |
| 95 btnSize.width, btnSize.height); | 110 btnSize.width, btnSize.height); |
| 96 } | 111 } |
| 97 | 112 |
| 113 #pragma mark - GlDisplayHandlerDelegate | |
| 114 | |
| 115 - (void)canvasSizeChanged:(CGSize)size { | |
| 116 _client.gestureInterpreter->OnDesktopSizeChanged(size.width, size.height); | |
|
nicholss
2017/05/03 22:47:35
Do we still need the host view controller to tell
Yuwei
2017/05/04 00:28:07
Nope. Move delegate to RemotingClient instead.
| |
| 117 } | |
| 118 | |
| 98 #pragma mark - Private | 119 #pragma mark - Private |
| 99 | 120 |
| 100 - (void)didTap:(id)sender { | 121 - (void)didTap:(id)sender { |
| 101 // TODO(nicholss): The FAB is being used to close the window at the moment | 122 // 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 | 123 // just as a demo as the integration continues. This will not be the case |
| 103 // in the final app. | 124 // in the final app. |
| 104 [self dismissViewControllerAnimated:YES completion:nil]; | 125 [self dismissViewControllerAnimated:YES completion:nil]; |
| 105 } | 126 } |
| 106 | 127 |
| 107 @end | 128 @end |
| OLD | NEW |