History

Fix text mark bug when clicking on a new instrument/sample

Olav Sørensen committed 4 years ago

Commit 08c115d1 parent 493bce52 files · +32 −29Browse files

Unified · Split

2 files
  1. src/ft2_header.h +1 −1
  2. src/ft2_textboxes.c +31 −28
src/ft2_header.h+1−1
@@ -12,7 +12,7 @@ · 11 unmodified lines
12#endif12#endif
13#include "ft2_replayer.h"13#include "ft2_replayer.h"
14 14
15#define PROG_VER_STR "1.53"15#define PROG_VER_STR "1.54"
16 16
17// do NOT change these! It will only mess things up...17// do NOT change these! It will only mess things up...
18 18
src/ft2_textboxes.c+31−28
@@ -515,45 +515,48 @@ void drawTextBox(uint16_t textBoxID) · 514 unmodified lines
515 if (t->textPtr == NULL)515 if (t->textPtr == NULL)
516 return;516 return;
517 517
518 // draw text mark background518 // draw text mark background (if this is the textbox we last interacted with)
519 if (textIsMarked())519 if (mouse.lastEditBox == textBoxID)
520 {520 {
521 hideSprite(SPRITE_TEXT_CURSOR);521 if (textIsMarked())
522 {
523 hideSprite(SPRITE_TEXT_CURSOR);
522 524
523 int32_t start = getTextMarkStart();525 int32_t start = getTextMarkStart();
524 int32_t end = getTextMarkEnd();526 int32_t end = getTextMarkEnd();
525 527
526 assert(start < t->maxChars && end <= t->maxChars);528 assert(start < t->maxChars && end <= t->maxChars);
527 529
528 // find pixel start/length from markX1 and markX2530 // find pixel start/length from markX1 and markX2
529 531
530 int32_t x1 = 0;532 int32_t x1 = 0;
531 int32_t x2 = 0;533 int32_t x2 = 0;
532 534
533 for (int32_t i = 0; i < end; i++)535 for (int32_t i = 0; i < end; i++)
534 {536 {
535 const char ch = t->textPtr[i];537 const char ch = t->textPtr[i];
536 if (ch == '\0')538 if (ch == '\0')
537 break;539 break;
538 540
539 cw = charWidth(ch);541 cw = charWidth(ch);
540 if (i < start)542 if (i < start)
541 x1 += cw;543 x1 += cw;
542 544
543 x2 += cw;545 x2 += cw;
544 }546 }
545 547
546 // render text mark background548 // render text mark background
547 if (x1 != x2)549 if (x1 != x2)
548 {550 {
549 start = x1;551 start = x1;
550 const int32_t length = x2 - x1;552 const int32_t length = x2 - x1;
551 553
552 assert(start+length <= t->renderBufW);554 assert(start+length <= t->renderBufW);
553 555
554 uint8_t *ptr32 = &t->renderBuf[start];556 uint8_t *ptr32 = &t->renderBuf[start];
555 for (uint16_t y = 0; y < t->renderBufH; y++, ptr32 += t->renderBufW)557 for (uint16_t y = 0; y < t->renderBufH; y++, ptr32 += t->renderBufW)
556 memset(ptr32, PAL_TEXTMRK, length);558 memset(ptr32, PAL_TEXTMRK, length);
559 }
557 }560 }
558 }561 }
559 562

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t