OSDN Git Service

BrowseRefs: Added option to delete branch or tag.
[tortoisegit/TortoiseGitJp.git] / src / TortoiseProc / RevisionGraph / StandardLayout.h
1 // TortoiseSVN - a Windows shell extension for easy version control\r
2 \r
3 // Copyright (C) 2003-2008 - TortoiseSVN\r
4 \r
5 // This program is free software; you can redistribute it and/or\r
6 // modify it under the terms of the GNU General Public License\r
7 // as published by the Free Software Foundation; either version 2\r
8 // of the License, or (at your option) any later version.\r
9 \r
10 // This program is distributed in the hope that it will be useful,\r
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of\r
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
13 // GNU General Public License for more details.\r
14 \r
15 // You should have received a copy of the GNU General Public License\r
16 // along with this program; if not, write to the Free Software Foundation,\r
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\r
18 //\r
19 #pragma once\r
20 \r
21 #include "IRevisionGraphLayout.h"\r
22 \r
23 class CVisibleGraphNode;\r
24 class CVisibleGraph;\r
25 \r
26 namespace LogCache\r
27 {\r
28     class CCachedLogInfo;\r
29 }\r
30 \r
31 class CStandardLayoutNodeInfo\r
32 {\r
33 public:\r
34 \r
35     /// the node to place within the layout\r
36 \r
37     const CVisibleGraphNode* node;\r
38 \r
39     /// links for faster navigation\r
40 \r
41     CStandardLayoutNodeInfo* parentBranch;\r
42     CStandardLayoutNodeInfo* firstSubBranch;\r
43     CStandardLayoutNodeInfo* nextInBranch;\r
44     CStandardLayoutNodeInfo* previousInBranch;\r
45     CStandardLayoutNodeInfo* lastInBranch;\r
46     CStandardLayoutNodeInfo* nextBranch;\r
47     CStandardLayoutNodeInfo* previousBranch;\r
48     CStandardLayoutNodeInfo* lastBranch;\r
49 \r
50     /// the graph may consist of multiple trees.\r
51     /// root(node) = graph (node)->GetRoot (rootID);\r
52 \r
53     index_t rootID;\r
54 \r
55     /// branch sizes\r
56 \r
57     index_t subTreeWidth;\r
58     index_t subTreeHeight;\r
59     index_t subTreeWeight;\r
60     index_t branchLength;\r
61 \r
62     /// node properties\r
63 \r
64     bool requiresRevision;\r
65     bool requiresPath;\r
66     bool requiresGap;\r
67 \r
68     /// number of path elements that shall not be shown\r
69     /// (used by "show diff path" option)\r
70 \r
71     index_t skipStartPathElements;\r
72     index_t skipTailPathElements;\r
73 \r
74     /// required size(s) to display all content\r
75 \r
76     CSize requiredSize;\r
77 \r
78     /// temp. value used to store the offset of the final position\r
79     /// to the current one (logical coordinates)\r
80 \r
81     CSize treeShift;\r
82     CSize subTreeShift;\r
83 \r
84     /// actual position (logical coordinates)\r
85 \r
86     CRect rect;\r
87 \r
88     /// initialization\r
89 \r
90     CStandardLayoutNodeInfo();\r
91 };\r
92 \r
93 /**\r
94 * utility interface that gives layout options access to the layout info\r
95 */\r
96 \r
97 class IStandardLayoutNodeAccess\r
98 {\r
99 public:\r
100 \r
101     /// make sub-classes deletable through the base interface\r
102 \r
103     virtual ~IStandardLayoutNodeAccess() {};\r
104 \r
105     /// access graph node layout\r
106 \r
107     virtual index_t GetNodeCount() const = 0;\r
108     virtual CStandardLayoutNodeInfo* GetNode (index_t index) = 0;\r
109 };\r
110 \r
111 class CStandardLayout \r
112     : public IRevisionGraphLayout\r
113     , public IStandardLayoutNodeAccess\r
114 {\r
115 public:\r
116 \r
117     struct STextInfo\r
118     {\r
119         index_t nodeIndex;\r
120         int subPathIndex;   // 0 -> revNum, pathElementIndex otherwise\r
121 \r
122         STextInfo (index_t nodeIndex, int subPathIndex)\r
123             : nodeIndex (nodeIndex)\r
124             , subPathIndex (subPathIndex) \r
125         {\r
126         }\r
127     };\r
128 \r
129 private:\r
130 \r
131     /// source of revision data\r
132 \r
133     const CCachedLogInfo* cache;\r
134 \r
135     /// logical tree structure\r
136 \r
137     const CVisibleGraph* graph;\r
138 \r
139     /// nodes (in the order defined by CVisibleGraphNode::index)\r
140 \r
141     std::vector<CStandardLayoutNodeInfo> nodes;\r
142 \r
143     /// connections with length > 0. Stored as node index pairs.\r
144 \r
145     std::vector<std::pair<index_t, index_t> > connections;\r
146 \r
147     /// non-empty texts. Stored as node index, 'is path' pairs\r
148 \r
149     std::vector<STextInfo> texts;\r
150 \r
151     /// bounding rects of the individual trees\r
152 \r
153     std::vector<CRect> trees;\r
154 \r
155     /// area that covers all visible items\r
156 \r
157     CRect boundingRect;\r
158 \r
159     /// layout creation\r
160 \r
161     void SortNodes();\r
162     void InitializeNodes ( const CVisibleGraphNode* node\r
163                          , CStandardLayoutNodeInfo* parentBranch);\r
164     void InitializeNodes();\r
165 \r
166     void CreateConnections();\r
167     void CreateTexts();\r
168 \r
169     void CloseTreeBoundingRectGaps();\r
170     void CalculateTreeBoundingRects();\r
171 \r
172     void CalculateBoundingRect();\r
173 \r
174 public:\r
175 \r
176     /// construction / destruction\r
177 \r
178     CStandardLayout (const CCachedLogInfo* cache, const CVisibleGraph* graph);\r
179     virtual ~CStandardLayout(void);\r
180 \r
181     /// call this after executing the format options\r
182 \r
183     void Finalize();\r
184 \r
185     /// implement IRevisionGraphLayout\r
186 \r
187     virtual CRect GetRect() const;\r
188 \r
189     virtual const ILayoutRectList* GetTrees() const;\r
190     virtual const ILayoutNodeList* GetNodes() const;\r
191     virtual const ILayoutConnectionList* GetConnections() const;\r
192     virtual const ILayoutTextList* GetTexts() const;\r
193 \r
194     /// implement IStandardLayoutNodeAccess\r
195 \r
196     virtual index_t GetNodeCount() const;\r
197     virtual CStandardLayoutNodeInfo* GetNode (index_t index);\r
198 };\r
199 \r