Skip to content

Commit

Permalink
Adding PR RobinPerris#52
Browse files Browse the repository at this point in the history
DarkTreeView rendering optimization from Quobi:patch-2
  • Loading branch information
FallenAvatar committed Mar 19, 2021
1 parent 8192707 commit 564d494
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 5 deletions.
27 changes: 23 additions & 4 deletions DarkUI/Controls/DarkTreeView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1268,10 +1268,29 @@ private void DrawNode(DarkTreeNode node, Graphics g)
}

// 5. Draw child nodes
if (node.Expanded)
{
foreach (var childNode in node.Nodes)
DrawNode(childNode, g);
DrawChildNodes(node, g);
}

/// <summary>
/// Recursively paints only the nodes and child nodes within the viewport.
/// </summary>
private void DrawChildNodes(DarkTreeNode node, Graphics g) {
if( node.Expanded ) {
foreach( var childNode in node.Nodes ) {

if( childNode.Expanded )
DrawChildNodes(childNode, g);

bool isInTopView = Viewport.Top <= childNode.FullArea.Y;
bool isWithin = childNode.FullArea.Y < Viewport.Top + Viewport.Height;
bool isPastBottomView = childNode.FullArea.Y > Viewport.Top + Viewport.Height;

if( isInTopView && isWithin )
DrawNode(childNode, g);

if( isPastBottomView )
break;
}
}
}

Expand Down
4 changes: 3 additions & 1 deletion SOURCES.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,6 @@ These PRs came from RobinPerris' Repo
3. #41 https://github.com/RobinPerris/DarkUI/pull/41
- Fixed the display of the selected item in the combobox when changing its visibility from ricardodalarme:FixedComboBox
4. #48 https://github.com/RobinPerris/DarkUI/pull/48
- Fix Issue #47 from cronoxyd:master
- Fix Issue #47 from cronoxyd:master
5. #52 https://github.com/RobinPerris/DarkUI/pull/52
- DarkTreeView rendering optimization from Quobi:patch-2

0 comments on commit 564d494

Please sign in to comment.