* [PATCH] gitk: Fix units in resize logic
@ 2009-07-16 2:12 Nelson Elhage
0 siblings, 0 replies; only message in thread
From: Nelson Elhage @ 2009-07-16 2:12 UTC (permalink / raw)
To: git; +Cc: Nelson Elhage
`resizeclistpanes' and `resizedetpanes' both contain logic that
clearly means to work in terms of columns of text, but are using APIs
that return pixels. Scale their inputs and outputs by $charspc
appropriately, resulting in much saner resize behavior.
In addition, keep the widths as floats through intermediate
calculations, which is necessary for smooth resizing behavior now that
we are working in columns.
Signed-off-by: Nelson Elhage <nelhage@mit.edu>
---
gitk-git/gitk | 28 +++++++++++++++-------------
1 files changed, 15 insertions(+), 13 deletions(-)
diff --git a/gitk-git/gitk b/gitk-git/gitk
index 4604c83..29e9442 100644
--- a/gitk-git/gitk
+++ b/gitk-git/gitk
@@ -2575,17 +2575,18 @@ proc savestuff {w} {
}
proc resizeclistpanes {win w} {
- global oldwidth
+ global oldwidth charspc
if {[info exists oldwidth($win)]} {
set s0 [$win sash coord 0]
set s1 [$win sash coord 1]
+ set w [expr {1.0 * $w / $charspc}]
if {$w < 60} {
- set sash0 [expr {int($w/2 - 2)}]
- set sash1 [expr {int($w*5/6 - 2)}]
+ set sash0 [expr {$w/2 - 2}]
+ set sash1 [expr {$w*5/6 - 2}]
} else {
- set factor [expr {1.0 * $w / $oldwidth($win)}]
- set sash0 [expr {int($factor * [lindex $s0 0])}]
- set sash1 [expr {int($factor * [lindex $s1 0])}]
+ set factor [expr {$w / $oldwidth($win)}]
+ set sash0 [expr {$factor * [lindex $s0 0] / $charspc}]
+ set sash1 [expr {$factor * [lindex $s1 0] / $charspc}]
if {$sash0 < 30} {
set sash0 30
}
@@ -2599,21 +2600,22 @@ proc resizeclistpanes {win w} {
}
}
}
- $win sash place 0 $sash0 [lindex $s0 1]
- $win sash place 1 $sash1 [lindex $s1 1]
+ $win sash place 0 [expr {int($charspc * $sash0)}] [lindex $s0 1]
+ $win sash place 1 [expr {int($charspc * $sash1)}] [lindex $s1 1]
}
set oldwidth($win) $w
}
proc resizecdetpanes {win w} {
- global oldwidth
+ global oldwidth charspc
if {[info exists oldwidth($win)]} {
set s0 [$win sash coord 0]
+ set w [expr {1.0 * $w / $charspc}]
if {$w < 60} {
- set sash0 [expr {int($w*3/4 - 2)}]
+ set sash0 [expr {$w*3/4 - 2}]
} else {
- set factor [expr {1.0 * $w / $oldwidth($win)}]
- set sash0 [expr {int($factor * [lindex $s0 0])}]
+ set factor [expr {$w / $oldwidth($win)}]
+ set sash0 [expr {$factor * [lindex $s0 0] / $charspc}]
if {$sash0 < 45} {
set sash0 45
}
@@ -2621,7 +2623,7 @@ proc resizecdetpanes {win w} {
set sash0 [expr {$w - 15}]
}
}
- $win sash place 0 $sash0 [lindex $s0 1]
+ $win sash place 0 [expr {int($charspc * $sash0)}] [lindex $s0 1]
}
set oldwidth($win) $w
}
--
1.6.3.3
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2009-07-16 2:12 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-07-16 2:12 [PATCH] gitk: Fix units in resize logic Nelson Elhage
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).