@@ -32,28 +32,32 @@ public HistoryControlRenderResult Render(Rect containingRect, Rect rect, Vector2
32
32
33
33
controlId = GUIUtility . GetControlID ( FocusType . Keyboard ) ;
34
34
35
- var treeHasFocus = GUIUtility . keyboardControl == controlId ;
36
35
if ( Event . current . type != EventType . Repaint )
37
36
{
38
37
if ( rightClickNextRender != null )
39
38
{
40
39
rightClickNextRender . Invoke ( rightClickNextRenderEntry ) ;
41
40
rightClickNextRender = null ;
42
- //TODO: Default GitLogEntry
43
- rightClickNextRenderEntry = new GitLogEntry ( ) ;
41
+ rightClickNextRenderEntry = GitLogEntry . Default ;
44
42
}
45
43
}
46
44
45
+ var startDisplay = scroll . y ;
46
+ var endDisplay = scroll . y + containingRect . height ;
47
+
47
48
rect = new Rect ( rect . x , rect . y , rect . width , 0 ) ;
48
49
49
50
for ( var index = 0 ; index < entries . Count ; index ++ )
50
51
{
51
52
var entry = entries [ index ] ;
52
- var isLocalCommit = index < statusAhead ;
53
53
54
54
var entryRect = new Rect ( rect . x , rect . y , rect . width , Styles . HistoryEntryHeight ) ;
55
55
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
+ }
57
61
58
62
var entryRequiresRepaint = HandleInput ( entryRect , entry , index , singleClick , doubleClick , rightClick ) ;
59
63
requiresRepaint = requiresRepaint || entryRequiresRepaint ;
@@ -67,6 +71,64 @@ public HistoryControlRenderResult Render(Rect containingRect, Rect rect, Vector2
67
71
} ;
68
72
}
69
73
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
+
70
132
private bool HandleInput ( Rect rect , GitLogEntry entry , int index , Action < GitLogEntry > singleClick = null ,
71
133
Action < GitLogEntry > doubleClick = null , Action < GitLogEntry > rightClick = null )
72
134
{
@@ -119,64 +181,6 @@ private bool HandleInput(Rect rect, GitLogEntry entry, int index, Action<GitLogE
119
181
return requiresRepaint ;
120
182
}
121
183
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
-
180
184
private void DrawTimelineRectAroundIconRect ( Rect parentRect , Rect iconRect )
181
185
{
182
186
Color timelineBarColor = new Color ( 0.51F , 0.51F , 0.51F , 0.2F ) ;
@@ -273,8 +277,6 @@ class HistoryView : Subview
273
277
private const string FetchActionTitle = "Fetch Changes" ;
274
278
private const string FetchButtonText = "Fetch" ;
275
279
private const string FetchFailureDescription = "Could not fetch changes" ;
276
- private const int HistoryExtraItemCount = 10 ;
277
- private const float MaxChangelistHeightRatio = .2f ;
278
280
279
281
[ NonSerialized ] private bool currentLogHasUpdate ;
280
282
[ NonSerialized ] private bool currentRemoteHasUpdate ;
0 commit comments