2016-03-11 00:19:27 +00:00
|
|
|
//
|
|
|
|
|
// "$Id: Fl_PicoAndroid_Window_Driver.cxx 11253 2016-03-01 00:54:21Z matt $"
|
|
|
|
|
//
|
|
|
|
|
// Definition of Android Window interface based on SDL
|
|
|
|
|
//
|
|
|
|
|
// Copyright 1998-2016 by Bill Spitzak and others.
|
|
|
|
|
//
|
|
|
|
|
// This library is free software. Distribution and use rights are outlined in
|
|
|
|
|
// the file "COPYING" which should have been included with this file. If this
|
|
|
|
|
// file is missing or damaged, see the license at:
|
|
|
|
|
//
|
|
|
|
|
// http://www.fltk.org/COPYING.php
|
|
|
|
|
//
|
|
|
|
|
// Please report all bugs and problems on the following page:
|
|
|
|
|
//
|
|
|
|
|
// http://www.fltk.org/str.php
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "../../config_lib.h"
|
|
|
|
|
#include "Fl_PicoAndroid_Window_Driver.H"
|
2016-03-11 17:12:21 +00:00
|
|
|
|
2016-03-11 22:01:55 +00:00
|
|
|
#include "Fl_PicoAndroid_Screen_Driver.H"
|
|
|
|
|
|
|
|
|
|
#include <jni.h>
|
|
|
|
|
#include <errno.h>
|
|
|
|
|
|
|
|
|
|
#include <android/sensor.h>
|
|
|
|
|
#include <android/log.h>
|
|
|
|
|
#include <android_native_app_glue.h>
|
|
|
|
|
|
2016-03-11 17:12:21 +00:00
|
|
|
#include <FL/x.H>
|
2016-03-11 00:19:27 +00:00
|
|
|
#include <FL/Fl.H>
|
2016-03-11 17:12:21 +00:00
|
|
|
#include <FL/Fl_Window.H>
|
|
|
|
|
#include <FL/Fl_Window_Driver.H>
|
2016-03-13 23:03:42 +00:00
|
|
|
#include <FL/fl_draw.h>
|
2016-03-11 00:19:27 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
Fl_Window_Driver *Fl_Window_Driver::newWindowDriver(Fl_Window *win)
|
|
|
|
|
{
|
|
|
|
|
return new Fl_PicoAndroid_Window_Driver(win);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Fl_PicoAndroid_Window_Driver::Fl_PicoAndroid_Window_Driver(Fl_Window *win)
|
|
|
|
|
: Fl_Pico_Window_Driver(win)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Fl_PicoAndroid_Window_Driver::~Fl_PicoAndroid_Window_Driver()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Fl_X *Fl_PicoAndroid_Window_Driver::makeWindow()
|
|
|
|
|
{
|
2016-03-11 22:01:55 +00:00
|
|
|
Fl_PicoAndroid_Screen_Driver *scr = (Fl_PicoAndroid_Screen_Driver*)Fl::screen_driver();
|
|
|
|
|
|
2016-03-11 00:19:27 +00:00
|
|
|
Fl_Group::current(0);
|
2016-03-24 01:20:08 +00:00
|
|
|
if (parent() && !Fl_X::i(pWindow->window())) {
|
2016-03-11 00:19:27 +00:00
|
|
|
pWindow->set_visible();
|
|
|
|
|
return 0L;
|
|
|
|
|
}
|
|
|
|
|
Window parent;
|
2016-03-25 23:10:15 +00:00
|
|
|
if (pWindow->parent()) {
|
2016-03-11 00:19:27 +00:00
|
|
|
parent = fl_xid(pWindow->window());
|
|
|
|
|
} else {
|
|
|
|
|
parent = 0;
|
|
|
|
|
}
|
|
|
|
|
Fl_X *x = new Fl_X;
|
|
|
|
|
x->other_xid = 0;
|
|
|
|
|
x->w = pWindow;
|
|
|
|
|
x->region = 0;
|
|
|
|
|
if (!pWindow->force_position()) {
|
2016-03-24 01:20:08 +00:00
|
|
|
// pNativeWindow = SDL_CreateWindow(pWindow->label(), SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, w(), h(), 0);
|
2016-03-11 00:19:27 +00:00
|
|
|
} else {
|
2016-03-24 01:20:08 +00:00
|
|
|
// pNativeWindow = SDL_CreateWindow(pWindow->label(), x(), y(), w(), h(), 0);
|
2016-03-11 00:19:27 +00:00
|
|
|
}
|
2016-03-11 22:01:55 +00:00
|
|
|
pNativeWindow = scr->pApp->window;
|
2016-03-11 00:19:27 +00:00
|
|
|
// x->xid = SDL_CreateRenderer(pNativeWindow, -1, SDL_RENDERER_ACCELERATED);
|
|
|
|
|
x->next = Fl_X::first;
|
|
|
|
|
x->wait_for_expose = 0;
|
|
|
|
|
pWindow->i = x;
|
|
|
|
|
Fl_X::first = x;
|
|
|
|
|
|
|
|
|
|
pWindow->set_visible();
|
|
|
|
|
pWindow->redraw();
|
2016-03-13 23:03:42 +00:00
|
|
|
pWindow->flush();
|
2016-03-11 00:19:27 +00:00
|
|
|
int old_event = Fl::e_number;
|
|
|
|
|
pWindow->handle(Fl::e_number = FL_SHOW);
|
|
|
|
|
Fl::e_number = old_event;
|
|
|
|
|
|
|
|
|
|
return x;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2016-03-13 23:03:42 +00:00
|
|
|
void Fl_PicoAndroid_Window_Driver::flush_single()
|
|
|
|
|
{
|
|
|
|
|
glClearColor(0, 0, 0, 1);
|
|
|
|
|
glClear(GL_COLOR_BUFFER_BIT);
|
|
|
|
|
Fl_X *i = Fl_X::i(pWindow);
|
|
|
|
|
if (!i) return;
|
|
|
|
|
fl_clip_region(i->region);
|
|
|
|
|
i->region = 0;
|
|
|
|
|
pWindow->draw();
|
|
|
|
|
Fl_PicoAndroid_Screen_Driver *scr = (Fl_PicoAndroid_Screen_Driver*)Fl::screen_driver();
|
|
|
|
|
scr->drawFrame();
|
|
|
|
|
}
|
|
|
|
|
|
2016-03-13 22:16:37 +00:00
|
|
|
|
2016-03-13 23:03:42 +00:00
|
|
|
#if 0
|
2016-03-11 00:19:27 +00:00
|
|
|
void Fl_PicoAndroid_Window_Driver::flush()
|
|
|
|
|
{
|
2016-03-11 22:01:55 +00:00
|
|
|
Fl_PicoAndroid_Screen_Driver *scr = (Fl_PicoAndroid_Screen_Driver*)Fl::screen_driver();
|
|
|
|
|
// LOGI("Flush...");
|
|
|
|
|
glClearColor(0, 0, 0, 1);
|
|
|
|
|
glClear(GL_COLOR_BUFFER_BIT);
|
2016-03-11 00:19:27 +00:00
|
|
|
pWindow->flush();
|
2016-03-11 22:01:55 +00:00
|
|
|
// fl_color(FL_RED);
|
|
|
|
|
// fl_rectf(10, 10, 300, 400);
|
|
|
|
|
scr->drawFrame();
|
2016-03-11 00:19:27 +00:00
|
|
|
}
|
2016-03-13 23:03:42 +00:00
|
|
|
#endif
|
2016-03-11 00:19:27 +00:00
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// End of "$Id: Fl_PicoSDL_Window_Driver.cxx 11253 2016-03-01 00:54:21Z matt $".
|
2016-03-25 23:10:15 +00:00
|
|
|
//
|