示例#1
0
    void Button::update(const sf::RenderWindow& window)
    {
        if (!isFocusable())
        {
            onLock();
            updateAppearance();
            return;
        }

        sf::Vector2i mousePos = sf::Mouse::getPosition(window);
        bool isMouseOn = mousePos.x >= (getGlobalPosition().x - getWidth() * .5f)
                        && mousePos.x <= (getGlobalPosition().x + getWidth() * .5f)
                        && mousePos.y >= (getGlobalPosition().y - getHeight() * .5f)
                        && mousePos.y <= (getGlobalPosition().y + getHeight() * .5f);
        if (isMouseOn)
        {
            if(sf::Mouse::isButtonPressed(sf::Mouse::Left))
            {
                onPress();
            }
            else
            {
                if(mState == Button::OnPressed) { onClick(); }
                onFocus();
            }
        }
        else
        {
            lostFocus();
        }
        updateAppearance();
    }
void GuiSlider::setPosition(float value)
{
    _pos = value;
    if( _pos < _lowerLimit ) _pos = _lowerLimit;
    if( _pos > _upperLimit ) _pos = _upperLimit;
    updateAppearance();
}
示例#3
0
void VESPERSEndstationConfigurationView::onGeometryClicked(int id)
{
	switch(id){

	case 1:	// Straight on.
		endstation_->setGeometry(VESPERS::StraightOn);
		break;

	case 2:	// Vertical 45.
		endstation_->setGeometry(VESPERS::Single45Vertical);
		break;

	case 3:	// Horizontal 45.
		endstation_->setGeometry(VESPERS::Single45Horizontal);
		break;

	case 4:	// Double 45.
		endstation_->setGeometry(VESPERS::Double45);
		break;

	case 5:	// Big beam.
		endstation_->setGeometry(VESPERS::BigBeam);
		break;
	}

	updateAppearance();
	updatePixmap();

	if (techniquesBox_->isHidden())
		techniquesBox_->show();

	if (detectorsBox_->isHidden())
		detectorsBox_->show();
}
示例#4
0
文件: beds.cpp 项目: Fir3element/035
void BedItem::sleep(Player* player)
{
	if(!house || !player || player->isRemoved())
		return;

	if(!sleeper)
	{
		Beds::getInstance().setBedSleeper(this, player->getGUID());
		internalSetSleeper(player);

		BedItem* nextBedItem = getNextBedItem();
		if(nextBedItem)
			nextBedItem->internalSetSleeper(player);

		updateAppearance(player);
		if(nextBedItem)
			nextBedItem->updateAppearance(player);

		player->getTile()->moveCreature(NULL, player, getTile());
		g_game.addMagicEffect(player->getPosition(), NM_ME_SLEEP);
		Scheduler::getScheduler().addEvent(createSchedulerTask(SCHEDULER_MINTICKS, boost::bind(&Game::kickPlayer, &g_game, player->getID(), false)));
	}
	else if(Item::items[getID()].transformToFree)
	{
		wakeUp();
		g_game.addMagicEffect(player->getPosition(), NM_ME_POFF);
	}
	else
		player->sendCancelMessage(RET_NOTPOSSIBLE);
}
示例#5
0
文件: beds.cpp 项目: Fir3element/035
void BedItem::wakeUp()
{
	if(!house)
		return;

	if(sleeper)
	{
		if(Player* player = g_game.getPlayerByGuidEx(sleeper))
		{
			regeneratePlayer(player);
			if(player->isVirtual())
			{
				IOLoginData::getInstance()->savePlayer(player);
				delete player;
			}
			else
				g_game.addCreatureHealth(player);
		}
	}

	Beds::getInstance().setBedSleeper(NULL, sleeper);
	internalRemoveSleeper();

	BedItem* nextBedItem = getNextBedItem();
	if(nextBedItem)
		nextBedItem->internalRemoveSleeper();

	updateAppearance(NULL);
	if(nextBedItem)
		nextBedItem->updateAppearance(NULL);
}
示例#6
0
void FrameCaret::setShouldShowBlockCursor(bool shouldShowBlockCursor) {
  m_shouldShowBlockCursor = shouldShowBlockCursor;

  m_frame->document()->updateStyleAndLayoutIgnorePendingStylesheets();

  updateAppearance();
}
void GuiSlider::setUpperLimit(float value)
{
    _upperLimit = value;
    if( _upperLimit < _lowerLimit ) _upperLimit = _lowerLimit;
    if( _pos > _upperLimit ) _pos = _upperLimit;
    updateAppearance();
}
示例#8
0
void FrameCaret::setCaretVisibility(CaretVisibility visibility) {
  if (m_caretVisibility == visibility)
    return;

  m_caretVisibility = visibility;

  updateAppearance();
}
void BaseChooserOnlyDateAndTimeInputType::createShadowSubtree()
{
    DEFINE_STATIC_LOCAL(AtomicString, valueContainerPseudo, ("-webkit-date-and-time-value", AtomicString::ConstructFromLiteral));

    RefPtr<HTMLDivElement> valueContainer = HTMLDivElement::create(element().document());
    valueContainer->setPseudo(valueContainerPseudo);
    element().userAgentShadowRoot()->appendChild(valueContainer.get());
    updateAppearance();
}
/**
 *	@brief	Starts task.
 */
