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:
@@ -1,5 +1,8 @@
|
|||||||
SubDir HAIKU_TOP src apps diskusage ;
|
SubDir HAIKU_TOP src apps diskusage ;
|
||||||
|
|
||||||
|
UsePrivateHeaders tracker ;
|
||||||
|
SubDirHdrs $(HAIKU_TOP) src kits tracker ;
|
||||||
|
|
||||||
Application DiskUsage :
|
Application DiskUsage :
|
||||||
App.cpp
|
App.cpp
|
||||||
Common.cpp
|
Common.cpp
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2008 Stephan Aßmus <[email protected]>. All rights reserved.
|
* Copyright (c) 2008 Stephan Aßmus <[email protected]>.
|
||||||
* Distributed under the terms of the MIT/X11 license.
|
* Copyright (c) 2009 Philippe Saint-Pierre, [email protected]
|
||||||
|
* 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
|
* 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.
|
* 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
|
bool
|
||||||
MainWindow::QuitRequested()
|
MainWindow::QuitRequested()
|
||||||
{
|
{
|
||||||
@@ -142,30 +123,3 @@ MainWindow::FindDeviceFor(dev_t device, bool invoke)
|
|||||||
{
|
{
|
||||||
return fControlsView->FindDeviceFor(device, 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 <[email protected]>. All rights reserved.
|
* Copyright (c) 2008 Stephan Aßmus <[email protected]>.
|
||||||
* Distributed under the terms of the MIT/X11 license.
|
* Copyright (c) 2009 Philippe Saint-Pierre, [email protected]
|
||||||
|
* 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
|
* 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.
|
* as long as it is accompanied by it's documentation and this copyright notice.
|
||||||
@@ -24,8 +25,6 @@ public:
|
|||||||
virtual ~MainWindow();
|
virtual ~MainWindow();
|
||||||
|
|
||||||
virtual void MessageReceived(BMessage* message);
|
virtual void MessageReceived(BMessage* message);
|
||||||
virtual void Zoom(BPoint origin, float width, float height);
|
|
||||||
virtual void FrameResized(float width, float height);
|
|
||||||
virtual bool QuitRequested();
|
virtual bool QuitRequested();
|
||||||
|
|
||||||
void ShowInfo(const FileInfo* info);
|
void ShowInfo(const FileInfo* info);
|
||||||
@@ -34,8 +33,6 @@ public:
|
|||||||
bool invoke = false);
|
bool invoke = false);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool _FixAspectRatio(float* width, float* height);
|
|
||||||
|
|
||||||
ControlsView* fControlsView;
|
ControlsView* fControlsView;
|
||||||
PieView* fPieView;
|
PieView* fPieView;
|
||||||
StatusView* fStatusView;
|
StatusView* fStatusView;
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2008 Stephan Aßmus <[email protected]>. All rights reserved.
|
* Copyright (c) 2008 Stephan Aßmus <[email protected]>.
|
||||||
* Distributed under the terms of the MIT/X11 license.
|
* Copyright (c) 2009 Philippe Saint-Pierre, [email protected]
|
||||||
|
* 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
|
* 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.
|
* as long as it is accompanied by it's documentation and this copyright notice.
|
||||||
@@ -16,12 +17,17 @@
|
|||||||
#include <Entry.h>
|
#include <Entry.h>
|
||||||
#include <File.h>
|
#include <File.h>
|
||||||
#include <MenuItem.h>
|
#include <MenuItem.h>
|
||||||
|
#include <Messenger.h>
|
||||||
#include <Path.h>
|
#include <Path.h>
|
||||||
#include <PopUpMenu.h>
|
#include <PopUpMenu.h>
|
||||||
#include <Roster.h>
|
#include <Roster.h>
|
||||||
#include <String.h>
|
#include <String.h>
|
||||||
#include <Volume.h>
|
#include <Volume.h>
|
||||||
|
#include <Alert.h>
|
||||||
|
|
||||||
|
#include <tracker_private.h>
|
||||||
|
|
||||||
|
#include "Commands.h"
|
||||||
#include "Common.h"
|
#include "Common.h"
|
||||||
#include "InfoWindow.h"
|
#include "InfoWindow.h"
|
||||||
#include "MainWindow.h"
|
#include "MainWindow.h"
|
||||||
@@ -433,13 +439,24 @@ void
|
|||||||
PieView::_DrawPieChart(BRect updateRect)
|
PieView::_DrawPieChart(BRect updateRect)
|
||||||
{
|
{
|
||||||
BRect pieRect = Bounds();
|
BRect pieRect = Bounds();
|
||||||
pieRect.InsetBy(kPieOuterMargin, kPieOuterMargin);
|
|
||||||
if (!updateRect.Intersects(pieRect))
|
if (!updateRect.Intersects(pieRect))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
pieRect.InsetBy(kPieOuterMargin, kPieOuterMargin);
|
||||||
|
|
||||||
SetHighColor(kPieBGColor);
|
SetHighColor(kPieBGColor);
|
||||||
FillRect(updateRect);
|
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;
|
int colorIdx = 0;
|
||||||
FileInfo* currentDir = fScanners[fCurrentVolume]->CurrentDir();
|
FileInfo* currentDir = fScanners[fCurrentVolume]->CurrentDir();
|
||||||
FileInfo* parent = currentDir;
|
FileInfo* parent = currentDir;
|
||||||
@@ -447,7 +464,8 @@ PieView::_DrawPieChart(BRect updateRect)
|
|||||||
parent = parent->parent;
|
parent = parent->parent;
|
||||||
colorIdx++;
|
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
|
// This is just for the case when the mouse hovers over the view
|
||||||
// while the scanning process is running and then does not move
|
// while the scanning process is running and then does not move
|
||||||
@@ -462,10 +480,9 @@ PieView::_DrawPieChart(BRect updateRect)
|
|||||||
|
|
||||||
|
|
||||||
float
|
float
|
||||||
PieView::_DrawDirectory(FileInfo* info, float parentSpan, float beginAngle,
|
PieView::_DrawDirectory(BRect b, FileInfo* info, float parentSpan,
|
||||||
int colorIdx, int level)
|
float beginAngle, int colorIdx, int level)
|
||||||
{
|
{
|
||||||
BRect b = Bounds();
|
|
||||||
if (b.Width() < 2.0 * (kPieCenterSize + level * kPieRingSize
|
if (b.Width() < 2.0 * (kPieCenterSize + level * kPieRingSize
|
||||||
+ kPieOuterMargin + kPieInnerMargin)) {
|
+ kPieOuterMargin + kPieInnerMargin)) {
|
||||||
return 0.0;
|
return 0.0;
|
||||||
@@ -602,7 +619,7 @@ PieView::_DrawDirectory(FileInfo* info, float parentSpan, float beginAngle,
|
|||||||
vector<FileInfo*>::iterator i = info->children.begin();
|
vector<FileInfo*>::iterator i = info->children.begin();
|
||||||
while (i != info->children.end()) {
|
while (i != info->children.end()) {
|
||||||
float childSpan
|
float childSpan
|
||||||
= _DrawDirectory(*i, mySpan, beginAngle, colorIdx, level + 1);
|
= _DrawDirectory(b, *i, mySpan, beginAngle, colorIdx, level + 1);
|
||||||
if (childSpan >= kMinSegmentSpan) {
|
if (childSpan >= kMinSegmentSpan) {
|
||||||
beginAngle += childSpan;
|
beginAngle += childSpan;
|
||||||
colorIdx = (colorIdx + 1) % kBasePieColorCount;
|
colorIdx = (colorIdx + 1) % kBasePieColorCount;
|
||||||
@@ -767,7 +784,7 @@ PieView::_ShowContextMenu(FileInfo* info, BPoint p)
|
|||||||
if (item != NULL) {
|
if (item != NULL) {
|
||||||
switch (fMouseOverMenu->IndexOf(item)) {
|
switch (fMouseOverMenu->IndexOf(item)) {
|
||||||
case kIdxGetInfo:
|
case kIdxGetInfo:
|
||||||
new InfoWin(p, info, Window());
|
_OpenInfo(info, p);
|
||||||
break;
|
break;
|
||||||
case kIdxOpen:
|
case kIdxOpen:
|
||||||
_Launch(info);
|
_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 <[email protected]>. All rights reserved.
|
* Copyright (c) 2008 Stephan Aßmus <[email protected]>.
|
||||||
* Distributed under the terms of the MIT/X11 license.
|
* Copyright (c) 2009 Philippe Saint-Pierre, [email protected]
|
||||||
|
* 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
|
* 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.
|
* as long as it is accompanied by it's documentation and this copyright notice.
|
||||||
@@ -45,7 +46,7 @@ private:
|
|||||||
void _ShowVolume(BVolume* volume);
|
void _ShowVolume(BVolume* volume);
|
||||||
void _DrawProgressBar(BRect updateRect);
|
void _DrawProgressBar(BRect updateRect);
|
||||||
void _DrawPieChart(BRect updateRect);
|
void _DrawPieChart(BRect updateRect);
|
||||||
float _DrawDirectory(FileInfo* info,
|
float _DrawDirectory(BRect b, FileInfo* info,
|
||||||
float parentSpan, float beginAngle,
|
float parentSpan, float beginAngle,
|
||||||
int colorIdx, int level);
|
int colorIdx, int level);
|
||||||
FileInfo* _FileAt(const BPoint& where);
|
FileInfo* _FileAt(const BPoint& where);
|
||||||
@@ -55,7 +56,7 @@ private:
|
|||||||
void _ShowContextMenu(FileInfo* info, BPoint where);
|
void _ShowContextMenu(FileInfo* info, BPoint where);
|
||||||
void _Launch(FileInfo* info,
|
void _Launch(FileInfo* info,
|
||||||
const entry_ref* ref = NULL);
|
const entry_ref* ref = NULL);
|
||||||
|
void _OpenInfo(FileInfo* info, BPoint p);
|
||||||
private:
|
private:
|
||||||
struct Segment {
|
struct Segment {
|
||||||
Segment()
|
Segment()
|
||||||
|
|||||||
Reference in New Issue
Block a user