top

Code proposal: tksurfer: Resizeable "Information" fields in tool window

Proposal status

Date

Who

Description

2008-02-22

GW

Originated

Introduction

Currently the tool window supports resizing, but this does not cause the contents to resize. This is a sore point for the information fields, where the information is sometimes longer than the field.

Use Case Analysis

1. Users need to see complete strings in "Information" fields. Currently these are sometimes too long and thus clipped. 2. There is motivation to add additional length to some of the information strings. In particular, I would like to revise tksurfer.c to add information to the "Label" field: namely Label numeric value, and also the names and values of 2nd and subsequent labels that are attached to a vertex. (That modification not considered here. However it is blocked by the non-resizing aspect of the fields in the UI.)

Analysis

Various tk frames in the hierarchy leading down to the fields in question need to be enabled for resizing.

Proposed fix

1. Add -expand yes -fill both (or similar) to various frames when they are "packed".

Proposed patches

File: tksurfer.tcl

Patch 1

-------------------------------
Near line 6123 in MAIN. Was:
-------------------------------
pack $fwMenuBar $fwToolBar \
  -side top \
  -expand true \
  -fill x

pack $fwCursor $fwMouseover \
  -side left \
  -padx 5 \
  -expand true \
  -fill x \
  -fill y \
  -anchor s

pack $wwTop

ShowToolBar main 1
-------------------------------
Change to:
-------------------------------
pack $wwTop -expand true -fill both

pack $fwMenuBar $fwToolBar \
  -side top \
  -expand true \
  -fill x

pack $fwCursor $fwMouseover \
  -side left \
  -padx 5 \
  -expand yes \
  -fill both \
  -anchor s

pack .w.fwCursor.fwLabels -fill both -expand yes
pack .w.fwMouseover.fwTop -fill both -expand yes
pack .w.fwMouseover.fwLabels -fill both -expand yes

ShowToolBar main 1

Patch 2

-------------------------------
Near line 3617 in CreateLabelFrame. Was:
-------------------------------
        # Pack them left to right.
        pack $fwLabel $fwValue $fwOverlay \
            -side left \
            -anchor w

-------------------------------
Change to:
-------------------------------
        # Pack them left to right.
        # GW mods
        # WAS: pack $fwLabel $fwValue $fwOverlay -side left -anchor w

        pack $fwLabel -side left -anchor w
        pack $fwValue -fill both -expand yes
        pack $fwOverlay -side right -anchor e
        # Not sure if this is the right treatment for fwOverlay

Patch 3

PackLabel is responsible for showing/hiding selected Information files.

Note: Remove/comment out "puts" statements after testing!

-------------------------------
Near line 3644 in PackLabel. Was:
-------------------------------
proc PackLabel { isLabel iSet ibShow } {

    global glLabel gfwaLabel

    # find the label index in our list.
    set nLabel [lsearch -exact $glLabel $isLabel]
    if { $nLabel == -1 } {
        puts "Couldn't find $isLabel\n"
        return;
    }
    
    # are we showing or hiding?
    if { $ibShow == 1 } {
        
        # go back and try to pack it after the previous labels
        set lTemp [lrange $glLabel 0 [expr $nLabel - 1]]
        set lLabelsBelow ""
        foreach element $lTemp {
            set lLabelsBelow [linsert $lLabelsBelow 0 $element]
        }
        foreach nLabel $lLabelsBelow {
            if {[catch { pack $gfwaLabel($isLabel,$iSet)      \
                             -after $gfwaLabel($nLabel,$iSet) \
                             -side top                \
                             -anchor w } sResult] == 0} {
                return;
            }
        }
        
        # if that fails, go forward and try to pack it before the later labels
        set lLabelsAbove [lrange $glLabel [expr $nLabel + 1] [llength $glLabel]]
        foreach nLabel $lLabelsAbove {
            if {[catch { pack $gfwaLabel($isLabel,$iSet)       \
                             -before $gfwaLabel($nLabel,$iSet) \
                             -side top                  \
                             -anchor w } sResult] == 0} {
                return;
            }
        }
        
        # must be the first one. just pack it.
        catch { pack $gfwaLabel($isLabel,$iSet)  \
                    -side top                \
                    -anchor w } sResult
        
    } else {
        
        # else just forget it
        pack forget $gfwaLabel($isLabel,$iSet)
    } 
}

-------------------------------
Change to:
-------------------------------
proc PackLabel { isLabel iSet ibShow } {

    global glLabel gfwaLabel

    # find the label index in our list.
    set nLabel [lsearch -exact $glLabel $isLabel]
    if { $nLabel == -1 } {
        puts "Couldn't find $isLabel\n"
        return;
    }
    
    # are we showing or hiding?
    if { $ibShow == 1 } {
        
        # go back and try to pack it after the previous labels
        set lTemp [lrange $glLabel 0 [expr $nLabel - 1]]
        set lLabelsBelow ""
        foreach element $lTemp {
            set lLabelsBelow [linsert $lLabelsBelow 0 $element]
        }
        foreach nLabel $lLabelsBelow {
            if {[catch { 
             set packee $gfwaLabel($isLabel,$iSet)
             puts "Pack: $packee" 
             pack $packee \
                             -after $gfwaLabel($nLabel,$iSet)  \
                             -side top -fill both -expand yes  \
                             -anchor w } sResult] == 0} {
                return;
            }
        }
        
        # if that fails, go forward and try to pack it before the later labels
        set lLabelsAbove [lrange $glLabel [expr $nLabel + 1] [llength $glLabel]]
        foreach nLabel $lLabelsAbove {
            if {[catch { 
             set packee $gfwaLabel($isLabel,$iSet)
             puts "Pack: $packee" 
             pack $packee \
                             -before $gfwaLabel($nLabel,$iSet)  \
                             -side top  -fill both -expand yes  \
                             -anchor w } sResult] == 0} {
                return;
            }
        }
        
        # must be the first one. just pack it.
        catch { 
             set packee $gfwaLabel($isLabel,$iSet)
             puts "Pack: $packee" 
             pack $packee \
                    -side top -fill both -expand yes  \
                    -anchor w } sResult
        
    } else {
        
        # else just forget it
        pack forget $gfwaLabel($isLabel,$iSet)
    } 
}

Trial implementation report

To be done.

Test Plan

Introduction

Tests should cover the following categories of testing:

1. Basic manual resize of the tool window.

2. Good behavior for all three sub frames that make up the tk frames that present each individual "information" field. (Beware: confusingly, the source code terms the overall field frame is "Label" and also calls the caption sub-frame a Label, and neither of these is related to the FreeSurfer concept of a per-vertex Label.) I am concerned with the subframe termed "Overlay", as I'm not sure what that's for.

References

Author(s)

GrahamWideman