void MouseHoverUITask::StartTask()
{
	UIManager* uiManager = getUIManager();
	ASSERT(NULL != uiManager);

	currentStep = 1;
	isBeingHot = true;
	updateAppearance();
	uiManager->GetUIController()->BeginTimer(UIController::TimerID_MouseHover, HOVER_TIMER_ELAPSE);
}
/**
 *	@brief	Called when timer event occurred.
 *	@param	timerId		ID of the timer.
 */
void MouseHoverUITask::TimerEvent(SInt32 timerId)
{
	if (timerId != UIController::TimerID_MouseHover)
	{
		return;
	}

	UInt32 commandState = getUIManager()->GetCommandState(targetCommandID);
	if (commandState & UIManager::CommandState_Disabled & commandState)
	{
		CancelTask();
		return;
	}

	if (!changeStatusAccordingToMouse())
	{
		CancelTask();
		return;
	}

	if (isBeingHot)
	{
		if (currentStep < stepCount)
		{
			currentStep++;
			updateAppearance();
		}
	}
	else
	{
		if (currentStep > 0)
		{
			currentStep--;
			updateAppearance();
			if (currentStep == 0)
			{
				CancelTask();
			}
		}
	}
}
/**
 *	@brief	Changes the status of this task according to mouse position.
 *	@return	false if this task shoule be canceled.
 */
