Ticket #3767: patch_diskusage_3

File patch_diskusage_3, 7.7 KB (added by stpere, 15 years ago)
Line 
1Index: src/apps/diskusage/PieView.cpp
2===================================================================
3--- src/apps/diskusage/PieView.cpp (révision 30167)
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@@ -21,7 +23,12 @@
15 #include <Roster.h>
16 #include <String.h>
17 #include <Volume.h>
18+#include <Alert.h>
19
20+#include <app/Messenger.h>
21+#include <tracker_private.h>
22+
23+#include "Commands.h"
24 #include "Common.h"
25 #include "InfoWindow.h"
26 #include "MainWindow.h"
27@@ -433,13 +440,24 @@
28 PieView::_DrawPieChart(BRect updateRect)
29 {
30 BRect pieRect = Bounds();
31- pieRect.InsetBy(kPieOuterMargin, kPieOuterMargin);
32 if (!updateRect.Intersects(pieRect))
33 return;
34
35+ pieRect.InsetBy(kPieOuterMargin, kPieOuterMargin);
36+
37 SetHighColor(kPieBGColor);
38 FillRect(updateRect);
39
40+ // constraint proportions
41+ if (pieRect.Width() > pieRect.Height()) {
42+ float moveBy = (pieRect.Width() - pieRect.Height()) / 2;
43+ pieRect.left += moveBy;
44+ pieRect.right -= moveBy;
45+ } else {
46+ float moveBy = (pieRect.Height() - pieRect.Width()) / 2;
47+ pieRect.top -= moveBy;
48+ pieRect.bottom += moveBy;
49+ }
50 int colorIdx = 0;
51 FileInfo* currentDir = fScanners[fCurrentVolume]->CurrentDir();
52 FileInfo* parent = currentDir;
53@@ -447,7 +465,7 @@
54 parent = parent->parent;
55 colorIdx++;
56 }
57- _DrawDirectory(currentDir, 0.0, 0.0, colorIdx % kBasePieColorCount, 0);
58+ _DrawDirectory(pieRect, currentDir, 0.0, 0.0, colorIdx % kBasePieColorCount, 0);
59
60 // This is just for the case when the mouse hovers over the view
61 // while the scanning process is running and then does not move
62@@ -462,10 +480,9 @@
63
64
65 float
66-PieView::_DrawDirectory(FileInfo* info, float parentSpan, float beginAngle,
67+PieView::_DrawDirectory(BRect b, FileInfo* info, float parentSpan, float beginAngle,
68 int colorIdx, int level)
69 {
70- BRect b = Bounds();
71 if (b.Width() < 2.0 * (kPieCenterSize + level * kPieRingSize
72 + kPieOuterMargin + kPieInnerMargin)) {
73 return 0.0;
74@@ -602,7 +619,7 @@
75 vector<FileInfo*>::iterator i = info->children.begin();
76 while (i != info->children.end()) {
77 float childSpan
78- = _DrawDirectory(*i, mySpan, beginAngle, colorIdx, level + 1);
79+ = _DrawDirectory(b, *i, mySpan, beginAngle, colorIdx, level + 1);
80 if (childSpan >= kMinSegmentSpan) {
81 beginAngle += childSpan;
82 colorIdx = (colorIdx + 1) % kBasePieColorCount;
83@@ -767,7 +784,7 @@
84 if (item != NULL) {
85 switch (fMouseOverMenu->IndexOf(item)) {
86 case kIdxGetInfo:
87- new InfoWin(p, info, Window());
88+ _OpenInfo(info, p);
89 break;
90 case kIdxOpen:
91 _Launch(info);
92@@ -814,4 +831,19 @@
93 }
94 }
95
96+void
97+PieView::_OpenInfo(FileInfo* info, BPoint p)
98+{
99+ BMessenger tracker(kTrackerSignature);
100+ if (!tracker.IsValid()) {
101+ new InfoWin(p, info, Window());
102+ } else {
103+ BMessage message;
104
105+ message.what = kGetInfo;
106+ message.AddRef("refs", &info->ref);
107+ tracker.SendMessage(&message);
108+ }
109+}
110+
111+
112Index: src/apps/diskusage/MainWindow.cpp
113===================================================================
114--- src/apps/diskusage/MainWindow.cpp (révision 30167)
115+++ src/apps/diskusage/MainWindow.cpp (copie de travail)
116@@ -2,6 +2,8 @@
117 * Copyright (c) 2008 Stephan Aßmus <superstippi@gmx.de>. All rights reserved.
118 * Distributed under the terms of the MIT/X11 license.
119 *
120+ * Modified by Philippe Saint-Pierre, stpere@gmail.com, 1999
121+ *
122 * Copyright (c) 1999 Mike Steed. You are free to use and distribute this software
123 * as long as it is accompanied by it's documentation and this copyright notice.
124 * The software comes with no warranty, etc.
125@@ -92,26 +94,6 @@
126 }
127
128
129-void
130-MainWindow::Zoom(BPoint origin, float width, float height)
131-{
132- width = Frame().Width();
133- height = Frame().Height();
134- if (_FixAspectRatio(&width, &height))
135- SetZoomLimits(width, height);
136-
137- BWindow::Zoom(Frame().LeftTop(), width, height);
138-}
139-
140-
141-void
142-MainWindow::FrameResized(float width, float height)
143-{
144- if (_FixAspectRatio(&width, &height))
145- ResizeTo(width, height);
146-}
147-
148-
149 bool
150 MainWindow::QuitRequested()
151 {
152@@ -142,30 +124,3 @@
153 {
154 return fControlsView->FindDeviceFor(device, invoke);
155 }
156-
157-
158-// #pragma mark -
159-
160-
161-bool
162-MainWindow::_FixAspectRatio(float* width, float* height)
163-{
164- float ctrlViewHeight = fControlsView->Bounds().Height();
165- float statusViewHeight = fStatusView->Bounds().Height();
166-
167- float newPieSize = *height - ctrlViewHeight - statusViewHeight;
168- if (*width < newPieSize)
169- newPieSize = *width;
170-
171- float newWidth = newPieSize;
172- float newHeight = newPieSize + ctrlViewHeight + statusViewHeight;
173- if (*width != newWidth || *height != newHeight) {
174- *width = newWidth;
175- *height = newHeight;
176- return true;
177- }
178-
179- return false;
180-}
181-
182-
183Index: src/apps/diskusage/PieView.h
184===================================================================
185--- src/apps/diskusage/PieView.h (révision 30167)
186+++ src/apps/diskusage/PieView.h (copie de travail)
187@@ -2,6 +2,8 @@
188 * Copyright (c) 2008 Stephan Aßmus <superstippi@gmx.de>. All rights reserved.
189 * Distributed under the terms of the MIT/X11 license.
190 *
191+ * Modified by Philippe Saint-Pierre, stpere@gmail.com, 1999
192+ *
193 * Copyright (c) 1999 Mike Steed. You are free to use and distribute this software
194 * as long as it is accompanied by it's documentation and this copyright notice.
195 * The software comes with no warranty, etc.
196@@ -45,7 +47,7 @@
197 void _ShowVolume(BVolume* volume);
198 void _DrawProgressBar(BRect updateRect);
199 void _DrawPieChart(BRect updateRect);
200- float _DrawDirectory(FileInfo* info,
201+ float _DrawDirectory(BRect b, FileInfo* info,
202 float parentSpan, float beginAngle,
203 int colorIdx, int level);
204 FileInfo* _FileAt(const BPoint& where);
205@@ -55,7 +57,7 @@
206 void _ShowContextMenu(FileInfo* info, BPoint where);
207 void _Launch(FileInfo* info,
208 const entry_ref* ref = NULL);
209-
210+ void _OpenInfo(FileInfo* info, BPoint p);
211 private:
212 struct Segment {
213 Segment()
214Index: src/apps/diskusage/MainWindow.h
215===================================================================
216--- src/apps/diskusage/MainWindow.h (révision 30167)
217+++ src/apps/diskusage/MainWindow.h (copie de travail)
218@@ -2,6 +2,8 @@
219 * Copyright (c) 2008 Stephan Aßmus <superstippi@gmx.de>. All rights reserved.
220 * Distributed under the terms of the MIT/X11 license.
221 *
222+ * Modified by Philippe Saint-Pierre, stpere@gmail.com, 1999
223+ *
224 * Copyright (c) 1999 Mike Steed. You are free to use and distribute this software
225 * as long as it is accompanied by it's documentation and this copyright notice.
226 * The software comes with no warranty, etc.
227@@ -24,8 +26,6 @@
228 virtual ~MainWindow();
229
230 virtual void MessageReceived(BMessage* message);
231- virtual void Zoom(BPoint origin, float width, float height);
232- virtual void FrameResized(float width, float height);
233 virtual bool QuitRequested();
234
235 void ShowInfo(const FileInfo* info);
236@@ -34,8 +34,6 @@
237 bool invoke = false);
238
239 private:
240- bool _FixAspectRatio(float* width, float* height);
241-
242 ControlsView* fControlsView;
243 PieView* fPieView;
244 StatusView* fStatusView;
245Index: src/apps/diskusage/Jamfile
246===================================================================
247--- src/apps/diskusage/Jamfile (révision 30167)
248+++ src/apps/diskusage/Jamfile (copie de travail)
249@@ -1,5 +1,8 @@
250 SubDir HAIKU_TOP src apps diskusage ;
251
252+UsePrivateHeaders tracker ;
253+SubDirHdrs $(HAIKU_TOP) src kits tracker ;
254+
255 Application DiskUsage :
256 App.cpp
257 Common.cpp