Ticket #3767: patch_diskusage

File patch_diskusage, 6.1 KB (added by stpere, 15 years ago)
Line 
1Index: src/apps/diskusage/PieView.cpp
2===================================================================
3--- src/apps/diskusage/PieView.cpp (révision 30165)
4+++ src/apps/diskusage/PieView.cpp (copie de travail)
5@@ -2,6 +2,8 @@
6 * Copyright (c) 2008 Stephan Aßmus <superstippi@gmx.de>. All rights reserved.
7 * Distributed under the terms of the MIT/X11 license.
8 *
9+ * Modified by Philippe Saint-Pierre, stpere@gmail.com, 1999
10+ *
11 * Copyright (c) 1999 Mike Steed. You are free to use and distribute this software
12 * as long as it is accompanied by it's documentation and this copyright notice.
13 * The software comes with no warranty, etc.
14@@ -440,6 +442,16 @@
15 SetHighColor(kPieBGColor);
16 FillRect(updateRect);
17
18+ // constraint proportions
19+ if (pieRect.Width() > pieRect.Height()) {
20+ float moveBy = (pieRect.Width() - pieRect.Height()) / 2;
21+ pieRect.left += moveBy;
22+ pieRect.right -= moveBy;
23+ } else {
24+ float moveBy = (pieRect.Height() - pieRect.Width()) / 2;
25+ pieRect.top -= moveBy;
26+ pieRect.bottom += moveBy;
27+ }
28 int colorIdx = 0;
29 FileInfo* currentDir = fScanners[fCurrentVolume]->CurrentDir();
30 FileInfo* parent = currentDir;
31@@ -447,7 +459,7 @@
32 parent = parent->parent;
33 colorIdx++;
34 }
35- _DrawDirectory(currentDir, 0.0, 0.0, colorIdx % kBasePieColorCount, 0);
36+ _DrawDirectory(pieRect, currentDir, 0.0, 0.0, colorIdx % kBasePieColorCount, 0);
37
38 // This is just for the case when the mouse hovers over the view
39 // while the scanning process is running and then does not move
40@@ -462,10 +474,9 @@
41
42
43 float
44-PieView::_DrawDirectory(FileInfo* info, float parentSpan, float beginAngle,
45+PieView::_DrawDirectory(BRect b, FileInfo* info, float parentSpan, float beginAngle,
46 int colorIdx, int level)
47 {
48- BRect b = Bounds();
49 if (b.Width() < 2.0 * (kPieCenterSize + level * kPieRingSize
50 + kPieOuterMargin + kPieInnerMargin)) {
51 return 0.0;
52@@ -602,7 +613,7 @@
53 vector<FileInfo*>::iterator i = info->children.begin();
54 while (i != info->children.end()) {
55 float childSpan
56- = _DrawDirectory(*i, mySpan, beginAngle, colorIdx, level + 1);
57+ = _DrawDirectory(b, *i, mySpan, beginAngle, colorIdx, level + 1);
58 if (childSpan >= kMinSegmentSpan) {
59 beginAngle += childSpan;
60 colorIdx = (colorIdx + 1) % kBasePieColorCount;
61Index: src/apps/diskusage/MainWindow.cpp
62===================================================================
63--- src/apps/diskusage/MainWindow.cpp (révision 30165)
64+++ src/apps/diskusage/MainWindow.cpp (copie de travail)
65@@ -2,6 +2,8 @@
66 * Copyright (c) 2008 Stephan Aßmus <superstippi@gmx.de>. All rights reserved.
67 * Distributed under the terms of the MIT/X11 license.
68 *
69+ * Modified by Philippe Saint-Pierre, stpere@gmail.com, 1999
70+ *
71 * Copyright (c) 1999 Mike Steed. You are free to use and distribute this software
72 * as long as it is accompanied by it's documentation and this copyright notice.
73 * The software comes with no warranty, etc.
74@@ -92,26 +94,6 @@
75 }
76
77
78-void
79-MainWindow::Zoom(BPoint origin, float width, float height)
80-{
81- width = Frame().Width();
82- height = Frame().Height();
83- if (_FixAspectRatio(&width, &height))
84- SetZoomLimits(width, height);
85-
86- BWindow::Zoom(Frame().LeftTop(), width, height);
87-}
88-
89-
90-void
91-MainWindow::FrameResized(float width, float height)
92-{
93- if (_FixAspectRatio(&width, &height))
94- ResizeTo(width, height);
95-}
96-
97-
98 bool
99 MainWindow::QuitRequested()
100 {
101@@ -142,30 +124,3 @@
102 {
103 return fControlsView->FindDeviceFor(device, invoke);
104 }
105-
106-
107-// #pragma mark -
108-
109-
110-bool
111-MainWindow::_FixAspectRatio(float* width, float* height)
112-{
113- float ctrlViewHeight = fControlsView->Bounds().Height();
114- float statusViewHeight = fStatusView->Bounds().Height();
115-
116- float newPieSize = *height - ctrlViewHeight - statusViewHeight;
117- if (*width < newPieSize)
118- newPieSize = *width;
119-
120- float newWidth = newPieSize;
121- float newHeight = newPieSize + ctrlViewHeight + statusViewHeight;
122- if (*width != newWidth || *height != newHeight) {
123- *width = newWidth;
124- *height = newHeight;
125- return true;
126- }
127-
128- return false;
129-}
130-
131-
132Index: src/apps/diskusage/PieView.h
133===================================================================
134--- src/apps/diskusage/PieView.h (révision 30165)
135+++ src/apps/diskusage/PieView.h (copie de travail)
136@@ -2,6 +2,8 @@
137 * Copyright (c) 2008 Stephan Aßmus <superstippi@gmx.de>. All rights reserved.
138 * Distributed under the terms of the MIT/X11 license.
139 *
140+ * Modified by Philippe Saint-Pierre, stpere@gmail.com, 1999
141+ *
142 * Copyright (c) 1999 Mike Steed. You are free to use and distribute this software
143 * as long as it is accompanied by it's documentation and this copyright notice.
144 * The software comes with no warranty, etc.
145@@ -45,7 +47,7 @@
146 void _ShowVolume(BVolume* volume);
147 void _DrawProgressBar(BRect updateRect);
148 void _DrawPieChart(BRect updateRect);
149- float _DrawDirectory(FileInfo* info,
150+ float _DrawDirectory(BRect b, FileInfo* info,
151 float parentSpan, float beginAngle,
152 int colorIdx, int level);
153 FileInfo* _FileAt(const BPoint& where);
154Index: src/apps/diskusage/MainWindow.h
155===================================================================
156--- src/apps/diskusage/MainWindow.h (révision 30165)
157+++ src/apps/diskusage/MainWindow.h (copie de travail)
158@@ -2,6 +2,8 @@
159 * Copyright (c) 2008 Stephan Aßmus <superstippi@gmx.de>. All rights reserved.
160 * Distributed under the terms of the MIT/X11 license.
161 *
162+ * Modified by Philippe Saint-Pierre, stpere@gmail.com, 1999
163+ *
164 * Copyright (c) 1999 Mike Steed. You are free to use and distribute this software
165 * as long as it is accompanied by it's documentation and this copyright notice.
166 * The software comes with no warranty, etc.
167@@ -24,8 +26,6 @@
168 virtual ~MainWindow();
169
170 virtual void MessageReceived(BMessage* message);
171- virtual void Zoom(BPoint origin, float width, float height);
172- virtual void FrameResized(float width, float height);
173 virtual bool QuitRequested();
174
175 void ShowInfo(const FileInfo* info);
176@@ -34,8 +34,6 @@
177 bool invoke = false);
178
179 private:
180- bool _FixAspectRatio(float* width, float* height);
181-
182 ControlsView* fControlsView;
183 PieView* fPieView;
184 StatusView* fStatusView;