Patch by stpere:
* Make DiskUsage use Tracker's "Get Info" panel instead of it's own (still falls back to it's own when Tracker isn't running...) * Fixed some drawing issues. * Removed the window aspect constraints. Thanks a lot! Philippe, please have a look how I changed the license, and the only coding style violation is that you need to watch out for the 80 chars per line limit. :-) Great work! git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30171 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
afa231acb8
commit
962bcf7da1
@ -1,5 +1,8 @@
|
||||
SubDir HAIKU_TOP src apps diskusage ;
|
||||
|
||||
UsePrivateHeaders tracker ;
|
||||
SubDirHdrs $(HAIKU_TOP) src kits tracker ;
|
||||
|
||||
Application DiskUsage :
|
||||
App.cpp
|
||||
Common.cpp
|
||||
|
@ -1,6 +1,7 @@
|
||||
/*
|
||||
* Copyright (c) 2008 Stephan Aßmus <superstippi@gmx.de>. All rights reserved.
|
||||
* Distributed under the terms of the MIT/X11 license.
|
||||
* Copyright (c) 2008 Stephan Aßmus <superstippi@gmx.de>.
|
||||
* Copyright (c) 2009 Philippe Saint-Pierre, stpere@gmail.com
|
||||
* All rights reserved. Distributed under the terms of the MIT license.
|
||||
*
|
||||
* Copyright (c) 1999 Mike Steed. You are free to use and distribute this software
|
||||
* as long as it is accompanied by it's documentation and this copyright notice.
|
||||
@ -92,26 +93,6 @@ MainWindow::MessageReceived(BMessage* message)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
MainWindow::Zoom(BPoint origin, float width, float height)
|
||||
{
|
||||
width = Frame().Width();
|
||||
height = Frame().Height();
|
||||
if (_FixAspectRatio(&width, &height))
|
||||
SetZoomLimits(width, height);
|
||||
|
||||
BWindow::Zoom(Frame().LeftTop(), width, height);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
MainWindow::FrameResized(float width, float height)
|
||||
{
|
||||
if (_FixAspectRatio(&width, &height))
|
||||
ResizeTo(width, height);
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
MainWindow::QuitRequested()
|
||||
{
|
||||
@ -142,30 +123,3 @@ MainWindow::FindDeviceFor(dev_t device, bool invoke)
|
||||
{
|
||||
return fControlsView->FindDeviceFor(device, invoke);
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark -
|
||||
|
||||
|
||||
bool
|
||||
MainWindow::_FixAspectRatio(float* width, float* height)
|
||||
{
|
||||
float ctrlViewHeight = fControlsView->Bounds().Height();
|
||||
float statusViewHeight = fStatusView->Bounds().Height();
|
||||
|
||||
float newPieSize = *height - ctrlViewHeight - statusViewHeight;
|
||||
if (*width < newPieSize)
|
||||
newPieSize = *width;
|
||||
|
||||
float newWidth = newPieSize;
|
||||
float newHeight = newPieSize + ctrlViewHeight + statusViewHeight;
|
||||
if (*width != newWidth || *height != newHeight) {
|
||||
*width = newWidth;
|
||||
*height = newHeight;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
/*
|
||||
* Copyright (c) 2008 Stephan Aßmus <superstippi@gmx.de>. All rights reserved.
|
||||
* Distributed under the terms of the MIT/X11 license.
|
||||
* Copyright (c) 2008 Stephan Aßmus <superstippi@gmx.de>.
|
||||
* Copyright (c) 2009 Philippe Saint-Pierre, stpere@gmail.com
|
||||
* All rights reserved. Distributed under the terms of the MIT license.
|
||||
*
|
||||
* Copyright (c) 1999 Mike Steed. You are free to use and distribute this software
|
||||
* as long as it is accompanied by it's documentation and this copyright notice.
|
||||
@ -24,8 +25,6 @@ public:
|
||||
virtual ~MainWindow();
|
||||
|
||||
virtual void MessageReceived(BMessage* message);
|
||||
virtual void Zoom(BPoint origin, float width, float height);
|
||||
virtual void FrameResized(float width, float height);
|
||||
virtual bool QuitRequested();
|
||||
|
||||
void ShowInfo(const FileInfo* info);
|
||||
@ -34,8 +33,6 @@ public:
|
||||
bool invoke = false);
|
||||
|
||||
private:
|
||||
bool _FixAspectRatio(float* width, float* height);
|
||||
|
||||
ControlsView* fControlsView;
|
||||
PieView* fPieView;
|
||||
StatusView* fStatusView;
|
||||
|
@ -1,6 +1,7 @@
|
||||
/*
|
||||
* Copyright (c) 2008 Stephan Aßmus <superstippi@gmx.de>. All rights reserved.
|
||||
* Distributed under the terms of the MIT/X11 license.
|
||||
* Copyright (c) 2008 Stephan Aßmus <superstippi@gmx.de>.
|
||||
* Copyright (c) 2009 Philippe Saint-Pierre, stpere@gmail.com
|
||||
* All rights reserved. Distributed under the terms of the MIT license.
|
||||
*
|
||||
* Copyright (c) 1999 Mike Steed. You are free to use and distribute this software
|
||||
* as long as it is accompanied by it's documentation and this copyright notice.
|
||||
@ -16,12 +17,17 @@
|
||||
#include <Entry.h>
|
||||
#include <File.h>
|
||||
#include <MenuItem.h>
|
||||
#include <Messenger.h>
|
||||
#include <Path.h>
|
||||
#include <PopUpMenu.h>
|
||||
#include <Roster.h>
|
||||
#include <String.h>
|
||||
#include <Volume.h>
|
||||
#include <Alert.h>
|
||||
|
||||
#include <tracker_private.h>
|
||||
|
||||
#include "Commands.h"
|
||||
#include "Common.h"
|
||||
#include "InfoWindow.h"
|
||||
#include "MainWindow.h"
|
||||
@ -433,13 +439,24 @@ void
|
||||
PieView::_DrawPieChart(BRect updateRect)
|
||||
{
|
||||
BRect pieRect = Bounds();
|
||||
pieRect.InsetBy(kPieOuterMargin, kPieOuterMargin);
|
||||
if (!updateRect.Intersects(pieRect))
|
||||
return;
|
||||
|
||||
pieRect.InsetBy(kPieOuterMargin, kPieOuterMargin);
|
||||
|
||||
SetHighColor(kPieBGColor);
|
||||
FillRect(updateRect);
|
||||
|
||||
// constraint proportions
|
||||
if (pieRect.Width() > pieRect.Height()) {
|
||||
float moveBy = (pieRect.Width() - pieRect.Height()) / 2;
|
||||
pieRect.left += moveBy;
|
||||
pieRect.right -= moveBy;
|
||||
} else {
|
||||
float moveBy = (pieRect.Height() - pieRect.Width()) / 2;
|
||||
pieRect.top -= moveBy;
|
||||
pieRect.bottom += moveBy;
|
||||
}
|
||||
int colorIdx = 0;
|
||||
FileInfo* currentDir = fScanners[fCurrentVolume]->CurrentDir();
|
||||
FileInfo* parent = currentDir;
|
||||
@ -447,7 +464,8 @@ PieView::_DrawPieChart(BRect updateRect)
|
||||
parent = parent->parent;
|
||||
colorIdx++;
|
||||
}
|
||||
_DrawDirectory(currentDir, 0.0, 0.0, colorIdx % kBasePieColorCount, 0);
|
||||
_DrawDirectory(pieRect, currentDir, 0.0, 0.0, colorIdx % kBasePieColorCount,
|
||||
0);
|
||||
|
||||
// This is just for the case when the mouse hovers over the view
|
||||
// while the scanning process is running and then does not move
|
||||
@ -462,10 +480,9 @@ PieView::_DrawPieChart(BRect updateRect)
|
||||
|
||||
|
||||
float
|
||||
PieView::_DrawDirectory(FileInfo* info, float parentSpan, float beginAngle,
|
||||
int colorIdx, int level)
|
||||
PieView::_DrawDirectory(BRect b, FileInfo* info, float parentSpan,
|
||||
float beginAngle, int colorIdx, int level)
|
||||
{
|
||||
BRect b = Bounds();
|
||||
if (b.Width() < 2.0 * (kPieCenterSize + level * kPieRingSize
|
||||
+ kPieOuterMargin + kPieInnerMargin)) {
|
||||
return 0.0;
|
||||
@ -602,7 +619,7 @@ PieView::_DrawDirectory(FileInfo* info, float parentSpan, float beginAngle,
|
||||
vector<FileInfo*>::iterator i = info->children.begin();
|
||||
while (i != info->children.end()) {
|
||||
float childSpan
|
||||
= _DrawDirectory(*i, mySpan, beginAngle, colorIdx, level + 1);
|
||||
= _DrawDirectory(b, *i, mySpan, beginAngle, colorIdx, level + 1);
|
||||
if (childSpan >= kMinSegmentSpan) {
|
||||
beginAngle += childSpan;
|
||||
colorIdx = (colorIdx + 1) % kBasePieColorCount;
|
||||
@ -767,7 +784,7 @@ PieView::_ShowContextMenu(FileInfo* info, BPoint p)
|
||||
if (item != NULL) {
|
||||
switch (fMouseOverMenu->IndexOf(item)) {
|
||||
case kIdxGetInfo:
|
||||
new InfoWin(p, info, Window());
|
||||
_OpenInfo(info, p);
|
||||
break;
|
||||
case kIdxOpen:
|
||||
_Launch(info);
|
||||
@ -814,4 +831,17 @@ PieView::_Launch(FileInfo* info, const entry_ref* appRef)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
PieView::_OpenInfo(FileInfo* info, BPoint p)
|
||||
{
|
||||
BMessenger tracker(kTrackerSignature);
|
||||
if (!tracker.IsValid()) {
|
||||
new InfoWin(p, info, Window());
|
||||
} else {
|
||||
BMessage message(kGetInfo);
|
||||
message.AddRef("refs", &info->ref);
|
||||
tracker.SendMessage(&message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
/*
|
||||
* Copyright (c) 2008 Stephan Aßmus <superstippi@gmx.de>. All rights reserved.
|
||||
* Distributed under the terms of the MIT/X11 license.
|
||||
* Copyright (c) 2008 Stephan Aßmus <superstippi@gmx.de>.
|
||||
* Copyright (c) 2009 Philippe Saint-Pierre, stpere@gmail.com
|
||||
* All rights reserved. Distributed under the terms of the MIT license.
|
||||
*
|
||||
* Copyright (c) 1999 Mike Steed. You are free to use and distribute this software
|
||||
* as long as it is accompanied by it's documentation and this copyright notice.
|
||||
@ -45,7 +46,7 @@ private:
|
||||
void _ShowVolume(BVolume* volume);
|
||||
void _DrawProgressBar(BRect updateRect);
|
||||
void _DrawPieChart(BRect updateRect);
|
||||
float _DrawDirectory(FileInfo* info,
|
||||
float _DrawDirectory(BRect b, FileInfo* info,
|
||||
float parentSpan, float beginAngle,
|
||||
int colorIdx, int level);
|
||||
FileInfo* _FileAt(const BPoint& where);
|
||||
@ -55,7 +56,7 @@ private:
|
||||
void _ShowContextMenu(FileInfo* info, BPoint where);
|
||||
void _Launch(FileInfo* info,
|
||||
const entry_ref* ref = NULL);
|
||||
|
||||
void _OpenInfo(FileInfo* info, BPoint p);
|
||||
private:
|
||||
struct Segment {
|
||||
Segment()
|
||||
|
Loading…
Reference in New Issue
Block a user