bool MouseHoverUITask::changeStatusAccordingToMouse()
{
	UIManager* uiManager = getUIManager();
	ASSERT(NULL != uiManager);

	Point32 mousePoint = uiManager->GetUIController()->GetMousePosition();
	ColorCodedSkin* skin = uiManager->GetSkin();
	
	SInt32 mouseSkinArea = skin->GetArea(mousePoint);
	bool isInArea = (mouseSkinArea == targetSkinArea);
	bool isHoverable;
#if defined(BEOS)
	isHoverable = uiManager->GetUIController()->IsUIActive();
#else
	isHoverable = true;
#endif
	if (isBeingHot && (!isInArea || !isHoverable))
	{
		isBeingHot = false;
		if (currentStep > 0)
		{
			currentStep--;
			updateAppearance();
			if (currentStep == 0)
			{
				return false;
			}
		}
	}
	else if (!isBeingHot && isInArea && isHoverable)
	{
		isBeingHot = true;
		if (currentStep < stepCount)
		{
			currentStep++;
			updateAppearance();
		}
	}	
	return true;
}
示例#13
0
/** Draw this UI element. In practice this means recursively drawing all its child items too.*/
void CGUIbase::Draw() {
	if (!visible)
		return;
	if (needsUpdate)
		updateAppearance();
	
	UIrect* parentClipbox = &parent->Clipbox;
	pDrawFuncs->setClip(Clipbox);

	DrawSelf(); 
	//then draw each subcontrol
	for (size_t i=0;i<Control.size();i++) 
		Control[i]->Draw();
}
void UINetworkManagerIndicator::sltSetProgress(const QUuid &uuid, qint64 iReceived, qint64 iTotal)
{
    /* Make sure that network-request still registered: */
    AssertMsg(m_ids.contains(uuid), ("That network-request already unregistered!"));

    /* Search for network-request index: */
    int iIndexOfNetworkRequest = m_ids.indexOf(uuid);
    /* Update corresponding network-request data: */
    UINetworkRequestData &data = m_data[iIndexOfNetworkRequest];
    data.bytesReceived = iReceived;
    data.bytesTotal = iTotal;

    /* Update appearance: */
    updateAppearance();
}
示例#15
0
DiagramOperation::DiagramOperation(const ProjectModel * model, const std::shared_ptr<Block> blockPointer, QMenu * contextMenu, QGraphicsItem * parent)
    : model(model)
    , operationPointer(std::static_pointer_cast<Operation>(blockPointer))
{
    myContextMenu = contextMenu;

    width = 150;
    height = 100;

    blockName = new BlockDescription(QString::fromStdString(operationPointer->name).replace(QRegExp("([A-Z])"), " \\1"), this);
    blockName->setAlignCenter(0); //to do: block types, have to do sth with argument
    setBrush(myItemColor);
    updateAppearance();

    // Get input names from the model
    const Library & library = model->getLibraries().at(operationPointer->module);
    const auto & inputMap = library.getInputs();
    const auto & outputMap = library.getOutputs();
    auto & inputs = inputMap.at(operationPointer->name);
    auto & outputs = outputMap.at(operationPointer->name);

    // IO circles
    for (int i = 0; i < inputs.size(); i++) {
        BlockIn * entry = new BlockIn(i, this);
        In.append(entry);
        entry->drawIn(QStringLiteral("%2").arg(QString::fromStdString(inputs.at(i)).section('.', 1)));
    }

    for (int i = 0; i < outputs.size(); i++) {
        BlockOut * exit = new BlockOut(i, operationPointer->outputs[i].id, this);
        Out.append(exit);
        exit->drawOut(QStringLiteral("%2").arg(QString::fromStdString(outputs.at(i)).section('.', 1)));
    }

    /*if (blockName->isLong()) {
            width = 200;
            blockName->setTextWidth(250);
        }

    height = height + (blockName->scale());*/

    height = blockName->getHeight() + (In.size() > Out.size() ? In.size() * 20 : Out.size() * 20) + 5;
    setRect(0, 0, width, height);

    setFlag(QGraphicsItem::ItemIsMovable, true);
    setFlag(QGraphicsItem::ItemIsSelectable, true);
    setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);
}
示例#16
0
void BedItem::wakeUp(Player* player)
{
	// avoid crashes
	if (!house) {
		return;
	}

	if (sleeperGUID != 0) {
		if (!player) {
			std::string name;

			if (IOLoginData::getInstance()->getNameByGuid(sleeperGUID, name)) {
				Player* _player = new Player(name, NULL);

				if (IOLoginData::getInstance()->loadPlayer(_player, name)) {
					regeneratePlayer(_player);
					IOLoginData::getInstance()->savePlayer(_player);
				}

				delete _player;
				_player = NULL;
			}
		} else {
			regeneratePlayer(player);
			g_game.addCreatureHealth(player);
		}
	}

	// update the BedSleepersMap
	Beds::getInstance().setBedSleeper(NULL, sleeperGUID);

	BedItem* nextBedItem = getNextBedItem();

	// unset sleep info
	internalRemoveSleeper();

	if (nextBedItem) {
		nextBedItem->internalRemoveSleeper();
	}

	// change self and partner's appearance
	updateAppearance(NULL);

	if (nextBedItem) {
		nextBedItem->updateAppearance(NULL);
	}
}
示例#17
0
LWindowFrame::LWindowFrame(WId client, QWidget *parent) : QFrame(parent, Qt::X11BypassWindowManagerHint){
  activeState = LWindowFrame::Normal;
  CID = client;
  lastAction = LWM::WA_NONE;
  Closing = false;
  //qDebug() << "New Window:" << CID << "Frame:" << this->winId();
  this->setMouseTracking(true); //need this to determine mouse location when not clicked
  this->setObjectName("LWindowFrame");
  this->setStyleSheet("LWindowFrame#LWindowFrame{ border: 2px solid white; border-radius:3px; } QWidget#TitleBar{background: grey; } QLabel{ color: black; }");
  InitWindow(); //initially create all the child widgets
  //LWM::SYSTEM->setupEventsForFrame(this->winId());
  updateAppearance(); //this loads the appearance based on window/theme settings
  //QApplication::processEvents();
  //Now set the frame size on this window
  SyncSize();
  SyncText();	
  this->show();
}
示例#18
0
LogfileReader::LogfileReader(QWidget* parent, const QString& log, const QString& caption) : ChatWindow(parent)
{
    setType(ChatWindow::LogFileReader);
    setName(i18n("Logfile of %1", caption));

    fileName = log;

    setSpacing(0);

    toolBar = new KToolBar(this, true, true);
    toolBar->setObjectName("logfile_toolbar");
    toolBar->addAction(QIcon::fromTheme("document-save-as"), i18n("Save As..."), this, SLOT(saveLog()));
    toolBar->addAction(QIcon::fromTheme("view-refresh"), i18n("Reload"), this, SLOT(updateView()));
    toolBar->addAction(QIcon::fromTheme("edit-delete"), i18n("Clear Logfile"), this, SLOT(clearLog()));

    toolBar->addWidget(new QLabel(i18n("Show last:"),toolBar));
    sizeSpin = new QSpinBox(toolBar);
    sizeSpin->setMinimum(10);
    sizeSpin->setMaximum(1000);
    sizeSpin->setSingleStep(10);
    sizeSpin->setObjectName("logfile_size_spinbox");
    sizeSpin->setWhatsThis(i18n("Use this box to set the maximum size of the log file. This setting does not take effect until you restart Konversation. Each log file may have a separate setting."));
    sizeSpin->setValue(Preferences::self()->logfileBufferSize());
    sizeSpin->setSuffix(i18n(" KB"));
    sizeSpin->installEventFilter(this);
    toolBar->addWidget(sizeSpin);
    connect(sizeSpin, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this, &LogfileReader::storeBufferSize);

    IRCViewBox* ircBox = new IRCViewBox(this);
    setTextView(ircBox->ircView());
    getTextView()->setWhatsThis(i18n("The messages in the log file are displayed here. The oldest messages are at the top and the most recent are at the bottom."));

    updateView();
    ircBox->ircView()->setFocusPolicy(Qt::StrongFocus);
    setFocusPolicy(Qt::StrongFocus);
    setFocusProxy(ircBox->ircView());

    updateAppearance();

    connect(getTextView(), SIGNAL(gotFocus()), getTextView(), SLOT(setFocus()));
}
示例#19
0
bool BedItem::sleep(Player* player)
{
	if (!house || !player || player->isRemoved()) {
		return false;
	}

	if (sleeperGUID != 0) {
		return false;
	}

	BedItem* nextBedItem = getNextBedItem();

	internalSetSleeper(player);

	if (nextBedItem) {
		nextBedItem->internalSetSleeper(player);
	}

	// update the BedSleepersMap
	Beds::getInstance().setBedSleeper(this, player->getGUID());

	// make the player walk onto the bed
	player->getTile()->moveCreature(player, getTile());

	// display 'Zzzz'/sleep effect
	g_game.addMagicEffect(player->getPosition(), NM_ME_SLEEP);

	// kick player after he sees himself walk onto the bed and it change id
	uint32_t playerId = player->getID();
	g_scheduler.addEvent(createSchedulerTask(SCHEDULER_MINTICKS, boost::bind(&Game::kickPlayer, &g_game, playerId, false)));

	// change self and partner's appearance
	updateAppearance(player);

	if (nextBedItem) {
		nextBedItem->updateAppearance(player);
	}

	return true;
}
示例#20
0
void BedItem::wakeUp(Player* player)
{
	// avoid crashes
	if (!house) {
		return;
	}

	if (sleeperGUID != 0) {
		if (!player) {
			Player _player(nullptr);
			if (IOLoginData::loadPlayerById(&_player, sleeperGUID)) {
				regeneratePlayer(&_player);
				IOLoginData::savePlayer(&_player);
			}
		} else {
			regeneratePlayer(player);
			g_game.addCreatureHealth(player);
		}
	}

	// update the BedSleepersMap
	Beds::getInstance().setBedSleeper(nullptr, sleeperGUID);

	BedItem* nextBedItem = getNextBedItem();

	// unset sleep info
	internalRemoveSleeper();

	if (nextBedItem) {
		nextBedItem->internalRemoveSleeper();
	}

	// change self and partner's appearance
	updateAppearance(nullptr);

	if (nextBedItem) {
		nextBedItem->updateAppearance(nullptr);
	}
}
void UINetworkManagerIndicator::recalculateIndicatorState()
{
    /* Check if there are network-requests at all: */
    if (m_ids.isEmpty())
    {
        /* Set state to 'idle': */
        setState(UINetworkManagerIndicatorState_Idle);
    }
    else
    {
        /* Check if there is at least one failed network-request: */
        bool fIsThereAtLeastOneFailedNetworkRequest = false;
        for (int i = 0; i < m_data.size(); ++i)
        {
            if (m_data[i].failed)
            {
                fIsThereAtLeastOneFailedNetworkRequest = true;
                break;
            }
        }

        /* If there it least one failed network-request: */
        if (fIsThereAtLeastOneFailedNetworkRequest)
        {
            /* Set state to 'error': */
            setState(UINetworkManagerIndicatorState_Error);
        }
        else
        {
            /* Set state to 'loading': */
            setState(UINetworkManagerIndicatorState_Loading);
        }
    }

    /* Update appearance finally: */
    updateAppearance();
}
示例#22
0
/** Set the dimensions and relative position of the control. */
void CGUIbase::SetPos(int x, int y, int w, int h) {
	xPos = x; yPos = y; width = w; height = h;
	updateAppearance();
}
示例#23
0
/** Schedule the modal control for deletion. We don't delete it now because it
	may still get accessed. */
