Allow to zoom out up to 1000000 ns per pixel instead of 1000. Missed that when

switching from micro- to nanoseconds.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34551 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold 2009-12-08 13:53:58 +00:00
parent f5c2932928
commit cfee620a7b

View File

@ -324,7 +324,7 @@ public:
BaseView("scheduling", fontInfo), BaseView("scheduling", fontInfo),
fStartTime(0), fStartTime(0),
fEndTime(0), fEndTime(0),
fUSecsPerPixel(1000), fNSecsPerPixel(1000000),
fLastMousePos(-1, -1), fLastMousePos(-1, -1),
fListener(NULL) fListener(NULL)
{ {
@ -375,7 +375,7 @@ public:
virtual BSize MinSize() virtual BSize MinSize()
{ {
nanotime_t timeSpan = fModel != NULL ? fModel->LastEventTime() : 0; nanotime_t timeSpan = fModel != NULL ? fModel->LastEventTime() : 0;
float width = std::max(float(timeSpan / fUSecsPerPixel), 100.0f); float width = std::max(float(timeSpan / fNSecsPerPixel), 100.0f);
return BSize(width, TotalHeight()); return BSize(width, TotalHeight());
} }
@ -470,8 +470,8 @@ public:
SetHighColor(color); SetHighColor(color);
BRect rect = LineRect(i); BRect rect = LineRect(i);
rect.left = startTime / fUSecsPerPixel; rect.left = startTime / fNSecsPerPixel;
rect.right = endTime / fUSecsPerPixel - 1; rect.right = endTime / fNSecsPerPixel - 1;
FillRect(rect); FillRect(rect);
} }
} }
@ -597,9 +597,9 @@ printf("failed to read event!\n");
{ {
if (fModel != NULL) { if (fModel != NULL) {
float scrollOffset = _ScrollOffset(); float scrollOffset = _ScrollOffset();
_startTime = (nanotime_t)scrollOffset * fUSecsPerPixel; _startTime = (nanotime_t)scrollOffset * fNSecsPerPixel;
_endTime = (nanotime_t)(scrollOffset + Bounds().Width() + 1) _endTime = (nanotime_t)(scrollOffset + Bounds().Width() + 1)
* fUSecsPerPixel; * fNSecsPerPixel;
} else { } else {
_startTime = 0; _startTime = 0;
_endTime = 1; _endTime = 1;
@ -620,7 +620,7 @@ printf("failed to read event!\n");
// compute the domain point where to zoom in // compute the domain point where to zoom in
float scrollOffset = _ScrollOffset(); float scrollOffset = _ScrollOffset();
double timeForX = (scrollOffset + x) * fUSecsPerPixel; double timeForX = (scrollOffset + x) * fNSecsPerPixel;
uint32 factor = 4; uint32 factor = 4;
if (steps < 0) { if (steps < 0) {
@ -628,23 +628,23 @@ printf("failed to read event!\n");
factor = 1; factor = 1;
} }
uint32 oldUsecPerPixel = fUSecsPerPixel; uint32 oldNsecPerPixel = fNSecsPerPixel;
for (; steps > 0; steps--) for (; steps > 0; steps--)
fUSecsPerPixel = fUSecsPerPixel * factor / 2; fNSecsPerPixel = fNSecsPerPixel * factor / 2;
if (fUSecsPerPixel < 1) if (fNSecsPerPixel < 1)
fUSecsPerPixel = 1; fNSecsPerPixel = 1;
else if (fUSecsPerPixel > 1000) else if (fNSecsPerPixel > 1000000)
fUSecsPerPixel = 1000; fNSecsPerPixel = 1000000;
if (fUSecsPerPixel == oldUsecPerPixel) if (fNSecsPerPixel == oldNsecPerPixel)
return; return;
Invalidate(); Invalidate();
UpdateScrollBar(); UpdateScrollBar();
if (BScrollBar* scrollBar = ScrollBar(B_HORIZONTAL)) if (BScrollBar* scrollBar = ScrollBar(B_HORIZONTAL))
scrollBar->SetValue(timeForX / fUSecsPerPixel - x); scrollBar->SetValue(timeForX / fNSecsPerPixel - x);
if (fListener != NULL) { if (fListener != NULL) {
fListener->DataWidthChanged(); fListener->DataWidthChanged();
@ -872,7 +872,7 @@ private:
SchedulingData fSchedulingData; SchedulingData fSchedulingData;
nanotime_t fStartTime; nanotime_t fStartTime;
nanotime_t fEndTime; nanotime_t fEndTime;
uint32 fUSecsPerPixel; uint32 fNSecsPerPixel;
BPoint fLastMousePos; BPoint fLastMousePos;
Listener* fListener; Listener* fListener;
}; };