Skip to content

Commit

Permalink
Merge pull request #234 from AgonConsole8/fix-print
Browse files Browse the repository at this point in the history
fix text print when changing text viewport
  • Loading branch information
stevesims authored Jun 17, 2024
2 parents 278e311 + 73dfe51 commit d4da265
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 0 additions & 1 deletion video/context/cursor.h
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,6 @@ inline void Context::setActiveCursor(CursorType type) {
setActiveViewport(ViewportType::Graphics);
break;
}
plottingText = false;
}

inline void Context::setCursorBehaviour(uint8_t setting, uint8_t mask = 0xFF) {
Expand Down
5 changes: 5 additions & 0 deletions video/context/viewport.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Rect * Context::getViewport(ViewportType type) {
bool Context::setTextViewport(Rect r) {
if (r.X2 >= canvasW) r.X2 = canvasW - 1;
if (r.Y2 >= canvasH) r.Y2 = canvasH - 1;
plottingText = false;

if (r.X2 > r.X1 && r.Y2 > r.Y1) {
textViewport = r;
Expand All @@ -49,16 +50,19 @@ void Context::viewportReset() {
textViewport = Rect(0, 0, canvasW - 1, canvasH - 1);
graphicsViewport = Rect(0, 0, canvasW - 1, canvasH - 1);
activeViewport = &textViewport;
plottingText = false;
}

void Context::setActiveViewport(ViewportType type) {
activeViewport = getViewport(type);
plottingText = false;
}

// Set graphics viewport
bool Context::setGraphicsViewport(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2) {
auto p1 = toScreenCoordinates(x1, y1);
auto p2 = toScreenCoordinates(x2, y2);
plottingText = false;

if (p1.X >= 0 && p2.X < canvasW && p1.Y >= 0 && p2.Y < canvasH && p2.X >= p1.X && p2.Y >= p1.Y) {
graphicsViewport = Rect(p1.X, p1.Y, p2.X, p2.Y);
Expand All @@ -73,6 +77,7 @@ bool Context::setGraphicsViewport() {
return false;
}
graphicsViewport = newViewport;
plottingText = false;
return true;
}

Expand Down

0 comments on commit d4da265

Please sign in to comment.