Android back button callback added
This commit is contained in:
parent
cfe250979a
commit
45dbde5da5
10 changed files with 39 additions and 6 deletions
|
|
@ -843,6 +843,13 @@ void InputManager::backend_key_down_update(const SDL_KeyboardEvent& e) {
|
|||
auto kPress = e.key;
|
||||
auto kMod = e.mod;
|
||||
|
||||
#ifdef __ANDROID__
|
||||
if(kPress == SDLK_AC_BACK) {
|
||||
main.input_global_back_button_callback();
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
if(kPress != SDLK_LSHIFT && kPress != SDLK_RSHIFT && kPress != SDLK_LCTRL && kPress != SDLK_RCTRL &&
|
||||
kPress != SDLK_LGUI && kPress != SDLK_RGUI &&
|
||||
kPress != SDLK_LALT && kPress != SDLK_RALT) {
|
||||
|
|
|
|||
|
|
@ -284,6 +284,11 @@ void MainProgram::input_paste_callback(const CustomEvents::PasteEvent& paste) {
|
|||
post_callback();
|
||||
}
|
||||
|
||||
void MainProgram::input_global_back_button_callback() {
|
||||
screen->input_global_back_button_callback();
|
||||
post_callback();
|
||||
}
|
||||
|
||||
bool MainProgram::input_keybind_callback(const Vector2ui32& newKey) {
|
||||
if(keybindWaiting.has_value()) {
|
||||
unsigned v = keybindWaiting.value();
|
||||
|
|
|
|||
|
|
@ -135,6 +135,7 @@ class MainProgram {
|
|||
void input_open_infinipaint_file_callback(const CustomEvents::OpenInfiniPaintFileEvent& openFile);
|
||||
void input_paste_callback(const CustomEvents::PasteEvent& paste);
|
||||
|
||||
void input_global_back_button_callback();
|
||||
bool input_keybind_callback(const Vector2ui32& newKey);
|
||||
void input_drop_file_callback(const InputManager::DropCallbackArgs& drop);
|
||||
void input_drop_text_callback(const InputManager::DropCallbackArgs& drop);
|
||||
|
|
|
|||
|
|
@ -672,16 +672,16 @@ void FileSelectScreen::file_view() {
|
|||
Vector2f iconSize{0.0f, 0.0f};
|
||||
switch(fileViewType) {
|
||||
case FileViewType::LARGE_GRID:
|
||||
entrySize = {200.0f, 220.0f};
|
||||
iconSize = {150.0f, 150.0f};
|
||||
entrySize = {170.0f, 190.0f};
|
||||
iconSize = {130.0f, 130.0f};
|
||||
break;
|
||||
case FileViewType::MEDIUM_GRID:
|
||||
entrySize = {170.0f, 190.0f};
|
||||
iconSize = {120.0f, 120.0f};
|
||||
entrySize = {140.0f, 160.0f};
|
||||
iconSize = {100.0f, 100.0f};
|
||||
break;
|
||||
case FileViewType::SMALL_GRID:
|
||||
entrySize = {140.0f, 160.0f};
|
||||
iconSize = {90.0f, 90.0f};
|
||||
entrySize = {110.0f, 130.0f};
|
||||
iconSize = {70.0f, 70.0f};
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
|
@ -741,6 +741,14 @@ void FileSelectScreen::input_open_infinipaint_file_callback(const CustomEvents::
|
|||
main.screen = std::make_unique<PhoneDrawingProgramScreen>(main);
|
||||
}
|
||||
|
||||
void FileSelectScreen::input_global_back_button_callback() {
|
||||
if(!mainMenuOpenAnim->is_at_start())
|
||||
mainMenuOpenAnim->animation_trigger_reverse();
|
||||
else if(editMode)
|
||||
editMode = false;
|
||||
main.g.gui.set_to_layout();
|
||||
}
|
||||
|
||||
void FileSelectScreen::draw(SkCanvas* canvas) {
|
||||
canvas->clear(main.g.gui.io.theme->backColor0);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ class FileSelectScreen : public Screen {
|
|||
virtual void gui_layout_run() override;
|
||||
virtual void draw(SkCanvas* canvas) override;
|
||||
virtual void input_open_infinipaint_file_callback(const CustomEvents::OpenInfiniPaintFileEvent& openFile) override;
|
||||
virtual void input_global_back_button_callback() override;
|
||||
|
||||
struct TrashInfo {
|
||||
struct TrashFile {
|
||||
|
|
|
|||
|
|
@ -65,3 +65,10 @@ void PhoneDrawingProgramScreen::top_toolbar() {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
void PhoneDrawingProgramScreen::input_global_back_button_callback() {
|
||||
main.world->save_to_file(main.world->filePath);
|
||||
main.set_tab_to_close(main.world.get());
|
||||
main.screen = std::make_unique<FileSelectScreen>(main);
|
||||
main.g.gui.set_to_layout();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ class PhoneDrawingProgramScreen : public DrawingProgramScreen {
|
|||
PhoneDrawingProgramScreen(MainProgram& m);
|
||||
virtual void update() override;
|
||||
virtual void gui_layout_run() override;
|
||||
virtual void input_global_back_button_callback() override;
|
||||
private:
|
||||
void top_toolbar();
|
||||
void main_display();
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ bool Screen::app_close_requested() { return true; }
|
|||
void Screen::input_add_file_to_canvas_callback(const CustomEvents::AddFileToCanvasEvent& addFile) {}
|
||||
void Screen::input_open_infinipaint_file_callback(const CustomEvents::OpenInfiniPaintFileEvent& openFile) {}
|
||||
void Screen::input_paste_callback(const CustomEvents::PasteEvent& paste) {}
|
||||
void Screen::input_global_back_button_callback() {}
|
||||
void Screen::input_drop_file_callback(const InputManager::DropCallbackArgs& drop) {}
|
||||
void Screen::input_drop_text_callback(const InputManager::DropCallbackArgs& drop) {}
|
||||
void Screen::input_key_callback(const InputManager::KeyCallbackArgs& key) {}
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ class Screen {
|
|||
virtual void input_add_file_to_canvas_callback(const CustomEvents::AddFileToCanvasEvent& addFile);
|
||||
virtual void input_open_infinipaint_file_callback(const CustomEvents::OpenInfiniPaintFileEvent& openFile);
|
||||
virtual void input_paste_callback(const CustomEvents::PasteEvent& paste);
|
||||
virtual void input_global_back_button_callback();
|
||||
virtual void input_drop_file_callback(const InputManager::DropCallbackArgs& drop);
|
||||
virtual void input_drop_text_callback(const InputManager::DropCallbackArgs& drop);
|
||||
virtual void input_key_callback(const InputManager::KeyCallbackArgs& key);
|
||||
|
|
|
|||
|
|
@ -204,6 +204,7 @@ void initialize_sdl(MainStruct& mS, int wWidth, int wHeight) {
|
|||
SDL_SetHint(SDL_HINT_PEN_MOUSE_EVENTS, "0");
|
||||
SDL_SetHint(SDL_HINT_MOUSE_TOUCH_EVENTS, "0");
|
||||
SDL_SetHint(SDL_HINT_TOUCH_MOUSE_EVENTS, "0");
|
||||
SDL_SetHint(SDL_HINT_ANDROID_TRAP_BACK_BUTTON, "1");
|
||||
SDL_SetHint(SDL_HINT_EMSCRIPTEN_KEYBOARD_ELEMENT, "#canvas"); // Ensures that SDL only grabs input when browser is focused on canvas
|
||||
|
||||
if(!SDL_Init(SDL_INIT_VIDEO))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue