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 | |
| 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
| -rw-r--r-- | ide/AndroidStudio3/app/src/main/cpp/HelloAndroid.cxx | 11 | ||||
| -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 |
4 files changed, 48 insertions, 8 deletions
diff --git a/ide/AndroidStudio3/app/src/main/cpp/HelloAndroid.cxx b/ide/AndroidStudio3/app/src/main/cpp/HelloAndroid.cxx index 3d916fbb9..01acf4904 100644 --- a/ide/AndroidStudio3/app/src/main/cpp/HelloAndroid.cxx +++ b/ide/AndroidStudio3/app/src/main/cpp/HelloAndroid.cxx @@ -261,6 +261,8 @@ int xmain(int argc, char **argv) - ...::line(...) has round ing issues (see rounded box type) - grab() not working when leaving window (adjuster...) - scrolling if implemented as a complete redraw. Must implement real scrolling + - the 'hotspot' idea to position dialogs under the mouse cursor makes little sense on touch screen devices + - fix screen when keyboard pops up in front of the text cursor or input field (temporarily shift up?) test/CubeMain.cxx @@ -335,18 +337,15 @@ test/utf8.cxx test/keyboard.cxx test/windowfocus.cxx - * test/ask.cxx : - * fix popup position for dialogs - * fix screen when keyboard pops up in fron of the text cursor or input field - + * test/ask.cxx : + 'ask' works + * test/button.cxx : + 'button' works, including beep * test/pack.cxx : + 'pack' works * test/adjuster.cxx : + 'adjuster' works * test/arc.cxx : + 'arc' works as expected * test/minimum.cxx : + 'minimum' works * test/boxtype.cxx : + 'boxtype' works - * test/button.cxx : + 'button' works, including beep * test/buttons.cxx : + 'buttons' works - * test/color_chooser.cxx:+ 'color_chooser' works + * test/color_chooser.cxx: + 'color_chooser' works * test/symbols.cxx : + 'symbols' working as expected * test/hello.cxx : + 'hello' works fine, italics, shadow, etc. * test/label.cxx : + 'label' works 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(); } } |
