@@ -32,28 +32,32 @@ public HistoryControlRenderResult Render(Rect containingRect, Rect rect, Vector2
3232
3333 controlId = GUIUtility . GetControlID ( FocusType . Keyboard ) ;
3434
35- var treeHasFocus = GUIUtility . keyboardControl == controlId ;
3635 if ( Event . current . type != EventType . Repaint )
3736 {
3837 if ( rightClickNextRender != null )
3938 {
4039 rightClickNextRender . Invoke ( rightClickNextRenderEntry ) ;
4140 rightClickNextRender = null ;
42- //TODO: Default GitLogEntry
43- rightClickNextRenderEntry = new GitLogEntry ( ) ;
41+ rightClickNextRenderEntry = GitLogEntry . Default ;
4442 }
4543 }
4644
45+ var startDisplay = scroll . y ;
46+ var endDisplay = scroll . y + containingRect . height ;
47+
4748 rect = new Rect ( rect . x , rect . y , rect . width , 0 ) ;
4849
4950 for ( var index = 0 ; index < entries . Count ; index ++ )
5051 {
5152 var entry = entries [ index ] ;
52- var isLocalCommit = index < statusAhead ;
5353
5454 var entryRect = new Rect ( rect . x , rect . y , rect . width , Styles . HistoryEntryHeight ) ;
5555
56- RenderEntry ( entryRect , entry , isLocalCommit , index == selectedIndex ) ;
56+ var shouldRenderEntry = ! ( entryRect . y > endDisplay || entryRect . yMax < startDisplay ) ;
57+ if ( shouldRenderEntry && Event . current . type == EventType . Repaint )
58+ {
59+ RenderEntry ( entryRect , entry , index ) ;
60+ }
5761
5862 var entryRequiresRepaint = HandleInput ( entryRect , entry , index , singleClick , doubleClick , rightClick ) ;
5963 requiresRepaint = requiresRepaint || entryRequiresRepaint ;
@@ -67,6 +71,64 @@ public HistoryControlRenderResult Render(Rect containingRect, Rect rect, Vector2
6771 } ;
6872 }
6973
74+ private void RenderEntry ( Rect entryRect , GitLogEntry entry , int index )
75+ {
76+ var isLocalCommit = index < statusAhead ;
77+ var isSelected = index == selectedIndex ;
78+ var summaryRect = new Rect ( entryRect . x , entryRect . y + Styles . BaseSpacing / 2 , entryRect . width , Styles . HistorySummaryHeight + Styles . BaseSpacing ) ;
79+ var timestampRect = new Rect ( entryRect . x , entryRect . yMax - Styles . HistoryDetailsHeight - Styles . BaseSpacing / 2 , entryRect . width , Styles . HistoryDetailsHeight ) ;
80+
81+ var hasKeyboardFocus = GUIUtility . keyboardControl == controlId ;
82+
83+ Styles . Label . Draw ( entryRect , GUIContent . none , false , false , isSelected , hasKeyboardFocus ) ;
84+ Styles . HistoryEntrySummaryStyle . Draw ( summaryRect , entry . Summary , false , false , isSelected , hasKeyboardFocus ) ;
85+
86+ var historyEntryDetail = string . Format ( HistoryEntryDetailFormat , entry . PrettyTimeString , entry . AuthorName ) ;
87+ Styles . HistoryEntryDetailsStyle . Draw ( timestampRect , historyEntryDetail , false , false , isSelected , hasKeyboardFocus ) ;
88+
89+ if ( ! string . IsNullOrEmpty ( entry . MergeA ) )
90+ {
91+ const float MergeIndicatorWidth = 10.28f ;
92+ const float MergeIndicatorHeight = 12f ;
93+ var mergeIndicatorRect = new Rect ( entryRect . x + 7 , summaryRect . y , MergeIndicatorWidth , MergeIndicatorHeight ) ;
94+
95+ GUI . DrawTexture ( mergeIndicatorRect , Styles . MergeIcon ) ;
96+
97+ DrawTimelineRectAroundIconRect ( entryRect , mergeIndicatorRect ) ;
98+
99+ summaryRect . Set ( mergeIndicatorRect . xMax , summaryRect . y , summaryRect . width - MergeIndicatorWidth ,
100+ summaryRect . height ) ;
101+ }
102+ else
103+ {
104+ if ( isLocalCommit )
105+ {
106+ const float LocalIndicatorSize = 6f ;
107+ var localIndicatorRect = new Rect ( entryRect . x + ( Styles . BaseSpacing - 2 ) , summaryRect . y + 5 , LocalIndicatorSize ,
108+ LocalIndicatorSize ) ;
109+
110+ DrawTimelineRectAroundIconRect ( entryRect , localIndicatorRect ) ;
111+
112+ GUI . DrawTexture ( localIndicatorRect , Styles . LocalCommitIcon ) ;
113+
114+ summaryRect . Set ( localIndicatorRect . xMax , summaryRect . y , summaryRect . width - LocalIndicatorSize ,
115+ summaryRect . height ) ;
116+ }
117+ else
118+ {
119+ const float NormalIndicatorWidth = 6f ;
120+ const float NormalIndicatorHeight = 6f ;
121+
122+ var normalIndicatorRect = new Rect ( entryRect . x + ( Styles . BaseSpacing - 2 ) , summaryRect . y + 5 ,
123+ NormalIndicatorWidth , NormalIndicatorHeight ) ;
124+
125+ DrawTimelineRectAroundIconRect ( entryRect , normalIndicatorRect ) ;
126+
127+ GUI . DrawTexture ( normalIndicatorRect , Styles . DotIcon ) ;
128+ }
129+ }
130+ }
131+
70132 private bool HandleInput ( Rect rect , GitLogEntry entry , int index , Action < GitLogEntry > singleClick = null ,
71133 Action < GitLogEntry > doubleClick = null , Action < GitLogEntry > rightClick = null )
72134 {
@@ -119,64 +181,6 @@ private bool HandleInput(Rect rect, GitLogEntry entry, int index, Action<GitLogE
119181 return requiresRepaint ;
120182 }
121183
122- private void RenderEntry ( Rect entryRect , GitLogEntry entry , bool isLocalCommit , bool isSelected )
123- {
124- if ( Event . current . type == EventType . Repaint )
125- {
126- var summaryRect = new Rect ( entryRect . x , entryRect . y + Styles . BaseSpacing / 2 , entryRect . width , Styles . HistorySummaryHeight + Styles . BaseSpacing ) ;
127- var timestampRect = new Rect ( entryRect . x , entryRect . yMax - Styles . HistoryDetailsHeight - Styles . BaseSpacing / 2 , entryRect . width , Styles . HistoryDetailsHeight ) ;
128-
129- var hasKeyboardFocus = false ;
130-
131- Styles . Label . Draw ( entryRect , GUIContent . none , false , false , isSelected , hasKeyboardFocus ) ;
132- Styles . HistoryEntrySummaryStyle . Draw ( summaryRect , entry . Summary , false , false , isSelected , hasKeyboardFocus ) ;
133-
134- var historyEntryDetail = string . Format ( HistoryEntryDetailFormat , entry . PrettyTimeString , entry . AuthorName ) ;
135- Styles . HistoryEntryDetailsStyle . Draw ( timestampRect , historyEntryDetail , false , false , isSelected , hasKeyboardFocus ) ;
136-
137- if ( ! string . IsNullOrEmpty ( entry . MergeA ) )
138- {
139- const float MergeIndicatorWidth = 10.28f ;
140- const float MergeIndicatorHeight = 12f ;
141- var mergeIndicatorRect = new Rect ( entryRect . x + 7 , summaryRect . y , MergeIndicatorWidth , MergeIndicatorHeight ) ;
142-
143- GUI . DrawTexture ( mergeIndicatorRect , Styles . MergeIcon ) ;
144-
145- DrawTimelineRectAroundIconRect ( entryRect , mergeIndicatorRect ) ;
146-
147- summaryRect . Set ( mergeIndicatorRect . xMax , summaryRect . y , summaryRect . width - MergeIndicatorWidth ,
148- summaryRect . height ) ;
149- }
150-
151- if ( isLocalCommit && string . IsNullOrEmpty ( entry . MergeA ) )
152- {
153- const float LocalIndicatorSize = 6f ;
154- var localIndicatorRect = new Rect ( entryRect . x + ( Styles . BaseSpacing - 2 ) , summaryRect . y + 5 , LocalIndicatorSize ,
155- LocalIndicatorSize ) ;
156-
157- DrawTimelineRectAroundIconRect ( entryRect , localIndicatorRect ) ;
158-
159- GUI . DrawTexture ( localIndicatorRect , Styles . LocalCommitIcon ) ;
160-
161- summaryRect . Set ( localIndicatorRect . xMax , summaryRect . y , summaryRect . width - LocalIndicatorSize ,
162- summaryRect . height ) ;
163- }
164-
165- if ( ! isLocalCommit && string . IsNullOrEmpty ( entry . MergeA ) )
166- {
167- const float NormalIndicatorWidth = 6f ;
168- const float NormalIndicatorHeight = 6f ;
169-
170- Rect normalIndicatorRect = new Rect ( entryRect . x + ( Styles . BaseSpacing - 2 ) , summaryRect . y + 5 ,
171- NormalIndicatorWidth , NormalIndicatorHeight ) ;
172-
173- DrawTimelineRectAroundIconRect ( entryRect , normalIndicatorRect ) ;
174-
175- GUI . DrawTexture ( normalIndicatorRect , Styles . DotIcon ) ;
176- }
177- }
178- }
179-
180184 private void DrawTimelineRectAroundIconRect ( Rect parentRect , Rect iconRect )
181185 {
182186 Color timelineBarColor = new Color ( 0.51F , 0.51F , 0.51F , 0.2F ) ;
@@ -273,8 +277,6 @@ class HistoryView : Subview
273277 private const string FetchActionTitle = "Fetch Changes" ;
274278 private const string FetchButtonText = "Fetch" ;
275279 private const string FetchFailureDescription = "Could not fetch changes" ;
276- private const int HistoryExtraItemCount = 10 ;
277- private const float MaxChangelistHeightRatio = .2f ;
278280
279281 [ NonSerialized ] private bool currentLogHasUpdate ;
280282 [ NonSerialized ] private bool currentRemoteHasUpdate ;
0 commit comments