gui icon indicating copy to clipboard operation
gui copied to clipboard

Support control alignment

Open sorawee opened this issue 5 years ago • 2 comments

When labels are specified in controls like text-box%, the controls are put right after the labels, causing the layout to look weird.

Screen Shot 2021-01-01 at 7 12 38 AM

In contrast, this is how the controls are usually aligned in most applications.

Screen Shot 2021-01-01 at 7 14 02 AM

sorawee avatar Jan 01 '21 15:01 sorawee

You can already achieve that layout by using separate message% objects for the labels and a custom panel% type. There's table-panel available as a package, but I haven't used that. I also wrote my own grid-pane% for this purpose and you can use it like this:

Screenshot 2021-01-02 075550
#lang racket/gui
(require "grid-pane.rkt")

(define toplevel (new frame% [label "Hello"] [width 300] [height 100]))

(define p (new grid-pane%
               [parent toplevel]
               [columns 2] ;; children are placed in two columns
               [spacing 5]
               [border 5]
               [alignment '(left center)]))

(new message%
     [parent p]
     [label "Font Name"])
(new choice%
     [parent p]
     [label ""]
     [choices '("Menlo")]
     [stretchable-width #t])

(new message%
     [parent p]
     [label "Font Smoothing"])
(new choice%
     [parent p]
     [label ""]
     [choices '("Use system-wide default")]
     [stretchable-width #t])

(new message%
     [parent p]
     [label "Weight"])
(new choice%
     [parent p]
     [label ""]
     [choices '("Normal")]
     [stretchable-width #t])

(send toplevel show #t)

alex-hhh avatar Jan 02 '21 00:01 alex-hhh

Your grid-pane% is published under GPL-3+, so it's not quite a replacement for this feature being in the gui package.

If anything, it's worth warning people that they should not look at your implementation if they wish to fix this issue in order to not write derived code that would then violate the GPL-3+ license if published as Apache-2 or MIT.

dancojocaru2000 avatar Mar 07 '23 12:03 dancojocaru2000