input boxes UI, keyboard animation
This commit is contained in:
@@ -7,9 +7,12 @@
|
||||
//
|
||||
|
||||
#import "AppDelegate.h"
|
||||
#import "GameViewController.h"
|
||||
#include "app.h"
|
||||
|
||||
@interface AppDelegate ()
|
||||
@interface AppDelegate () {
|
||||
GameViewController* view;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -18,17 +21,21 @@
|
||||
|
||||
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
|
||||
// Override point for customization after application launch.
|
||||
view = (GameViewController*)self.window.rootViewController;
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (void)applicationWillResignActive:(UIApplication *)application {
|
||||
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
|
||||
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
|
||||
App::I.redraw = true;
|
||||
[view reset_touch];
|
||||
}
|
||||
|
||||
- (void)applicationDidEnterBackground:(UIApplication *)application {
|
||||
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
|
||||
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
|
||||
App::I.redraw = true;
|
||||
}
|
||||
|
||||
- (void)applicationWillEnterForeground:(UIApplication *)application {
|
||||
@@ -43,6 +50,7 @@
|
||||
|
||||
- (void)applicationWillTerminate:(UIApplication *)application {
|
||||
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
|
||||
App::I.redraw = true;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -11,4 +11,6 @@
|
||||
|
||||
@interface GameViewController : GLKViewController <UIKeyInput>
|
||||
|
||||
- (void)reset_touch;
|
||||
|
||||
@end
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -173,10 +173,10 @@
|
||||
<text text="Rename Layer" font-face="arial" font-size="11"></text>
|
||||
</border>
|
||||
<border width="400" color="0 0 0 .9" pad="10" dir="col">
|
||||
<node dir="row">
|
||||
<text text="New name: " font-face="arial" font-size="11"/>
|
||||
<text-input id="txt-input" width="100" height="20" color=".3"/>
|
||||
</node>
|
||||
<border dir="row" align="center" height="30" color=".2 .2 .2 1">
|
||||
<text text="New name: " font-face="arial" font-size="11" margin="0 5 0 5"/>
|
||||
<text-input id="txt-input" justify="center" pad="5" grow="1" height="30" color=".3"/>
|
||||
</border>
|
||||
<node height="40" grow="1" dir="row" align="flex-end" justify="flex-end">
|
||||
<button id="btn-ok" text="Rename Layer" width="100" height="30" margin="0 10 0 0"/>
|
||||
<button id="btn-cancel" text="Cancel" width="60" height="30" pad="10"/>
|
||||
@@ -187,7 +187,7 @@
|
||||
</layout>
|
||||
|
||||
<layout id="dialog-open-item">
|
||||
<border dir="row" color=".4 .4 .4 .8" pad="4">
|
||||
<border dir="row" color=".4 .4 .4 .8" pad="4" height="30" margin="1 0 1 0" align="center">
|
||||
<!--<image-texture id="thumb-tex" width="64" height="64"/>-->
|
||||
<text id="title" text="Title" font-face="arial" font-size="11"/>
|
||||
</border>
|
||||
@@ -202,12 +202,14 @@
|
||||
</border>
|
||||
<border width="400" color="0 0 0 .9" pad="10" dir="col">
|
||||
<node dir="row">
|
||||
<node id="files-list" dir="col"/>
|
||||
<scroll id="files-list" dir="col" flood-events="1" grow="1" height="150" margin="0 10 0 0" pad="0 20 0 0" color=".2 .2 .2 1"/>
|
||||
<!--
|
||||
<node dir="col" grow="1" margin="0 0 0 10">
|
||||
<border height="20" align="center" justify="center" color=".2 .2 .2 1"><text id="info-title" text="Title" font-face="arial" font-size="11"/></border>
|
||||
<text id="info-data" text="Title" font-face="arial" font-size="11"/>
|
||||
</node>
|
||||
<image-texture id="thumb-tex" width="100" height="100"/>
|
||||
-->
|
||||
<image-texture id="thumb-tex" aspect-ratio="1" width="150" height="150"/>
|
||||
</node>
|
||||
<!--<text-input width="100" height="100" color=".3"/>-->
|
||||
<node height="40" grow="1" dir="row" align="flex-end" justify="flex-end">
|
||||
@@ -227,10 +229,10 @@
|
||||
<text text="Save Pano Project" font-face="arial" font-size="11"></text>
|
||||
</border>
|
||||
<border width="400" color="0 0 0 .9" pad="10" dir="col">
|
||||
<node dir="row">
|
||||
<text text="Project name: " font-face="arial" font-size="11"/>
|
||||
<text-input id="txt-input" width="100" height="20" color=".3"/>
|
||||
</node>
|
||||
<border dir="row" align="center" height="30" color=".2 .2 .2 1">
|
||||
<text text="Project name: " font-face="arial" font-size="11" margin="0 5 0 5"/>
|
||||
<text-input id="txt-input" justify="center" pad="5" grow="1" height="30" color=".3"/>
|
||||
</border>
|
||||
<node height="40" grow="1" dir="row" align="flex-end" justify="flex-end">
|
||||
<button id="btn-ok" text="Save Project" width="100" height="30" margin="0 10 0 0"/>
|
||||
<button id="btn-cancel" text="Cancel" width="60" height="30" pad="10"/>
|
||||
@@ -250,7 +252,7 @@
|
||||
<border width="400" color="0 0 0 .9" pad="10" dir="col">
|
||||
<border dir="row" align="center" height="30" color=".2 .2 .2 1">
|
||||
<text text="Project name: " font-face="arial" font-size="11" margin="0 5 0 5"/>
|
||||
<text-input id="txt-input" grow="1" height="30" color=".3"/>
|
||||
<text-input id="txt-input" justify="center" pad="5" grow="1" height="30" color=".3"/>
|
||||
</border>
|
||||
<node height="40" grow="1" dir="row" align="flex-end" justify="flex-end">
|
||||
<button id="btn-ok" text="Create Project" width="100" height="30" margin="0 10 0 0"/>
|
||||
|
||||
@@ -121,7 +121,7 @@ void App::update(float dt)
|
||||
if (canvas && canvas->m_canvas)
|
||||
canvas->m_canvas->stroke_draw();
|
||||
|
||||
if (!redraw)
|
||||
if (!(redraw || animate))
|
||||
return;
|
||||
|
||||
//glClearColor(.1f, .1f, .1f, 1.f);
|
||||
@@ -146,7 +146,8 @@ void App::update(float dt)
|
||||
if (n && n->m_display)
|
||||
{
|
||||
auto box = n->m_clip;
|
||||
glm::ivec4 c = glm::vec4((int)box.x - 1, (int)(height / zoom - box.y - box.w) - 1, (int)box.z + 2, (int)box.w + 2) * zoom;
|
||||
//glm::ivec4 c = glm::vec4((int)box.x - 1, (int)(height / zoom - box.y - box.w) - 1, (int)box.z + 2, (int)box.w + 2) * zoom;
|
||||
glm::ivec4 c = glm::vec4((int)box.x, (int)(height / zoom - box.y - box.w), (int)box.z, (int)box.w) * zoom;
|
||||
glScissor(c.x, c.y, c.z, c.w);
|
||||
n->draw();
|
||||
}
|
||||
|
||||
@@ -53,6 +53,7 @@ public:
|
||||
float height;
|
||||
bool keys[256];
|
||||
bool redraw = true;
|
||||
bool animate = false;
|
||||
glm::vec2 gesture_p0;
|
||||
glm::vec2 gesture_p1;
|
||||
#ifdef __ANDROID__
|
||||
@@ -101,4 +102,5 @@ public:
|
||||
void dialog_save();
|
||||
void dialog_open();
|
||||
void dialog_export();
|
||||
void dialog_layer_rename();
|
||||
};
|
||||
|
||||
@@ -11,22 +11,35 @@ void App::dialog_newdoc()
|
||||
dialog->init();
|
||||
dialog->create();
|
||||
dialog->loaded();
|
||||
dialog->input->set_text("");
|
||||
dialog->input->set_text("name");
|
||||
|
||||
layout[main_id]->add_child(dialog);
|
||||
layout[main_id]->update();
|
||||
|
||||
App::I.showKeyboard();
|
||||
|
||||
dialog->btn_ok->on_click = [this, dialog](Node*)
|
||||
{
|
||||
doc_name = dialog->input->m_string;
|
||||
if (auto docname = layout[main_id]->find<NodeText>("txt-docname"))
|
||||
docname->set_text(("Panodoc: " + doc_name).c_str());
|
||||
|
||||
layers->clear();
|
||||
canvas->m_canvas->m_layers.clear();
|
||||
canvas->m_canvas->m_order.clear();
|
||||
canvas->reset_camera();
|
||||
ActionManager::clear();
|
||||
|
||||
canvas->m_canvas->layer_add("Default");
|
||||
layers->add_layer("Default");
|
||||
|
||||
dialog->destroy();
|
||||
App::I.hideKeyboard();
|
||||
};
|
||||
dialog->btn_cancel->on_click = [this, dialog](Node*)
|
||||
{
|
||||
dialog->destroy();
|
||||
App::I.hideKeyboard();
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -73,6 +86,8 @@ void App::dialog_save()
|
||||
dialog->loaded();
|
||||
dialog->input->set_text(doc_name);
|
||||
|
||||
App::I.showKeyboard();
|
||||
|
||||
layout[main_id]->add_child(dialog);
|
||||
layout[main_id]->update();
|
||||
|
||||
@@ -83,6 +98,12 @@ void App::dialog_save()
|
||||
docname->set_text(("Panodoc: " + doc_name).c_str());
|
||||
canvas->m_canvas->project_save(data_path + "/" + doc_name + ".pano");
|
||||
dialog->destroy();
|
||||
App::I.hideKeyboard();
|
||||
};
|
||||
dialog->btn_cancel->on_click = [this, dialog](Node*)
|
||||
{
|
||||
dialog->destroy();
|
||||
App::I.hideKeyboard();
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -94,3 +115,35 @@ void App::dialog_export()
|
||||
canvas->m_canvas->export_equirectangular(data_path);
|
||||
}
|
||||
}
|
||||
|
||||
void App::dialog_layer_rename()
|
||||
{
|
||||
auto dialog = std::make_shared<NodeDialogLayerRename>();
|
||||
dialog->m_manager = &layout;
|
||||
dialog->data_path = data_path;
|
||||
dialog->init();
|
||||
dialog->create();
|
||||
dialog->loaded();
|
||||
dialog->input->set_text(layers->m_current_layer->m_label_text);
|
||||
|
||||
App::I.showKeyboard();
|
||||
|
||||
layout[main_id]->add_child(dialog);
|
||||
layout[main_id]->update();
|
||||
|
||||
dialog->btn_ok->on_click = [this,dialog](Node*)
|
||||
{
|
||||
layers->m_current_layer->set_name(dialog->get_name().c_str());
|
||||
canvas->m_canvas->m_layers[canvas->m_canvas->m_current_layer_idx].m_name = dialog->get_name();
|
||||
dialog->destroy();
|
||||
App::I.hideKeyboard();
|
||||
};
|
||||
dialog->btn_cancel->on_click = [this, dialog](Node*)
|
||||
{
|
||||
dialog->destroy();
|
||||
App::I.hideKeyboard();
|
||||
};
|
||||
|
||||
popup->mouse_release();
|
||||
popup->destroy();
|
||||
}
|
||||
|
||||
@@ -390,25 +390,7 @@ void App::init_menu_layer()
|
||||
};
|
||||
|
||||
popup->find<NodeButtonCustom>("layer-rename")->on_click = [this](Node*) {
|
||||
auto open_dialog = std::make_shared<NodeDialogLayerRename>();
|
||||
open_dialog->m_manager = &layout;
|
||||
open_dialog->data_path = data_path;
|
||||
open_dialog->init();
|
||||
open_dialog->create();
|
||||
open_dialog->loaded();
|
||||
|
||||
layout[main_id]->add_child(open_dialog);
|
||||
layout[main_id]->update();
|
||||
|
||||
open_dialog->btn_ok->on_click = [this,open_dialog](Node*)
|
||||
{
|
||||
layers->m_current_layer->set_name(open_dialog->get_name().c_str());
|
||||
canvas->m_canvas->m_layers[canvas->m_canvas->m_current_layer_idx].m_name = open_dialog->get_name();
|
||||
open_dialog->destroy();
|
||||
};
|
||||
|
||||
popup->mouse_release();
|
||||
popup->destroy();
|
||||
dialog_layer_rename();
|
||||
};
|
||||
if (layers->m_current_layer)
|
||||
popup->find<NodeButtonCustom>("layer-rename")->
|
||||
@@ -482,6 +464,7 @@ void App::initLayout()
|
||||
|
||||
canvas->m_canvas->layer_add("Default");
|
||||
layers->add_layer("Default");
|
||||
|
||||
init_toolbar_draw();
|
||||
init_toolbar_main();
|
||||
init_menu_file();
|
||||
|
||||
@@ -553,7 +553,7 @@ void Node::update_internal(const glm::vec2& origin, const glm::mat4& proj)
|
||||
float pl = 0;//YGNodeLayoutGetPadding(parent->y_node, YGEdgeLeft);
|
||||
glm::vec2 off_p(pl, pt);
|
||||
glm::vec2 off_s(pr, pb);
|
||||
m_clip_uncut = glm::vec4(m_pos - off_p, m_size + off_p + off_s);
|
||||
m_clip_uncut = glm::vec4(m_pos - off_p - glm::vec2(1), m_size + off_p + off_s + glm::vec2(2));
|
||||
m_clip = rect_intersection(m_clip_uncut, parent->m_clip);
|
||||
}
|
||||
else
|
||||
|
||||
@@ -112,6 +112,9 @@ kEventResult NodeButton::handle_event(Event* e)
|
||||
if (m_mouse_inside && on_click != nullptr)
|
||||
on_click(this);
|
||||
break;
|
||||
case kEventType::MouseCancel:
|
||||
m_border->m_color = color_normal;
|
||||
break;
|
||||
default:
|
||||
return kEventResult::Available;
|
||||
break;
|
||||
|
||||
@@ -49,12 +49,17 @@ kEventResult NodeButtonCustom::handle_event(Event* e)
|
||||
mouse_capture();
|
||||
break;
|
||||
case kEventType::MouseUpL:
|
||||
m_color = m_mouse_inside ? color_hover : color_normal;
|
||||
#ifdef __IOS__
|
||||
m_color = color_normal;
|
||||
#else
|
||||
m_color = m_mouse_inside ? color_hover : color_normal;
|
||||
#endif
|
||||
if (m_mouse_inside && on_click != nullptr)
|
||||
on_click(this);
|
||||
mouse_release();
|
||||
break;
|
||||
case kEventType::MouseCancel:
|
||||
m_color = color_normal;
|
||||
mouse_release();
|
||||
break;
|
||||
default:
|
||||
|
||||
@@ -101,7 +101,7 @@ void NodeDialogOpenItem::loaded()
|
||||
void NodeDialogOpenItem::draw()
|
||||
{
|
||||
auto c = m_selected ? m_color_selected : m_color_normal;
|
||||
//m_thinkness = m_selected ? 1.f : 0.f;
|
||||
m_thinkness = m_selected ? 1.f : 0.f;
|
||||
m_color = m_mouse_inside ? m_color_hover : c;
|
||||
NodeBorder::draw();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user