Ticket #3767: patch_diskusage_2

File patch_diskusage_2, 7.5 KB (added by stpere, 16 years ago)

Additional enhancements

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