adding color picking on iOS

This commit is contained in:
2017-08-02 19:51:59 +01:00
parent d01ec65cad
commit 235862c9d1
13 changed files with 202 additions and 15 deletions

View File

@@ -5,6 +5,7 @@ using namespace ui;
void App::resize(float w, float h)
{
redraw = true;
width = w;
height = h;
if (auto* main = layout[main_id])
@@ -13,6 +14,7 @@ void App::resize(float w, float h)
void App::showKeyboard()
{
redraw = true;
#ifdef __IOS__
[ios_view becomeFirstResponder];
#endif
@@ -20,6 +22,7 @@ void App::showKeyboard()
void App::hideKeyboard()
{
redraw = true;
#ifdef __IOS__
[ios_view resignFirstResponder];
#endif
@@ -27,6 +30,7 @@ void App::hideKeyboard()
bool App::mouse_down(int button, float x, float y, float pressure)
{
redraw = true;
MouseEvent e;
e.m_type = button ? kEventType::MouseDownR : kEventType::MouseDownL;
e.m_pos = { x / zoom, y / zoom };
@@ -37,6 +41,7 @@ bool App::mouse_down(int button, float x, float y, float pressure)
}
bool App::mouse_move(float x, float y, float pressure)
{
redraw = true;
MouseEvent e;
e.m_type = kEventType::MouseMove;
e.m_pos = { x / zoom, y / zoom };
@@ -48,6 +53,7 @@ bool App::mouse_move(float x, float y, float pressure)
}
bool App::mouse_up(int button, float x, float y)
{
redraw = true;
MouseEvent e;
e.m_type = button ? kEventType::MouseUpR : kEventType::MouseUpL;
e.m_pos = { x / zoom, y / zoom };
@@ -57,6 +63,7 @@ bool App::mouse_up(int button, float x, float y)
}
bool App::mouse_scroll(float x, float y, float delta)
{
redraw = true;
MouseEvent e;
e.m_type = kEventType::MouseScroll;
e.m_pos = { x / zoom, y / zoom };
@@ -67,6 +74,7 @@ bool App::mouse_scroll(float x, float y, float delta)
}
bool App::mouse_cancel(int button)
{
redraw = true;
MouseEvent e;
e.m_type = kEventType::MouseCancel;
auto ret = layout[main_id]->on_event(&e);
@@ -75,6 +83,7 @@ bool App::mouse_cancel(int button)
}
bool App::gesture_start(const glm::vec2& p0, const glm::vec2& p1)
{
redraw = true;
GestureEvent e;
glm::vec2 p = glm::lerp(p0, p1, 0.5f);
e.m_type = kEventType::GestureStart;
@@ -88,6 +97,7 @@ bool App::gesture_start(const glm::vec2& p0, const glm::vec2& p1)
}
bool App::gesture_move(const glm::vec2& p0, const glm::vec2& p1)
{
redraw = true;
GestureEvent e;
glm::vec2 p = glm::lerp(p0, p1, 0.5f);
e.m_type = kEventType::GestureMove;
@@ -101,6 +111,7 @@ bool App::gesture_move(const glm::vec2& p0, const glm::vec2& p1)
}
bool App::gesture_end()
{
redraw = true;
GestureEvent e;
e.m_type = kEventType::GestureEnd;
auto ret = layout[main_id]->on_event(&e);
@@ -109,6 +120,7 @@ bool App::gesture_end()
}
bool App::key_down(kKey key)
{
redraw = true;
keys[(int)key] = true;
KeyEvent e;
e.m_type = kEventType::KeyDown;
@@ -119,6 +131,7 @@ bool App::key_down(kKey key)
}
bool App::key_up(kKey key)
{
redraw = true;
keys[(int)key] = false;
KeyEvent e;
e.m_type = kEventType::KeyUp;
@@ -129,6 +142,7 @@ bool App::key_up(kKey key)
}
bool App::key_char(char key)
{
redraw = true;
KeyEvent e;
e.m_type = kEventType::KeyChar;
e.m_char = key;