void XlinkPreview::updateMulticolor2() { if(!isConnected()) return; auto state = State::getInstance(); xlink_poke(0x37, 0x00, 0xd023, (uchar) state->getColorForPen(State::PEN_MULTICOLOR2)); }
void XlinkPreview::updateBackgroundColor() { if(!_xlink->isLoaded()) return; auto state = State::getInstance(); xlink_poke(0x37, 0x00, 0xd020, (uchar) state->getColorForPen(State::PEN_BACKGROUND)); xlink_poke(0x37, 0x00, 0xd021, (uchar) state->getColorForPen(State::PEN_BACKGROUND)); }
void XlinkPreview::updateForegroundColor() { if(!isConnected()) return; auto state = State::getInstance(); uchar foreground = state->getColorForPen(State::PEN_FOREGROUND); foreground |= state->isMulticolorMode() ? 8 : 0; xlink_fill(0xb7, 0x00, 0xd800, foreground, 1000); xlink_poke(0x37, 0x00, 0x0286, foreground); }
void PaletteWidget::mousePressEvent(QMouseEvent * event) { event->accept(); auto pos = event->localPos(); int x = pos.x() / PIXEL_SIZE_X; int y = pos.y() / PIXEL_SIZE_Y; int color = 8 * y + x; auto state = State::getInstance(); int pen = state->getSelectedPen(); int oldColor = state->getColorForPen(pen); if (oldColor != color) { state->getUndoStack()->push(new SetColorCommand(state, color, pen)); emit colorSelected(); update(); } }
int State::getCurrentColor() const { return getColorForPen(_selectedPen, -1); }
int State::getColorForPen(int pen) const { return getColorForPen(pen, -1); }