summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMatthias Melcher <fltk@matthiasm.com>2018-03-16 17:53:09 +0000
committerMatthias Melcher <fltk@matthiasm.com>2018-03-16 17:53:09 +0000
commit6c234ad12ed4d5bbaff68165bf77430027fca55c (patch)
treef2d08621defcc251182a58f4c7cf41e4fcdcf9bb /src
parentb6858cef5694f3c2aa9a9899d2516ef07ea7d85c (diff)
Android: starting to handle user clipping regions, but first I will
render better text, so I have something to test this on. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.4@12761 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src')
-rw-r--r--src/drivers/Android/Fl_Android_Graphics_Clipping.H3
-rw-r--r--src/drivers/Android/Fl_Android_Graphics_Clipping.cxx30
2 files changed, 22 insertions, 11 deletions
diff --git a/src/drivers/Android/Fl_Android_Graphics_Clipping.H b/src/drivers/Android/Fl_Android_Graphics_Clipping.H
index 7c88b54a5..7f6d43f96 100644
--- a/src/drivers/Android/Fl_Android_Graphics_Clipping.H
+++ b/src/drivers/Android/Fl_Android_Graphics_Clipping.H
@@ -64,7 +64,7 @@ public:
bool is_empty() const;
bool is_infinite() const;
- void set_empty();
+ virtual void set_empty();
void set(int x, int y, int w, int h);
void set_ltrb(int l, int t, int r, int b);
virtual void set(const Fl_Rect_Region &r);
@@ -152,6 +152,7 @@ public:
virtual void set(const Fl_Rect_Region &r) override;
void set(const Fl_Complex_Region &r);
+ virtual void set_empty() override { delete pSubregion; pSubregion=0L; Fl_Rect_Region::set_empty(); }
Fl_Complex_Region *subregion() const { return pSubregion; }
Fl_Complex_Region *next() const { return pNext; }
Fl_Complex_Region *parent() const { return pParent; }
diff --git a/src/drivers/Android/Fl_Android_Graphics_Clipping.cxx b/src/drivers/Android/Fl_Android_Graphics_Clipping.cxx
index 022acea86..86f04f412 100644
--- a/src/drivers/Android/Fl_Android_Graphics_Clipping.cxx
+++ b/src/drivers/Android/Fl_Android_Graphics_Clipping.cxx
@@ -304,7 +304,7 @@ int Fl_Complex_Region::subtract(const Fl_Rect_Region &r)
// nothing to do
break;
case SAME:
- set_empty(); // FIXME: delete this Rect!
+ set_empty(); // Will be deleted by compress()
break;
case LESS:
// split this rect into 1, 2, 3, or 4 new ones
@@ -361,16 +361,15 @@ void Fl_Complex_Region::compress()
}
/**
- * Subtract a rect from another rect, potentially creating four new rectangles.
+ * Subtract a smaller rect from a larger rect, potentially creating four new rectangles.
* This assumes that the calling region is NOT complex.
- * @param r subtract the area of this rectangle.
+ * @param r subtract the area of this rectangle; r must fit within ``this``.
* @return currently 0, but this may change
*/
int Fl_Complex_Region::subtract_smaller_region(const Fl_Rect_Region &r)
{
// subtract a smaller rect from a larger rect and create subrects as needed
- // FIXME: make sure that the bbox of the parent region is shrunk to the size of all children
- // if there is only one single coordinte different, we can reuse this container
+ // if there is only one single coordinate different, we can reuse this container
if (left()==r.left() && top()==r.top() && right()==r.right() && bottom()==r.bottom()) {
// this should not happen
set_empty();
@@ -647,12 +646,23 @@ void Fl_Android_Graphics_Driver::restore_clip()
{
fl_clip_state_number++;
- pClippingRegion.set(pDesktopWindowRegion);
-
-
- Fl_Region b = rstack[rstackptr];
+ // find the current user clipping rectangle
+ Fl_Region b = rstack[rstackptr]; // Fl_Region is a pointer to Fl_Rect_Region
if (b) {
- // FIXME: pClippingRegion.intersect_with(*b);
+ if (b->is_empty()) {
+ // if this is an empty region, the intersection is always empty as well
+ pClippingRegion.set_empty();
+ } else {
+ // if there is a region, copy the full window region
+ pClippingRegion.set(pDesktopWindowRegion);
+ if (!b->is_infinite()) {
+ // if the rect has dimensions, calculate the intersection
+ pClippingRegion.intersect_with(*b);
+ }
+ }
+ } else {
+ // no rect? Just copy the window region
+ pClippingRegion.set(pDesktopWindowRegion);
}
}