void Button::update(const sf::RenderWindow& screen, const float time, const sf::Vector2i& mouseOffset) { auto position = getPosition(); auto offset = getOffset(); sf::IntRect buttonRect(static_cast<int>(position.x + offset.x + m_style.mouseRect.left - getSize().x / 2), static_cast<int>(position.y + offset.y + m_style.mouseRect.top), m_style.mouseRect.width, m_style.mouseRect.height); auto mousePosition = getCursorPosition(screen); if(buttonRect.contains(mousePosition + mouseOffset) && isVisible()) { if(!m_playHoverSound && m_style.hoverStyle.sound) { m_playHoverSound = true; m_style.hoverStyle.sound->play(); } m_showToolTip = true; m_toolTip.setPosition(static_cast<const sf::Vector2f>(mousePosition), screen); if(utility::Mouse.leftButtonPressed()) { m_sprite = &m_style.pressedStyle.sprite; m_label = &m_style.pressedStyle.label; onPositionChanged(); if(!m_playPressedSound && m_style.pressedStyle.sound) { m_playPressedSound = true; m_style.pressedStyle.sound->play(); } } else { m_playPressedSound = false; m_sprite = &m_style.hoverStyle.sprite; m_label = &m_style.hoverStyle.label; onPositionChanged(); if(m_isTriggering && utility::Mouse.leftButtonReleased() && m_callback != nullptr) m_callback(*this); } } else { m_playHoverSound = false; m_playPressedSound = false; m_sprite = &m_style.idleStyle.sprite; m_label = &m_style.idleStyle.label; onPositionChanged(); m_showToolTip = false; } }
//---------------------------------------- void ofLight::enable() { setup(); data->isEnabled = true; onPositionChanged(); // update the position // onOrientationChanged(); ofGetGLRenderer()->enableLight(data->glIndex); }
void Level::initialize() { PlayerCityPtr city = _d->game->city(); _d->initRender(); _d->initMainUI(); _d->installHandlers( this ); _d->initSound(); _d->initTabletUI( this ); _d->undoStack.init( city ); //connect elements //city->tilemap().setFlag( Tilemap::fSvkGround, !KILLSWITCH(oldgfx) ); CONNECT( city, onWarningMessage(), _d.data(), Impl::resolveWarningMessage ) //CONNECT( _d->extMenu, onSelectOverlayType(), _d.data(), Impl::resolveSelectLayer ) CONNECT( city, onDisasterEvent(), &_d->alarmsHolder, AlarmEventHolder::add ) CONNECT( &_d->alarmsHolder, onMoveToAlarm(), _d->renderer.camera(), Camera::setCenter ) CONNECT( &_d->alarmsHolder, onAlarmChange(), _d.data(), Impl::setAlarmEnabled ) CONNECT( _d->renderer.camera(), onPositionChanged(), _d.data(), Impl::saveCameraPos ) CONNECT( _d->renderer.camera(), onDirectionChanged(), _d.data(), Impl::handleDirectionChange ) CONNECT( &_d->renderer, onLayerSwitch(), _d.data(), Impl::layerChangedOut ) CONNECT( &_d->undoStack, onUndoChange(), _d.data(), Impl::resolveUndoChange ) _d->renderer.camera()->setCenter(city->cameraPos()); _d->dhandler.insertTo(_d->game, _d->topMenu); _d->dhandler.setVisible(false); events::dispatch<events::ScriptFunc>("OnMissionStart"); }
//---------------------------------------- void ofLight::setup() { if(glIndex==-1){ bool bLightFound = false; // search for the first free block for(int i=0; i<OF_MAX_LIGHTS; i++) { if(getActiveLights()[i] == false) { glIndex = i; retain(glIndex); bLightFound = true; break; } } if( !bLightFound ){ ofLog(OF_LOG_ERROR, "ofLight : Trying to create too many lights: " + ofToString(glIndex)); } if(bLightFound) { // run this the first time, since it was not found before // onPositionChanged(); setAmbientColor( getAmbientColor() ); setDiffuseColor( getDiffuseColor() ); setSpecularColor( getSpecularColor() ); setAttenuation( getAttenuationConstant(), getAttenuationLinear(), getAttenuationQuadratic() ); if(getIsSpotlight()) { setSpotlightCutOff(getSpotlightCutOff()); setSpotConcentration(getSpotConcentration()); } if(getIsSpotlight() || getIsDirectional()) { onOrientationChanged(); } } } }
/// Immediately sets the center of the control to a new position void UIView::setCenter(float x, float y) { mRect.setCenter(x,y); onPositionChanged(); updateLayout(); };
MediaApp::MediaApp(QWidget *parent) : QWidget(parent) { //create the player m_player = new Player(this); connect(m_player, SIGNAL(positionChanged()), this, SLOT(onPositionChanged())); connect(m_player, SIGNAL(stateChanged()), this, SLOT(onStateChanged())); //m_baseDir is used to remember the last directory that was used. //defaults to the current working directory m_baseDir = QLatin1String("."); //this timer (re-)hides the controls after a few seconds when we are in fullscreen mode m_fullScreenTimer.setSingleShot(true); connect(&m_fullScreenTimer, SIGNAL(timeout()), this, SLOT(hideControls())); //create the UI QVBoxLayout *appLayout = new QVBoxLayout; appLayout->setContentsMargins(0, 0, 0, 0); createUI(appLayout); setLayout(appLayout); onStateChanged(); //set the controls to their default state setWindowTitle(tr("QtGStreamer example player")); resize(400, 400); }
/** * private constructor */ MediaApp::MediaApp() : QWidget(), m_libraryOpened(false) { m_player = new Player(this); m_playlist = new Playlist(this); m_albumWidget = new AlbumWidget(this); m_albumWidget->LoadImage("Player", "The"); m_albumWidget->setGeometry(46, 16, 300, 300); connect(m_player, SIGNAL(positionChanged()), this, SLOT(onPositionChanged())); connect(m_player, SIGNAL(stateChanged()), this, SLOT(onStateChanged())); m_baseDir = QLatin1String("."); m_fullScreenTimer.setSingleShot(true); connect(&m_fullScreenTimer, SIGNAL(timeout()), this, SLOT(hideControls())); QHBoxLayout* mainLayout = new QHBoxLayout(); mainLayout->setContentsMargins(0, 0, 0, 0); createUI(mainLayout); setLayout(mainLayout); onStateChanged(); setWindowTitle(tr("ThePlayer")); resize(700, 400); }
void View::onSetPosition(const glm::vec3 &v) { if (mPosition == v) return; mPosition = v; mTransformDirty = true; // if (mHooks) mHooks->onPositionChanged(mPosition); onPositionChanged(v); }
MenuSprite::MenuSprite(const sf::Sprite& sprite, const sf::Vector2f& position, const sf::Vector2f& offset, const int id) : MenuElement(id, MenuElementType::Image, position, offset), m_sprite(sprite), m_showToolTip(false) { onPositionChanged(); }
PlayMusicWindow::PlayMusicWindow(QWidget *parent, PlaylistHandler *plh, API *api, CoverHelper *coverHelper, QMainWindow* mainWindow, Player *player) : QMainWindow(parent), ui(new Ui::PlayMusicWindow) { timer = new QTimer(this); timer->setInterval(1000); timer->setSingleShot(true); currCurrentCover = ""; nextCurrentCover = ""; prevCurrentCover = ""; connect(timer, SIGNAL(timeout()), this, SLOT(timerDone())); posSliderMoving = false; this->realMainWindow = mainWindow; this->plh = plh; this->api = api; this->player = player; this->apb = new AudioPlayerBridge(realMainWindow); this->coverHelper = coverHelper; int volume = player->getVolume(); ui->setupUi(this); this->setWindowFlags(this->windowFlags() & ~(Qt::WindowFullscreenButtonHint)); messageHandler = new MessageHandler(this); QRect geometry = QApplication::desktop()->screenGeometry(); this->setGeometry((geometry.width() - this->width()) / 2, (geometry.height() - this->height()) / 2, this->width(), this->height()); ui->sldVolume->setStyle(new MyVolumeStyle); ui->sldVolume->setValue(volume); ui->sldPosition->setStyle(new MyVolumeStyle); this->setAttribute(Qt::WA_QuitOnClose, false); this->setAttribute(Qt::WA_DeleteOnClose); this->setFixedSize(this->size()); playlistsRefreshing = false; QWidget* shadowArray[] = {ui->lblPlayMusic, ui->lblPlayedPlaylist}; int count = sizeof(shadowArray) / sizeof(QWidget*); for (int i = 0; i < count; i++) { QGraphicsDropShadowEffect *effect = new QGraphicsDropShadowEffect(shadowArray[i]); effect->setBlurRadius(1); effect->setColor(QColor("#bb6008")); effect->setOffset(0, 1); shadowArray[i]->setGraphicsEffect(effect); } QWidget* clickthruArray[] = {}; count = sizeof(clickthruArray) / sizeof(QWidget*); for (int i = 0; i < count; i++) { clickthruArray[i]->setAttribute(Qt::WA_TransparentForMouseEvents); } connect(player, SIGNAL(playlistsChanged(std::vector<std::string>)), this, SLOT(playlistsChanged(std::vector<std::string>))); connect(player, SIGNAL(currentSongChanged()), this, SLOT(songsChanged())); connect(player, SIGNAL(songPositionChanged()), this, SLOT(onPositionChanged())); connect(player, SIGNAL(stateChanged()), this, SLOT(refreshPlayPause())); connect(coverHelper, SIGNAL(coverGotten(std::string)), this, SLOT(gotCover(std::string)), Qt::DirectConnection); connect(messageHandler, SIGNAL(addedMessage(Message*)), this, SLOT(addedMessage(Message*))); connect(messageHandler, SIGNAL(removedMessage(Message*)), this, SLOT(deletedMessage(Message*))); connect(player, SIGNAL(songFailed()), this, SLOT(songFailed())); playlistsChanged(plh->getPlaylists()); songsChanged(); refreshPlayPause(); wasPlaying = player->isPlaying() || player->isPaused(); }
//---------------------------------------- void ofNode::orbit(float longitude, float latitude, float radius, const ofVec3f& centerPoint) { ofQuaternion q(latitude, ofVec3f(1,0,0), longitude, ofVec3f(0,1,0), 0, ofVec3f(0,0,1)); setPosition((ofVec3f(0,0,radius)-centerPoint)*q +centerPoint); setOrientation(q); onOrientationChanged(); onPositionChanged(); // lookAt(centerPoint);//, v - centerPoint); }
//---------------------------------------- void ofNode::rotateAround(const ofQuaternion& q, const ofVec3f& point) { ofMatrix4x4 m = getLocalTransformMatrix(); // m.setTranslation(point); // m.rotate(q); onOrientationChanged(); onPositionChanged(); }
void Editor::onDrawingStarted(const SDL_Point & p) { _drawing = true; _currentPoint = _startPoint = p; if (_savedTexture == NULL) resetSavedTexture(); onPositionChanged(p); }
//---------------------------------------- void ofNode::setTransformMatrix(float *m44) { memcpy(localTransformMatrix._mat, m44, sizeof(float) * 16); ofQuaternion so; localTransformMatrix.decompose(position, orientation, scale, so); onPositionChanged(); onOrientationChanged(); onScaleChanged(); }
//---------------------------------------- void ofNode::setTransformMatrix(const ofMatrix4x4 &m44) { localTransformMatrix = m44; ofQuaternion so; localTransformMatrix.decompose(position, orientation, scale, so); onPositionChanged(); onOrientationChanged(); onScaleChanged(); }
void LocationData::start() { source = QGeoPositionInfoSource::createDefaultSource(this); if (source) { source->setPreferredPositioningMethods(QGeoPositionInfoSource::SatellitePositioningMethods); source->setUpdateInterval(1000); connect(source, SIGNAL(positionUpdated(QGeoPositionInfo)), this, SLOT(onPositionChanged(QGeoPositionInfo))); source->startUpdates(); } }
//---------------------------------------- void ofNode::rotateAround(const glm::quat& q, const glm::vec3& point) { // ofLogVerbose("ofNode") << "rotateAround(const glm::quat& q, const ofVec3f& point) not implemented yet"; // ofMatrix4x4 m = getLocalTransformMatrix(); // m.setTranslation(point); // m.rotate(q); setGlobalPosition(q * (getGlobalPosition() - point) + point); onOrientationChanged(); onPositionChanged(); }
void UIView::setPosition(float x, float y) { // Offset children vec2 offset = vec2(x,y) - getPosition(); // -- update the top-left position of this control mRect.left = x; mRect.top = y; updateLayout(); offsetChildrenPosition(offset); onPositionChanged(); }
Button::Button(int id, ButtonStyle style, const sf::Vector2f& position, const sf::Vector2f& offset, bool triggers) : MenuElement(id, MenuElementType::Button, position, offset), m_style(style), m_playHoverSound(false), m_showToolTip(false), m_isTriggering(triggers) { m_sprite = &m_style.idleStyle.sprite; m_label = &m_style.idleStyle.label; m_size.x = m_style.idleStyle.sprite.getTextureRect().width; m_size.y = m_style.idleStyle.sprite.getTextureRect().height; onPositionChanged(); }
/** * function called everytime app changes it's state */ void MediaApp::onStateChanged() { QGst::State newState = m_player->getState(); m_playButton->setEnabled(newState != QGst::StatePlaying); m_pauseButton->setEnabled(newState == QGst::StatePlaying); m_nextButton->setEnabled(newState == QGst::StatePlaying); m_prevButton->setEnabled(newState == QGst::StatePlaying); m_stopButton->setEnabled(newState != QGst::StateNull); m_positionSlider->setEnabled(newState != QGst::StateNull); m_volumeSlider->setEnabled(newState != QGst::StateNull); m_volumeLabel->setEnabled(newState != QGst::StateNull); m_volumeSlider->setValue(m_player->getVolume()); if (newState == QGst::StateNull) { onPositionChanged(); } }
//---------------------------------------- void ofNode::orbitRad(float longitude, float latitude, float radius, const glm::vec3& centerPoint) { glm::quat q = glm::angleAxis(longitude, glm::vec3(0, 1, 0)) * glm::angleAxis(latitude, glm::vec3(1, 0, 0)); glm::vec4 p { 0.f, 0.f, 1.f, 0.f }; // p is a direction, not a position, so .w == 0 p = q * p; // rotate p on unit sphere based on quaternion p = p * radius; // scale p by radius from its position on unit sphere setGlobalPosition(centerPoint + p); setOrientation(q); onOrientationChanged(); onPositionChanged(); }
void MediaApp::onStateChanged() { QGst::State newState = m_player->state(); m_playButton->setEnabled(newState != QGst::StatePlaying); m_pauseButton->setEnabled(newState == QGst::StatePlaying); m_stopButton->setEnabled(newState != QGst::StateNull); m_positionSlider->setEnabled(newState != QGst::StateNull); m_volumeSlider->setEnabled(newState != QGst::StateNull); m_volumeLabel->setEnabled(newState != QGst::StateNull); m_volumeSlider->setValue(m_player->volume()); //if we are in Null state, call onPositionChanged() to restore //the position of the slider and the text on the label if (newState == QGst::StateNull) { onPositionChanged(); } }
void ViewComponent::onAddedToMapEntity(MapEntity* entity) { Base::onAddedToMapEntity(entity); auto mapNode = entity->getMap()->getMapView()->getMainNode(); for (auto& part : parts) { mapNode->addChild(part.viewPart->getNode()); part.viewPart->onAddedToMapEntity(entity); } auto positionComponent = entity->getComponent<PositionComponent>(); positionComponent->getPositionChangedSignal().Connect(this, &ViewComponent::onPositionChanged); onPositionChanged(positionComponent); alreadyAdded = true; }
//---------------------------------------- void ofNode::setTransformMatrix(const ofMatrix4x4 &m44) { localTransformMatrix = m44; ofVec3f position; ofQuaternion orientation; ofVec3f scale; ofQuaternion so; localTransformMatrix.decompose(position, orientation, scale, so); this->position = position; this->orientation = orientation; this->scale = scale; updateAxis(); onPositionChanged(); onOrientationChanged(); onScaleChanged(); }
//---------------------------------------- void ofNode::setTransformMatrix(const glm::mat4 &m44) { localTransformMatrix = m44; glm::vec3 scale; glm::quat orientation; glm::vec3 translation; glm::vec3 skew; glm::vec4 perspective; glm::decompose(m44, scale, orientation, translation, skew, perspective); this->position = translation; this->scale = scale; this->orientation = orientation; updateAxis(); onPositionChanged(); onOrientationChanged(); onScaleChanged(); }
void ViewComponent::addPart(ViewPart* part, bool takeOwnership) { ViewPartData partData; partData.viewPart = part; partData.owned = takeOwnership; parts.push_back(partData); if (alreadyAdded) { auto mapNode = entity->getMap()->getMapView()->getMainNode(); mapNode->addChild(part->getNode()); part->onAddedToMapEntity(entity); auto positionComponent = entity->getComponent<PositionComponent>(); onPositionChanged(positionComponent); } }
LineEdit::LineEdit(Widget *parent, float width, std::function<void(std::string)> callback): Widget(parent), m_inputison(false), m_drawcursor(false), m_maxchar(0), m_positioncursor(0), m_width(width), m_func(callback) { m_text.setFont(ResourceManager::getInstance().getFont(ResourceSection::Base, Resource::STANDARD_FONT)); m_text.setCharacterSize(LINEEDIT_FONT_SIZE); m_text.setColor(sf::Color::White); setSize(m_width, LINEEDIT_HEIGHT); m_cursor.setSize(sf::Vector2f(2, LINEEDIT_HEIGHT)); m_cursor.setFillColor(sf::Color::White); onPositionChanged(); updateCursor(); }
void HTML5FullScreenVideoHandler::enterFullScreen(QMediaPlayer *player) { if (!player) return; m_videoWidget = new HTML5VideoWidget(); if (!m_videoWidget) return; m_videoWidget->setDuration(player->duration() / 1000); CAknAppUi* appUi = dynamic_cast<CAknAppUi*>(CEikonEnv::Static()->AppUi()); if (appUi) { m_savedOrientation = appUi->Orientation(); appUi->SetOrientationL(CAknAppUi::EAppUiOrientationLandscape); } m_mediaPlayer = player; connect(m_mediaPlayer, SIGNAL(positionChanged(qint64)), m_videoWidget, SLOT(onPositionChanged(qint64))); connect(m_mediaPlayer, SIGNAL(durationChanged(qint64)), m_videoWidget, SLOT(setDuration(qint64))); connect(m_mediaPlayer, SIGNAL(stateChanged(QMediaPlayer::State)), this, SLOT(onPlayerStateChanged(QMediaPlayer::State))); connect(m_mediaPlayer, SIGNAL(error(QMediaPlayer::Error)), this, SLOT(onPlayerError(QMediaPlayer::Error))); connect(m_mediaPlayer, SIGNAL(mediaStatusChanged(QMediaPlayer::MediaStatus)), this, SLOT(onMediaStatusChanged(QMediaPlayer::MediaStatus))); connect(m_videoWidget, SIGNAL(positionChangedByUser(qint64)), m_mediaPlayer, SLOT(setPosition(qint64))); connect(m_videoWidget, SIGNAL(closeClicked()), this, SIGNAL(fullScreenClosed())); connect(m_videoWidget, SIGNAL(muted(bool)), m_mediaPlayer, SLOT(setMuted(bool))); connect(m_videoWidget, SIGNAL(volumeChanged(int)), m_mediaPlayer, SLOT(setVolume(int))); connect(m_videoWidget, SIGNAL(pauseClicked()), m_mediaPlayer, SLOT(pause())); connect(m_videoWidget, SIGNAL(playClicked()), m_mediaPlayer, SLOT(play())); m_mediaPlayer->setVideoOutput(m_videoWidget); m_videoWidget->setVolume(m_mediaPlayer->volume()); m_videoWidget->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored); m_videoWidget->showFullScreen(); m_fullScreen = true; // Handle current Media Status and Media Player error. onMediaStatusChanged(m_mediaPlayer->mediaStatus()); onPlayerError(m_mediaPlayer->error()); }
void MusicWidget::initPlayer() { m_player = new QMediaPlayer(this); connect(m_player, SIGNAL(mediaStatusChanged(QMediaPlayer::MediaStatus)) ,this, SLOT(onMediaStatusChanged(QMediaPlayer::MediaStatus))); connect(m_player, SIGNAL(stateChanged(QMediaPlayer::State)), this, SLOT(onStateChanged(QMediaPlayer::State))); connect(m_player, SIGNAL(seekableChanged(bool)), this, SLOT(onSeekableChanged(bool))); connect(m_player, SIGNAL(error(QMediaPlayer::Error)), this, SLOT(onError(QMediaPlayer::Error))); connect(m_player, SIGNAL(durationChanged(qint64)), this, SLOT(onDurationChanged(qint64))); connect(m_player, SIGNAL(positionChanged(qint64)), this, SLOT(onPositionChanged(qint64))); m_playlist = new QMediaPlaylist(this); connect(m_playlist, SIGNAL(currentIndexChanged(int)), this, SLOT(onCurrentMediaIndexChanged(int))); m_player->setPlaylist(m_playlist); }
//---------------------------------------- void ofLight::setup() { if(data->glIndex==-1){ bool bLightFound = false; // search for the first free block for(size_t i=0; i<ofLightsData().size(); i++) { if(ofLightsData()[i].expired()) { data->glIndex = i; data->isEnabled = true; ofLightsData()[i] = data; bLightFound = true; break; } } if(!bLightFound && ofIsGLProgrammableRenderer()){ ofLightsData().push_back(data); data->glIndex = ofLightsData().size() - 1; data->isEnabled = true; bLightFound = true; } if( bLightFound ){ // run this the first time, since it was not found before // onPositionChanged(); setAmbientColor( getAmbientColor() ); setDiffuseColor( getDiffuseColor() ); setSpecularColor( getSpecularColor() ); setAttenuation( getAttenuationConstant(), getAttenuationLinear(), getAttenuationQuadratic() ); if(getIsSpotlight()) { setSpotlightCutOff(getSpotlightCutOff()); setSpotConcentration(getSpotConcentration()); } if(getIsSpotlight() || getIsDirectional()) { onOrientationChanged(); } }else{ ofLogError("ofLight") << "setup(): couldn't get active GL light, maximum number of "<< ofLightsData().size() << " reached"; } } }