From: marko Date: Sun, 13 Nov 2005 14:01:22 +0000 (+0000) Subject: Implement automatic scrolling of the canvas tabs line, depending on which X-Git-Url: https://git.entuzijast.net/?a=commitdiff_plain;h=8245d6f1c8a9190afe4084aea3d64290054827c8;p=imunes.git Implement automatic scrolling of the canvas tabs line, depending on which canvas is currently selected. Bug found by: Submitted by: Requested by: Reviewed by: Approved by: Obtained from: --- diff --git a/editor.tcl b/editor.tcl index e10cb30..78513bd 100755 --- a/editor.tcl +++ b/editor.tcl @@ -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 diff --git a/initgui.tcl b/initgui.tcl index b52c8c4..35512d9 100755 --- a/initgui.tcl +++ b/initgui.tcl @@ -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