=?UTF-8?Q?Lauri=20Kentt=C3=A4=20?=: winefile: Clarify header width calculations.

Alexandre Julliard julliard at winehq.org
Tue May 31 10:42:52 CDT 2016


Module: wine
Branch: master
Commit: a3547a1359f9bf0f0603ff44c5eaf7972723d21a
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=a3547a1359f9bf0f0603ff44c5eaf7972723d21a

Author: Lauri Kenttä <lauri.kentta at gmail.com>
Date:   Mon May 30 20:42:54 2016 +0300

winefile: Clarify header width calculations.

Signed-off-by: Lauri Kenttä <lauri.kentta at gmail.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 programs/winefile/winefile.c | 27 +++++++++------------------
 1 file changed, 9 insertions(+), 18 deletions(-)

diff --git a/programs/winefile/winefile.c b/programs/winefile/winefile.c
index 5709c8e..327e92a 100644
--- a/programs/winefile/winefile.c
+++ b/programs/winefile/winefile.c
@@ -3163,29 +3163,20 @@ static void set_header(Pane* pane)
 {
 	HDITEMW item;
 	int scroll_pos = GetScrollPos(pane->hwnd, SB_HORZ);
-	int i=0, x=0;
+	int i;
 
 	item.mask = HDI_WIDTH;
-	item.cxy = 0;
 
-	for(; (i < COLUMNS) && (x+pane->widths[i] < scroll_pos); i++) {
-		x += pane->widths[i];
-		pane->widths_shown[i] = item.cxy;
-		SendMessageW(pane->hwndHeader, HDM_SETITEMW, i, (LPARAM)&item);
-	}
-
-	if (i < COLUMNS) {
-		x += pane->widths[i];
-		item.cxy = x - scroll_pos;
-		pane->widths_shown[i] = item.cxy;
-		SendMessageW(pane->hwndHeader, HDM_SETITEMW, i++, (LPARAM)&item);
-
-		for(; i < COLUMNS; i++) {
+	for (i = 0; i < COLUMNS; ++i) {
+		if (pane->positions[i] >= scroll_pos) {
 			item.cxy = pane->widths[i];
-			x += pane->widths[i];
-			pane->widths_shown[i] = item.cxy;
-			SendMessageW(pane->hwndHeader, HDM_SETITEMW, i, (LPARAM)&item);
+		} else if (pane->positions[i+1] <= scroll_pos) {
+			item.cxy = 0;
+		} else {
+			item.cxy = pane->positions[i+1] - scroll_pos;
 		}
+		pane->widths_shown[i] = item.cxy;
+		SendMessageW(pane->hwndHeader, HDM_SETITEMW, i, (LPARAM)&item);
 	}
 }
 




More information about the wine-cvs mailing list