[PATCH 2/2] winefile: Clarify header width calculations.

Lauri Kenttä lauri.kentta at gmail.com
Mon May 30 12:42:54 CDT 2016


Signed-off-by: Lauri Kenttä <lauri.kentta at gmail.com>
---
 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);
 	}
 }
 
-- 
2.8.3




More information about the wine-patches mailing list