some more hscrolling!
This commit is contained in:
parent
aff6317808
commit
f483f6cfc2
@ -21,7 +21,9 @@ TrackView::TrackView(HWND hwnd)
|
|||||||
scrollPosY = 0;
|
scrollPosY = 0;
|
||||||
windowWidth = -1;
|
windowWidth = -1;
|
||||||
windowHeight = -1;
|
windowHeight = -1;
|
||||||
|
|
||||||
editLine = 0;
|
editLine = 0;
|
||||||
|
editTrack = 0;
|
||||||
|
|
||||||
this->hwnd = hwnd;
|
this->hwnd = hwnd;
|
||||||
|
|
||||||
@ -38,6 +40,11 @@ int TrackView::getScreenY(int line)
|
|||||||
return topMarginHeight + (line * fontHeight) - scrollPosY;
|
return topMarginHeight + (line * fontHeight) - scrollPosY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int TrackView::getScreenX(int track)
|
||||||
|
{
|
||||||
|
return leftMarginWidth + (track * trackWidth) - scrollPosX;
|
||||||
|
}
|
||||||
|
|
||||||
void TrackView::onCreate()
|
void TrackView::onCreate()
|
||||||
{
|
{
|
||||||
setupScrollBars();
|
setupScrollBars();
|
||||||
@ -119,23 +126,22 @@ void TrackView::paintTracks(HDC hdc, RECT rcTracks)
|
|||||||
|
|
||||||
SetTextColor(hdc, RGB(0, 0, 0));
|
SetTextColor(hdc, RGB(0, 0, 0));
|
||||||
|
|
||||||
int trackLeft = leftMarginWidth - scrollPosX;
|
for (int track = 0; track < tracks; ++track)
|
||||||
for (int x = 0; x < tracks; ++x)
|
|
||||||
{
|
{
|
||||||
RECT topMargin;
|
RECT topMargin;
|
||||||
|
|
||||||
topMargin.top = 0;
|
topMargin.top = 0;
|
||||||
topMargin.bottom = topMarginHeight;
|
topMargin.bottom = topMarginHeight;
|
||||||
|
|
||||||
topMargin.left = trackLeft;
|
topMargin.left = getScreenX(track);
|
||||||
topMargin.right = trackLeft + trackWidth;
|
topMargin.right = topMargin.left + trackWidth;
|
||||||
|
|
||||||
RECT fillRect = topMargin;
|
RECT fillRect = topMargin;
|
||||||
DrawEdge(hdc, &fillRect, BDR_RAISEDINNER | BDR_RAISEDOUTER, BF_ADJUST | BF_LEFT | BF_RIGHT | BF_BOTTOM);
|
DrawEdge(hdc, &fillRect, BDR_RAISEDINNER | BDR_RAISEDOUTER, BF_ADJUST | BF_LEFT | BF_RIGHT | BF_BOTTOM);
|
||||||
FillRect(hdc, &fillRect, (HBRUSH)GetStockObject(LTGRAY_BRUSH));
|
FillRect(hdc, &fillRect, (HBRUSH)GetStockObject(LTGRAY_BRUSH));
|
||||||
|
|
||||||
/* format the text */
|
/* format the text */
|
||||||
_sntprintf_s(temp, 256, _T("track %d"), x);
|
_sntprintf_s(temp, 256, _T("track %d"), track);
|
||||||
TextOut(hdc,
|
TextOut(hdc,
|
||||||
fillRect.left, 0,
|
fillRect.left, 0,
|
||||||
temp, int(_tcslen(temp))
|
temp, int(_tcslen(temp))
|
||||||
@ -146,8 +152,8 @@ void TrackView::paintTracks(HDC hdc, RECT rcTracks)
|
|||||||
for (int line = firstLine; line <= lastLine; ++line)
|
for (int line = firstLine; line <= lastLine; ++line)
|
||||||
{
|
{
|
||||||
RECT patternDataRect;
|
RECT patternDataRect;
|
||||||
patternDataRect.left = trackLeft;
|
patternDataRect.left = getScreenX(track);
|
||||||
patternDataRect.right = trackLeft + trackWidth;
|
patternDataRect.right = patternDataRect.left + trackWidth;
|
||||||
patternDataRect.top = getScreenY(line);
|
patternDataRect.top = getScreenY(line);
|
||||||
patternDataRect.bottom = patternDataRect.top + fontHeight;
|
patternDataRect.bottom = patternDataRect.top + fontHeight;
|
||||||
|
|
||||||
@ -156,7 +162,7 @@ void TrackView::paintTracks(HDC hdc, RECT rcTracks)
|
|||||||
if (line == editLine) bgBrush = editBrush;
|
if (line == editLine) bgBrush = editBrush;
|
||||||
|
|
||||||
RECT fillRect = patternDataRect;
|
RECT fillRect = patternDataRect;
|
||||||
if (line == editLine && x == 1) DrawEdge(hdc, &fillRect, BDR_RAISEDINNER | BDR_SUNKENOUTER, BF_ADJUST | BF_TOP | BF_BOTTOM | BF_LEFT | BF_RIGHT);
|
if (line == editLine && track == editTrack) DrawEdge(hdc, &fillRect, BDR_RAISEDINNER | BDR_SUNKENOUTER, BF_ADJUST | BF_TOP | BF_BOTTOM | BF_LEFT | BF_RIGHT);
|
||||||
FillRect( hdc, &fillRect, bgBrush);
|
FillRect( hdc, &fillRect, bgBrush);
|
||||||
|
|
||||||
bool key = (line % 8 == 0);
|
bool key = (line % 8 == 0);
|
||||||
@ -166,7 +172,7 @@ void TrackView::paintTracks(HDC hdc, RECT rcTracks)
|
|||||||
if (!key) _sntprintf_s(temp, 256, _T(" - - -"));
|
if (!key) _sntprintf_s(temp, 256, _T(" - - -"));
|
||||||
else _sntprintf_s(temp, 256, _T("%2.2f"), val);
|
else _sntprintf_s(temp, 256, _T("%2.2f"), val);
|
||||||
TextOut(hdc,
|
TextOut(hdc,
|
||||||
trackLeft, patternDataRect.top,
|
patternDataRect.left, patternDataRect.top,
|
||||||
temp, int(_tcslen(temp))
|
temp, int(_tcslen(temp))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -179,14 +185,14 @@ void TrackView::paintTracks(HDC hdc, RECT rcTracks)
|
|||||||
DrawEdge(hdc, &bottomMargin, BDR_SUNKENINNER | BDR_RAISEDOUTER, BF_ADJUST | BF_TOP);
|
DrawEdge(hdc, &bottomMargin, BDR_SUNKENINNER | BDR_RAISEDOUTER, BF_ADJUST | BF_TOP);
|
||||||
FillRect(hdc, &bottomMargin, (HBRUSH)GetStockObject(WHITE_BRUSH));
|
FillRect(hdc, &bottomMargin, (HBRUSH)GetStockObject(WHITE_BRUSH));
|
||||||
*/
|
*/
|
||||||
trackLeft += trackWidth;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* pad top margin to the left edge */
|
/* pad top margin to the left edge */
|
||||||
|
|
||||||
RECT topMargin;
|
RECT topMargin;
|
||||||
topMargin.top = 0;
|
topMargin.top = 0;
|
||||||
topMargin.bottom = topMarginHeight;
|
topMargin.bottom = topMarginHeight;
|
||||||
topMargin.left = trackLeft;
|
topMargin.left = getScreenX(tracks);
|
||||||
topMargin.right = rcTracks.right;
|
topMargin.right = rcTracks.right;
|
||||||
DrawEdge(hdc, &topMargin, BDR_SUNKENINNER | BDR_RAISEDOUTER, BF_ADJUST | BF_LEFT);
|
DrawEdge(hdc, &topMargin, BDR_SUNKENINNER | BDR_RAISEDOUTER, BF_ADJUST | BF_LEFT);
|
||||||
FillRect(hdc, &topMargin, (HBRUSH)GetStockObject(LTGRAY_BRUSH));
|
FillRect(hdc, &topMargin, (HBRUSH)GetStockObject(LTGRAY_BRUSH));
|
||||||
@ -195,7 +201,7 @@ void TrackView::paintTracks(HDC hdc, RECT rcTracks)
|
|||||||
RECT rightMargin;
|
RECT rightMargin;
|
||||||
rightMargin.top = getScreenY(0);
|
rightMargin.top = getScreenY(0);
|
||||||
rightMargin.bottom = getScreenY(lines);
|
rightMargin.bottom = getScreenY(lines);
|
||||||
rightMargin.left = trackLeft;
|
rightMargin.left = getScreenX(tracks);
|
||||||
rightMargin.right = rcTracks.right;
|
rightMargin.right = rcTracks.right;
|
||||||
FillRect( hdc, &rightMargin, (HBRUSH)GetStockObject(GRAY_BRUSH));
|
FillRect( hdc, &rightMargin, (HBRUSH)GetStockObject(GRAY_BRUSH));
|
||||||
|
|
||||||
@ -298,6 +304,29 @@ void TrackView::setEditLine(int newEditLine)
|
|||||||
setScrollPos(scrollPosX, (editLine * fontHeight) - ((windowHeight - topMarginHeight) / 2) + fontHeight / 2);
|
setScrollPos(scrollPosX, (editLine * fontHeight) - ((windowHeight - topMarginHeight) / 2) + fontHeight / 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TrackView::setEditTrack(int newEditTrack)
|
||||||
|
{
|
||||||
|
int oldEditTrack = editTrack;
|
||||||
|
editTrack = newEditTrack;
|
||||||
|
|
||||||
|
// clamp to document
|
||||||
|
editTrack = max(editTrack, 0);
|
||||||
|
editTrack = min(editTrack, tracks - 1);
|
||||||
|
|
||||||
|
RECT trackRect;
|
||||||
|
trackRect.top = getScreenY(editLine);
|
||||||
|
trackRect.bottom = trackRect.top + fontHeight;
|
||||||
|
|
||||||
|
trackRect.left = getScreenX(oldEditTrack);
|
||||||
|
trackRect.right = trackRect.left + trackWidth;
|
||||||
|
InvalidateRect(hwnd, &trackRect, TRUE);
|
||||||
|
|
||||||
|
trackRect.left = getScreenX(editTrack);
|
||||||
|
trackRect.right = trackRect.left + trackWidth;
|
||||||
|
InvalidateRect(hwnd, &trackRect, TRUE);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
static int getScrollPos(HWND hwnd, int bar)
|
static int getScrollPos(HWND hwnd, int bar)
|
||||||
{
|
{
|
||||||
SCROLLINFO si = { sizeof(si), SIF_TRACKPOS };
|
SCROLLINFO si = { sizeof(si), SIF_TRACKPOS };
|
||||||
@ -375,6 +404,9 @@ void TrackView::onKeyDown(UINT keyCode, UINT flags)
|
|||||||
case VK_UP: setEditLine(editLine - 1); break;
|
case VK_UP: setEditLine(editLine - 1); break;
|
||||||
case VK_DOWN: setEditLine(editLine + 1); break;
|
case VK_DOWN: setEditLine(editLine + 1); break;
|
||||||
|
|
||||||
|
case VK_LEFT: setEditTrack(editTrack - 1); break;
|
||||||
|
case VK_RIGHT: setEditTrack(editTrack + 1); break;
|
||||||
|
|
||||||
case VK_PRIOR: setEditLine(editLine - windowLines / 2); break;
|
case VK_PRIOR: setEditLine(editLine - windowLines / 2); break;
|
||||||
case VK_NEXT: setEditLine(editLine + windowLines / 2); break;
|
case VK_NEXT: setEditLine(editLine + windowLines / 2); break;
|
||||||
}
|
}
|
||||||
|
|||||||
11
trackview.h
11
trackview.h
@ -21,12 +21,17 @@ public:
|
|||||||
|
|
||||||
void setupScrollBars();
|
void setupScrollBars();
|
||||||
void setScrollPos(int newScrollPosX, int newScrollPosY);
|
void setScrollPos(int newScrollPosX, int newScrollPosY);
|
||||||
void setEditLine(int newEditLine);
|
|
||||||
void scrollWindow(int newScrollPosX, int newScrollPosY);
|
void scrollWindow(int newScrollPosX, int newScrollPosY);
|
||||||
|
|
||||||
int getScreenY(int line);
|
void setEditLine(int newEditLine);
|
||||||
|
void setEditTrack(int newEditTrack);
|
||||||
|
|
||||||
|
int getScreenY(int line);
|
||||||
|
int getScreenX(int track);
|
||||||
|
|
||||||
|
/* cursor position */
|
||||||
|
int editLine, editTrack;
|
||||||
|
|
||||||
int editLine;
|
|
||||||
int scrollPosX, scrollPosY;
|
int scrollPosX, scrollPosY;
|
||||||
int windowWidth, windowHeight;
|
int windowWidth, windowHeight;
|
||||||
int windowLines;
|
int windowLines;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user