11#if __has_feature(objc_arc)
12#error "File should not be compiled with ARC."
27Window_ios* Window_ios::gWindow =
nullptr;
35 Window_ios*
window =
new Window_ios();
36 if (!
window->initWindow()) {
56 fWindow = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
58 [viewController release];
61 fWindow.backgroundColor = [UIColor whiteColor];
64 [fWindow setRootViewController:viewController];
65 [fWindow makeKeyAndVisible];
72void Window_ios::closeWindow() {
85 info.fViewController = fWindow.rootViewController;
88 case kMetal_BackendType:
91#if defined(SK_GRAPHITE)
92 case kGraphiteMetal_BackendType:
98 case kNativeGL_BackendType:
130 self = [
super initWithNibName:nil bundle:nil];
132 fWindow = initWindow;
141- (void)didReceiveMemoryWarning {
145- (void)viewWillTransitionToSize:(CGSize)size
146 withTransitionCoordinator:(
id<UIViewControllerTransitionCoordinator>)coordinator {
157- (void)panGestureAction:(UIGestureRecognizer*)sender {
158 CGPoint location = [sender locationInView:self];
159 switch (sender.state) {
160 case UIGestureRecognizerStateBegan:
161 fWindow->
onMouse(location.x, location.y,
164 case UIGestureRecognizerStateChanged:
165 fWindow->onMouse(location.x, location.y,
168 case UIGestureRecognizerStateEnded:
169 fWindow->onMouse(location.x, location.y,
172 case UIGestureRecognizerStateCancelled:
173 fWindow->onMouse(location.x, location.y,
181- (void)tapGestureAction:(UIGestureRecognizer*)sender {
182 CGPoint location = [sender locationInView:self];
183 switch (sender.state) {
184 case UIGestureRecognizerStateEnded:
185 fWindow->onMouse(location.x, location.y,
187 fWindow->onMouse(location.x, location.y,
195- (void)pinchGestureAction:(UIGestureRecognizer*)sender {
196 CGPoint location = [sender locationInView:self];
197 UIPinchGestureRecognizer* pinchGestureRecognizer = (UIPinchGestureRecognizer*) sender;
198 float scale = pinchGestureRecognizer.scale;
199 switch (sender.state) {
200 case UIGestureRecognizerStateBegan:
203 case UIGestureRecognizerStateChanged:
206 case UIGestureRecognizerStateEnded:
209 case UIGestureRecognizerStateCancelled:
217- (void)swipeRightGestureAction:(UIGestureRecognizer*)sender {
218 if (UIGestureRecognizerStateEnded == sender.state) {
223- (void)swipeLeftGestureAction:(UIGestureRecognizer*)sender {
224 if (UIGestureRecognizerStateEnded == sender.state) {
232 UIPanGestureRecognizer* panGestureRecognizer = [[UIPanGestureRecognizer alloc] init];
233 panGestureRecognizer.maximumNumberOfTouches = 1;
234 [panGestureRecognizer addTarget:self action:@selector(panGestureAction:)];
235 [
self addGestureRecognizer:panGestureRecognizer];
237 UITapGestureRecognizer* tapGestureRecognizer = [[UITapGestureRecognizer alloc] init];
238 [tapGestureRecognizer addTarget:self action:@selector(tapGestureAction:)];
239 [
self addGestureRecognizer:tapGestureRecognizer];
241 UIPinchGestureRecognizer* pinchGestureRecognizer = [[UIPinchGestureRecognizer alloc] init];
242 [pinchGestureRecognizer addTarget:self action:@selector(pinchGestureAction:)];
243 [
self addGestureRecognizer:pinchGestureRecognizer];
245 UISwipeGestureRecognizer* swipeRightGestureRecognizer = [[UISwipeGestureRecognizer alloc] init];
246 swipeRightGestureRecognizer.direction = UISwipeGestureRecognizerDirectionRight;
247 [swipeRightGestureRecognizer addTarget:self action:@selector(swipeRightGestureAction:)];
248 [
self addGestureRecognizer:swipeRightGestureRecognizer];
250 UISwipeGestureRecognizer* swipeLeftGestureRecognizer = [[UISwipeGestureRecognizer alloc] init];
251 swipeLeftGestureRecognizer.direction = UISwipeGestureRecognizerDirectionLeft;
252 [swipeLeftGestureRecognizer addTarget:self action:@selector(swipeLeftGestureAction:)];
253 [
self addGestureRecognizer:swipeLeftGestureRecognizer];
256 [panGestureRecognizer requireGestureRecognizerToFail:swipeLeftGestureRecognizer];
257 [panGestureRecognizer requireGestureRecognizerToFail:swipeRightGestureRecognizer];
259 fWindow = initWindow;
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
#define SkASSERT_RELEASE(cond)
static constexpr bool SkToBool(const T &x)
bool attach(BackendType) override
static Window_ios * MainWindow()
static void PaintWindow()
static Window * CreateNativeWindow(void *platformData)
DisplayParams fRequestedDisplayParams
std::unique_ptr< skwindow::WindowContext > fWindowContext
bool onMouse(int x, int y, skui::InputState state, skui::ModifierKey modifiers)
FlutterViewController * viewController
std::unique_ptr< WindowContext > MakeMetalForIOS(const IOSWindowInfo &info, const DisplayParams ¶ms)
std::unique_ptr< WindowContext > MakeRasterForIOS(const IOSWindowInfo &info, const DisplayParams ¶ms)
std::unique_ptr< WindowContext > MakeGLForIOS(const IOSWindowInfo &info, const DisplayParams ¶ms)
std::unique_ptr< WindowContext > MakeGraphiteMetalForIOS(const IOSWindowInfo &info, const DisplayParams ¶ms)