diff options
author | Michael Drake <tlsa@netsurf-browser.org> | 2014-07-26 22:12:55 +0100 |
---|---|---|
committer | Michael Drake <tlsa@netsurf-browser.org> | 2014-07-26 22:12:55 +0100 |
commit | 31def6a33878b1ca8f5340d30708c853cdafefa1 (patch) | |
tree | e8ec8b84db672163a1a01ee93937adefe6b1cc57 /framebuffer/fbtk/fbtk.c | |
parent | 989e82544e3a5b2f74216e91d269e3572c8053ce (diff) | |
download | netsurf-31def6a33878b1ca8f5340d30708c853cdafefa1.tar.gz netsurf-31def6a33878b1ca8f5340d30708c853cdafefa1.tar.bz2 |
Add rudimentary support for resizing.
- Currently only libnsfb's SDL surface supports resizing.
- Flickers like crazy while resizing. Possibly because the SDL
surface is not set to use double buffering.
- The internal widget library, fbtk, was never intended for this,
as such it has no knowledge of how a widget should be positioned
with respect to its parent.
This means the top level window has to track everything and move
them itself.
Diffstat (limited to 'framebuffer/fbtk/fbtk.c')
-rw-r--r-- | framebuffer/fbtk/fbtk.c | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/framebuffer/fbtk/fbtk.c b/framebuffer/fbtk/fbtk.c index 984748402..cb8aec57f 100644 --- a/framebuffer/fbtk/fbtk.c +++ b/framebuffer/fbtk/fbtk.c @@ -209,6 +209,29 @@ fbtk_set_pos_and_size(fbtk_widget_t *widget, int x, int y, int width, int height) { + if (widget->parent != NULL) { + fbtk_widget_t *parent = widget->parent; + + /* make new window fit inside parent */ + if (width == 0) { + width = parent->width - x; + } else if (width < 0) { + width = parent->width + width - x; + } + if ((width + x) > parent->width) { + width = parent->width - x; + } + + if (height == 0) { + height = parent->height - y; + } else if (height < 0) { + height = parent->height + height - y; + } + if ((height + y) > parent->height) { + height = parent->height - y; + } + } + if ((widget->x != x) || (widget->y != y) || (widget->width != width) || @@ -217,10 +240,6 @@ fbtk_set_pos_and_size(fbtk_widget_t *widget, widget->y = y; widget->width = width; widget->height = height; - /* @todo This should limit the redrawn area to the sum - * of the old and new widget dimensions, not redraw the lot. - */ - fbtk_request_redraw(widget->parent); return true; } return false; |