Skip to content

Commit

Permalink
[#59] TrackEditor (Part 86: Can display Byte values in decadic or hex…
Browse files Browse the repository at this point in the history
…a-decimal format)
  • Loading branch information
tomas-nestorovic committed Oct 24, 2024
1 parent 6686126 commit 15b6b1e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
2 changes: 2 additions & 0 deletions Main/res/resource.rc
Original file line number Diff line number Diff line change
Expand Up @@ -817,6 +817,8 @@ BEGIN
MENUITEM SEPARATOR
MENUITEM "Decoding evaluation...", ID_INDICATOR_REC
MENUITEM "Export...", ID_FILE_SAVE_AS
MENUITEM SEPARATOR
MENUITEM "Decadic Byte values", ID_NUMBER
END
END

Expand Down
18 changes: 15 additions & 3 deletions Main/src/Image_TrackEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ using namespace Charting;

#define MSG_FUZZY_NAVIGATION _T("This fuzzy bit has no counterpart in any revolution")

#define INI_SECTION _T("imgte")
#define INI_DECADIC _T("dec")

class CTrackEditor sealed:public Utils::CRideDialog{
const CImage::CTrackReader &tr;
const UINT messageBoxButtons;
Expand Down Expand Up @@ -141,9 +144,9 @@ using namespace Charting;
const auto dcSettings0=::SaveDC(dc);
::SelectObject( dc, Utils::CRidePen::BlackHairline );
::SetBkMode( dc, OPAQUE );
static constexpr TCHAR ByteInfoFormat[]=_T("%c\n$%02X");
const LPCTSTR byteInfoFormat= te.decadicByteValues ? _T("%c\n%d") : _T("%c\n$%02X");
TCHAR label[80];
const SIZE byteInfoSizeMin=te.timeline.font.GetTextSize( label, ::wsprintf( label, ByteInfoFormat, 'M', 255 ) );
const SIZE byteInfoSizeMin=te.timeline.font.GetTextSize( label, ::wsprintf( label, byteInfoFormat, 'M', 255 ) );
const int nUnitsPerByte=Utils::LogicalUnitScaleFactor*te.timeline.GetUnitCount( CImage::GetActive()->EstimateNanosecondsPerOneByte() );
const enum{ BI_NONE, BI_MINIMAL, BI_FULL } showByteInfo = nUnitsPerByte>byteInfoSizeMin.cx ? BI_FULL : nUnitsPerByte>1 ? BI_MINIMAL : BI_NONE;
for( auto it=peList.GetIterator(); continuePainting&⁢ ){
Expand Down Expand Up @@ -179,7 +182,7 @@ using namespace Charting;
::LineTo( dc, rcLabel.left,rcLabel.bottom );
::DrawText(
dc,
label, ::wsprintf( label, ByteInfoFormat, ::isprint(pbi->value)?pbi->value:'?', pbi->value ),
label, ::wsprintf( label, byteInfoFormat, ::isprint(pbi->value)?pbi->value:'?', pbi->value ),
&rcLabel, DT_LEFT|DT_BOTTOM
);
break;
Expand Down Expand Up @@ -467,6 +470,7 @@ using namespace Charting;
const PCRegion pRegions;
const DWORD nRegions;
const Utils::CRidePen penIndex;
bool decadicByteValues;

CTimeEditor(const CImage::CTrackReader &tr,CImage::CTrackReader::PCRegion pRegions,DWORD nRegions)
// ctor
Expand All @@ -475,6 +479,7 @@ using namespace Charting;
, pRegions(pRegions) , nRegions(nRegions) // up to the caller to dispose allocated Regions!
, penIndex( 2, COLOR_BLUE )
, painter(*this)
, decadicByteValues( app.GetProfileBool(INI_SECTION,INI_DECADIC) )
, draggedTime(-1)
, cursorTime(-1) , cursorFeaturesShown(false) , cursorFeatures(TCursorFeatures::DEFAULT)
, scrollTime(0) {
Expand Down Expand Up @@ -1464,6 +1469,13 @@ using namespace Charting;
);
return TRUE;
}
case ID_NUMBER:
// decadic or hexa-decimal Byte values
app.WriteProfileInt( INI_SECTION, INI_DECADIC,
timeEditor.decadicByteValues=!timeEditor.decadicByteValues
);
timeEditor.Invalidate();
return TRUE;
case ID_FILE_SAVE_AS:
// export Track timing
class CExportDialog sealed:public Utils::CRideDialog{
Expand Down

0 comments on commit 15b6b1e

Please sign in to comment.