You've already forked lazarus-ccr
NiceSidebar: Attempting to fix component not being updated on qt5 (drawing outside paint cycle).
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8865 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -304,6 +304,7 @@ type
|
|||||||
procedure ClearList;
|
procedure ClearList;
|
||||||
procedure ListChange(RebuildItems: Boolean);
|
procedure ListChange(RebuildItems: Boolean);
|
||||||
procedure DoDrawItem(Index: Integer);
|
procedure DoDrawItem(Index: Integer);
|
||||||
|
procedure InvalidateItem(Index: Integer); // <---
|
||||||
function GetIndexAtPos(X, Y: Integer): Integer;
|
function GetIndexAtPos(X, Y: Integer): Integer;
|
||||||
function CreateItem: TSideBarItem;
|
function CreateItem: TSideBarItem;
|
||||||
procedure UpdateItem(Index: Integer);
|
procedure UpdateItem(Index: Integer);
|
||||||
@ -842,8 +843,12 @@ begin
|
|||||||
begin
|
begin
|
||||||
FItemIndex := P^.ItemIndex;
|
FItemIndex := P^.ItemIndex;
|
||||||
FSubItemIndex := P^.SubIndex;
|
FSubItemIndex := P^.SubIndex;
|
||||||
|
InvalidateItem(LastSubIndex);
|
||||||
|
InvalidateItem(i);
|
||||||
|
{
|
||||||
DoDrawItem(LastSubIndex);
|
DoDrawItem(LastSubIndex);
|
||||||
DoDrawItem(i);
|
DoDrawItem(i);
|
||||||
|
}
|
||||||
LastSubIndex := i;
|
LastSubIndex := i;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -856,9 +861,14 @@ begin
|
|||||||
begin
|
begin
|
||||||
if FItems[FItemIndex].FExpanded then
|
if FItems[FItemIndex].FExpanded then
|
||||||
begin
|
begin
|
||||||
|
InvalidateItem(LastIndex);
|
||||||
|
InvalidateItem(LastSubIndex);
|
||||||
|
InvalidateItem(i);
|
||||||
|
{
|
||||||
DoDrawItem(LastIndex);
|
DoDrawItem(LastIndex);
|
||||||
DoDrawItem(LastSubIndex);
|
DoDrawItem(LastSubIndex);
|
||||||
DoDrawItem(i);
|
DoDrawItem(i);
|
||||||
|
}
|
||||||
LastIndex := i;
|
LastIndex := i;
|
||||||
LastSubIndex := -1;
|
LastSubIndex := -1;
|
||||||
end else
|
end else
|
||||||
@ -872,10 +882,16 @@ begin
|
|||||||
end else
|
end else
|
||||||
// on sub items
|
// on sub items
|
||||||
begin
|
begin
|
||||||
|
InvalidateItem(LastIndex);
|
||||||
|
InvalidateItem(LastSubIndex);
|
||||||
|
InvalidateItem(i);
|
||||||
|
InvalidateItem(i - FSubItemIndex - 1);
|
||||||
|
{
|
||||||
DoDrawItem(LastIndex);
|
DoDrawItem(LastIndex);
|
||||||
DoDrawItem(LastSubIndex);
|
DoDrawItem(LastSubIndex);
|
||||||
DoDrawItem(i);
|
DoDrawItem(i);
|
||||||
DoDrawItem(i - FSubItemIndex - 1);
|
DoDrawItem(i - FSubItemIndex - 1);
|
||||||
|
}
|
||||||
LastSubIndex := i;
|
LastSubIndex := i;
|
||||||
LastIndex := i - FSubItemIndex - 1;
|
LastIndex := i - FSubItemIndex - 1;
|
||||||
end;
|
end;
|
||||||
@ -901,8 +917,12 @@ begin
|
|||||||
if (HoverIndex <> SCTOPINDEX) then
|
if (HoverIndex <> SCTOPINDEX) then
|
||||||
begin
|
begin
|
||||||
HoverIndex := SCTOPINDEX;
|
HoverIndex := SCTOPINDEX;
|
||||||
|
InvalidateItem(LastHover);
|
||||||
|
InvalidateItem(HoverIndex);
|
||||||
|
{
|
||||||
DoDrawItem(LastHover);
|
DoDrawItem(LastHover);
|
||||||
DoDrawItem(HoverIndex);
|
DoDrawItem(HoverIndex);
|
||||||
|
}
|
||||||
LastHover := SCTOPINDEX;
|
LastHover := SCTOPINDEX;
|
||||||
end;
|
end;
|
||||||
Exit;
|
Exit;
|
||||||
@ -916,8 +936,12 @@ begin
|
|||||||
if (HoverIndex <> SCBOTTOMINDEX) then
|
if (HoverIndex <> SCBOTTOMINDEX) then
|
||||||
begin
|
begin
|
||||||
HoverIndex := SCBOTTOMINDEX;
|
HoverIndex := SCBOTTOMINDEX;
|
||||||
|
InvalidateItem(LastHover);
|
||||||
|
InvalidateItem(HoverIndex);
|
||||||
|
{
|
||||||
DoDrawItem(LastHover);
|
DoDrawItem(LastHover);
|
||||||
DoDrawItem(HoverIndex);
|
DoDrawItem(HoverIndex);
|
||||||
|
}
|
||||||
LastHover := SCBOTTOMINDEX;
|
LastHover := SCBOTTOMINDEX;
|
||||||
end;
|
end;
|
||||||
Exit;
|
Exit;
|
||||||
@ -944,10 +968,11 @@ begin
|
|||||||
begin
|
begin
|
||||||
HoverIndex := i;
|
HoverIndex := i;
|
||||||
if (LastHover >= 0) and (LastHover < FList.Count)
|
if (LastHover >= 0) and (LastHover < FList.Count)
|
||||||
then DoDrawItem(LastHover);
|
then InvalidateItem(LastHover); //DoDrawItem(LastHover);
|
||||||
if (HoverIndex > -1) then
|
if (HoverIndex > -1) then
|
||||||
begin
|
begin
|
||||||
DoDrawItem(HoverIndex);
|
InvalidateItem(HoverIndex);
|
||||||
|
//DoDrawItem(HoverIndex);
|
||||||
P := PSBInfo(FList[i]);
|
P := PSBInfo(FList[i]);
|
||||||
if Assigned(FOnHover)
|
if Assigned(FOnHover)
|
||||||
then FOnHover(Self, P^.ItemIndex, P^.SubIndex, P^.Caption);
|
then FOnHover(Self, P^.ItemIndex, P^.SubIndex, P^.Caption);
|
||||||
@ -965,7 +990,7 @@ begin
|
|||||||
begin
|
begin
|
||||||
HoverIndex := -1;
|
HoverIndex := -1;
|
||||||
if (LastHover >= 0) and (LastHover < FList.Count)
|
if (LastHover >= 0) and (LastHover < FList.Count)
|
||||||
then DoDrawItem(LastHover);
|
then InvalidateItem(LastHover); //DoDrawItem(LastHover);
|
||||||
LastHover := -1;
|
LastHover := -1;
|
||||||
end;
|
end;
|
||||||
if Assigned(FOnHover)
|
if Assigned(FOnHover)
|
||||||
@ -1068,6 +1093,28 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TNiceSideBar.InvalidateItem(Index: Integer);
|
||||||
|
var
|
||||||
|
Rc: TRect;
|
||||||
|
Info: PSBInfo;
|
||||||
|
begin
|
||||||
|
if Index = -1 then
|
||||||
|
exit;
|
||||||
|
|
||||||
|
if Index = SCTOPINDEX then
|
||||||
|
Rc := ScTop
|
||||||
|
else
|
||||||
|
if Index = SCBOTTOMINDEX then
|
||||||
|
Rc := ScBottom
|
||||||
|
else
|
||||||
|
begin
|
||||||
|
Info := PSBInfo(FList[Index]);
|
||||||
|
CopyRect(Rc, Info^.Rc);
|
||||||
|
OffsetRect(Rc, 0, -DeltaY);
|
||||||
|
end;
|
||||||
|
InvalidateRect(Handle, @Rc, false);
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TNiceSideBar.DoDrawItem(Index: Integer);
|
procedure TNiceSideBar.DoDrawItem(Index: Integer);
|
||||||
var
|
var
|
||||||
Info: PSBInfo;
|
Info: PSBInfo;
|
||||||
@ -1622,7 +1669,8 @@ begin
|
|||||||
Break;
|
Break;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
DoDrawItem(i);
|
InvalidateItem(i);
|
||||||
|
//DoDrawItem(i);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TNiceSideBar.UpdateItems;
|
procedure TNiceSideBar.UpdateItems;
|
||||||
@ -1671,8 +1719,12 @@ begin
|
|||||||
begin
|
begin
|
||||||
if FItems[FItemIndex].FExpanded then
|
if FItems[FItemIndex].FExpanded then
|
||||||
begin
|
begin
|
||||||
|
InvalidateItem(LastIndex);
|
||||||
|
InvalidateItem(LastSubIndex);
|
||||||
|
{
|
||||||
DoDrawItem(LastIndex);
|
DoDrawItem(LastIndex);
|
||||||
DoDrawItem(LastSubIndex);
|
DoDrawItem(LastSubIndex);
|
||||||
|
}
|
||||||
end else
|
end else
|
||||||
begin
|
begin
|
||||||
FItems[FItemIndex].Expand;
|
FItems[FItemIndex].Expand;
|
||||||
@ -1680,8 +1732,12 @@ begin
|
|||||||
end;
|
end;
|
||||||
end else
|
end else
|
||||||
begin
|
begin
|
||||||
|
InvalidateItem(LastIndex);
|
||||||
|
InvalidateItem(LastSubIndex);
|
||||||
|
{
|
||||||
DoDrawItem(LastIndex);
|
DoDrawItem(LastIndex);
|
||||||
DoDrawItem(LastSubIndex);
|
DoDrawItem(LastSubIndex);
|
||||||
|
}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
if IsUpdating then
|
if IsUpdating then
|
||||||
@ -1702,7 +1758,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
if Redraw
|
if Redraw
|
||||||
then DoDrawItem(LastIndex);
|
then InvalidateItem(LastIndex); //DoDrawItem(LastIndex);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -1735,10 +1791,11 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
DoDrawItem(LastSubIndex);
|
InvalidateItem(LastSubIndex);
|
||||||
|
//DoDrawItem(LastSubIndex);
|
||||||
LastSubIndex := i;
|
LastSubIndex := i;
|
||||||
if (i > -1)
|
if (i > -1)
|
||||||
then DoDrawItem(i);
|
then InvalidateItem(i); //DoDrawItem(i);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -1969,13 +2026,15 @@ begin
|
|||||||
begin
|
begin
|
||||||
LastHover := TopIndex;
|
LastHover := TopIndex;
|
||||||
HoverIndex := TopIndex;
|
HoverIndex := TopIndex;
|
||||||
DoDrawItem(HoverIndex);
|
InvalidateItem(HoverIndex);
|
||||||
|
//DoDrawItem(HoverIndex);
|
||||||
end else
|
end else
|
||||||
begin
|
begin
|
||||||
HoverIndex := Min(FList.Count-1, HoverIndex + 1);
|
HoverIndex := Min(FList.Count-1, HoverIndex + 1);
|
||||||
if (LastHover >= 0) and (LastHover < FList.Count)
|
if (LastHover >= 0) and (LastHover < FList.Count)
|
||||||
then DoDrawItem(LastHover);
|
then InvalidateItem(LastHover); //DoDrawItem(LastHover);
|
||||||
DoDrawItem(HoverIndex);
|
InvalidateItem(HoverIndex);
|
||||||
|
//DoDrawItem(HoverIndex);
|
||||||
LastHover := HoverIndex;
|
LastHover := HoverIndex;
|
||||||
end;
|
end;
|
||||||
if (HoverIndex >= BottomIndex-1) and ScBottomVisible then
|
if (HoverIndex >= BottomIndex-1) and ScBottomVisible then
|
||||||
@ -1999,13 +2058,15 @@ begin
|
|||||||
begin
|
begin
|
||||||
LastHover := BottomIndex;
|
LastHover := BottomIndex;
|
||||||
HoverIndex := BottomIndex;
|
HoverIndex := BottomIndex;
|
||||||
DoDrawItem(HoverIndex);
|
InvalidateItem(HoverIndex);
|
||||||
|
//DoDrawItem(HoverIndex);
|
||||||
end else
|
end else
|
||||||
begin
|
begin
|
||||||
HoverIndex := Max(0, HoverIndex - 1);
|
HoverIndex := Max(0, HoverIndex - 1);
|
||||||
if (LastHover >= 0) and (LastHover < FList.Count)
|
if (LastHover >= 0) and (LastHover < FList.Count)
|
||||||
then DoDrawItem(LastHover);
|
then InvalidateItem(LastHover); //DoDrawItem(LastHover);
|
||||||
DoDrawItem(HoverIndex);
|
InvalidateItem(HoverIndex);
|
||||||
|
//DoDrawItem(HoverIndex);
|
||||||
LastHover := HoverIndex;
|
LastHover := HoverIndex;
|
||||||
end;
|
end;
|
||||||
end else
|
end else
|
||||||
|
Reference in New Issue
Block a user