void FlowContextController::startRoute(QPoint location) { if (!isInRange(location)) return; int dot_color = m_board->getColorAt(location); int context_color = m_stable->getColorAt(location); int color = dot_color != -1 ? dot_color : context_color; setCurrentColor(color); if (getCurrentColor() == -1) // on the board return; // update moves count if (getCurrentColor() != m_previous_legal_color) { setMoves(getMoves() + 1); // save for undo m_undo.push(new FlowContext(m_board, this)); m_stable->cloneTo(*m_undo.top()); } m_previous_legal_color = getCurrentColor(); if (dot_color != -1) // is a terminal m_current_route.clear(); else // is on a existing route m_current_route = m_stable->getRouteOf(color); m_stable->clearRouteOf(color); newRoutePoint(location); }
QColorButton::QColorButton( QWidget *parent ) : QPushButton( parent ), mEnableColorText( true ), mEnableToolTip( true ) { connect( this, SIGNAL( clicked() ), SLOT( slotChangeColor() ) ); setCurrentColor( "#ffffff" ); }
void ColorEditorImpl::onPickerColorChanged(const QColor &color) { QColor newColor(color); newColor.setAlpha(opacitySlider->value()); updateColorWidgets(newColor, ColorEditorImpl::UpdateFromColorPicker); setCurrentColor(newColor); }
void LevelEditor::init() { for(std::size_t i = 0; i < m_display.size(); i++) { int col = i; while(col >= 32) { col -= 32; } m_display[i].setPosition(col * 25, static_cast<int>(i / 32) * 25); m_display[i].setSize(sf::Vector2f(25.f, 25.f)); m_display[i].setOutlineThickness(1.f); m_display[i].setOutlineColor(sf::Color::White); m_display[i].setFillColor(sf::Color(0,0,0,0)); } for(std::size_t i = 0; i < 32; i++) { m_lines.push_back(LevelLine()); } updateDisplay(); //Init interface m_font.loadFromFile("data/fonts/DejaVuSans.ttf"); m_displayOffset.setFont(m_font); m_displayOffset.setPosition(10, 460); m_displayOffset.setString("Grid left upper corner : 0 | 0"); m_displayOffset.setCharacterSize(20); m_displayOffset.setColor(sf::Color::White); m_displayMousePos.setFont(m_font); m_displayMousePos.setPosition(10, 485); m_displayMousePos.setString("Mouse position : 0 | 0"); m_displayMousePos.setCharacterSize(20); m_displayMousePos.setColor(sf::Color::White); //Display last colors for(std::size_t i = 0; i < m_displayLastColors.size(); i++) { int col = i; while(col > 4) { col -= 5; } m_displayLastColors[i].setSize(sf::Vector2f(25.f,25.f)); m_displayLastColors[i].setPosition(950 + (col*25), 375 + (static_cast<int>(i / 5.f)*25)); m_displayLastColors[i].setOutlineThickness(1); m_displayLastColors[i].setOutlineColor(sf::Color::Black); m_displayLastColors[i].setFillColor(sf::Color::White); } setCurrentColor(sf::Color::White); }
void FlowContextController::restart(void) { setCurrentColor(-1); setMoves(0); m_previous_legal_color = -1; while (m_undo.size()) delete m_undo.pop(); }
void ColorEditorImpl::onOpacityChanged(int opacity) { QColor newColor = QColor::fromHsv(hueSlider->value(), color.hsvSaturation(), color.value(), opacity); updateColorWidgets(newColor, ColorEditorImpl::UpdateFromOpacitySlider); setCurrentColor(newColor); }
void ColorEditorImpl::onValueChanged(int value) { QColor newColor = QColor::fromHsv(color.hsvHue(), color.hsvSaturation(), value, opacitySlider->value()); updateColorWidgets(newColor, ColorEditorImpl::UpdateFromValueSlider); setCurrentColor(newColor); }
void KoColorPopupAction::setCurrentColor( const QColor &_color ) { #ifndef NDEBUG if (!_color.isValid()) { warnWidgets << "Invalid color given, defaulting to black"; } #endif const QColor color(_color.isValid() ? _color : QColor(0,0,0,255)); setCurrentColor(KoColor(color, KoColorSpaceRegistry::instance()->rgb8() )); }
void ColorEditorImpl::onSaturationChanged(int saturation) { QColor newColor = QColor::fromHsv(color.hsvHue(), saturation, color.value(), opacitySlider->value()); updateColorWidgets(newColor, ColorEditorImpl::UpdateFromSaturationSlider); setCurrentColor(newColor); }
void AskColorDialog::setHex(){ QColor c = QString2QColor( hexcode->text() ); if (c.isValid()) setCurrentColor( c ); // set bold if color is valid QFont f = hexcode->font(); f.setBold(c.isValid()); hexcode->setFont( f ); }
void QQuickAbstractColorDialog::setColor(QColor arg) { if (m_dlgHelper) m_dlgHelper->setCurrentColor(arg); // m_options->setCustomColor or setStandardColor don't make sense here if (m_color != arg) { m_color = arg; emit colorChanged(); } setCurrentColor(arg); }
void FlowContextController::endRoute(void) { if (m_beta->isTruncatedComparedTo(*m_stable)) emit flowTruncated(); else if (m_current_route.size() > 1 && m_board->getColorAt(m_current_route.back()) == m_current_color) emit flowAddedWithoutTruncation(); setCurrentColor(-1); m_beta->cloneTo(*m_stable); }
void ColorSelect::onActivated(const QString& text) { if(text == CUSTOM) { auto colorDialog = new QColorDialog(this); if(_customColor.isValid()) { colorDialog->setCurrentColor(_customColor); } colorDialog->show(); connect(colorDialog, &QColorDialog::colorSelected, this, &ColorSelect::on_customColorChanged); } }
void FlowContextController::undo(void) { if (!m_undo.size()) return; setCurrentColor(-1); setMoves(getMoves() - 1); m_previous_legal_color = -1; FlowContext *top = m_undo.pop(); top->cloneTo(*m_stable); top->cloneTo(*m_beta); delete top; }
void SelectColorDialog::mousePressEvent(QMouseEvent* event) { for (int i=0; i<16; i++) { auto localPos = _widgets[i]->mapFromParent(event->pos()); if (_widgets[i]->rect().contains(localPos)) { setCurrentColor(i); event->accept(); return; } } event->ignore(); }
QPlatformColorDialogHelper *QQuickQColorDialog::helper() { QQuickItem *parentItem = qobject_cast<QQuickItem *>(parent()); if (parentItem) m_parentWindow = parentItem->window(); if (!m_dlgHelper) { m_dlgHelper = new QColorDialogHelper(); connect(m_dlgHelper, SIGNAL(currentColorChanged(QColor)), this, SLOT(setCurrentColor(QColor))); connect(m_dlgHelper, SIGNAL(colorSelected(QColor)), this, SLOT(setColor(QColor))); connect(m_dlgHelper, SIGNAL(accept()), this, SLOT(accept())); connect(m_dlgHelper, SIGNAL(reject()), this, SLOT(reject())); } return m_dlgHelper; }
FlowContextController::FlowContextController(FlowBoard *mother, QObject *parent) : QObject(parent), m_board(mother), m_stable(new FlowContext(mother, this)), m_beta(new FlowContext(mother, this)), m_previous_legal_color(-1) { m_solver = new FlowSolver(m_board, this); connect(m_board, SIGNAL(boardLoaded(int)), this, SLOT(restart())); connect(m_stable, SIGNAL(contextRatioChanged(double)), this, SLOT(stableRatioChanged(double))); connect(m_beta, SIGNAL(contextRatioChanged(double)), this, SIGNAL(realTimeRatioChanged(double))); setCurrentColor(-1); setMoves(0); }
void setCurrentColorWithUndo(const TPixel32 &color) { TTool::Application *app = TTool::getApplication(); TPaletteHandle *ph = app->getPaletteController()->getCurrentPalette(); int styleId = ph->getStyleIndex(); TPalette *palette = ph->getPalette(); TXshSimpleLevel *level = app->getCurrentLevel()->getSimpleLevel(); if (palette) TUndoManager::manager()->add( new UndoPickRGBM(palette, styleId, color, level)); setCurrentColor(color); if (level) { std::vector<TFrameId> fids; level->getFids(fids); invalidateIcons(level, fids); } }
void QColorButton::slotChangeColor() { QColor newColor = QColorDialog::getColor( mCurrentColor, this ); if ( newColor.isValid() ) setCurrentColor( newColor ); }
void LevelEditor::mouseInput() { if(sf::Mouse::isButtonPressed(sf::Mouse::Left)) { sf::Vector2f mousePos = m_window.mapPixelToCoords(sf::Mouse::getPosition(m_window)); if(mousePos.x < 800 && mousePos.y < 450 && mousePos.x > 0 && mousePos.y > 0) { int col = static_cast<int>(mousePos.x / 25.f); int row = static_cast<int>(mousePos.y / 25.f); if(m_drawMode == DrawMode::opticalBlock) { if(m_currentColor != -1) m_lines[m_xOffset + col].addColor(m_yOffset + row, m_currentColor); } else if(m_drawMode == DrawMode::collisionBlock) { m_lines[m_xOffset + col].addCollisionType(m_yOffset + row, CollisionType::COLLISION); } else if(m_drawMode == DrawMode::finishBlock) { m_lines[m_xOffset + col].addCollisionType(m_yOffset + row, CollisionType::FINISH); } else if(m_drawMode == DrawMode::scripts) { m_selectedXPos = col + m_xOffset; m_selectedScript = nullptr; } } //Check last colors if(m_drawMode == DrawMode::collisionBlock || m_drawMode == DrawMode::opticalBlock || m_drawMode == DrawMode::finishBlock) { if(mousePos.x >= 950 && mousePos.y <= 1050 && mousePos.y >= 375 && mousePos.y <= 475) { int col = static_cast<int>((mousePos.x - 950) / 25.f); int row = static_cast<int>((mousePos.y - 375) / 25.f); setCurrentColor(m_displayLastColors[(row*5)+col].getFillColor()); } } } else if(sf::Mouse::isButtonPressed(sf::Mouse::Right)) { sf::Vector2f mousePos = m_window.mapPixelToCoords(sf::Mouse::getPosition(m_window)); if(mousePos.x < 800 && mousePos.y < 450 && mousePos.x > 0 && mousePos.y > 0) { int col = static_cast<int>(mousePos.x / 25.f); int row = static_cast<int>(mousePos.y / 25.f); if(m_drawMode == DrawMode::opticalBlock) { m_lines[m_xOffset + col].addColor(m_yOffset + row, -1); } else if(m_drawMode == DrawMode::finishBlock || m_drawMode == DrawMode::collisionBlock) { m_lines[m_xOffset + col].addCollisionType(m_yOffset + row, CollisionType::NONE); } } } updateDisplay(); }
void TdwPalette::mousePressEvent(QMouseEvent *e) { if(readOnly || palette.isEmpty()) return; setCurrentColor(getColorId(e->pos())); }