/*!
	\brief 
*/
bool QPanel::shallShow() const
{
	return m_shownOnce ? isHidden() : m_defaultVisibility;
}
Beispiel #2
0
void UIProgressDialog::timerEvent(QTimerEvent* /* pEvent */)
{
    /* We should hide progress-dialog
     * if it was already finalized but not yet closed.
     * This could happens in case of some other
     * modal dialog prevents our event-loop from
     * being exit overlapping 'this'. */
    if (m_fEnded && !isHidden() && windowManager().isWindowOnTheTopOfTheModalWindowStack(this))
    {
        hide();
        return;
    }
    else if (m_fEnded)
        return;

    if (!m_fEnded && (!m_progress.isOk() || m_progress.GetCompleted()))
    {
        /* Is this progress-dialog a top-level modal-dialog now? */
        if (windowManager().isWindowOnTheTopOfTheModalWindowStack(this))
        {
            /* Progress finished: */
            if (m_progress.isOk())
            {
                m_pProgressBar->setValue(100);
                done(Accepted);
            }
            /* Progress is not valid: */
            else
                done(Rejected);

            /* Request to exit loop: */
            m_fEnded = true;
            return;
        }
        /* Else we should wait until all the subsequent
         * top-level modal-dialog(s) will be dismissed: */
        return;
    }

    if (!m_progress.GetCanceled())
    {
        /* Update the progress dialog: */
        /* First ETA */
        long newTime = m_progress.GetTimeRemaining();
        long seconds;
        long minutes;
        long hours;
        long days;

        seconds  = newTime < 0 ? 0 : newTime;
        minutes  = seconds / 60;
        seconds -= minutes * 60;
        hours    = minutes / 60;
        minutes -= hours   * 60;
        days     = hours   / 24;
        hours   -= days    * 24;

        QString strDays = VBoxGlobal::daysToString(days);
        QString strHours = VBoxGlobal::hoursToString(hours);
        QString strMinutes = VBoxGlobal::minutesToString(minutes);
        QString strSeconds = VBoxGlobal::secondsToString(seconds);

        QString strTwoComp = tr("%1, %2 remaining", "You may wish to translate this more like \"Time remaining: %1, %2\"");
        QString strOneComp = tr("%1 remaining", "You may wish to translate this more like \"Time remaining: %1\"");

        if      (days > 1 && hours > 0)
            m_pEtaLbl->setText(strTwoComp.arg(strDays).arg(strHours));
        else if (days > 1)
            m_pEtaLbl->setText(strOneComp.arg(strDays));
        else if (days > 0 && hours > 0)
            m_pEtaLbl->setText(strTwoComp.arg(strDays).arg(strHours));
        else if (days > 0 && minutes > 5)
            m_pEtaLbl->setText(strTwoComp.arg(strDays).arg(strMinutes));
        else if (days > 0)
            m_pEtaLbl->setText(strOneComp.arg(strDays));
        else if (hours > 2)
            m_pEtaLbl->setText(strOneComp.arg(strHours));
        else if (hours > 0 && minutes > 0)
            m_pEtaLbl->setText(strTwoComp.arg(strHours).arg(strMinutes));
        else if (hours > 0)
            m_pEtaLbl->setText(strOneComp.arg(strHours));
        else if (minutes > 2)
            m_pEtaLbl->setText(strOneComp.arg(strMinutes));
        else if (minutes > 0 && seconds > 5)
            m_pEtaLbl->setText(strTwoComp.arg(strMinutes).arg(strSeconds));
        else if (minutes > 0)
            m_pEtaLbl->setText(strOneComp.arg(strMinutes));
        else if (seconds > 5)
            m_pEtaLbl->setText(strOneComp.arg(strSeconds));
        else if (seconds > 0)
            m_pEtaLbl->setText(tr("A few seconds remaining"));
        else
            m_pEtaLbl->clear();

        /* Then operation text if changed: */
        ulong newOp = m_progress.GetOperation() + 1;
        if (newOp != m_iCurrentOperation)
        {
            m_iCurrentOperation = newOp;
            m_pDescriptionLbl->setText(QString(m_spcszOpDescTpl)
                                       .arg(m_progress.GetOperationDescription())
                                       .arg(m_iCurrentOperation).arg(m_cOperations));
        }
        m_pProgressBar->setValue(m_progress.GetPercent());

        /* Then cancel button: */
        m_fCancelEnabled = m_progress.GetCancelable();
        m_pCancelBtn->setEnabled(m_fCancelEnabled);
    }
    else
        m_pEtaLbl->setText(m_strCancel);
}
 /**
  * Determine if the presenter is hidden.
  * @param peaksWS to use to find the right presenter.
  * @return True if hidden.
  */
 bool CompositePeaksPresenter::getIsHidden(boost::shared_ptr<const Mantid::API::IPeaksWorkspace> peaksWS) const
 {
   auto iterator = getPresenterIteratorFromWorkspace(peaksWS);
   auto subjectPresenter = *iterator;
   return subjectPresenter->isHidden();
 }
