input boxes UI, keyboard animation

This commit is contained in:
2017-08-13 12:41:10 +01:00
parent 6d3c9380b2
commit 060e08a891
12 changed files with 132 additions and 41 deletions

View File

@@ -21,6 +21,7 @@
//std::map<
int t_count = 0;
glm::vec2 t_pos;
@implementation GameViewController
@@ -49,11 +50,27 @@ int t_count = 0;
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyboardWasShown:)
name:UIKeyboardWillShowNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyboardWillBeHidden:)
name:UIKeyboardWillHideNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyboardWillBeShown:)
name:UIKeyboardDidShowNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyboardWasHidden:)
name:UIKeyboardDidHideNotification object:nil];
}
- (void)keyboardWillBeShown:(NSNotification*)aNotification
{
App::I.redraw = true;
App::I.animate = true;
}
- (void)keyboardWasHidden:(NSNotification*)aNotification
{
App::I.redraw = true;
App::I.animate = false;
}
// Called when the UIKeyboardDidShowNotification is sent.
@@ -66,8 +83,10 @@ int t_count = 0;
CGRect frame = view.frame;
frame.size.height -= kbSize.height;
view.frame = frame;
App::I.resize(frame.size.width * view.contentScaleFactor,
frame.size.height * view.contentScaleFactor);
App::I.animate = false;
}
// Called when the UIKeyboardWillHideNotification is sent
@@ -77,6 +96,16 @@ int t_count = 0;
self.view.frame = frame;
App::I.resize(frame.size.width * self.view.contentScaleFactor,
frame.size.height * self.view.contentScaleFactor);
App::I.animate = true;
}
- (void)reset_touch
{
if (t_count == 2)
App::I.gesture_end();
else
App::I.mouse_cancel(0);
t_count = 0;
}
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
@@ -88,6 +117,7 @@ int t_count = 0;
App::I.mouse_down(0, touchLocation.x * scale, touchLocation.y * scale, touch.force);
t_count = 1;
t_pos = {touchLocation.x * scale, touchLocation.y * scale};
}
- (void)touchesMoved:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
@@ -135,6 +165,7 @@ int t_count = 0;
App::I.mouse_move(touchLocation.x * scale, touchLocation.y * scale, force);
}
}
t_pos = {tl0.x * scale, tl0.y * scale};
}
-(void)touchesEnded:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
@@ -147,6 +178,7 @@ int t_count = 0;
else
App::I.mouse_up(0, touchLocation.x * scale, touchLocation.y * scale);
t_count = 0;
t_pos = {touchLocation.x * scale, touchLocation.y * scale};
}
- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator
@@ -236,7 +268,7 @@ int t_count = 0;
- (void)glkView:(GLKView *)view drawInRect:(CGRect)rect
{
if (!App::I.redraw)
if (!(App::I.redraw || App::I.animate))
return;
App::I.clear();
App::I.update(0);