void CGUIroot::removeModal() {
	killModal = true;
	updateAppearance();
}
示例#24
0
 void retranslateUi()
 {
     updateAppearance();
 }
void BaseChooserOnlyDateAndTimeInputType::setValue(const String& value, bool valueChanged, TextFieldEventBehavior eventBehavior)
{
    BaseDateAndTimeInputType::setValue(value, valueChanged, eventBehavior);
    if (valueChanged)
        updateAppearance();
}
void UINetworkManagerIndicator::retranslateUi()
{
    /* Update appearance: */
    updateAppearance();
}
GuiSlider::GuiSlider(TiXmlNode* node)
{
    // retrieve name
    _name = static_cast<TiXmlElement*>( node )->Attribute( "name" );

    // initialize control panel
    initializePanel( node );

    // determine type of slider
    const char* orientation = static_cast<TiXmlElement*>( node )->Attribute( "orientation" );                                                                              
    assert( orientation );
    if( strstr( orientation, "h" ) || strstr( orientation, "H" ) )
    {
        _horizontal = true;
    }
    else if( strstr( orientation, "v" ) || strstr( orientation, "V" ) )
    {
        _horizontal = false;
    }
    else
    {
        throw Exception( "Unknown slider type: \"%s\"", _name.c_str() );
    }
    if( strstr( orientation, "r" ) || strstr( orientation, "R" ) )
    {
        _reverse = true;
    }
    else
    {
        _reverse = false;
    }

    // search for scroll button
    _scrollButton = NULL;
    for( GuiPanelI panelI = _children.begin(); panelI != _children.end(); panelI++ )
    {
        if( strcmp( (*panelI)->getName(), "ScrollButton" ) == 0 )
        {
            _scrollButton = dynamic_cast<GuiButton*>( (*panelI)->getButton() );            
        }
    }
    assert( _scrollButton );

    // initialize autos
    if( _horizontal )
    {
        _lowerRect.left   = 0;
        _lowerRect.top    = 0;
        _lowerRect.right  = _rect.bottom - _rect.top;
        _lowerRect.bottom = _lowerRect.right;
        _upperRect.left   = ( _rect.right - _rect.left ) - _lowerRect.right;
        _upperRect.top    = 0;
        _upperRect.right  = ( _rect.right - _rect.left );
        _upperRect.bottom = _lowerRect.right;
    }
    else
    {
        _lowerRect.left   = 0;
        _lowerRect.top    = 0;
        _lowerRect.right  = _rect.right - _rect.left;    
        _lowerRect.bottom = _lowerRect.right;
        _upperRect.left   = 0;
        _upperRect.top    = ( _rect.bottom - _rect.top ) - _lowerRect.bottom;
        _upperRect.right  = _rect.right - _rect.left;
        _upperRect.bottom = ( _rect.bottom - _rect.top );
    }

    if( _reverse )
    {
        RECT temp = _lowerRect;
        _lowerRect = _upperRect;
        _upperRect = temp;
    }

    // update slider appearance
    _lowerLimit = 0;
    _upperLimit = 10;
    _pos        = 0;
    _scrolling  = false;
    updateAppearance();
}
/**
 *	@brief	Called when user interface is being activated or being deactivated.
 */
void MouseHoverUITask::UIActivated()
{
	updateAppearance();
}