Beispiel #4
0
void lmcTransferWindow::receiveMessage(MessageType type, QString* lpszUserId, XmlMessage* pMessage) {
    Q_UNUSED(type);
    Q_UNUSED(lpszUserId);
	
	int fileMode = Helper::indexOf(FileModeNames, FM_Max, pMessage->data(XN_MODE));
	int fileOp = Helper::indexOf(FileOpNames, FO_Max, pMessage->data(XN_FILEOP));
	QString id = pMessage->data(XN_FILEID);

	FileView* view = NULL;
    FileView::TransferMode transferMode = fileMode == FM_Send ? FileView::TM_Send : FileView::TM_Receive;
    int itemIndex = -1;
	QString trayMsg;

    switch(fileOp) {
    case FO_Decline:
        //	receiver has declined
        view = ui.lvTransferList->item(id, FileView::TM_Send);
        if(!view)
            return;
        itemIndex = ui.lvTransferList->itemIndex(id, FileView::TM_Send);
        view->state = FileView::TS_Decline;
        break;
    case FO_Cancel:
        view = ui.lvTransferList->item(id, transferMode);
        if(!view)
            return;
        itemIndex = ui.lvTransferList->itemIndex(id, transferMode);
        view->state = FileView::TS_Cancel;
        break;
    case FO_Progress:
        view = ui.lvTransferList->item(id, transferMode);
        if(!view)
            return;
        itemIndex = ui.lvTransferList->itemIndex(id, transferMode);
        updateProgress(view, pMessage->data(XN_FILESIZE).toLongLong());
        break;
    case FO_Error:
        view = ui.lvTransferList->item(id, transferMode);
        if(!view)
            return;
        itemIndex = ui.lvTransferList->itemIndex(id, transferMode);
        view->state = FileView::TS_Abort;
        break;
    case FO_Abort:
        view = ui.lvTransferList->item(id, transferMode);
        if(!view)
            return;
        itemIndex = ui.lvTransferList->itemIndex(id, transferMode);
        view->state = FileView::TS_Abort;
        break;
    case FO_Complete:
        if(fileMode == FM_Send) {
            view = ui.lvTransferList->item(id, FileView::TM_Send);
            if(!view)
                return;
            itemIndex = ui.lvTransferList->itemIndex(id, FileView::TM_Send);
            view->state = FileView::TS_Complete;
            if(isHidden() || !isActiveWindow()) {
                trayMsg = tr("'%1' has been sent to %2.");
                emit showTrayMessage(TM_Transfer, trayMsg.arg(view->fileName, view->userName),
                    tr("File Transfer Completed"), TMI_Info);
                pSoundPlayer->play(SE_FileDone);
            }
        } else {
            view = ui.lvTransferList->item(id, FileView::TM_Receive);
            if(!view)
                return;
            itemIndex = ui.lvTransferList->itemIndex(id, FileView::TM_Receive);
            view->filePath = QDir::fromNativeSeparators(pMessage->data(XN_FILEPATH));
            view->icon = getIcon(view->filePath);
            pactShowFolder->setEnabled(QFile::exists(view->filePath));
            view->state = FileView::TS_Complete;
            if(isHidden() || !isActiveWindow()) {
                trayMsg = tr("'%1' has been received from %2.");
                emit showTrayMessage(TM_Transfer, trayMsg.arg(view->fileName, view->userName),
                    tr("File Transfer Completed"), TMI_Info);
                pSoundPlayer->play(SE_FileDone);
            }
        }
        break;
    }

	ui.lvTransferList->itemChanged(itemIndex);

	FileView* current = ui.lvTransferList->currentItem();
	setButtonState(current->state);
}
Beispiel #5
0
void PlayerWidget::stopPressed() {
	if (!_song || isHidden()) return;

	audioPlayer()->stop(OverviewFiles);
}
Beispiel #6
0
void Trap::disarm() {
  //Abort if trap is hidden
  if(isHidden()) {
    eng.log->addMsg(msgDisarmNoTrap);
    Renderer::drawMapAndInterface();
    return;
  }

  //Spider webs are automatically destroyed if wielding machete
  bool isAutoSucceed = false;
  if(getTrapType() == trap_spiderWeb) {
    Item* item = eng.player->getInv().getItemInSlot(SlotId::wielded);
    if(item != NULL) {
      isAutoSucceed = item->getData().id == ItemId::machete;
    }
  }

  const bool IS_OCCULTIST   = PlayerBon::getBg() == Bg::occultist;

  if(isMagical() && IS_OCCULTIST == false) {
    eng.log->addMsg("I do not know how to dispel magic traps.");
    return;
  }

  vector<PropId> props;
  eng.player->getPropHandler().getAllActivePropIds(props);

  const bool IS_BLESSED =
    find(props.begin(), props.end(), propBlessed) != props.end();
  const bool IS_CURSED =
    find(props.begin(), props.end(), propCursed)  != props.end();

  int       disarmNumerator     = 5;
  const int DISARM_DENOMINATOR  = 10;

  if(IS_BLESSED)  disarmNumerator += 3;
  if(IS_CURSED)   disarmNumerator -= 3;

  constrInRange(1, disarmNumerator, DISARM_DENOMINATOR - 1);

  const bool IS_DISARMED =
    Rnd::fraction(disarmNumerator, DISARM_DENOMINATOR) || isAutoSucceed;
  if(IS_DISARMED) {
    eng.log->addMsg(specificTrap_->getDisarmMsg());
  } else {
    eng.log->addMsg(specificTrap_->getDisarmFailMsg());

    Renderer::drawMapAndInterface();
    const int TRIGGER_ONE_IN_N = IS_BLESSED ? 9 : IS_CURSED ? 2 : 4;
    if(Rnd::oneIn(TRIGGER_ONE_IN_N)) {
      if(getTrapType() == trap_spiderWeb) {
        eng.player->pos = pos_;
      }
      triggerTrap(*eng.player);
    }
  }
  eng.gameTime->actorDidAct();

  if(IS_DISARMED) {
    eng.featureFactory->spawnFeatureAt(feature_stoneFloor, pos_);
  }
}
Beispiel #7
0
void SearchBar::toggleShown()
{
    isHidden() ? show() : hide();
}
Beispiel #8
0
void PasscodeBox::onSave(bool force) {
	if (_setRequest) return;

	QString old = _oldPasscode.text(), pwd = _newPasscode.text(), conf = _reenterPasscode.text();
	bool has = _cloudPwd ? (!_curSalt.isEmpty()) : cHasPasscode();
	if (!_cloudPwd && (_turningOff || has)) {
		if (!passcodeCanTry()) {
			_oldError = lang(lng_flood_error);
			_oldPasscode.setFocus();
			_oldPasscode.showError();
			update();
			return;
		}

		if (Local::checkPasscode(old.toUtf8())) {
			cSetPasscodeBadTries(0);
			if (_turningOff) pwd = conf = QString();
		} else {
			cSetPasscodeBadTries(cPasscodeBadTries() + 1);
			cSetPasscodeLastTry(getms(true));
			onBadOldPasscode();
			return;
		}
	}
	if (!_turningOff && pwd.isEmpty()) {
		_newPasscode.setFocus();
		_newPasscode.showError();
		if (isHidden() && _replacedBy && !_replacedBy->isHidden()) _replacedBy->onClose();
		return;
	}
	if (pwd != conf) {
		_reenterPasscode.selectAll();
		_reenterPasscode.setFocus();
		_reenterPasscode.showError();
		if (!conf.isEmpty()) {
			_newError = lang(_cloudPwd ? lng_cloud_password_differ : lng_passcode_differ);
			update();
		}
		if (isHidden() && _replacedBy && !_replacedBy->isHidden()) _replacedBy->onClose();
	} else if (!_turningOff && has && old == pwd) {
		_newPasscode.setFocus();
		_newPasscode.showError();
		_newError = lang(_cloudPwd ? lng_cloud_password_is_same : lng_passcode_is_same);
		update();
		if (isHidden() && _replacedBy && !_replacedBy->isHidden()) _replacedBy->onClose();
	} else if (_cloudPwd) {
		QString hint = _passwordHint.getLastText(), email = _recoverEmail.getLastText().trimmed();
		if (_cloudPwd && pwd == hint && !_passwordHint.isHidden() && !_newPasscode.isHidden()) {
			_newPasscode.setFocus();
			_newPasscode.showError();
			_newError = lang(lng_cloud_password_bad);
			update();
			if (isHidden() && _replacedBy && !_replacedBy->isHidden()) _replacedBy->onClose();
			return;
		}
		if (!_recoverEmail.isHidden() && email.isEmpty() && !force) {
			_skipEmailWarning = true;
			_replacedBy = new ConfirmBox(lang(lng_cloud_password_about_recover), lang(lng_cloud_password_skip_email), st::attentionBoxButton);
			connect(_replacedBy, SIGNAL(confirmed()), this, SLOT(onForceNoMail()));
			connect(_replacedBy, SIGNAL(destroyed(QObject*)), this, SLOT(onBoxDestroyed(QObject*)));
			Ui::showLayer(_replacedBy, KeepOtherLayers);
		} else {
Beispiel #9
0
/*! \reimp */
bool QToolBar::event(QEvent *event)
{
    Q_D(QToolBar);

    switch (event->type()) {
    case QEvent::Timer:
        if (d->waitForPopupTimer.timerId() == static_cast<QTimerEvent*>(event)->timerId()) {
            QWidget *w = QApplication::activePopupWidget();
            if (!waitForPopup(this, w)) {
                d->waitForPopupTimer.stop();
                if (!this->underMouse())
                    d->layout->setExpanded(false);
            }
        }
        break;
    case QEvent::Hide:
        if (!isHidden())
            break;
        Q_FALLTHROUGH();
    case QEvent::Show:
        d->toggleViewAction->setChecked(event->type() == QEvent::Show);
#ifdef Q_OS_OSX
        enableMacToolBar(this, event->type() == QEvent::Show);
#endif
        emit visibilityChanged(event->type() == QEvent::Show);
        break;
    case QEvent::ParentChange:
        d->layout->checkUsePopupMenu();
        break;

    case QEvent::MouseButtonPress: {
        if (d->mousePressEvent(static_cast<QMouseEvent*>(event)))
            return true;
        break;
    }
    case QEvent::MouseButtonRelease:
        if (d->mouseReleaseEvent(static_cast<QMouseEvent*>(event)))
            return true;
        break;
    case QEvent::HoverEnter:
    case QEvent::HoverLeave:
        // there's nothing special to do here and we don't want to update the whole widget
        return true;
    case QEvent::HoverMove: {
#ifndef QT_NO_CURSOR
        QHoverEvent *e = static_cast<QHoverEvent*>(event);
        QStyleOptionToolBar opt;
        initStyleOption(&opt);
        if (style()->subElementRect(QStyle::SE_ToolBarHandle, &opt, this).contains(e->pos()))
            setCursor(Qt::SizeAllCursor);
        else
            unsetCursor();
#endif
        break;
    }
    case QEvent::MouseMove:
        if (d->mouseMoveEvent(static_cast<QMouseEvent*>(event)))
            return true;
        break;
    case QEvent::Leave:
        if (d->state != 0 && d->state->dragging) {
#ifdef Q_OS_WIN
            // This is a workaround for loosing the mouse on Vista.
            QPoint pos = QCursor::pos();
            QMouseEvent fake(QEvent::MouseMove, mapFromGlobal(pos), pos, Qt::NoButton,
                             QApplication::mouseButtons(), QApplication::keyboardModifiers());
            d->mouseMoveEvent(&fake);
#endif
        } else {
            if (!d->layout->expanded)
                break;

            QWidget *w = QApplication::activePopupWidget();
            if (waitForPopup(this, w)) {
                d->waitForPopupTimer.start(POPUP_TIMER_INTERVAL, this);
                break;
            }

            d->waitForPopupTimer.stop();
            d->layout->setExpanded(false);
            break;
        }
    default:
        break;
    }
    return QWidget::event(event);
}
Beispiel #10
0
void RenderObject::onUpdate(float dt)
{
	if (isDead()) return;
	//collisionShape.updatePosition(position);
	updateLife(dt);

	// FIXME: We might not need to do lifetime checks either; I just
	// left that above for safety since I'm not certain.  --achurch
	if (isHidden()) return;

	position += velocity * dt;
	velocity += gravity * dt;
	position.update(dt);
	velocity.update(dt);
	scale.update(dt);
	rotation.update(dt);
	color.update(dt);
	alpha.update(dt);
	offset.update(dt);
	internalOffset.update(dt);
	beforeScaleOffset.update(dt);
	rotationOffset.update(dt);

	for (Children::iterator i = children.begin(); i != children.end(); i++)
	{
		if (shareAlphaWithChildren)
			(*i)->alpha.x = this->alpha.x;
		if (shareColorWithChildren)
			(*i)->color = this->color;

		if (!(*i)->updateAfterParent && (((*i)->pm == PM_POINTER) || ((*i)->pm == PM_STATIC)))
		{
			(*i)->update(dt);
		}
	}
	
	if (!childGarbage.empty())
	{
		for (Children::iterator i = childGarbage.begin(); i != childGarbage.end(); i++)
		{
			removeChild(*i);
			(*i)->destroy();
			delete (*i);
		}
		childGarbage.clear();
	}

	if (motionBlur)
	{
		if (motionBlurFrameOffsetCounter >= motionBlurFrameOffset)
		{
			motionBlurFrameOffsetCounter = 0;
			motionBlurPositions[0].position = position;
			motionBlurPositions[0].rotz = rotation.z;
			for (int i = motionBlurPositions.size()-1; i > 0; i--)
			{
				motionBlurPositions[i] = motionBlurPositions[i-1];
			}
		}
		else
			motionBlurFrameOffsetCounter ++;
	}
	if (motionBlurTransition)
	{
		motionBlurTransitionTimer -= dt*2;
		if (motionBlurTransitionTimer <= 0)
		{
			motionBlur = motionBlurTransition = false;
			motionBlurTransitionTimer = 0;
		}
	}

//	updateCullVariables();
}
void cMobile::draw(int cellx, int celly, int leftClip, int topClip, int rightClip, int bottomClip) {
	// Save the original cellx, celly for the greyed out stuff
	int orgCellX = cellx;
	int orgCellY = celly;
	static int cellXOffset = 0;
	static int cellYOffset = 0;

	if (Config->gameHideMobiles()) {
		return;
	}

	// Test for smoother player movement
	if (this == Player) {
		cellx = WorldView->x() + WorldView->width() / 2;
		celly = WorldView->y() + WorldView->height() / 2;
	}

	cellx += cellXOffset;
	celly += cellYOffset;

	// See if the current action expired
	if (currentActionEnd_ != 0 && currentActionEnd_ < Utilities::getTicks()) {
		// Don't cancel the movement action while we're still moving -or- have movement requests left
		if (this != Player || ((!WorldView->isMoving() || WorldView->isMovementBlocked()) && (!UoSocket || UoSocket->sequenceQueueLength() == 0))) {
			freeSequence(); // Free current surface
			currentActionEnd_ = 0; // Reset end time
			currentAction_ = getIdleAction();
		}
	}

	// Refresh the sequence
	if (!sequence_) {
		refreshSequence();
	}

	float alpha = 1.0f;

	// Modify cellx/celly based on the smooth move settings
	// Smooth move handling.
	if (smoothMoveEnd != 0) {
		int moveProgress = smoothMoveTime - (smoothMoveEnd - Utilities::getTicks());
		if (moveProgress < 0 || moveProgress >= (int)smoothMoveTime) {
			smoothMoveEnd = 0;
			World->removeEntity(this);
			World->addEntity(this);
		} else if (this != Player) {
			if (moveProgress <= 0) {
				cellx += drawxoffset;
				celly += drawyoffset;
			} else {
				float factor = 1.0f - (float)moveProgress / (float)smoothMoveTime;
				cellx += (int)(factor * (float)drawxoffset);
				celly += (int)(factor * (float)drawyoffset);
			}
		}
	}

	static bool inGreyDraw = false;
	static bool inBlurDraw = false;

	if (isHidden()) {
		glPushAttrib(GL_ENABLE_BIT);

		glEnable(GL_ALPHA_TEST); // Make sure that transparent pixels wont touch our stencil buffer
		glAlphaFunc(GL_GREATER, 0.0f);

		glEnable(GL_STENCIL_TEST); // Enable per-pixel stencil testing
		glStencilFunc(GL_EQUAL, 1, 1); // Draw if stencil buffer is not zero
		glStencilOp(GL_KEEP, GL_KEEP, GL_ZERO);

		if (!inGreyDraw) {
			glClearStencil(1);
			glClear(GL_STENCIL_BUFFER_BIT);
		}

		static uint nextPeak = 0;
		static uint lastPeak = 0;
		static bool peakDirection = false;

		uint time = Utilities::getTicks();

		if (time >= nextPeak) {
			lastPeak = Utilities::getTicks();
			nextPeak = lastPeak + 1500 + Random->randInt(1000);				
			peakDirection = !peakDirection;
		}

		alpha = (nextPeak - Utilities::getTicks()) / (float)(nextPeak - lastPeak);
		if (peakDirection) {
			alpha = 1.0f - alpha;
		}

		if (inGreyDraw) {			
			if (inBlurDraw) {
				alpha *= 0.5f;
			} else {
				alpha *= 0.8f;
			}
		} else {
			GLWidget->enableGrayShader();
			alpha = 0.8 * (1.0f - alpha); // Invert alpha value
		}
	}

	// Draw
	if (sequence_) {
		// Only advance to the next frame if we're not beyond the end of this action
		if (currentActionEnd_ != 0 && currentActionEnd_ >= Utilities::getTicks()) {
			// Skip to next frame
			if (nextFrame < Utilities::getTicks()) {
				if (++frame >= sequence_->frameCount()) {
					frame = 0;
				}
				nextFrame = Utilities::getTicks() + getFrameDelay();
			}
		}

		// The anims facing right are generated by flipping the ones facing left
		bool flip = (direction_ >= 0 && direction_ < 4);

		// Mounts come always first
		if (!isHidden()) {
			if ((bodyType() == HUMAN || bodyType() == EQUIPMENT) && equipment[LAYER_MOUNT] && equipmentSequences[LAYER_MOUNT]) {
				// Only advance to the next frame if we're not beyond the end of this action
				if (currentActionEnd_ != 0 && currentActionEnd_ >= Utilities::getTicks()) {
					// Skip to next frame
					if (nextMountFrame < Utilities::getTicks()) {
						if (++mountFrame >= equipmentSequences[LAYER_MOUNT]->frameCount()) {
							mountFrame = 0;
						}
						nextMountFrame = Utilities::getTicks() + getMountFrameDelay();
					}
				}
				
				mountFrame = frame; // Until something better is found
				equipmentSequences[LAYER_MOUNT]->draw(mountFrame, cellx, celly, flip, alpha);            
			}

			sequence_->draw(frame, cellx, celly, flip, alpha);
		}

		// Draw the equipment
		if (bodyType() == HUMAN || bodyType() == EQUIPMENT) {
			// Reverse the draw order if hidden
			if (isHidden()) {
				uint count = 0;
				const int *order = drawOrder[direction_ % 8];
				while (order[count] != -1) {
					count++;
				}

				for (int i = count - 1; i >= 0; --i) {
					enLayer layer = (enLayer)order[i];

					if (layer < LAYER_VISIBLECOUNT && equipmentSequences[layer]) {
						// Oh great OSI... Another exception from the rule *sigh*
						// Don't draw Hair if we're wearing a gm robe
						if (layer != LAYER_HAIR || !equipmentSequences[LAYER_OUTERTORSO] || equipmentSequences[LAYER_OUTERTORSO]->body() != 0x3db) {					
							equipmentSequences[layer]->draw(frame, cellx, celly, flip, alpha);
						}
					}
				}
			} else {
				const int *order = drawOrder[direction_ % 8];
				while (*order != -1) {
					enLayer layer = (enLayer)*order;
		
					if (layer < LAYER_VISIBLECOUNT && equipmentSequences[layer]) {
						// Oh great OSI... Another exception from the rule *sigh*
						// Don't draw Hair if we're wearing a gm robe
						if (layer != LAYER_HAIR || !equipmentSequences[LAYER_OUTERTORSO] || equipmentSequences[LAYER_OUTERTORSO]->body() != 0x3db) {					
							equipmentSequences[layer]->draw(frame, cellx, celly, flip, alpha);
						}				
					}
		
					++order; // Next layer
				}
			}
		}

		// If we're hidden, mount+body come last
		if (isHidden()) {
			sequence_->draw(frame, cellx, celly, flip, alpha);

			if ((bodyType() == HUMAN || bodyType() == EQUIPMENT) && equipment[LAYER_MOUNT] && equipmentSequences[LAYER_MOUNT]) {
				// Only advance to the next frame if we're not beyond the end of this action
				if (currentActionEnd_ != 0 && currentActionEnd_ >= Utilities::getTicks()) {
					// Skip to next frame
					if (nextMountFrame < Utilities::getTicks()) {
						if (++mountFrame >= equipmentSequences[LAYER_MOUNT]->frameCount()) {
							mountFrame = 0;
						}
						nextMountFrame = Utilities::getTicks() + getMountFrameDelay();
					}
				}
				
				mountFrame = frame; // Until something better is found
				equipmentSequences[LAYER_MOUNT]->draw(mountFrame, cellx, celly, flip, alpha);            
			}
		}
	}

	if (isHidden()) {
		glPopAttrib();
		if (!inGreyDraw) {
			GLWidget->disableGrayShader();
		}
	}

	drawx_ = cellx;
	drawy_ = celly;

	if (isHidden() && !inGreyDraw) {
		glClearStencil(1);
		glClear(GL_STENCIL_BUFFER_BIT);

		inGreyDraw = true;	
		inBlurDraw = true;
		cellXOffset = 1;
		draw(orgCellX, orgCellY, leftClip, topClip, rightClip, bottomClip);
		cellXOffset = -1;
		draw(orgCellX, orgCellY, leftClip, topClip, rightClip, bottomClip);
		cellXOffset = 0;
		cellYOffset = 1;
		draw(orgCellX, orgCellY, leftClip, topClip, rightClip, bottomClip);
		cellYOffset = -1;
		draw(orgCellX, orgCellY, leftClip, topClip, rightClip, bottomClip);
		cellYOffset = 0;
		inBlurDraw = false;
		draw(orgCellX, orgCellY, leftClip, topClip, rightClip, bottomClip);
		inGreyDraw = false;
	}
}
Beispiel #12
0
/**
 * Implementation of algorithm given on P65 of the Script
 * (With the discussed modifications)
 */
Color RayTracer::calculateColor(Ray& r, int recursions) {

    //FIXME Initialize with the background color
    Color c = Color(0.0, 0.0, 0.0);

    //Get the first intersection with any shape
    Shape* closestShape = _scene._shapes[0];
    double closestIP;
    bool hasIntersection = false;
    r[1].normalize();
    Ray r_moved = Ray(r.getPoint(1), r[1]);
    for (unsigned i = 0; i < _scene._shapes.size(); i++) {
        std::vector<double> intersections = _scene._shapes[i]->ensIntersect(r_moved);

        if (!hasIntersection && !intersections.empty()) {
            closestShape = _scene._shapes[i];
            closestIP = intersections[0];
            hasIntersection = true;
        } else if (hasIntersection && !intersections.empty()
                   && intersections[0] < closestIP) {
            closestShape = _scene._shapes[i];
            closestIP = intersections[0];
        }

    }

    //if there are any intersections
    if (hasIntersection) {
        //Get the Point of the first intersection
        Vector3 intersection = r_moved.getPoint(closestIP); //P := intersection

        //The normal at the point of intersection
        Vector3 n = closestShape->normal(intersection).normalize();

        //Make sure the normal points into the right direction
        //FIXME is this correct??
        Vector3 r_dir_op = -r[1];
        if (dot_product(r_dir_op, n) < 0) {
            //if (dot_product(V, n) < 0) {
            n = -n;
        }
        Ray normal = Ray(intersection, n);

        //The reflected ray at the point of intersection
        //FIXME Move to the shape class, as it is the same for all the shapes
        Ray reflected = Ray(intersection, (2 * n * (dot_product(n, r_dir_op)) - r_dir_op));

        /*
         * Calculate the light compartments using the lightmodel
         */

        //Ambient color
        //FIXME: Take L_a of scene instead of 1
        c = 1 * _lightModel.getAmbient(closestShape->_material)
                * closestShape->getColor(intersection);

        for (unsigned i = 0; i < _scene._lightSources.size(); i++) {
            LightSource* l = _scene._lightSources[i];
            if (!isHidden(l, intersection)) {

                double diffuse = _lightModel.getDiffuse(normal, l, closestShape->_material);
                double specular = _lightModel.getSpecular(reflected, l, closestShape->_material);
                c += diffuse * closestShape->getColor(intersection) * l->_intensity;
                c += specular * l->_color * l->_intensity;

            }
        }

        //Recursive call
        if (recursions > 0) {
            c += closestShape->_material.k_reflex * calculateColor(reflected, --recursions);
        }
    }
    return c;
}
Beispiel #13
0
void WPopupMenu::cancel()
{
  if (!isHidden())
    done(0);
}
Beispiel #14
0
bool Canvas2DLayerBridge::prepareMailbox(WebExternalTextureMailbox* outMailbox, WebExternalBitmap* bitmap)
{
    if (m_destructionInProgress) {
        // It can be hit in the following sequence.
        // 1. Canvas draws something.
        // 2. The compositor begins the frame.
        // 3. Javascript makes a context be lost.
        // 4. Here.
        return false;
    }
    if (bitmap) {
        // Using accelerated 2d canvas with software renderer, which
        // should only happen in tests that use fake graphics contexts
        // or in Android WebView in software mode. In this case, we do
        // not care about producing any results for this canvas.
        m_canvas->silentFlush();
        m_lastImageId = 0;
        return false;
    }
    if (!checkSurfaceValid())
        return false;

    WebGraphicsContext3D* webContext = context();

    // Release to skia textures that were previouosly released by the
    // compositor. We do this before acquiring the next snapshot in
    // order to cap maximum gpu memory consumption.
    flush();

    RefPtr<SkImage> image = adoptRef(m_canvas->newImageSnapshot());

    // Early exit if canvas was not drawn to since last prepareMailbox
    GLenum filter = m_filterLevel == SkPaint::kNone_FilterLevel ? GL_NEAREST : GL_LINEAR;
    if (image->uniqueID() == m_lastImageId && filter == m_lastFilter)
        return false;
    m_lastImageId = image->uniqueID();
    m_lastFilter = filter;

    {
        MailboxInfo tmp;
        tmp.m_image = image;
        tmp.m_parentLayerBridge = this;
        m_mailboxes.prepend(tmp);
    }
    MailboxInfo& mailboxInfo = m_mailboxes.first();

    mailboxInfo.m_mailbox.nearestNeighbor = filter == GL_NEAREST;

    GrContext* grContext = m_contextProvider->grContext();
    if (!grContext)
        return true; // for testing: skip gl stuff when using a mock graphics context.

    ASSERT(image->getTexture());

    // Because of texture sharing with the compositor, we must invalidate
    // the state cached in skia so that the deferred copy on write
    // in SkSurface_Gpu does not make any false assumptions.
    mailboxInfo.m_image->getTexture()->textureParamsModified();

    webContext->bindTexture(GL_TEXTURE_2D, mailboxInfo.m_image->getTexture()->getTextureHandle());
    webContext->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filter);
    webContext->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filter);
    webContext->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
    webContext->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);

    // Re-use the texture's existing mailbox, if there is one.
    if (image->getTexture()->getCustomData()) {
        ASSERT(image->getTexture()->getCustomData()->size() == sizeof(mailboxInfo.m_mailbox.name));
        memcpy(&mailboxInfo.m_mailbox.name[0], image->getTexture()->getCustomData()->data(), sizeof(mailboxInfo.m_mailbox.name));
    } else {
        context()->genMailboxCHROMIUM(mailboxInfo.m_mailbox.name);
        RefPtr<SkData> mialboxNameData = adoptRef(SkData::NewWithCopy(&mailboxInfo.m_mailbox.name[0], sizeof(mailboxInfo.m_mailbox.name)));
        image->getTexture()->setCustomData(mialboxNameData.get());
        webContext->produceTextureCHROMIUM(GL_TEXTURE_2D, mailboxInfo.m_mailbox.name);
    }

    if (isHidden()) {
        // With hidden canvases, we release the SkImage immediately because
        // there is no need for animations to be double buffered.
        mailboxInfo.m_image.clear();
    } else {
        webContext->flush();
        mailboxInfo.m_mailbox.syncPoint = webContext->insertSyncPoint();
    }
    webContext->bindTexture(GL_TEXTURE_2D, 0);
    // Because we are changing the texture binding without going through skia,
    // we must dirty the context.
    grContext->resetContext(kTextureBinding_GrGLBackendState);

    *outMailbox = mailboxInfo.m_mailbox;
    return true;
}
void Placement::updateBucketOpacities(SymbolBucket& bucket, std::set<uint32_t>& seenCrossTileIDs) {
    if (bucket.hasTextData()) bucket.text.opacityVertices.clear();
    if (bucket.hasIconData()) bucket.icon.opacityVertices.clear();
    if (bucket.hasCollisionBoxData()) bucket.collisionBox.dynamicVertices.clear();
    if (bucket.hasCollisionCircleData()) bucket.collisionCircle.dynamicVertices.clear();

    JointOpacityState duplicateOpacityState(false, false, true);

    const bool textAllowOverlap = bucket.layout.get<style::TextAllowOverlap>();
    const bool iconAllowOverlap = bucket.layout.get<style::IconAllowOverlap>();
    
    // If allow-overlap is true, we can show symbols before placement runs on them
    // But we have to wait for placement if we potentially depend on a paired icon/text
    // with allow-overlap: false.
    // See https://github.com/mapbox/mapbox-gl-native/issues/12483
    JointOpacityState defaultOpacityState(
            textAllowOverlap && (iconAllowOverlap || !bucket.hasIconData() || bucket.layout.get<style::IconOptional>()),
            iconAllowOverlap && (textAllowOverlap || !bucket.hasTextData() || bucket.layout.get<style::TextOptional>()),
            true);

    for (SymbolInstance& symbolInstance : bucket.symbolInstances) {
        bool isDuplicate = seenCrossTileIDs.count(symbolInstance.crossTileID) > 0;

        auto it = opacities.find(symbolInstance.crossTileID);
        auto opacityState = defaultOpacityState;
        if (isDuplicate) {
            opacityState = duplicateOpacityState;
        } else if (it != opacities.end()) {
            opacityState = it->second;
        }

        if (it == opacities.end()) {
            opacities.emplace(symbolInstance.crossTileID, defaultOpacityState);
        }

        seenCrossTileIDs.insert(symbolInstance.crossTileID);

        if (symbolInstance.hasText) {
            auto opacityVertex = SymbolOpacityAttributes::vertex(opacityState.text.placed, opacityState.text.opacity);
            for (size_t i = 0; i < symbolInstance.horizontalGlyphQuads.size() * 4; i++) {
                bucket.text.opacityVertices.emplace_back(opacityVertex);
            }
            for (size_t i = 0; i < symbolInstance.verticalGlyphQuads.size() * 4; i++) {
                bucket.text.opacityVertices.emplace_back(opacityVertex);
            }
            if (symbolInstance.placedTextIndex) {
                bucket.text.placedSymbols[*symbolInstance.placedTextIndex].hidden = opacityState.isHidden();
            }
            if (symbolInstance.placedVerticalTextIndex) {
                bucket.text.placedSymbols[*symbolInstance.placedVerticalTextIndex].hidden = opacityState.isHidden();
            }
        }
        if (symbolInstance.hasIcon) {
            auto opacityVertex = SymbolOpacityAttributes::vertex(opacityState.icon.placed, opacityState.icon.opacity);
            if (symbolInstance.iconQuad) {
                bucket.icon.opacityVertices.emplace_back(opacityVertex);
                bucket.icon.opacityVertices.emplace_back(opacityVertex);
                bucket.icon.opacityVertices.emplace_back(opacityVertex);
                bucket.icon.opacityVertices.emplace_back(opacityVertex);
            }
            if (symbolInstance.placedIconIndex) {
                bucket.icon.placedSymbols[*symbolInstance.placedIconIndex].hidden = opacityState.isHidden();
            }
        }
        
        auto updateCollisionBox = [&](const auto& feature, const bool placed) {
            if (feature.alongLine) {
                return;
            }
            auto dynamicVertex = CollisionBoxDynamicAttributes::vertex(placed, false);
            for (size_t i = 0; i < feature.boxes.size() * 4; i++) {
                bucket.collisionBox.dynamicVertices.emplace_back(dynamicVertex);
            }
        };
        
        auto updateCollisionCircles = [&](const auto& feature, const bool placed) {
            if (!feature.alongLine) {
                return;
            }
            for (const CollisionBox& box : feature.boxes) {
                auto dynamicVertex = CollisionBoxDynamicAttributes::vertex(placed, !box.used);
                bucket.collisionCircle.dynamicVertices.emplace_back(dynamicVertex);
                bucket.collisionCircle.dynamicVertices.emplace_back(dynamicVertex);
                bucket.collisionCircle.dynamicVertices.emplace_back(dynamicVertex);
                bucket.collisionCircle.dynamicVertices.emplace_back(dynamicVertex);
            }
        };
        
        if (bucket.hasCollisionBoxData()) {
            updateCollisionBox(symbolInstance.textCollisionFeature, opacityState.text.placed);
            updateCollisionBox(symbolInstance.iconCollisionFeature, opacityState.icon.placed);
        }
        if (bucket.hasCollisionCircleData()) {
            updateCollisionCircles(symbolInstance.textCollisionFeature, opacityState.text.placed);
            updateCollisionCircles(symbolInstance.iconCollisionFeature, opacityState.icon.placed);
        }
    }

    bucket.updateOpacity();
    bucket.sortFeatures(state.getAngle());
    auto retainedData = retainedQueryData.find(bucket.bucketInstanceId);
    if (retainedData != retainedQueryData.end()) {
        retainedData->second.featureSortOrder = bucket.featureSortOrder;
    }
}
Beispiel #16
0
bool BackgroundWidget::contentOverlapped(const QRect &globalRect) {
	if (isHidden()) return false;
	return w && w->overlaps(globalRect);
}
Beispiel #17
0
bool Sidebar::isSidebarVisible() const
{
    return !isHidden();
}
Beispiel #18
0
/*! \reimp */
bool QToolBar::event(QEvent *event)
{
    Q_D(QToolBar);

    switch (event->type()) {
    case QEvent::Timer:
        if (d->waitForPopupTimer.timerId() == static_cast<QTimerEvent*>(event)->timerId()) {
            QWidget *w = QApplication::activePopupWidget();
            if (!waitForPopup(this, w)) {
                d->waitForPopupTimer.stop();
                if (!this->underMouse())
                    d->layout->setExpanded(false);
            }
        }
        break;
    case QEvent::Hide:
        if (!isHidden())
            break;
        // fallthrough intended
    case QEvent::Show:
        d->toggleViewAction->setChecked(event->type() == QEvent::Show);
        emit visibilityChanged(event->type() == QEvent::Show);
#if defined(Q_WS_MAC)
        if (toolbarInUnifiedToolBar(this)) {
             // I can static_cast because I did the qobject_cast in the if above, therefore
            // we must have a QMainWindowLayout here.
            QMainWindowLayout *mwLayout = qt_mainwindow_layout(qobject_cast<QMainWindow *>(parentWidget()));
            mwLayout->fixSizeInUnifiedToolbar(this);
            mwLayout->syncUnifiedToolbarVisibility();
        }
#endif // Q_WS_MAC
        break;
    case QEvent::ParentChange:
        d->layout->checkUsePopupMenu();
#if defined(Q_WS_MAC)
        if (parentWidget() && parentWidget()->isWindow())
            qt_mac_updateToolBarButtonHint(parentWidget());
#endif
        break;

    case QEvent::MouseButtonPress: {
        if (d->mousePressEvent(static_cast<QMouseEvent*>(event)))
            return true;
        break;
    }
    case QEvent::MouseButtonRelease:
        if (d->mouseReleaseEvent(static_cast<QMouseEvent*>(event)))
            return true;
        break;
    case QEvent::HoverEnter:
    case QEvent::HoverLeave:
        // there's nothing special to do here and we don't want to update the whole widget
        return true;
    case QEvent::HoverMove: {
#ifndef QT_NO_CURSOR
        QHoverEvent *e = static_cast<QHoverEvent*>(event);
        QStyleOptionToolBar opt;
        initStyleOption(&opt);
        if (style()->subElementRect(QStyle::SE_ToolBarHandle, &opt, this).contains(e->pos()))
            setCursor(Qt::SizeAllCursor);
        else
            unsetCursor();
#endif
        break;
    }
    case QEvent::MouseMove:
        if (d->mouseMoveEvent(static_cast<QMouseEvent*>(event)))
            return true;
        break;
#ifdef Q_WS_WINCE
    case QEvent::ContextMenu:
        {
            QContextMenuEvent* contextMenuEvent = static_cast<QContextMenuEvent*>(event);
            QWidget* child = childAt(contextMenuEvent->pos());
            QAbstractButton* button = qobject_cast<QAbstractButton*>(child);
            if (button)
                button->setDown(false);
        }
        break;
#endif
    case QEvent::Leave:
        if (d->state != 0 && d->state->dragging) {
#ifdef Q_OS_WIN
            // This is a workaround for loosing the mouse on Vista.
            QPoint pos = QCursor::pos();
            QMouseEvent fake(QEvent::MouseMove, mapFromGlobal(pos), pos, Qt::NoButton,
                             QApplication::mouseButtons(), QApplication::keyboardModifiers());
            d->mouseMoveEvent(&fake);
#endif
        } else {
            if (!d->layout->expanded)
                break;

            QWidget *w = QApplication::activePopupWidget();
            if (waitForPopup(this, w)) {
                d->waitForPopupTimer.start(POPUP_TIMER_INTERVAL, this);
                break;
            }

            d->waitForPopupTimer.stop();
            d->layout->setExpanded(false);
            break;
        }
    default:
        break;
    }
    return QWidget::event(event);
}
Beispiel #19
0
void InnerDropdown::onWindowActiveChanged() {
	if (!App::wnd()->windowHandle()->isActive() && !isHidden()) {
		leaveEvent(nullptr);
	}
}
Beispiel #20
0
bool Pawn::nameVisible() const {
    return (!selected && name_interval < 0.0 || isHidden()) ? false : true;
}
Beispiel #21
0
void MainWindow::queryLivePaused()
{
    if (isHidden())
        bcApp->pauseLive();
}
Beispiel #22
0
void PopupMenu::hideAnimated() {
	if (isHidden()) return;
	if (_hiding) return;

	startOpacityAnimation(true);
}
Beispiel #23
0
void LyricsDialog::setSong(const MPDSong &s) {
	m_artist=s.artist();
	m_title=s.title();
	if(!isHidden()) updateLyrics();
}
Beispiel #24
0
void MainWindow::dockClicked()
{
    if (isHidden())
        show();
}
Beispiel #25
0
QSize KoDockWidgetTitleBar::sizeHint() const
{
    if (isHidden()) {
        return QSize(0, 0);
    }

    QDockWidget *q = qobject_cast<QDockWidget*>(parentWidget());

    int mw = q->style()->pixelMetric(QStyle::PM_DockWidgetTitleMargin, 0, q);
    int fw = q->style()->pixelMetric(QStyle::PM_DockWidgetFrameWidth, 0, q);

    // get size of buttons...
    QSize closeSize(0, 0);
    if (d->closeButton && hasFeature(q, QDockWidget::DockWidgetClosable)) {
        closeSize = d->closeButton->sizeHint();
    }

    QSize floatSize(0, 0);
    if (d->floatButton && hasFeature(q, QDockWidget::DockWidgetFloatable)) {
        floatSize = d->floatButton->sizeHint();
    }

    QSize hideSize(0, 0);
    if (d->collapseButton && d->collapsable) {
        hideSize = d->collapseButton->sizeHint();
    }

    QSize lockSize(0, 0);
    if (d->lockButton && d->lockable) {
        lockSize = d->lockButton->sizeHint();
    }

    int buttonHeight = qMax(qMax(qMax(closeSize.height(), floatSize.height()), hideSize.height()), lockSize.height()) + 2;
    int buttonWidth = closeSize.width() + floatSize.width() + hideSize.width() + lockSize.width();

    int height = buttonHeight;
    if (d->textVisibilityMode == FullTextAlwaysVisible) {
        // get font size
        QFontMetrics titleFontMetrics = q->fontMetrics();
        int fontHeight = titleFontMetrics.lineSpacing() + 2 * mw;

        height = qMax(height, fontHeight);
    }

    /*
     * Calculate the width of title and add to the total width of the docker window when collapsed.
     */
    const int titleWidth =
        (d->textVisibilityMode == FullTextAlwaysVisible) ? (q->fontMetrics().width(q->windowTitle()) + 2*mw) :
                                                           0;

    if (d->preCollapsedWidth > 0) {
        return QSize(d->preCollapsedWidth, height);
    }
    else {
        if (d->textVisibilityMode == FullTextAlwaysVisible) {
            return QSize(buttonWidth /*+ height*/ + 2*mw + 2*fw + titleWidth, height);
        }
        else {
            if (q->widget()) {
                return QSize(qMin(q->widget()->sizeHint().width(), buttonWidth), height);
            }
            else {
                return QSize(buttonWidth, height);
            }
        }
    }
}
Beispiel #26
0
void PlayerWidget::stopPressed() {
	if (!_song || isHidden()) return;

	audioPlayer()->stop(OverviewDocuments);
	if (App::main()) App::main()->hidePlayer();
}
Beispiel #27
0
bool TWidget::inFocusChain() const {
	return !isHidden() && App::wnd() && (App::wnd()->focusWidget() == this || isAncestorOf(App::wnd()->focusWidget()));
}