// **************************************************************************** // Method: QvisColorGridWidget::emitSelection // // Purpose: // Emit any signals associated with making a selection. // // Programmer: Jeremy Meredith // Creation: August 11, 2006 // // **************************************************************************** void QvisColorGridWidget::emitSelection() { emit selectedColor(paletteColors[currentSelectedItem]); emit selectedColor(paletteColors[currentSelectedItem], currentSelectedItem); int row, column; getRowColumnFromIndex(currentSelectedItem, row, column); emit selectedColor(paletteColors[currentSelectedItem], row, column); }
void InputTreeView::paintEvent(QPaintEvent *event) { QPainter painter(this); //Selected or not selected if(selected()) { painter.fillRect( this->rect(), QBrush( selectedColor() )); painter.setPen(QPen( QBrush( QColor(160,0,0) ), 2, Qt::SolidLine)); } else { painter.fillRect( this->rect(), QBrush( backgroundColor() )); painter.setPen(QPen(Qt::black,1, Qt::SolidLine)); } if(isVisible()) { QPolygon points(4); int w = width() / 2; points[0] = QPoint(1,2); points[1] = QPoint(w,2); points[2] = QPoint(w,height()-2); points[3] = QPoint(1,height()-2); painter.drawPolyline(points); QWidget::paintEvent(event); } }
// Load the resources for the scene from a resource loader void MainMenu::load(const ResourceLoader& resourceLoader) { Color normalColor(100, 100, 0), selectedColor(255, 255, 0); Font menuFont = resourceLoader.loadFont("mainMenu.ttf", 42); Game* game = getGame(); _mainMenu.addElement( menuFont, "Play", normalColor, selectedColor); _mainMenu.addElement( menuFont, "Settings", normalColor, selectedColor); _mainMenu.addElement( menuFont, "Quit", normalColor, selectedColor, [&game](){ game->quit(); }); }
void PanelPreferenceFirestorm::refreshTagCombos() { //WS: Set the combo_boxes to the right value U32 usel_u = gSavedSettings.getU32("FSUseLegacyClienttags"); U32 tagv_u = gSavedSettings.getU32("FSClientTagsVisibility2"); U32 tagc_u = gSavedSettings.getU32("FSColorClienttags"); std::string usel = llformat("%d",usel_u); std::string tagv = llformat("%d",tagv_u); std::string tagc = llformat("%d",tagc_u); m_UseLegacyClienttags->setCurrentByIndex(usel_u); m_ColorClienttags->setCurrentByIndex(tagc_u); m_ClientTagsVisibility->setCurrentByIndex(tagv_u); getChild<LLUICtrl>("usernamecolorswatch")->setValue(gSavedSettings.getColor4("FSColorUsernameColor").getValue()); getChild<LLUICtrl>("FSColorUsername_toggle")->setValue(gSavedSettings.getBOOL("FSColorUsername")); getChild<LLUICtrl>("FSShowOwnTagColor_toggle")->setValue(gSavedSettings.getBOOL("FSShowOwnTagColor")); LLColor4 tag_color = gSavedPerAccountSettings.getColor4("AngstromTagColor"); LLSD selectedColor("red"); // default case: red if (tag_color==LLColor4::blue) selectedColor = LLSD("blue"); else if (tag_color==LLColor4::yellow) selectedColor = LLSD("yellow"); else if (tag_color==LLColor4::purple) selectedColor = LLSD("purple"); else if (tag_color==LLColor4((F32)0.99,(F32)0.56,(F32)0.65,(F32)1)) selectedColor = LLSD("pink"); else if (tag_color==LLColor4::white) selectedColor = LLSD("white"); else if (tag_color==LLColor4((F32)0.99,(F32)0.39,(F32)0.12,(F32)1)) selectedColor = LLSD("orange"); else if (tag_color==LLColor4::green) selectedColor = LLSD("green"); getChild<LLComboBox>("ClientTagColor")->setValue(selectedColor); }
void ColorSelectButton::createGUI() { setPopupMode( QToolButton::InstantPopup ); QObject::connect( this, SIGNAL( selectedColor(QColor) ), SLOT( setColor(QColor) ) ); QObject::disconnect( this, SIGNAL( clicked() ), this, SLOT( defaultColor() ) ); d->tButtonDefaultColor->deleteLater(); }
void ofxGuiGrid::draw() { selectedColor(); glPushMatrix(); glTranslatef( mObjX, mObjY, 0.0f ); if ( bDblClickMode ) { this->dblClickImage->draw(); } else { if ( mParamName != "" ) { drawParamString( 0.0, 0.0, mParamName, false ); } ofFill(); //! Background //glColor4f( mGlobals->mCoverColor.r, mGlobals->mCoverColor.g, mGlobals->mCoverColor.b, mGlobals->mCoverColor.a ); ofNoFill(); //! Grids for ( int j = 0; j < mYGrid; j++ ) { for ( int i = 0; i < mXGrid; i++ ) { int index = i + j * mXGrid; ofNoFill(); if ( mSelectedId == index ) { drawSelectedRect( getGridX(i), getGridY(j), getGridWidth(), getGridHeight() ); } else { glColor4f( mGlobals->mFrameColor.r, mGlobals->mFrameColor.g, mGlobals->mFrameColor.b, mGlobals->mFrameColor.a ); //ofRect( mCtrX + mBorder + i * mSpacing + i * mGridWidth, // mCtrY + mBorder + j * mSpacing + j * mGridHeight, // mGridWidth, mGridHeight ); ofRect( getGridX(i), getGridY(j), getGridWidth(), getGridHeight() ); } if ( gridImages[index] != NULL ) { gridImages[index]->draw(); } } } } ofNoFill(); //! Frame glColor4f( mGlobals->mFrameColor.r, mGlobals->mFrameColor.g, mGlobals->mFrameColor.b, mGlobals->mFrameColor.a ); ofRect( mCtrX, mCtrY, mCtrWidth, mCtrHeight ); glPopMatrix(); if ( !bDblClickMode ) { for ( int i = 0; i < mObjects.size(); ++i ) { mObjects[i]->draw(); } } }
void MannequinMoveManipulator::preDrawUI(const M3dView &view) { recalcMetrics(); _xColor = xColor(); _yColor = yColor(); _zColor = zColor(); _selColor = selectedColor(); _selected[0] = shouldDrawHandleAsSelected(0); _selected[1] = shouldDrawHandleAsSelected(1); _selected[2] = shouldDrawHandleAsSelected(2); }
void QvisColorGridWidget::setSelectedColorIndex(int index) { if (index >= -1 && index < numPaletteColors) { QRegion region; // If we currently have a selected color, unhighlight it. if (currentSelectedColor != -1) region = drawUnHighlightedColor(0, currentSelectedColor); // Set the new value. currentSelectedColor = index; // If the selected color that we set is a real color, highlight // the new selected color. if (currentSelectedColor != -1) { region = region + drawSelectedColor(0, currentSelectedColor); } // Update the widget. if (isVisible()) repaint(region); else if (drawPixmap) { delete drawPixmap; drawPixmap = 0; } // emit the selectedColor signal. if (currentSelectedColor != -1) { emit selectedColor(paletteColors[currentSelectedColor]); emit selectedColor(paletteColors[currentSelectedColor], currentSelectedColor); int row, column; getRowColumnFromIndex(currentSelectedColor, row, column); emit selectedColor(paletteColors[currentSelectedColor], row, column); } } }
void IsoSurfaceDialog::init() { update(); connect(&m_viewer.trapMesh(), SIGNAL(colorAChanged(QColor)), ui->colorButtonA, SLOT(setButtonColor(QColor))); connect(ui->colorButtonA, SIGNAL(selectedColor(QColor)), &m_viewer.trapMesh(), SLOT(setColorA(QColor))); connect(&m_viewer.trapMesh(), SIGNAL(colorBChanged(QColor)), ui->colorButtonB, SLOT(setButtonColor(QColor))); connect(ui->colorButtonB, SIGNAL(selectedColor(QColor)), &m_viewer.trapMesh(), SLOT(setColorB(QColor))); connect(ui->checkBoxVisible, SIGNAL(toggled(bool)), &m_viewer.trapMesh(), SLOT(setVisible(bool))); connect(&m_viewer.trapMesh(), SIGNAL(visibleChanged(bool)), ui->checkBoxVisible, SLOT(setChecked(bool))); connect(&m_viewer, SIGNAL(canCalculateIsoSurface(bool)), this, SLOT(setCalculateEnabled(bool))); connect(&m_viewer, SIGNAL(isoSurfaceProgress(int)), ui->calculateProgress, SLOT(setValue(int))); connect(&m_viewer.trapMesh(), SIGNAL(modeChanged(Mesh::Mode)), this, SLOT(updateComboBoxMode(Mesh::Mode))); connect(&m_viewer.trapMesh(), SIGNAL(colorAChanged(QColor)), this, SLOT(extractAlpha(QColor))); connect(&m_viewer.trapMesh(), SIGNAL(colorBChanged(QColor)), this, SLOT(extractAlpha(QColor))); connect(this, SIGNAL(sendAlpha(int)), this, SLOT(updateSpinBoxAlpha(int))); }
void PanelPreferenceFirestorm::applyTagCombos() { //WS: If the user hits "apply" then write everything (if something changed) into the Debug Settings bool change=false; if(gSavedSettings.getU32("FSUseLegacyClienttags")!=m_UseLegacyClienttags->getCurrentIndex() || gSavedSettings.getU32("FSColorClienttags")!=m_ColorClienttags->getCurrentIndex() || gSavedSettings.getU32("FSClientTagsVisibility2")!=m_ClientTagsVisibility->getCurrentIndex()){ gSavedSettings.setU32("FSUseLegacyClienttags",m_UseLegacyClienttags->getCurrentIndex()); gSavedSettings.setU32("FSColorClienttags",m_ColorClienttags->getCurrentIndex()); gSavedSettings.setU32("FSClientTagsVisibility2",m_ClientTagsVisibility->getCurrentIndex()); //WS: Clear all nametags to make everything display properly! change=true; } if(LLColor4(getChild<LLUICtrl>("usernamecolorswatch")->getValue()) != gSavedSettings.getColor4("FSColorUsernameColor")) { gSavedSettings.setColor4("FSColorUsernameColor",LLColor4(getChild<LLUICtrl>("usernamecolorswatch")->getValue())); change=true; } if(getChild<LLUICtrl>("FSColorUsername_toggle")->getValue().asBoolean() != (LLSD::Boolean)gSavedSettings.getBOOL("FSColorUsername")){ gSavedSettings.setBOOL("FSColorUsername",getChild<LLUICtrl>("FSColorUsername_toggle")->getValue().asBoolean()); change=true; } if(getChild<LLUICtrl>("FSShowOwnTagColor_toggle")->getValue().asBoolean() != (LLSD::Boolean)gSavedSettings.getBOOL("FSShowOwnTagColor")){ gSavedSettings.setBOOL("FSShowOwnTagColor",getChild<LLUICtrl>("FSShowOwnTagColor_toggle")->getValue().asBoolean()); change=true; } LLColor4 tag_color=LLColor4::red; std::string selectedColor(getChild<LLComboBox>("ClientTagColor")->getValue().asString()); if (selectedColor == "blue") tag_color = LLColor4::blue; else if (selectedColor == "yellow") tag_color = LLColor4::yellow; else if (selectedColor == "purple") tag_color = LLColor4::purple; else if (selectedColor == "pink") tag_color = LLColor4((F32)0.99,(F32)0.56,(F32)0.65,(F32)1); else if (selectedColor == "white") tag_color = LLColor4::white; else if (selectedColor == "orange") tag_color = LLColor4((F32)0.99,(F32)0.39,(F32)0.12,(F32)1); else if (selectedColor == "green") tag_color = LLColor4::green; if(tag_color!=gSavedPerAccountSettings.getColor4("AngstromTagColor")){ gSavedPerAccountSettings.setColor4("AngstromTagColor",tag_color); if(gAgentAvatarp.notNull()) gAgentAvatarp->forceBakeAllTextures(true); if(gSavedSettings.getBOOL("FSShowOwnTagColor")) change=true; } if(change) LLVOAvatar::invalidateNameTags(); }
void QvisColorGridWidget::keyPressEvent(QKeyEvent *e) { QColor temp; int column = activeIndex() % numColumns; int row = activeIndex() / numColumns; // Handle the key strokes. switch(e->key()) { case Qt::Key_Escape: // emit an empty color. emit selectedColor(temp); break; case Qt::Key_Return: case Qt::Key_Enter: setSelectedIndex(activeIndex()); break; case Qt::Key_Left: if(column == 0) setActiveIndex(getIndex(row, numColumns - 1)); else setActiveIndex(getIndex(row, column - 1)); break; case Qt::Key_Right: if(column == numColumns - 1) setActiveIndex(getIndex(row, 0)); else setActiveIndex(getIndex(row, column + 1)); break; case Qt::Key_Up: if(row == 0) setActiveIndex(getIndex(numRows - 1, column)); else setActiveIndex(getIndex(row - 1, column)); break; case Qt::Key_Down: if(row == numRows - 1) setActiveIndex(getIndex(0, column)); else setActiveIndex(getIndex(row + 1, column)); break; } }
void QvisColorGridWidget::mousePressEvent(QMouseEvent* e) { if (e->button() == Qt::RightButton) { int index = getColorIndex(e->x(), e->y()); // If a valid color index was returned, select the color. if (index != -1) { // Set the selected color. setSelectedColorIndex(index); // Emit a signal that allows us to activate a menu. int row, column; QPoint center(e->x(), e->y()); getRowColumnFromIndex(currentSelectedColor, row, column); emit activateMenu(selectedColor(), row, column, mapToGlobal(center)); } } }
/*! \brief Describes what a TreeView widget will look like. * * \bug Some cells are closed even if they cant be closed. This must * be fixed in some way. */ void TreeView::paintEvent(QPaintEvent *event) { QPainter painter(this); if(selected_) { painter.setPen( QPen( QBrush( selectedColor() ), 10 )); painter.drawRect( this->rect() ); painter.setPen(QPen( QBrush( QColor(160,0,0) ), 1, Qt::SolidLine)); } else { painter.setPen( QPen( QBrush( backgroundColor() ), 10 )); painter.drawRect( this->rect() ); painter.setPen(QPen(Qt::black,1, Qt::SolidLine)); } QPolygon points(4); if(closed_) { points[0] = QPoint(1,2); points[1] = QPoint(5,2); points[2] = QPoint(5, height()-2); points[3] = QPoint(1, height()-8); } else { points[0] = QPoint(1,2); points[1] = QPoint(5,2); points[2] = QPoint(5,height()-2); points[3] = QPoint(1,height()-2); } painter.drawPolyline(points); QWidget::paintEvent(event); }
TAO_BEGIN XLHighlighter::XLHighlighter(QTextDocument *parent) // ---------------------------------------------------------------------------- // Define the patterns and formats for the XL syntax // ---------------------------------------------------------------------------- : QSyntaxHighlighter(parent) { QColor selectedColor("#FFFF30"); QColor longTextColor("#005500"); // Build the highlighting rules highlightingRules // Infix, postfix, prefix and names << HighlightingRule(Qt::darkCyan, "", "") << HighlightingRule(Qt::darkYellow, "", "") << HighlightingRule(Qt::darkMagenta, "", "") << HighlightingRule(Qt::darkGray, "", "") // Digits << HighlightingRule(Qt::darkBlue, "\\d*\\.?\\d+") // Text << HighlightingRule(Qt::darkGreen, "\"[^\"]*\"") << HighlightingRule(Qt::darkGreen, "'[^']*'") // Multiline text << HighlightingRule(Qt::darkGreen, "<<", ">>") // Single line comment << HighlightingRule(Qt::darkRed, "//[^\n]*") // Multi-line comment << HighlightingRule(Qt::darkRed, "/\\*", "\\*/"); selectedFormat.setBackground(selectedColor); }
void SampleTCOView::paintEvent( QPaintEvent * pe ) { QPainter painter( this ); if( !needsUpdate() ) { painter.drawPixmap( 0, 0, m_paintPixmap ); return; } setNeedsUpdate( false ); if (m_paintPixmap.isNull() || m_paintPixmap.size() != size()) { m_paintPixmap = QPixmap(size()); } QPainter p( &m_paintPixmap ); QLinearGradient lingrad( 0, 0, 0, height() ); QColor c; bool muted = m_tco->getTrack()->isMuted() || m_tco->isMuted(); // state: selected, muted, normal c = isSelected() ? selectedColor() : ( muted ? mutedBackgroundColor() : painter.background().color() ); lingrad.setColorAt( 1, c.darker( 300 ) ); lingrad.setColorAt( 0, c ); // paint a black rectangle under the pattern to prevent glitches with transparent backgrounds p.fillRect( rect(), QColor( 0, 0, 0 ) ); if( gradient() ) { p.fillRect( rect(), lingrad ); } else { p.fillRect( rect(), c ); } p.setPen( !muted ? painter.pen().brush().color() : mutedColor() ); const int spacing = TCO_BORDER_WIDTH + 1; const float ppt = fixedTCOs() ? ( parentWidget()->width() - 2 * TCO_BORDER_WIDTH ) / (float) m_tco->length().getTact() : pixelsPerTact(); float nom = Engine::getSong()->getTimeSigModel().getNumerator(); float den = Engine::getSong()->getTimeSigModel().getDenominator(); float ticksPerTact = DefaultTicksPerTact * nom / den; float offset = m_tco->startTimeOffset() / ticksPerTact * pixelsPerTact(); QRect r = QRect( TCO_BORDER_WIDTH + offset, spacing, qMax( static_cast<int>( m_tco->sampleLength() * ppt / ticksPerTact ), 1 ), rect().bottom() - 2 * spacing ); m_tco->m_sampleBuffer->visualize( p, r, pe->rect() ); QFileInfo fileInfo(m_tco->m_sampleBuffer->audioFile()); QString filename = fileInfo.fileName(); paintTextLabel(filename, p); // disable antialiasing for borders, since its not needed p.setRenderHint( QPainter::Antialiasing, false ); // inner border p.setPen( c.lighter( 160 ) ); p.drawRect( 1, 1, rect().right() - TCO_BORDER_WIDTH, rect().bottom() - TCO_BORDER_WIDTH ); // outer border p.setPen( c.darker( 300 ) ); p.drawRect( 0, 0, rect().right(), rect().bottom() ); // draw the 'muted' pixmap only if the pattern was manualy muted if( m_tco->isMuted() ) { const int spacing = TCO_BORDER_WIDTH; const int size = 14; p.drawPixmap( spacing, height() - ( size + spacing ), embed::getIconPixmap( "muted", size, size ) ); } // recording sample tracks is not possible at the moment /* if( m_tco->isRecord() ) { p.setFont( pointSize<7>( p.font() ) ); p.setPen( textShadowColor() ); p.drawText( 10, p.fontMetrics().height()+1, "Rec" ); p.setPen( textColor() ); p.drawText( 9, p.fontMetrics().height(), "Rec" ); p.setBrush( QBrush( textColor() ) ); p.drawEllipse( 4, 5, 4, 4 ); }*/ p.end(); painter.drawPixmap( 0, 0, m_paintPixmap ); }
void BBTCOView::paintEvent( QPaintEvent * ) { QPainter painter( this ); if( !needsUpdate() ) { painter.drawPixmap( 0, 0, m_paintPixmap ); return; } setNeedsUpdate( false ); m_paintPixmap = m_paintPixmap.isNull() == true || m_paintPixmap.size() != size() ? QPixmap( size() ) : m_paintPixmap; QPainter p( &m_paintPixmap ); QLinearGradient lingrad( 0, 0, 0, height() ); QColor c; bool muted = m_bbTCO->getTrack()->isMuted() || m_bbTCO->isMuted(); // state: selected, muted, default, user selected c = isSelected() ? selectedColor() : ( muted ? mutedBackgroundColor() : ( m_bbTCO->m_useStyleColor ? painter.background().color() : m_bbTCO->colorObj() ) ); lingrad.setColorAt( 0, c.light( 130 ) ); lingrad.setColorAt( 1, c.light( 70 ) ); if( gradient() ) { p.fillRect( rect(), lingrad ); } else { p.fillRect( rect(), c ); } // bar lines const int lineSize = 3; p.setPen( c.darker( 200 ) ); tact_t t = Engine::getBBTrackContainer()->lengthOfBB( m_bbTCO->bbTrackIndex() ); if( m_bbTCO->length() > MidiTime::ticksPerTact() && t > 0 ) { for( int x = static_cast<int>( t * pixelsPerTact() ); x < width() - 2; x += static_cast<int>( t * pixelsPerTact() ) ) { p.drawLine( x, TCO_BORDER_WIDTH, x, TCO_BORDER_WIDTH + lineSize ); p.drawLine( x, rect().bottom() - ( TCO_BORDER_WIDTH + lineSize ), x, rect().bottom() - TCO_BORDER_WIDTH ); } } // pattern name p.setRenderHint( QPainter::TextAntialiasing ); if( m_staticTextName.text() != m_bbTCO->name() ) { m_staticTextName.setText( m_bbTCO->name() ); } QFont font; font.setHintingPreference( QFont::PreferFullHinting ); font.setPointSize( 8 ); p.setFont( font ); const int textTop = TCO_BORDER_WIDTH + 1; const int textLeft = TCO_BORDER_WIDTH + 1; p.setPen( textShadowColor() ); p.drawStaticText( textLeft + 1, textTop + 1, m_staticTextName ); p.setPen( textColor() ); p.drawStaticText( textLeft, textTop, m_staticTextName ); // inner border p.setPen( c.lighter( 130 ) ); p.drawRect( 1, 1, rect().right() - TCO_BORDER_WIDTH, rect().bottom() - TCO_BORDER_WIDTH ); // outer border p.setPen( c.darker( 300 ) ); p.drawRect( 0, 0, rect().right(), rect().bottom() ); // draw the 'muted' pixmap only if the pattern was manualy muted if( m_bbTCO->isMuted() ) { const int spacing = TCO_BORDER_WIDTH; const int size = 14; p.drawPixmap( spacing, height() - ( size + spacing ), embed::getIconPixmap( "muted", size, size ) ); } p.end(); painter.drawPixmap( 0, 0, m_paintPixmap ); }
void Render::run() { font.loadFromFile("nasalization-rg.ttf"); sf::Color color(65, 105, 255); sf::Color selectedColor(200, 100, 100); sf::Text menu; sf::Text play; sf::Text load; sf::Text exit; sf::Text loadLevel; setTextBox(&menu, &font, "MENU", 64, color); setTextBox(&play, &font, "Play", 32, color); setTextBox(&load, &font, "Load Game", 32, color); setTextBox(&exit, &font, "Exit", 32, color); setTextBox(&loadLevel, &font, "Load Level", 32, color); sf::Texture backgroundTexture; backgroundTexture.loadFromFile("Space.gif"); sf::Sprite background; setSprite(&background, &backgroundTexture, 0, 0, 3, 3); center(&menu, -60); center(&play); center(&load, 40); center(&loadLevel, 80); center(&exit, 120); while (!game) { if (opt == 0) play.setFillColor(selectedColor); else play.setFillColor(color); if (opt == 1) load.setFillColor(selectedColor); else load.setFillColor(color); if(opt == 2) loadLevel.setFillColor(selectedColor); else loadLevel.setFillColor(color); if (opt == 3) exit.setFillColor(selectedColor); else exit.setFillColor(color); window->clear(); window->draw(background); window->draw(menu); window->draw(play); window->draw(load); window->draw(loadLevel); window->draw(exit); window->display(); } std::string points; sf::Text playAgain; sf::Text pointsText; sf::Text gameOverText; setTextBox(&playAgain, &font, "Play again", 32, color); setTextBox(&pointsText, &font, "Points:", 24, color); setTextBox(&gameOverText, &font, "Game Over", 64, color); sf::Text continueText; sf::Text save; setTextBox(&continueText, &font, "Continue", 32, color); setTextBox(&save, &font, "Save", 32, color); sf::Texture playerShipTexture; playerShipTexture.loadFromFile("Statek.png"); sf::Texture projectileTexture; projectileTexture.loadFromFile("projectile.png"); sf::Texture enemyShipTexture; enemyShipTexture.loadFromFile("Statek.png"); sf::Texture enemy2ShipTexture; enemy2ShipTexture.loadFromFile("Statekzielony.png"); sf::Texture enemy3ShipTexture; enemy3ShipTexture.loadFromFile("Statekczerwony.png"); sf::Texture powerUpTexture[3]; powerUpTexture[0].loadFromFile("powerup1.png"); powerUpTexture[1].loadFromFile("powerup2.png"); powerUpTexture[2].loadFromFile("powerup3.png"); sf::Sprite hpSprite[MAX_HP]; for (int i = 0; i < MAX_HP; i++) setSprite(&hpSprite[i], &playerShipTexture, 8, 8, 1, 1, 10 + (32 * i), 740); sf::Sprite playerShip; setSprite(&playerShip, &playerShipTexture, 16, -16, 2, 2, playerhandler.player.getx(), playerhandler.player.gety()); sf::Sprite enemyShip[ENEMY]; for (int i = 0; i < ENEMY; i++) setSprite(&enemyShip[i], &enemyShipTexture, 16, 16, 2, 2, 0, 0, 180); sf::Sprite enemy2Ship[ENEMY]; for (int i = 0; i < ENEMY; i++) setSprite(&enemy2Ship[i], &enemy2ShipTexture, 16, 16, 2, 2, 0, 0, 180); sf::Sprite enemy3Ship[ENEMY]; for (int i = 0; i < ENEMY; i++) setSprite(&enemy3Ship[i], &enemy3ShipTexture, 16, 16, 2, 2, 0, 0, 180); sf::Sprite projectile[5]; for (int i = 0; i < 5; i++) setSprite(&projectile[i], &projectileTexture, 8, -8); sf::Sprite enemyProjectile[EPROJ]; sf::Sprite enemyProjectileDiagonalLeft[EPROJ]; sf::Sprite enemyProjectileDiagonalRight[EPROJ]; for (int i = 0; i < EPROJ; i++) { setSprite(&enemyProjectile[i], &projectileTexture, 8, -8); setSprite(&enemyProjectileDiagonalLeft[i], &projectileTexture, 8, 8, 1, 1, 0, 0, 45); setSprite(&enemyProjectileDiagonalRight[i], &projectileTexture, 8, -8, 1, 1, 0, 0, -45); } sf::Sprite powerUp[3]; for (int i = 0; i < 3; i++) { setSprite(&powerUp[i], &powerUpTexture[i], 8 - 8); } while (window->isOpen()) { window->clear(); window->draw(background); if (playerhandler.player.getHp() != 0) { playerShip.setPosition(playerhandler.player.getx(), y); for (int i = 0; i < playerhandler.player.getPlayerProjectile(); i++) { if (playerhandler.proj[i] != NULL) { projectile[i].setPosition(playerhandler.proj[i]->getx(), playerhandler.proj[i]->gety()); window->draw(projectile[i]); } } for (int i = 0; i < EPROJ; i++) { if (enemyHandler.enemyProj[i] != NULL) { enemyProjectile[i].setPosition(enemyHandler.enemyProj[i]->getx(), enemyHandler.enemyProj[i]->gety()); window->draw(enemyProjectile[i]); } } for (int i = 0; i < 3; i++) { if (playerhandler.powerUpHandler.powerUp[i] != NULL) { powerUp[i].setPosition(playerhandler.powerUpHandler.powerUp[i]->getx(), playerhandler.powerUpHandler.powerUp[i]->gety()); window->draw(powerUp[i]); } } for (int i = 0; i < EPROJ; i++) { if (enemyHandler.enemyProjDiagonalLeft[i] != NULL) { enemyProjectileDiagonalLeft[i].setPosition(enemyHandler.enemyProjDiagonalLeft[i]->getx(), enemyHandler.enemyProjDiagonalLeft[i]->gety()); window->draw(enemyProjectileDiagonalLeft[i]); } } for (int i = 0; i < EPROJ; i++) { if (enemyHandler.enemyProjDiagonalRight[i] != NULL) { enemyProjectileDiagonalRight[i].setPosition(enemyHandler.enemyProjDiagonalRight[i]->getx(), enemyHandler.enemyProjDiagonalRight[i]->gety()); window->draw(enemyProjectileDiagonalRight[i]); } } for (int i = 0; i < ENEMY; i++) { if ((enemyHandler.enemy[i] != NULL) && (enemyHandler.enemy[i]->getType() == 1)) { enemyShip[i].setRotation(enemyHandler.enemy[i]->getRotation()); enemyShip[i].setPosition(enemyHandler.enemy[i]->getx(), enemyHandler.enemy[i]->gety()); window->draw(enemyShip[i]); } if ((enemyHandler.enemy[i] != NULL) && (enemyHandler.enemy[i]->getType() == 2)) { enemy2Ship[i].setRotation(enemyHandler.enemy[i]->getRotation()); enemy2Ship[i].setPosition(enemyHandler.enemy[i]->getx(), enemyHandler.enemy[i]->gety()); window->draw(enemy2Ship[i]); } if ((enemyHandler.enemy[i] != NULL) && (enemyHandler.enemy[i]->getType() == 3)) { enemy3Ship[i].setRotation(enemyHandler.enemy[i]->getRotation()); enemy3Ship[i].setPosition(enemyHandler.enemy[i]->getx(), enemyHandler.enemy[i]->gety()); window->draw(enemy3Ship[i]); } } for (int i = 0; i < playerhandler.player.getHp(); i++) { window->draw(hpSprite[i]); } points = intToStr(playerhandler.player.getPoints()); pointsText.setString("Points " + points); window->draw(playerShip); } else if(playerhandler.player.getHp() == 0) { pointsText.setCharacterSize(48); center(&pointsText); center(&playAgain, 100); center(&gameOverText, -60); center(&exit, 140); while (!game) { if (opt == 0) playAgain.setFillColor(selectedColor); else playAgain.setFillColor(color); if (opt == 1) exit.setFillColor(selectedColor); else exit.setFillColor(color); window->clear(); window->draw(background); window->draw(gameOverText); window->draw(pointsText); window->draw(playAgain); window->draw(exit); window->display(); } pointsText.setCharacterSize(24); pointsText.setOrigin(0, 0); pointsText.setPosition(0, 0); } if (!playerhandler.nopause) { center(&continueText, -40); center(&save); center(&load, 40); center(&exit, 80); while (!playerhandler.nopause) { if (opt == 0) continueText.setFillColor(selectedColor); else continueText.setFillColor(color); if (opt == 1) save.setFillColor(selectedColor); else save.setFillColor(color); if (opt == 2) load.setFillColor(selectedColor); else load.setFillColor(color); if (opt == 3) exit.setFillColor(selectedColor); else exit.setFillColor(color); window->clear(); window->draw(background); window->draw(pointsText); window->draw(continueText); window->draw(save); window->draw(load); window->draw(exit); window->display(); } } window->draw(pointsText); window->display(); } }
/// PRIVATE void UFindReplaceTextDialog::createForm() { /// labelFind = new QLabel(); labelReplaceTo = new QLabel(); QPixmap pixmap_enter(IconClearTextEnter); QPixmap pixmap_leave(IconClearTextLeave); int widthIcon = 20; int heightIcon = 20; pixmap_enter = pixmap_enter.scaled(widthIcon, heightIcon, Qt::KeepAspectRatio, Qt::SmoothTransformation); pixmap_leave = pixmap_leave.scaled(widthIcon, heightIcon, Qt::KeepAspectRatio, Qt::SmoothTransformation); lineEditFindText = new ULineEditWithClearButton(); lineEditFindText->setIconButton(pixmap_leave); lineEditFindText->setIconButton(ULineEditWithClearButton::EnterEvent, pixmap_enter); lineEditFindText->setIconButton(ULineEditWithClearButton::LeaveEvent, pixmap_leave); lineEditReplaceText = new ULineEditWithClearButton(); lineEditReplaceText->setIconButton(pixmap_leave); lineEditReplaceText->setIconButton(ULineEditWithClearButton::EnterEvent, pixmap_enter); lineEditReplaceText->setIconButton(ULineEditWithClearButton::LeaveEvent, pixmap_leave); QGridLayout *gLayout1 = new QGridLayout(); gLayout1->addWidget(labelFind, 0, 0); gLayout1->addWidget(lineEditFindText, 0, 1); gLayout1->addWidget(labelReplaceTo, 1, 0); gLayout1->addWidget(lineEditReplaceText, 1, 1); /// /// labelStatus = new QLabel(); /// /// rButtonUp = new QRadioButton(); rButtonDown = new QRadioButton(); rButtonDown->setChecked(true); QVBoxLayout *vBoxLayoutGBoxDirection = new QVBoxLayout(); vBoxLayoutGBoxDirection->addWidget(rButtonDown); groupBoxDirection = new QGroupBox(); groupBoxDirection->setLayout(vBoxLayoutGBoxDirection); checkBoxWholeWords = new QCheckBox(); checkBoxCaseSensitive = new QCheckBox(); checkBoxRegExp = new QCheckBox(); QVBoxLayout *vBoxLayoutGBoxSettings = new QVBoxLayout(); vBoxLayoutGBoxSettings->addWidget(checkBoxWholeWords); vBoxLayoutGBoxSettings->addWidget(checkBoxCaseSensitive); vBoxLayoutGBoxSettings->addWidget(checkBoxRegExp); groupBoxSettings = new QGroupBox(); groupBoxSettings->setLayout(vBoxLayoutGBoxSettings); pButtonSelectColor = new UPushButtonSelectColor(); selectColor(colorSelection); connect(pButtonSelectColor, SIGNAL(selectedColor(QColor)), this, SLOT(selectColor(QColor))); QHBoxLayout *hBoxLayoutGroupBoxs = new QHBoxLayout(); hBoxLayoutGroupBoxs->addWidget(groupBoxDirection); hBoxLayoutGroupBoxs->addWidget(groupBoxSettings); /// QVBoxLayout *vBoxLayoutMain1 = new QVBoxLayout(); vBoxLayoutMain1->addLayout(gLayout1); vBoxLayoutMain1->addWidget(labelStatus); vBoxLayoutMain1->addLayout(hBoxLayoutGroupBoxs); vBoxLayoutMain1->addWidget(pButtonSelectColor); /// pButtonFind = new QPushButton(); pButtonReplace = new QPushButton(); pButtonReplaceAll = new QPushButton(); pButtonClose = new QPushButton(); connect(pButtonFind, SIGNAL(clicked()), this, SLOT(find())); connect(pButtonReplace, SIGNAL(clicked()), this, SLOT(replace())); connect(pButtonReplaceAll, SIGNAL(clicked()), this, SLOT(replaceAll())); connect(pButtonClose, SIGNAL(clicked()), this, SLOT(close())); QVBoxLayout *vBoxLayoutMain2 = new QVBoxLayout(); vBoxLayoutMain2->addWidget(pButtonFind); vBoxLayoutMain2->addWidget(pButtonReplace); vBoxLayoutMain2->addWidget(pButtonReplaceAll); vBoxLayoutMain2->addWidget(pButtonClose); vBoxLayoutMain2->addStretch(); /// QHBoxLayout *hBoxLayoutMain = new QHBoxLayout(); hBoxLayoutMain->addLayout(vBoxLayoutMain1); hBoxLayoutMain->addLayout(vBoxLayoutMain2); setLayout(hBoxLayoutMain); }
ScreenProgressBar::ScreenProgressBar() :_nodeBase(NULL), _layerFrame(NULL), _layerProgressBar(NULL), _controller(NULL) { { CCSize size; size.width = SingleElementWidth(); size.height = CCDirector::sharedDirector()->getWinSize().height; setContentSize(size); } { CCLayerColor* layerN = CCLayerColor::create(normalColor(), SingleElementWidth(), 30); CCLabelTTF *label = CCLabelTTF::create("Loading. Please stand by.", MAX_DEFAULT_FONT, 10); label->setTag(BUTTON_LABEL_TAG); label->setColor(MAX_COLOR_WHITE); CCSize sz = layerN->getContentSize(); sz.height /= 2; label->setPosition(ccp((int)(sz.width * 0.25), (int)(sz.height * 0.25))); sz.width *= CCDirector::sharedDirector()->getContentScaleFactor(); sz.height *= CCDirector::sharedDirector()->getContentScaleFactor(); label->setContentSize(sz); label->setAnchorPoint(ccp(0, 0)); layerN->addChild(label); CocosHelper::MoveNode(layerN->getChildByTag(11), ccp(15, 5)); addChild(layerN); _buttons->addObject(layerN); } if (!_nodeBase) { _nodeBase = CCNode::create(); _nodeBase->setContentSize(CCSizeMake(SingleElementWidth(), SingleElementHeight())); _nodeBase->setAnchorPoint(ccp(0, 0)); _nodeBase->setPosition(ccp(0, 0)); addChild(_nodeBase); _buttons->addObject(_nodeBase); } ccColor4B color; color = normalColor(); if (!_layerFrame) { _layerFrame = CCLayerColor::create(color, SingleElementWidth(), 50); _layerFrame->setAnchorPoint(ccp(0, 0)); _layerFrame->setPosition(ccp(0, 0)); _nodeBase->addChild(_layerFrame); } color = selectedColor(); if (!_layerProgressBar) { _layerProgressBar = CCLayerColor::create(color, 0, 50); _layerProgressBar->setAnchorPoint(ccp(0, 0)); _layerProgressBar->setPosition(ccp(0, 0)); _nodeBase->addChild(_layerProgressBar); } SetProgress(0.0); }
void SampleTCOView::paintEvent( QPaintEvent * pe ) { QPainter painter( this ); if( !needsUpdate() ) { painter.drawPixmap( 0, 0, m_paintPixmap ); return; } setNeedsUpdate( false ); m_paintPixmap = m_paintPixmap.isNull() == true || m_paintPixmap.size() != size() ? QPixmap( size() ) : m_paintPixmap; QPainter p( &m_paintPixmap ); QLinearGradient lingrad( 0, 0, 0, height() ); QColor c; bool muted = m_tco->getTrack()->isMuted() || m_tco->isMuted(); // state: selected, muted, normal c = isSelected() ? selectedColor() : ( muted ? mutedBackgroundColor() : painter.background().color() ); lingrad.setColorAt( 1, c.darker( 300 ) ); lingrad.setColorAt( 0, c ); if( gradient() ) { p.fillRect( rect(), lingrad ); } else { p.fillRect( rect(), c ); } p.setPen( !muted ? painter.pen().brush().color() : mutedColor() ); const int spacing = TCO_BORDER_WIDTH + 1; QRect r = QRect( TCO_BORDER_WIDTH, spacing, qMax( static_cast<int>( m_tco->sampleLength() * pixelsPerTact() / DefaultTicksPerTact ), 1 ), rect().bottom() - 2 * spacing ); m_tco->m_sampleBuffer->visualize( p, r, pe->rect() ); // disable antialiasing for borders, since its not needed p.setRenderHint( QPainter::Antialiasing, false ); if( r.width() < width() - 1 ) { p.drawLine( r.x(), r.y() + r.height() / 2, rect().right() - TCO_BORDER_WIDTH, r.y() + r.height() / 2 ); } // inner border p.setPen( c.lighter( 160 ) ); p.drawRect( 1, 1, rect().right() - TCO_BORDER_WIDTH, rect().bottom() - TCO_BORDER_WIDTH ); // outer border p.setPen( c.darker( 300 ) ); p.drawRect( 0, 0, rect().right(), rect().bottom() ); // draw the 'muted' pixmap only if the pattern was manualy muted if( m_tco->isMuted() ) { const int spacing = TCO_BORDER_WIDTH; const int size = 14; p.drawPixmap( spacing, height() - ( size + spacing ), embed::getIconPixmap( "muted", size, size ) ); } // recording sample tracks is not possible at the moment /* if( m_tco->isRecord() ) { p.setFont( pointSize<7>( p.font() ) ); p.setPen( textShadowColor() ); p.drawText( 10, p.fontMetrics().height()+1, "Rec" ); p.setPen( textColor() ); p.drawText( 9, p.fontMetrics().height(), "Rec" ); p.setBrush( QBrush( textColor() ) ); p.drawEllipse( 4, 5, 4, 4 ); }*/ p.end(); painter.drawPixmap( 0, 0, m_paintPixmap ); }