From b023ebf7a51594acf03d0a0639bb1b0617a385e5 Mon Sep 17 00:00:00 2001 From: Jon Harper Date: Sat, 8 Sep 2012 14:33:22 +0200 Subject: [PATCH] Add resize-window and relayout-window --- basis/ui/backend/gtk/gtk.factor | 2 ++ basis/ui/ui.factor | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/basis/ui/backend/gtk/gtk.factor b/basis/ui/backend/gtk/gtk.factor index 64e53a6a61..adcad20e0e 100644 --- a/basis/ui/backend/gtk/gtk.factor +++ b/basis/ui/backend/gtk/gtk.factor @@ -479,6 +479,8 @@ M: gtk-ui-backend (close-window) ( handle -- ) window>> [ gtk_widget_destroy ] [ unregister-window ] bi event-loop? [ gtk_main_quit ] unless ; +M: gtk-ui-backend resize-window [ handle>> window>> ] [ first2 ] bi* gtk_window_resize ; + M: gtk-ui-backend set-title swap [ handle>> window>> ] [ utf8 string>alien ] bi* gtk_window_set_title ; diff --git a/basis/ui/ui.factor b/basis/ui/ui.factor index f30821fa96..f4c8b3af8b 100644 --- a/basis/ui/ui.factor +++ b/basis/ui/ui.factor @@ -214,6 +214,13 @@ M: object close-window ui-notify-flag set-global ] "ui" add-startup-hook +HOOK: resize-window ui-backend ( world dim -- ) +M: object resize-window 2drop ; + +: relayout-window ( gadget -- ) + [ relayout ] + [ find-world [ dup pref-dim resize-window ] when* ] bi ; + : with-ui ( quot: ( -- ) -- ) ui-running? [ call( -- ) ] [ '[ init-ui @ ] (with-ui) ] if ;