More cleanup of the iOS Objective-C code.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325
diff --git a/src/video/uikit/SDL_uikitappdelegate.m b/src/video/uikit/SDL_uikitappdelegate.m
index 212d576..b72a52c 100644
--- a/src/video/uikit/SDL_uikitappdelegate.m
+++ b/src/video/uikit/SDL_uikitappdelegate.m
@@ -75,16 +75,17 @@ SDL_IdleTimerDisabledChanged(void *userdata, const char *name, const char *oldVa
[UIApplication sharedApplication].idleTimerDisabled = disable;
}
-@interface SDL_splashviewcontroller : UIViewController {
- UIImageView *splash;
- UIImage *splashPortrait;
- UIImage *splashLandscape;
-}
+@interface SDL_splashviewcontroller : UIViewController
- (void)updateSplashImage:(UIInterfaceOrientation)interfaceOrientation;
+
@end
-@implementation SDL_splashviewcontroller
+@implementation SDL_splashviewcontroller {
+ UIImageView *splash;
+ UIImage *splashPortrait;
+ UIImage *splashLandscape;
+}
- (id)init
{
diff --git a/src/video/uikit/SDL_uikitmessagebox.m b/src/video/uikit/SDL_uikitmessagebox.m
index 0fa4bda..4a1d32b 100644
--- a/src/video/uikit/SDL_uikitmessagebox.m
+++ b/src/video/uikit/SDL_uikitmessagebox.m
@@ -30,17 +30,16 @@
static SDL_bool s_showingMessageBox = SDL_FALSE;
-@interface UIKit_UIAlertViewDelegate : NSObject <UIAlertViewDelegate> {
-@private
- int *clickedButtonIndex;
-}
+@interface UIKit_UIAlertViewDelegate : NSObject <UIAlertViewDelegate>
- (id)initWithButtonIndex:(int *)_buttonIndex;
- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex;
@end
-@implementation UIKit_UIAlertViewDelegate
+@implementation UIKit_UIAlertViewDelegate {
+ int *clickedButtonIndex;
+}
- (id)initWithButtonIndex:(int *)buttonIndex
{
@@ -48,7 +47,8 @@ static SDL_bool s_showingMessageBox = SDL_FALSE;
if (self == nil) {
return nil;
}
- self->clickedButtonIndex = buttonIndex;
+
+ clickedButtonIndex = buttonIndex;
return self;
}
diff --git a/src/video/uikit/SDL_uikitopenglview.h b/src/video/uikit/SDL_uikitopenglview.h
index b951ac5..4f40514 100644
--- a/src/video/uikit/SDL_uikitopenglview.h
+++ b/src/video/uikit/SDL_uikitopenglview.h
@@ -29,38 +29,7 @@
The view content is basically an EAGL surface you render your OpenGL scene into.
Note that setting the view non-opaque will only work if the EAGL surface has an alpha channel.
*/
-@interface SDL_uikitopenglview : SDL_uikitview {
-
-@private
- /* The pixel dimensions of the backbuffer */
- GLint backingWidth;
- GLint backingHeight;
-
- EAGLContext *context;
-
- /* OpenGL names for the renderbuffer and framebuffers used to render to this view */
- GLuint viewRenderbuffer, viewFramebuffer;
-
- /* OpenGL name for the depth buffer that is attached to viewFramebuffer, if it exists (0 if it does not exist) */
- GLuint depthRenderbuffer;
-
- /* format of depthRenderbuffer */
- GLenum depthBufferFormat;
-
- id displayLink;
- int animationInterval;
- void (*animationCallback)(void*);
- void *animationCallbackParam;
-}
-
-@property (nonatomic, retain, readonly) EAGLContext *context;
-
-/* The width and height of the drawable in pixels (as opposed to points.) */
-@property (nonatomic, readonly) int backingWidth;
-@property (nonatomic, readonly) int backingHeight;
-
-- (void)swapBuffers;
-- (void)setCurrentContext;
+@interface SDL_uikitopenglview : SDL_uikitview
- (id)initWithFrame:(CGRect)frame
scale:(CGFloat)scale
@@ -75,11 +44,20 @@
majorVersion:(int)majorVersion
shareGroup:(EAGLSharegroup*)shareGroup;
+@property (nonatomic, retain, readonly) EAGLContext *context;
+
+/* The width and height of the drawable in pixels (as opposed to points.) */
+@property (nonatomic, readonly) int backingWidth;
+@property (nonatomic, readonly) int backingHeight;
+
+- (void)swapBuffers;
+- (void)setCurrentContext;
+
- (void)updateFrame;
- (void)setAnimationCallback:(int)interval
- callback:(void (*)(void*))callback
- callbackParam:(void*)callbackParam;
+ callback:(void (*)(void*))callback
+ callbackParam:(void*)callbackParam;
- (void)startAnimation;
- (void)stopAnimation;
diff --git a/src/video/uikit/SDL_uikitopenglview.m b/src/video/uikit/SDL_uikitopenglview.m
index f388fa3..40127c0 100644
--- a/src/video/uikit/SDL_uikitopenglview.m
+++ b/src/video/uikit/SDL_uikitopenglview.m
@@ -28,12 +28,28 @@
#include "SDL_uikitmessagebox.h"
-@implementation SDL_uikitopenglview
+@implementation SDL_uikitopenglview {
+
+ /* OpenGL names for the renderbuffer and framebuffers used to render to this view */
+ GLuint viewRenderbuffer, viewFramebuffer;
+
+ /* OpenGL name for the depth buffer that is attached to viewFramebuffer, if it exists (0 if it does not exist) */
+ GLuint depthRenderbuffer;
+
+ /* format of depthRenderbuffer */
+ GLenum depthBufferFormat;
+
+ id displayLink;
+ int animationInterval;
+ void (*animationCallback)(void*);
+ void *animationCallbackParam;
+
+}
@synthesize context;
-@synthesize backingWidth = backingWidth;
-@synthesize backingHeight = backingHeight;
+@synthesize backingWidth;
+@synthesize backingHeight;
+ (Class)layerClass
{
@@ -53,8 +69,6 @@
majorVersion:(int)majorVersion
shareGroup:(EAGLSharegroup*)shareGroup
{
- depthBufferFormat = 0;
-
if ((self = [super initWithFrame:frame])) {
const BOOL useStencilBuffer = (stencilBits != 0);
const BOOL useDepthBuffer = (depthBits != 0);
diff --git a/src/video/uikit/SDL_uikitview.h b/src/video/uikit/SDL_uikitview.h
index 8191915..417a68f 100644
--- a/src/video/uikit/SDL_uikitview.h
+++ b/src/video/uikit/SDL_uikitview.h
@@ -35,23 +35,10 @@
#else
@interface SDL_uikitview : UIView {
#endif
-
- SDL_TouchID touchId;
- UITouch *leftFingerDown;
-#ifndef IPHONE_TOUCH_EFFICIENT_DANGEROUS
- UITouch *finger[MAX_SIMULTANEOUS_TOUCHES];
-#endif
-
-#if SDL_IPHONE_KEYBOARD
- UITextField *textField;
- BOOL keyboardVisible;
- SDL_Rect textInputRect;
- int keyboardHeight;
-#endif
-
@public
SDL_uikitviewcontroller *viewcontroller;
}
+
- (CGPoint)touchLocation:(UITouch *)touch shouldNormalize:(BOOL)normalize;
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event;
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event;
@@ -61,7 +48,8 @@
- (void)showKeyboard;
- (void)hideKeyboard;
- (void)initializeKeyboard;
-@property (nonatomic, readonly) BOOL keyboardVisible;
+
+@property (nonatomic, readonly, assign, getter=isKeyboardVisible) BOOL keyboardVisible;
@property (nonatomic, assign) SDL_Rect textInputRect;
@property (nonatomic, assign) int keyboardHeight;
diff --git a/src/video/uikit/SDL_uikitview.m b/src/video/uikit/SDL_uikitview.m
index 0f79016..18a0538 100644
--- a/src/video/uikit/SDL_uikitview.m
+++ b/src/video/uikit/SDL_uikitview.m
@@ -37,7 +37,19 @@
void _uikit_keyboard_init();
-@implementation SDL_uikitview
+@implementation SDL_uikitview {
+
+ SDL_TouchID touchId;
+ UITouch *leftFingerDown;
+#ifndef IPHONE_TOUCH_EFFICIENT_DANGEROUS
+ UITouch *finger[MAX_SIMULTANEOUS_TOUCHES];
+#endif
+
+#if SDL_IPHONE_KEYBOARD
+ UITextField *textField;
+#endif
+
+}
- (void)dealloc
{
@@ -66,7 +78,7 @@ void _uikit_keyboard_init();
CGPoint point = [touch locationInView: self];
if (normalize) {
- CGRect bounds = [self bounds];
+ CGRect bounds = self.bounds;
point.x /= bounds.size.width;
point.y /= bounds.size.height;
}
@@ -122,7 +134,7 @@ void _uikit_keyboard_init();
CGPoint locationInView = [self touchLocation:touch shouldNormalize:YES];
#ifdef IPHONE_TOUCH_EFFICIENT_DANGEROUS
- SDL_SendTouch(touchId, (long)touch,
+ SDL_SendTouch(touchId, (SDL_FingerID)((size_t)touch),
SDL_FALSE, locationInView.x, locationInView.y, 1.0f);
#else
int i;
@@ -160,7 +172,7 @@ void _uikit_keyboard_init();
CGPoint locationInView = [self touchLocation:touch shouldNormalize:YES];
#ifdef IPHONE_TOUCH_EFFICIENT_DANGEROUS
- SDL_SendTouchMotion(touchId, (long)touch,
+ SDL_SendTouchMotion(touchId, (SDL_FingerID)((size_t)touch),
locationInView.x, locationInView.y, 1.0f);
#else
int i;
@@ -180,14 +192,9 @@ void _uikit_keyboard_init();
*/
#if SDL_IPHONE_KEYBOARD
-@synthesize textInputRect = textInputRect;
-@synthesize keyboardHeight = keyboardHeight;
-
-/* Is the iPhone virtual keyboard visible onscreen? */
-- (BOOL)keyboardVisible
-{
- return keyboardVisible;
-}
+@synthesize textInputRect;
+@synthesize keyboardHeight;
+@synthesize keyboardVisible;
/* Set ourselves up as a UITextFieldDelegate */
- (void)initializeKeyboard
@@ -337,7 +344,7 @@ SDL_bool UIKit_IsScreenKeyboardShown(_THIS, SDL_Window *window)
return 0;
}
- return view.keyboardVisible;
+ return view.isKeyboardVisible;
}
diff --git a/src/video/uikit/SDL_uikitviewcontroller.h b/src/video/uikit/SDL_uikitviewcontroller.h
index 64cb47e..0ca98eb 100644
--- a/src/video/uikit/SDL_uikitviewcontroller.h
+++ b/src/video/uikit/SDL_uikitviewcontroller.h
@@ -23,12 +23,9 @@
#include "../SDL_sysvideo.h"
-@interface SDL_uikitviewcontroller : UIViewController {
-@private
- SDL_Window *window;
-}
+@interface SDL_uikitviewcontroller : UIViewController
-@property (nonatomic, readwrite) SDL_Window *window;
+@property (nonatomic, assign) SDL_Window *window;
- (id)initWithSDLWindow:(SDL_Window *)_window;
- (void)loadView;
diff --git a/src/video/uikit/SDL_uikitwindow.m b/src/video/uikit/SDL_uikitwindow.m
index 9d5f0ee..b636ed7 100644
--- a/src/video/uikit/SDL_uikitwindow.m
+++ b/src/video/uikit/SDL_uikitwindow.m
@@ -239,7 +239,6 @@ UIKit_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * display
SDL_DisplayData *displaydata = (SDL_DisplayData *) display->driverdata;
SDL_WindowData *windowdata = (SDL_WindowData *) window->driverdata;
SDL_uikitviewcontroller *viewcontroller = windowdata->viewcontroller;
- UIWindow *uiwindow = windowdata->uiwindow;
CGRect bounds;
if (fullscreen || (window->flags & SDL_WINDOW_BORDERLESS)) {