Fix icon alignment when the screen width is not a multiple of the icon spacing.

Fixes bug 912.

svn path=/trunk/; revision=18673
This commit is contained in:
Gé van Geldorp 2005-10-22 12:01:29 +00:00
parent 72f86b85b9
commit bcd9ce027b

View file

@ -730,14 +730,11 @@ void DesktopShellView::PositionIcons(int dir)
int dx2 = dir_x2 * cx; int dx2 = dir_x2 * cx;
int dy2 = dir_y2 * cy; int dy2 = dir_y2 * cy;
int start_x = (start_pos.x * work_area.right)/cx*cx + (cx-32)/2; int xoffset = (cx-32)/2;
int start_y = (start_pos.y * work_area.bottom)/cy*cy + 4/*(cy-32)/2*/; int yoffset = 4/*(cy-32)/2*/;
if (start_x >= work_area.right) int start_x = start_pos.x * (work_area.right - cx) + xoffset;
start_x -= cx; int start_y = start_pos.y * (work_area.bottom - cy) + yoffset;
if (start_y >= work_area.bottom)
start_y -= cy;
int x = start_x; int x = start_x;
int y = start_y; int y = start_y;
@ -755,19 +752,22 @@ void DesktopShellView::PositionIcons(int dir)
IconMap pos_idx; IconMap pos_idx;
int cnt = 0; int cnt = 0;
int xhv = start_x;
int yhv = start_y;
for(int idx=i1; idx!=i2; idx+=dir) { for(int idx=i1; idx!=i2; idx+=dir) {
pos_idx[IconPos(y, x)] = idx; pos_idx[IconPos(y, x)] = idx;
if (_icon_algo == ARRANGE_BORDER_DOWN) { if (_icon_algo == ARRANGE_BORDER_DOWN) {
if (++cnt & 1) if (++cnt & 1)
x = work_area.right - x; x = work_area.right - x - cx + 2*xoffset;
else { else {
y += dy1; y += dy1;
if (y >= work_area.bottom) { if (y + cy - 2 * yoffset > work_area.bottom) {
y = start_y; y = start_y;
x += dx2; start_x += dx2;
x = start_x;
} }
} }
@ -775,20 +775,32 @@ void DesktopShellView::PositionIcons(int dir)
} }
else if (_icon_algo == ARRANGE_BORDER_HV) { else if (_icon_algo == ARRANGE_BORDER_HV) {
if (++cnt & 1) if (++cnt & 1)
x = work_area.right - x; x = work_area.right - x - cx + 2*xoffset;
else if (cnt & 2) { else if (cnt & 2) {
y += dy1; yhv += cy;
y = yhv;
x = start_x;
if (y >= work_area.bottom) { if (y + cy - 2 * yoffset > work_area.bottom) {
y = start_y; start_x += cx;
x += dx2; xhv = start_x;
x = xhv;
start_y += cy;
yhv = start_y;
y = yhv;
} }
} else { } else {
x += dx1; xhv += cx;
x = xhv;
y = start_y;
if (x >= work_area.right) { if (x + cx - 2 * xoffset > work_area.right) {
x = start_x; start_x += cx;
y += dy2; xhv = start_x;
x = xhv;
start_y += cy;
yhv = start_y;
y = yhv;
} }
} }
@ -803,10 +815,10 @@ void DesktopShellView::PositionIcons(int dir)
x += dx1; x += dx1;
y += dy1; y += dy1;
if (x<0 || x>=work_area.right) { if (x<0 || x+cx-2*xoffset>work_area.right) {
x = start_x; x = start_x;
y += dy2; y += dy2;
} else if (y<0 || y>=work_area.bottom) { } else if (y<0 || y+cy-2*yoffset>work_area.bottom) {
y = start_y; y = start_y;
x += dx2; x += dx2;
} }