]> git.entuzijast.net Git - imunes.git/commitdiff
Implement automatic scrolling of the canvas tabs line, depending on which
authormarko <marko>
Sun, 13 Nov 2005 14:01:22 +0000 (14:01 +0000)
committermarko <marko>
Sun, 13 Nov 2005 14:01:22 +0000 (14:01 +0000)
canvas is currently selected.

Bug found by:
Submitted by:
Requested by:
Reviewed by:
Approved by:
Obtained from:

editor.tcl
initgui.tcl

index e10cb305b047688e7396e696f4947579b33d97f4..78513bd73b044b411d49c3a174c5419ec59d4f93 100755 (executable)
@@ -2050,8 +2050,22 @@ proc switchCanvas { direction } {
        .hframe.t raise $text
        incr x [expr 2 * $ox + 17]
     }
+    incr x 7
     .hframe.t raise "$curcanvas"
     .hframe.t itemconfigure "tab && $curcanvas" -fill #e0e0e0
+    .hframe.t configure -scrollregion "0 0 $x 18"
+    update
+    set width [lindex [.hframe.t configure -width] 4]
+    set lborder [lindex [.hframe.t bbox "tab && $curcanvas"] 0]
+    set rborder [lindex [.hframe.t bbox "tab && $curcanvas"] 2]
+    set lmargin [expr [lindex [.hframe.t xview] 0] * $x - 1]
+    set rmargin [expr [lindex [.hframe.t xview] 1] * $x + 1]
+    if { $lborder < $lmargin } {
+       .hframe.t xview moveto [expr 1.0 * ($lborder - 10) / $x]
+    }
+    if { $rborder > $rmargin } {
+       .hframe.t xview moveto [expr 1.0 * ($rborder - $width + 10) / $x]
+    }
 
     redrawAll
     return
index b52c8c4537f6baeb70d31b13e94bcc5a48f53994..35512d90743dfe74de72738857a1387111f8a1bd 100755 (executable)
@@ -187,7 +187,11 @@ menu .menubar.canvas -tearoff 0
     deleteSelection
     set i [lsearch $canvas_list $curcanvas]
     set canvas_list [lreplace $canvas_list $i $i]
-    switchCanvas prev
+    set curcanvas [lindex $canvas_list $i]
+    if { $curcanvas == "" } {
+       set curcanvas [lindex $canvas_list end]
+    }
+    switchCanvas none
     set changed 1
     updateUndoLog
 }
@@ -323,7 +327,8 @@ set c [canvas .c -bd 0 -relief sunken -highlightthickness 0\
        -xscrollcommand ".hframe.scroll set" \
        -yscrollcommand ".vframe.scroll set"]
 canvas .hframe.t -width 300 -height 18 -bd 0 -highlightthickness 0 \
-       -background gray
+       -background gray \
+       -xscrollcommand ".hframe.ts set"
 bind .hframe.t <1> {
     set canvas [lindex [.hframe.t gettags current] 1]
     if { $canvas != "" && $canvas != $curcanvas } {
@@ -341,7 +346,7 @@ scrollbar .hframe.scroll -orient horiz -command "$c xview" \
        -bd 1 -width 14
 scrollbar .vframe.scroll -command "$c yview" \
        -bd 1 -width 14
-scrollbar .hframe.ts -orient horiz -command "" \
+scrollbar .hframe.ts -orient horiz -command ".hframe.t xview" \
        -bd 1 -width 14
 pack .hframe.ts .hframe.t -side left -padx 0 -pady 0
 pack .hframe.scroll -side left -padx 0 -pady 0 -fill both -expand true