summaryrefslogtreecommitdiff
path: root/framebuffer/fbtk
diff options
context:
space:
mode:
Diffstat (limited to 'framebuffer/fbtk')
-rw-r--r--framebuffer/fbtk/event.c7
-rw-r--r--framebuffer/fbtk/fbtk.c27
-rw-r--r--framebuffer/fbtk/scroll.c41
3 files changed, 71 insertions, 4 deletions
diff --git a/framebuffer/fbtk/event.c b/framebuffer/fbtk/event.c
index bd018c52c..2ef36321e 100644
--- a/framebuffer/fbtk/event.c
+++ b/framebuffer/fbtk/event.c
@@ -248,6 +248,13 @@ fbtk_event(fbtk_widget_t *root, nsfb_event_t *event, int timeout)
timeout = 0;
break;
+ case NSFB_EVENT_RESIZE:
+ /* Try to resize framebuffer */
+ gui_resize(root,
+ event->value.resize.w,
+ event->value.resize.h);
+ break;
+
default:
break;
}
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;
diff --git a/framebuffer/fbtk/scroll.c b/framebuffer/fbtk/scroll.c
index 0ce56a6ee..e91c3ef6e 100644
--- a/framebuffer/fbtk/scroll.c
+++ b/framebuffer/fbtk/scroll.c
@@ -18,6 +18,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#include <assert.h>
+
#include <stdbool.h>
#include <libnsfb.h>
@@ -272,6 +274,26 @@ fbtk_create_vscroll(fbtk_widget_t *parent,
return neww;
}
+
+/* exported function documented in fbtk.h */
+void
+fbtk_reposition_vscroll(fbtk_widget_t *vscroll,
+ int x,
+ int y,
+ int width,
+ int height)
+{
+ assert(vscroll->type == FB_WIDGET_TYPE_VSCROLL);
+
+ fbtk_set_pos_and_size(vscroll, x, y + scrollu.height,
+ width, height - scrollu.height - scrolld.height);
+ fbtk_set_pos_and_size(vscroll->u.scroll.btnul,
+ x, y, width, scrollu.height);
+ fbtk_set_pos_and_size(vscroll->u.scroll.btndr,
+ x, y + height - scrolld.height,
+ width, scrolld.height);
+}
+
/* Horizontal scroll widget */
static int
@@ -488,6 +510,25 @@ fbtk_create_hscroll(fbtk_widget_t *parent,
return neww;
}
+/* exported function documented in fbtk.h */
+void
+fbtk_reposition_hscroll(fbtk_widget_t *scrollh,
+ int x,
+ int y,
+ int width,
+ int height)
+{
+ assert(scrollh->type == FB_WIDGET_TYPE_HSCROLL);
+
+ fbtk_set_pos_and_size(scrollh, x + scrolll.width, y,
+ width - scrolll.width - scrollr.width, height);
+ fbtk_set_pos_and_size(scrollh->u.scroll.btnul,
+ x, y, scrolll.width, height);
+ fbtk_set_pos_and_size(scrollh->u.scroll.btndr,
+ x + width - scrollr.width, y,
+ scrollr.width, height);
+}
+
/* exported function documented in fbtk.h */
bool