]> git.entuzijast.net Git - imunes.git/commitdiff
Implement canvas switching by clicking on a canvas "tab" at the bottom
authormarko <marko>
Sun, 13 Nov 2005 12:00:23 +0000 (12:00 +0000)
committermarko <marko>
Sun, 13 Nov 2005 12:00:23 +0000 (12:00 +0000)
of the main window.

Double-click on a canvas "tab" opens up a canvas-rename dialog box.

Remove canvas switching / selection entries from the top-level canvas menu.

Add several new key bindings: Home/End switches to first/last canvas,
cursor keys scroll/pan the current viewport on the current canvas.

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

editor.tcl
filemgmt.tcl
initgui.tcl

index 741dfd72e1e0c98703c3e685fcf895247a338903..a81a02c62895ba31e1d69d298a97fa952bbe0884 100755 (executable)
@@ -123,7 +123,6 @@ proc undo {} {
        incr undolevel -1
        loadCfg $undolog($undolevel)
        switchCanvas none
-       redrawAll
     }
     return
 }
@@ -136,7 +135,6 @@ proc redo {} {
        incr undolevel
        loadCfg $undolog($undolevel)
        switchCanvas none
-       redrawAll
     }
     return
 }
@@ -156,7 +154,6 @@ proc redrawAll {} {
            drawNode $node
        }
     }
-
     foreach link $link_list {
        set nodes [linkPeers $link]
        if { [getNodeCanvas [lindex $nodes 0]] != $curcanvas ||
@@ -167,8 +164,6 @@ proc redrawAll {} {
        redrawLink $link
        updateLinkLabel $link
     }
-
-    refreshCanvasMenu
     return
 }
 
@@ -2024,6 +2019,12 @@ proc switchCanvas { direction } {
                set curcanvas [lindex $canvas_list $i]
            }
        }
+       first {
+           set curcanvas [lindex $canvas_list 0]
+       }
+       last {
+           set curcanvas [lindex $canvas_list end]
+       }
     }
 
     .hframe.t delete all
@@ -2051,6 +2052,32 @@ proc switchCanvas { direction } {
 }
 
 
+proc renameCanvasPopup {} {
+    global curcanvas
+
+    set w .entry1
+    catch {destroy $w}
+    toplevel $w -takefocus 1
+    update
+    grab $w
+    wm title $w "Canvas rename"
+    wm iconname $w "Canvas rename"
+
+    label $w.msg -wraplength 5i -justify left -text "Canvas name:"
+    pack $w.msg -side top
+
+    frame $w.buttons
+    pack $w.buttons -side bottom -fill x -pady 2m
+    button $w.buttons.print -text "Apply" -command "renameCanvasApply $w"
+    button $w.buttons.cancel -text "Cancel" -command "destroy $w"
+    pack $w.buttons.print $w.buttons.cancel -side left -expand 1
+
+    entry $w.e1 -bg white
+    $w.e1 insert 0 [getCanvasName $curcanvas]
+    pack $w.e1 -side top -pady 5 -padx 10 -fill x
+}
+
+
 proc renameCanvasApply { w } {
     global curcanvas changed
 
@@ -2060,75 +2087,11 @@ proc renameCanvasApply { w } {
        set changed 1
     }
     setCanvasName $curcanvas $newname
-    refreshCanvasMenu
     switchCanvas none
     updateUndoLog
 }
 
 
