diff options
| author | Matthias Melcher <fltk@matthiasm.com> | 2018-06-21 17:02:47 +0000 |
|---|---|---|
| committer | Matthias Melcher <fltk@matthiasm.com> | 2018-06-21 17:02:47 +0000 |
| commit | 333e718ae735411fec220334256360b8e3b4b1bb (patch) | |
| tree | e3d5a504565f1f2bdd461e7e9c90ae454dc62a5f /src/drivers/Android | |
| parent | 22c21fa8401b6e433611258a703a0d7eda64584a (diff) | |
Android: Windows are now centered on screen if no position is defined, dialogs pop up in a more logical position.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.4@12958 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src/drivers/Android')
| -rw-r--r-- | src/drivers/Android/Fl_Android_Screen_Driver.H | 4 | ||||
| -rw-r--r-- | src/drivers/Android/Fl_Android_Screen_Driver.cxx | 21 | ||||
| -rw-r--r-- | src/drivers/Android/Fl_Android_Window_Driver.cxx | 20 |
3 files changed, 43 insertions, 2 deletions
diff --git a/src/drivers/Android/Fl_Android_Screen_Driver.H b/src/drivers/Android/Fl_Android_Screen_Driver.H index d9054efa5..714be5fd2 100644 --- a/src/drivers/Android/Fl_Android_Screen_Driver.H +++ b/src/drivers/Android/Fl_Android_Screen_Driver.H @@ -126,7 +126,9 @@ public: virtual int compose(int &del); virtual Fl_RGB_Image *read_win_rectangle(int X, int Y, int w, int h); Fl_RGB_Image *read_win_rectangle_unscaled(int X, int Y, int w, int h); - virtual int get_mouse(int &x, int &y); +#endif + virtual int get_mouse(int &x, int &y) override; +#if 0 virtual void enable_im(); virtual void disable_im(); virtual void open_display_platform(); diff --git a/src/drivers/Android/Fl_Android_Screen_Driver.cxx b/src/drivers/Android/Fl_Android_Screen_Driver.cxx index 060cda304..4a9674a2b 100644 --- a/src/drivers/Android/Fl_Android_Screen_Driver.cxx +++ b/src/drivers/Android/Fl_Android_Screen_Driver.cxx @@ -483,6 +483,27 @@ void Fl_Android_Screen_Driver::beep(int type) } +/** + * Get the current mouse coordinates. + * + * This is used, among other things, to position the FLTK standard dialogs in + * a way that makes it easy to click the most common button. For an Android + * touch screen, this makes no sense at all, which is why we return the center + * of the screen for now. + * + * TODO: rethink the dialog positioning scheme for touch devices. + * + * @param [out] x + * @param [out] y + * @return + */ +int Fl_Android_Screen_Driver::get_mouse(int &x, int &y) +{ + x = 600/2; + y = 800/2; + return 1; +} + // // End of "$Id$". // diff --git a/src/drivers/Android/Fl_Android_Window_Driver.cxx b/src/drivers/Android/Fl_Android_Window_Driver.cxx index 7a06bc372..364e0b62f 100644 --- a/src/drivers/Android/Fl_Android_Window_Driver.cxx +++ b/src/drivers/Android/Fl_Android_Window_Driver.cxx @@ -49,12 +49,29 @@ void Fl_Android_Window_Driver::show() if (!shown()) { // make window fl_open_display(); + if (pWindow->parent() && !Fl_X::i(pWindow->window())) { + pWindow->set_visible(); + return; + } pWindow->set_visible(); Fl_X *x = new Fl_X; x->w = pWindow; i(x); x->next = Fl_X::first; Fl_X::first = x; + // position window + // TODO: we want to scale the screen to hold all windows + // TODO: we want to allow for screen size hints to make apps look perfect, even if the screen is rotated + if (force_position()) { + // TODO: make sure that we are on a screen if this is just a regular window + } else { + // Center any new window on screen + pWindow->position( + (600-pWindow->w())/2, + (800-pWindow->h())/2 + ); + } + // show window or defer showing window if (Fl_Android_Application::native_window()) { pWindow->redraw(); } else { @@ -62,7 +79,8 @@ void Fl_Android_Window_Driver::show() } } else { // bring window to front - Fl::first_window(pWindow); // TODO: does this really work? + if (!pWindow->parent()) + Fl::first_window(pWindow); // TODO: does this really work? expose_all(); } } |
