Skip to content

Commit

Permalink
[#40] Track Map: General improvements and bugfixes (Part 14: Fixed ho…
Browse files Browse the repository at this point in the history
…vering on sectors with mouse)
  • Loading branch information
tomas-nestorovic committed Aug 16, 2020
1 parent f747471 commit b6870d2
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 19 deletions.
41 changes: 22 additions & 19 deletions Main/src/ViewTrackMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,18 @@
Utils::ScaleLogicalUnit(*pDC);
}

void CTrackMapView::TimesToPixels(TSector nSectors,PINT pInOutBuffer,PCWORD pInSectorLengths) const{
// converts times (in nanoseconds) in Buffer to pixels
if (showTimed)
for( TSector s=0; s<nSectors; s++ )
pInOutBuffer[s] = SECTOR1_X + (pInOutBuffer[s]/nNanosecondsPerByte>>zoomLengthFactor);
else
for( TSector s=0; s<nSectors; s++ )
pInOutBuffer[s] = s>0
? pInOutBuffer[s-1]+(pInSectorLengths[s-1]>>zoomLengthFactor)+SECTOR_MARGIN
: SECTOR1_X;
}

static const int Tabs[]={ VIEW_PADDING, VIEW_PADDING+60, SECTOR1_X };

afx_msg LRESULT CTrackMapView::__drawTrack__(WPARAM trackNumber,LPARAM pTrackInfo){
Expand Down Expand Up @@ -293,14 +305,7 @@
// : drawing Sectors
iScrollX=GetScrollPos(SB_HORZ)/Utils::LogicalUnitScaleFactor;
int sectorStartPixels[(TSector)-1];
if (showTimed)
for( TSector s=0; s<rti.nSectors; s++ )
sectorStartPixels[s] = SECTOR1_X + (rti.bufferStartNanoseconds[s]/nNanosecondsPerByte>>zoomLengthFactor);
else
for( TSector s=0; s<rti.nSectors; s++ )
sectorStartPixels[s] = s>0
? sectorStartPixels[s-1]+(rti.bufferLength[s-1]>>zoomLengthFactor)+SECTOR_MARGIN
: SECTOR1_X;
TimesToPixels( rti.nSectors, (PINT)::memcpy(sectorStartPixels,rti.bufferStartNanoseconds,rti.nSectors*sizeof(int)), rti.bufferLength );
RECT r={ SECTOR1_X, y+(TRACK_HEIGHT-SECTOR_HEIGHT)/2, SECTOR1_X, y+(TRACK_HEIGHT+SECTOR_HEIGHT)/2 };
const HGDIOBJ hBrush0=::SelectObject(dc,Utils::CRideBrush::White);
if (displayType==TDisplayType::STATUS){
Expand Down Expand Up @@ -462,22 +467,20 @@
// cursor over a Track
const TTrack track=point.y/TRACK_HEIGHT;
const THead nSides=__getNumberOfFormattedSidesInImage__(IMAGE);
point.x-=SECTOR1_X;
const div_t d=div((int)track,nSides);
TSectorId bufferId[(TSector)-1],*pId=bufferId;
WORD bufferLength[(TSector)-1],*pLength=bufferLength;
TSector nSectors=IMAGE->ScanTrack( d.quot, d.rem, bufferId, bufferLength );
for( int xL=0,xR=0; nSectors--; pId++ ){
xR+=*pLength++>>zoomLengthFactor;
if (point.x>=xL && point.x<=xR){
TSectorId bufferId[(TSector)-1];
WORD bufferLength[(TSector)-1];
int bufferStarts[(TSector)-1];
const TSector nSectors=IMAGE->ScanTrack( d.quot, d.rem, bufferId, bufferLength, bufferStarts );
TimesToPixels( nSectors, bufferStarts, bufferLength );
for( TSector s=0; s<nSectors; s++ )
if (bufferStarts[s]<=point.x && point.x<=bufferStarts[s]+(bufferLength[s]>>zoomLengthFactor)){
// cursor over a Sector
rOutChs.cylinder=d.quot, rOutChs.head=d.rem;
rOutChs.sectorId=*pId;
rnOutSectorsToSkip=pId-bufferId;
rOutChs.sectorId=bufferId[s];
rnOutSectorsToSkip=s;
return true;
}
xL=xR+=SECTOR_MARGIN;
}
}
return false;
}
Expand Down
1 change: 1 addition & 0 deletions Main/src/ViewTrackMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
void OnPrepareDC(CDC *pDC,CPrintInfo *pInfo=nullptr) override;
void OnDraw(CDC *pDC) override;
void PostNcDestroy() override;
void TimesToPixels(TSector nSectors,PINT pInOutBuffer,PCWORD pInSectorLengths) const;
bool __getPhysicalAddressFromPoint__(POINT point,TPhysicalAddress &rOutChs,BYTE &rnOutSectorsToSkip);
void __updateStatusBarIfCursorOutsideAnySector__() const;
void __updateLogicalDimensions__();
Expand Down

0 comments on commit b6870d2

Please sign in to comment.