-proc refreshCanvasMenu {} {
-    global canvas_list curcanvas
-
-    .menubar.canvas delete 0 end
-    .menubar.canvas add command -label "New" -command {
-        newCanvas ""
-        set curcanvas [lindex $canvas_list 0]
-        switchCanvas prev
-        set changed 1
-        updateUndoLog
-        refreshCanvasMenu
-    }
-    .menubar.canvas add command -label "Rename" -command {
-       set w .entry1
-       catch {destroy $w}
-       toplevel $w -takefocus 1
-       grab $w
-       wm title $w "Canvas rename"
-       wm iconname $w "Canvas rename"
-
-       label $w.msg -wraplength 5i -justify left -text "Canvas name:"
-       pack $w.msg -side top
-
-       frame $w.buttons
-       pack $w.buttons -side bottom -fill x -pady 2m
-       button $w.buttons.print -text "Apply" -command "renameCanvasApply $w"
-       button $w.buttons.cancel -text "Cancel" -command "destroy $w"
-       pack $w.buttons.print $w.buttons.cancel -side left -expand 1
-
-       entry $w.e1 -bg white
-       $w.e1 insert 0 [getCanvasName $curcanvas]
-       pack $w.e1 -side top -pady 5 -padx 10 -fill x
-    }
-    .menubar.canvas add command -label "Delete" -command {
-        if { [llength $canvas_list] == 1 } {
-            return
-        }
-        foreach obj [.c find withtag node] {
-            selectNode .c $obj
-        }
-        deleteSelection
-        set i [lsearch $canvas_list $curcanvas]
-        set canvas_list [lreplace $canvas_list $i $i]
-        switchCanvas none
-        set changed 1
-        updateUndoLog
-        refreshCanvasMenu
-    }
-    .menubar.canvas add separator
-    .menubar.canvas add command -label "Previous" -accelerator "PgUp" \
-       -command { switchCanvas prev }
-    .menubar.canvas add command -label "Next" -accelerator "PgDown" \
-       -command { switchCanvas next }
-    .menubar.canvas add separator
-    foreach canvas $canvas_list {
-       .menubar.canvas add radiobutton -label [getCanvasName $canvas] \
-               -command "switchCanvas none" -indicatoron true \
-               -value $canvas -variable curcanvas
-    }
-    return
-}
-
-
 proc animate {} {
     global animatephase oper_mode
 
index b277ef5f83ad6315c18a4cea50084008a692e611..ccd8c267ff423f475860957c31e42e3aa49e77fa 100755 (executable)
@@ -86,6 +86,7 @@ proc newFile {} {
     }
     loadCfg ""
     set curcanvas [lindex $canvas_list 0]
+    switchCanvas none
     redrawAll
     set currentFile ""
     wm title . "IMUNES"
@@ -107,6 +108,7 @@ proc openFile {} {
     close $fileId
     loadCfg $cfg
     set curcanvas [lindex $canvas_list 0]
+    switchCanvas none
     redrawAll
     set undolevel 0
     set redolevel 0
index 87c66af467914940739a141b0cdde38a130b11a4..b52c8c4537f6baeb70d31b13e94bcc5a48f53994 100755 (executable)
@@ -170,8 +170,40 @@ bind . <Control-a> {
 # Canvas
 #
 menu .menubar.canvas -tearoff 0
+.menubar.canvas add command -label "New" -command {
+    newCanvas ""
+    switchCanvas last
+    set changed 1
+    updateUndoLog
+}
+.menubar.canvas add command -label "Rename" -command renameCanvasPopup
+.menubar.canvas add command -label "Delete" -command {
+    if { [llength $canvas_list] == 1 } {
+         return
+    }
+    foreach obj [.c find withtag node] {
+        selectNode .c $obj
+    }
+    deleteSelection
+    set i [lsearch $canvas_list $curcanvas]
+    set canvas_list [lreplace $canvas_list $i $i]
+    switchCanvas prev
+    set changed 1
+    updateUndoLog
+}
+.menubar.canvas add separator
+.menubar.canvas add command -label "Previous" -accelerator "PgUp" \
+    -command { switchCanvas prev }
 bind . <Prior> { switchCanvas prev }
+.menubar.canvas add command -label "Next" -accelerator "PgDown" \
+    -command { switchCanvas next }
 bind . <Next> { switchCanvas next }
+.menubar.canvas add command -label "First" -accelerator "Home" \
+    -command { switchCanvas first }
+bind . <Home> { switchCanvas first }
+.menubar.canvas add command -label "Last" -accelerator "End" \
+    -command { switchCanvas last }
+bind . <End> { switchCanvas last }
 
 
 #
@@ -292,6 +324,19 @@ set c [canvas .c -bd 0 -relief sunken -highlightthickness 0\
        -yscrollcommand ".vframe.scroll set"]
 canvas .hframe.t -width 300 -height 18 -bd 0 -highlightthickness 0 \
        -background gray
+bind .hframe.t <1> {
+    set canvas [lindex [.hframe.t gettags current] 1]
+    if { $canvas != "" && $canvas != $curcanvas } {
+       set curcanvas $canvas
+       switchCanvas none
+    }
+}
+bind .hframe.t <Double-1> {
+    set canvas [lindex [.hframe.t gettags current] 1]
+    if { $canvas != "" } {
+       renameCanvasPopup
+    }
+}
 scrollbar .hframe.scroll -orient horiz -command "$c xview" \
        -bd 1 -width 14
 scrollbar .vframe.scroll -command "$c yview" \
@@ -352,7 +397,10 @@ bind $c <2> "$c scan mark %x %y"
 bind $c <B2-Motion> "$c scan dragto %x %y 1"
 bind $c <4> "$c yview scroll 1 units"
 bind $c <5> "$c yview scroll -1 units"
-
+bind . <Right> ".c xview scroll 1 units"
+bind . <Left> ".c xview scroll -1 units"
+bind . <Down> ".c yview scroll 1 units"
+bind . <Up> ".c yview scroll -1 units"
 
 #
 # Popup-menu hierarchy
@@ -376,8 +424,7 @@ bind . <Control-i> {
 #
 # Done with initialization, draw an empty canvas
 #
-refreshCanvasMenu
-redrawAll
+switchCanvas first
 
 #
 # Fire up the animation loop - used basically for selectbox