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
1212 #endif
1313 #include "ft2_replayer.h"
1414
15−#define PROG_VER_STR "1.53"
15+#define PROG_VER_STR "1.54"
1616
1717 // do NOT change these! It will only mess things up...
1818
src/ft2_textboxes.c+31−28
@@ -515,45 +515,48 @@ void drawTextBox(uint16_t textBoxID) · 514 unmodified lines
515515 if (t->textPtr == NULL)
516516 return;
517517
518− // draw text mark background
519− if (textIsMarked())
518+ // draw text mark background (if this is the textbox we last interacted with)
519+ if (mouse.lastEditBox == textBoxID)
520520 {
521− hideSprite(SPRITE_TEXT_CURSOR);
521+ if (textIsMarked())
522+ {
523+ hideSprite(SPRITE_TEXT_CURSOR);
522524
523− int32_t start = getTextMarkStart();
524− int32_t end = getTextMarkEnd();
525+ int32_t start = getTextMarkStart();
526+ int32_t end = getTextMarkEnd();
525527
526− assert(start < t->maxChars && end <= t->maxChars);
528+ assert(start < t->maxChars && end <= t->maxChars);
527529
528− // find pixel start/length from markX1 and markX2
530+ // find pixel start/length from markX1 and markX2
529531
530− int32_t x1 = 0;
531− int32_t x2 = 0;
532+ int32_t x1 = 0;
533+ int32_t x2 = 0;
532534
533− for (int32_t i = 0; i < end; i++)
534− {
535− const char ch = t->textPtr[i];
536− if (ch == '\0')
537− break;
535+ for (int32_t i = 0; i < end; i++)
536+ {
537+ const char ch = t->textPtr[i];
538+ if (ch == '\0')
539+ break;
538540
539− cw = charWidth(ch);
540− if (i < start)
541− x1 += cw;
541+ cw = charWidth(ch);
542+ if (i < start)
543+ x1 += cw;
542544
543− x2 += cw;
544− }
545+ x2 += cw;
546+ }
545547
546− // render text mark background
547− if (x1 != x2)
548− {
549− start = x1;
550− const int32_t length = x2 - x1;
548+ // render text mark background
549+ if (x1 != x2)
550+ {
551+ start = x1;
552+ const int32_t length = x2 - x1;
551553
552− assert(start+length <= t->renderBufW);
554+ assert(start+length <= t->renderBufW);
553555
554− uint8_t *ptr32 = &t->renderBuf[start];
555− for (uint16_t y = 0; y < t->renderBufH; y++, ptr32 += t->renderBufW)
556− memset(ptr32, PAL_TEXTMRK, length);
556+ uint8_t *ptr32 = &t->renderBuf[start];
557+ for (uint16_t y = 0; y < t->renderBufH; y++, ptr32 += t->renderBufW)
558+ memset(ptr32, PAL_TEXTMRK, length);
559+ }
557560 }
558561 }
559562

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