Tweaks to mosaic character editing

This commit is contained in:
G.K.MacGregor
2024-07-07 19:41:39 +01:00
parent fbdde54fe4
commit c32876600b
4 changed files with 24 additions and 12 deletions

View File

@@ -169,7 +169,8 @@ TeletextPageDecode::TeletextPageDecode()
m_rowHeight[r] = NormalHeight;
for (int c=0; c<72; c++) {
if (c < 40) {
m_cellLevel1Mosaic[r][c] = false;
m_cellLevel1MosaicAttr[r][c] = false;
m_cellLevel1MosaicChar[r][c] = false;
m_cellLevel1CharSet[r][c] = 0;
}
m_refresh[r][c] = true;
@@ -723,13 +724,18 @@ void TeletextPageDecode::decodeRow(int r)
}
// Level 1 character
if (c < 40) {
m_cellLevel1CharSet[r][c] = level1CharSet;
m_cellLevel1MosaicAttr[r][c] = level1Mosaics;
// Set to true on mosaic CHARACTER - not on blast through alphanumerics
m_cellLevel1MosaicChar[r][c] = level1Mosaics && (m_levelOnePage->character(r, c) & 0x20);
}
if (c < 40 && m_rowHeight[r] != BottomHalf) {
m_level1ActivePainter.result.character.diacritical = 0;
if (m_levelOnePage->character(r, c) >= 0x20) {
m_level1ActivePainter.result.character.code = m_levelOnePage->character(r, c);
// Set to true on mosaic character - not on blast through alphanumerics
m_cellLevel1Mosaic[r][c] = level1Mosaics && (m_levelOnePage->character(r, c) & 0x20);
if (m_cellLevel1Mosaic[r][c]) {
if (m_cellLevel1MosaicChar[r][c]) {
m_level1ActivePainter.result.character.set = 24 + (level1SeparatedMosaics || m_level1ActivePainter.attribute.display.underlineSeparated);
level1HoldMosaicCharacter = m_levelOnePage->character(r, c);
level1HoldMosaicSeparated = level1SeparatedMosaics;
@@ -743,9 +749,6 @@ void TeletextPageDecode::decodeRow(int r)
// In side panel or on bottom half of Level 1 double height row, no Level 1 characters here
m_level1ActivePainter.result.character = { 0x20, 0, 0 };
if (c < 40)
m_cellLevel1CharSet[r][c] = level1CharSet;
// X/26 characters
// Used to track if character was placed by X/26 data

View File

@@ -64,7 +64,8 @@ public:
bool cellItalic(int r, int c) const { return m_cell[r][c].attribute.style.italic; };
bool cellProportional(int r, int c) const { return m_cell[r][c].attribute.style.proportional; };
bool level1MosaicAttribute(int r, int c) const { return m_cellLevel1Mosaic[r][c]; };
bool level1MosaicAttr(int r, int c) const { return m_cellLevel1MosaicAttr[r][c]; };
bool level1MosaicChar(int r, int c) const { return m_cellLevel1MosaicChar[r][c]; };
int level1CharSet(int r, int c) const { return m_cellLevel1CharSet[r][c]; };
RowHeight rowHeight(int r) const { return m_rowHeight[r]; };
@@ -261,7 +262,8 @@ private:
bool m_refresh[25][72];
textCell m_cell[25][72];
bool m_cellLevel1Mosaic[25][40];
bool m_cellLevel1MosaicAttr[25][40];
bool m_cellLevel1MosaicChar[25][40];
int m_cellLevel1CharSet[25][40];
LevelOnePage* m_levelOnePage;
int m_fullRowColour[25];

View File

@@ -149,12 +149,19 @@ bool TypeCharacterCommand::mergeWith(const QUndoCommand *command)
ToggleMosaicBitCommand::ToggleMosaicBitCommand(TeletextDocument *teletextDocument, unsigned char bitToToggle, QUndoCommand *parent) : LevelOneCommand(teletextDocument, parent)
{
m_oldCharacter = teletextDocument->currentSubPage()->character(m_row, m_column);
if (bitToToggle == 0x20 || bitToToggle == 0x7f)
// Clear or fill the whole mosaic character
m_newCharacter = bitToToggle;
else if (bitToToggle == 0x66)
// Dither
m_newCharacter = (m_row & 1) ? 0x66 : 0x39;
else
else if (m_oldCharacter & 0x20)
// Previous character was mosaic, just toggle the bit(s)
m_newCharacter = m_oldCharacter ^ bitToToggle;
else
// Previous character was blast-through, change to mosaic and set bit alone
m_newCharacter = bitToToggle | 0x20;
setText(QObject::tr("mosaic"));

View File

@@ -227,7 +227,7 @@ void TeletextWidget::keyPressEvent(QKeyEvent *event)
// Map it to block character so it doesn't need to be inserted-between later on
if (mappedKeyPress & 0x80)
mappedKeyPress = 0x7f;
if (m_pageDecode.level1MosaicAttribute(m_teletextDocument->cursorRow(), m_teletextDocument->cursorColumn()) && (mappedKeyPress < 0x40 || mappedKeyPress > 0x5f)) {
if (m_pageDecode.level1MosaicAttr(m_teletextDocument->cursorRow(), m_teletextDocument->cursorColumn()) && (mappedKeyPress < 0x40 || mappedKeyPress > 0x5f)) {
// We're on a mosaic and a blast-through character was NOT pressed
if (event->key() >= Qt::Key_0 && event->key() <= Qt::Key_9 && event->modifiers() & Qt::KeypadModifier) {
switch (event->key()) {
@@ -406,7 +406,7 @@ void TeletextWidget::selectionToClipboard()
else
plainTextData.append(' ');
if (m_pageDecode.level1MosaicAttribute(r, c) && m_teletextDocument->currentSubPage()->character(r, c) & 0x20) {
if (m_pageDecode.level1MosaicChar(r, c)) {
// A first mosaic character was found so create the image "just in time"
if (imageData == nullptr) {
imageData = new QImage(m_teletextDocument->selectionWidth() * 2, m_teletextDocument->selectionHeight() * 3, QImage::Format_Mono);