From 112e3c9ccc64ee631d2789e710bbcfac526b1ca9 Mon Sep 17 00:00:00 2001 From: Matt Birkholz Date: Thu, 29 Sep 2011 18:29:04 -0700 Subject: [PATCH] Do not require a resizee for make-fix-resizer. Allow the resizee slot to be #f, at least initially, for easier "reverse" packing as in a 's hboxes. --- src/gtk/fix-demo.scm | 3 ++- src/gtk/fix-layout.scm | 27 ++++++++++++++------------- src/gtk/gtk.pkg | 3 ++- 3 files changed, 18 insertions(+), 15 deletions(-) diff --git a/src/gtk/fix-demo.scm b/src/gtk/fix-demo.scm index e17d3b372..28676cdbf 100644 --- a/src/gtk/fix-demo.scm +++ b/src/gtk/fix-demo.scm @@ -34,7 +34,7 @@ USA. (scroller2 (gtk-scrolled-window-new)) (layout1 (make-demo-layout 200 200)) (layout2 (make-demo-layout 200 200)) - (resizer (make-fix-resizer layout1 -1 10))) + (resizer (make-fix-resizer -1 10))) (gtk-window-set-opacity window 0.90) (gtk-window-set-title window "fix-layout-demo") (gtk-window-set-geometry-hints window window 'min-width 10 'min-height 10) @@ -43,6 +43,7 @@ USA. (gtk-container-set-border-width window 10) (gtk-container-add scroller1 layout1) (gtk-box-pack-start vbox scroller1 #t #t 0) + (set-fix-resizer-resizee! resizer layout1) (gtk-box-pack-start vbox resizer #f #f 0) (gtk-container-add scroller2 layout2) (gtk-box-pack-start vbox scroller2 #t #t 0) diff --git a/src/gtk/fix-layout.scm b/src/gtk/fix-layout.scm index 9196a8e48..fb867ccf1 100644 --- a/src/gtk/fix-layout.scm +++ b/src/gtk/fix-layout.scm @@ -716,14 +716,14 @@ USA. ;;; This is a simple that handles expose events by ;;; calling gtk_paint_handle(). -(define-class ( (constructor (resizee) (width height))) +(define-class ( (constructor () (width height))) () ;; Inferred from aspect ratio (for now?). (stack-vertical? define standard) ;; The widget that is above or left of this widget. - (resizee define accessor) + (resizee define standard initial-value #f) ;; While a gtk_grab_add is in effect, this is the starting position ;; of the pointer (in parent coords!) and the starting size of the @@ -789,17 +789,18 @@ USA. (define (resizer-press-handler resizer type button modifiers x y) ;;; (declare (ignore type)) ;; 'press (%trace ";resizer-press-handler "type" "button" "modifiers" "x","y"\n") - (if (eq? button 1) - (let* ((geom (fix-widget-geometry resizer)) - (x-parent (fix:+ x (fix-rect-x geom))) - (y-parent (fix:+ y (fix-rect-y geom))) - (width.height (gtk-widget-get-size resizee))) - (%trace "; drag start" - " at "x-parent","y-parent - " with "(car width.height)"x"(cdr width.height)"!\n") - (set-fix-resizer-drag-start! resizer (cons (cons x-parent y-parent) - width.height)) - (C-call "gtk_grab_add" (gobject-alien resizer))))) + (let ((resizee (fix-resizer-resizee resizer))) + (if (and resizee (eq? button 1)) + (let* ((geom (fix-widget-geometry resizer)) + (x-parent (fix:+ x (fix-rect-x geom))) + (y-parent (fix:+ y (fix-rect-y geom))) + (width.height (gtk-widget-get-size resizee))) + (%trace "; drag start" + " at "x-parent","y-parent + " with "(car width.height)"x"(cdr width.height)"!\n") + (set-fix-resizer-drag-start! resizer (cons (cons x-parent y-parent) + width.height)) + (C-call "gtk_grab_add" (gobject-alien resizer)))))) (define (resizer-release-handler resizer type button modifiers x y) ;;; (declare (ignore type)) ;; 'release diff --git a/src/gtk/gtk.pkg b/src/gtk/gtk.pkg index 24b303144..2c32b5a7f 100644 --- a/src/gtk/gtk.pkg +++ b/src/gtk/gtk.pkg @@ -243,8 +243,9 @@ USA. fix-layout-scroll-step set-fix-layout-scroll-step! fix-layout-scroll-to! fix-layout-scroll-nw! - + fix-resizer? make-fix-resizer + fix-resizer-resizee set-fix-resizer-resizee! guarantee-fix-drawing make-fix-drawing fix-drawing-widgets -- 2.25.1