From 5591ba811aab2fc67255a4bc469e86ecc1fad37d Mon Sep 17 00:00:00 2001 From: Matthias Melcher Date: Sat, 10 Mar 2018 13:17:41 +0000 Subject: Android: adding and fixing to the graphics clipping code Android has no classic window manager, so FLTK has to make sure that popup windows, dialog boxes and multi window interfaces work as expectd. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.4@12729 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- .../Android/Fl_Android_Graphics_Driver_region.cxx | 71 ++++++++++++++-------- 1 file changed, 45 insertions(+), 26 deletions(-) (limited to 'src/drivers/Android/Fl_Android_Graphics_Driver_region.cxx') diff --git a/src/drivers/Android/Fl_Android_Graphics_Driver_region.cxx b/src/drivers/Android/Fl_Android_Graphics_Driver_region.cxx index 107a6e708..27e105d89 100644 --- a/src/drivers/Android/Fl_Android_Graphics_Driver_region.cxx +++ b/src/drivers/Android/Fl_Android_Graphics_Driver_region.cxx @@ -23,37 +23,55 @@ #include -Fl_Clip_Rect Fl_Android_Graphics_Driver::pClipRect; +Fl_Complex_Region Fl_Android_Graphics_Driver::pWindowRegion; + // return 0 for empty, 1 for same, 2 if intersecting -int Fl_Clip_Rect::intersect_with(Fl_Clip_Rect *a) +int Fl_Rect_Region::intersect_with(Fl_Rect_Region *a) { - if (pRect.is_empty()) { - return 0; + if (is_empty()) { + return EMPTY; } - if (a->pRect.is_empty()) { - pRect.clear(); - return 0; + if (a->is_empty()) { + clear(); + return EMPTY; } - int x = max(pRect.x(), a->pRect.x()); - int y = max(pRect.y(), a->pRect.y()); - int r = min(pRect.r(), a->pRect.r()); - int b = min(pRect.b(), a->pRect.b()); - int w = r-x; - int h = b-y; - if (pRect.equals(x, y, w, h)) { - return 1; + int lx = max(x(), a->x()); + int ly = max(y(), a->y()); + int lr = min(r(), a->r()); + int lb = min(b(), a->b()); + int lw = lr-lx; + int lh = lb-ly; + if (equals(lx, ly, lw, lh)) { + return SAME; } - pRect.set(x, y, w, h); - if ( (pRect.w()<=0) || (pRect.h()<=0) ) { - pRect.clear(); - return 0; + set(lx, ly, lw, lh); + if ( (w()<=0) || (h()<=0) ) { + clear(); + return EMPTY; } - return 2; + return LESS; +} + + + +Fl_Complex_Region::~Fl_Complex_Region() +{ + delete pSubregion; // recursively delete all subregions + delete pNext; // recursively delete all following regions } +void Fl_Complex_Region::set(Fl_Rect *rect) +{ + delete pSubregion; + pSubregion = 0L; + delete pNext; + pNext = 0L; + Fl_Rect_Region::set(rect); +} + void Fl_Android_Graphics_Driver::clip_region(Fl_Region r) { @@ -73,27 +91,28 @@ void Fl_Android_Graphics_Driver::restore_clip() { fl_clip_state_number++; Fl_Window *win = Fl_Window::current(); - Fl_Clip_Rect a(0, 0, win->w(), win->h()); + Fl_Rect_Region a(0, 0, win->w(), win->h()); Fl_Region b = rstack[rstackptr]; if (b) { // FIXME: scaling! a.intersect_with(b); } - pClipRect = a; + pWindowRegion.set(b); + // FIXME: intersect with complex window region } void Fl_Android_Graphics_Driver::push_clip(int x, int y, int w, int h) { Fl_Region r; if (w > 0 && h > 0) { - r = new Fl_Clip_Rect(x,y,w,h); + r = new Fl_Rect_Region(x,y,w,h); Fl_Region current = rstack[rstackptr]; if (current) { r->intersect_with(current); } } else { // make empty clip region: - r = new Fl_Clip_Rect(); + r = new Fl_Rect_Region(); } if (rstackptr < region_stack_max) rstack[++rstackptr] = r; else Fl::warning("Fl_Android_Graphics_Driver::push_clip: clip stack overflow!\n"); @@ -136,7 +155,7 @@ int Fl_Android_Graphics_Driver::clip_box(int x, int y, int w, int h, int& X, int return 0; } - Fl_Clip_Rect a(x, y, w, h); + Fl_Rect_Region a(x, y, w, h); int ret = a.intersect_with(r); // return 0 for empty, 1 for same, 2 if intersecting X = a.x(); Y = a.y(); @@ -161,7 +180,7 @@ int Fl_Android_Graphics_Driver::not_clipped(int x, int y, int w, int h) { Fl_Region r = rstack[rstackptr]; if (!r) return 1; - Fl_Clip_Rect a(x, y, w, h); // return 0 for empty, 1 for same, 2 if intersecting + Fl_Rect_Region a(x, y, w, h); // return 0 for empty, 1 for same, 2 if intersecting return a.intersect_with(r); } -- cgit v1.2.3