Commit 5a6f9561 authored by Florian Köberle's avatar Florian Köberle Committed by Alexandre Julliard

comctl32: Fix expanding of invisible sub trees.

parent 123dc34a
......@@ -810,13 +810,10 @@ static void TestExpandInvisible(void)
nodeVisible = TreeView_GetItemRect(hTree, node[1], &dummyRect, FALSE);
ok(!nodeVisible, "Node 1 should not be visible.\n");
nodeVisible = TreeView_GetItemRect(hTree, node[2], &dummyRect, FALSE);
todo_wine
ok(!nodeVisible, "Node 2 should not be visible.\n");
nodeVisible = TreeView_GetItemRect(hTree, node[3], &dummyRect, FALSE);
todo_wine
ok(!nodeVisible, "Node 3 should not be visible.\n");
nodeVisible = TreeView_GetItemRect(hTree, node[4], &dummyRect, FALSE);
todo_wine
ok(!nodeVisible, "Node 4 should not be visible.\n");
}
......
......@@ -3292,56 +3292,59 @@ TREEVIEW_Expand(TREEVIEW_INFO *infoPtr, TREEVIEW_ITEM *wineItem,
if (bExpandPartial)
FIXME("TVE_EXPANDPARTIAL not implemented\n");
TREEVIEW_RecalculateVisibleOrder(infoPtr, wineItem);
TREEVIEW_UpdateSubTree(infoPtr, wineItem);
TREEVIEW_UpdateScrollBars(infoPtr);
scrollRect.left = 0;
scrollRect.bottom = infoPtr->treeHeight;
scrollRect.right = infoPtr->clientWidth;
if (nextItem)
if (ISVISIBLE(wineItem))
{
scrollDist = nextItem->rect.top - orgNextTop;
scrollRect.top = orgNextTop;
TREEVIEW_RecalculateVisibleOrder(infoPtr, wineItem);
TREEVIEW_UpdateSubTree(infoPtr, wineItem);
TREEVIEW_UpdateScrollBars(infoPtr);
ScrollWindowEx (infoPtr->hwnd, 0, scrollDist, &scrollRect, NULL,
NULL, NULL, SW_ERASE | SW_INVALIDATE);
TREEVIEW_Invalidate (infoPtr, wineItem);
} else {
scrollRect.top = wineItem->rect.top;
InvalidateRect(infoPtr->hwnd, &scrollRect, FALSE);
}
scrollRect.left = 0;
scrollRect.bottom = infoPtr->treeHeight;
scrollRect.right = infoPtr->clientWidth;
if (nextItem)
{
scrollDist = nextItem->rect.top - orgNextTop;
scrollRect.top = orgNextTop;
ScrollWindowEx (infoPtr->hwnd, 0, scrollDist, &scrollRect, NULL,
NULL, NULL, SW_ERASE | SW_INVALIDATE);
TREEVIEW_Invalidate (infoPtr, wineItem);
} else {
scrollRect.top = wineItem->rect.top;
InvalidateRect(infoPtr->hwnd, &scrollRect, FALSE);
}
/* Scroll up so that as many children as possible are visible.
* This fails when expanding causes an HScroll bar to appear, but we
* don't know that yet, so the last item is obscured. */
if (wineItem->firstChild != NULL)
{
int nChildren = wineItem->lastChild->visibleOrder
- wineItem->firstChild->visibleOrder + 1;
/* Scroll up so that as many children as possible are visible.
* This fails when expanding causes an HScroll bar to appear, but we
* don't know that yet, so the last item is obscured. */
if (wineItem->firstChild != NULL)
{
int nChildren = wineItem->lastChild->visibleOrder
- wineItem->firstChild->visibleOrder + 1;
int visible_pos = wineItem->visibleOrder
- infoPtr->firstVisible->visibleOrder;
int visible_pos = wineItem->visibleOrder
- infoPtr->firstVisible->visibleOrder;
int rows_below = TREEVIEW_GetVisibleCount(infoPtr) - visible_pos - 1;
int rows_below = TREEVIEW_GetVisibleCount(infoPtr) - visible_pos - 1;
if (visible_pos > 0 && nChildren > rows_below)
{
int scroll = nChildren - rows_below;
if (visible_pos > 0 && nChildren > rows_below)
{
int scroll = nChildren - rows_below;
if (scroll > visible_pos)
scroll = visible_pos;
if (scroll > visible_pos)
scroll = visible_pos;
if (scroll > 0)
{
TREEVIEW_ITEM *newFirstVisible
= TREEVIEW_GetListItem(infoPtr, infoPtr->firstVisible,
scroll);
if (scroll > 0)
{
TREEVIEW_ITEM *newFirstVisible
= TREEVIEW_GetListItem(infoPtr, infoPtr->firstVisible,
scroll);
TREEVIEW_SetFirstVisible(infoPtr, newFirstVisible, TRUE);
}
}
TREEVIEW_SetFirstVisible(infoPtr, newFirstVisible, TRUE);
}
}
}
}
return TRUE;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment