Example #1
0
void BaseRenderOSystem::fadeToColor(byte r, byte g, byte b, byte a, Common::Rect *rect) {
	Common::Rect fillRect;

	if (rect) {
		fillRect.left = rect->left;
		fillRect.top = rect->top;
		fillRect.setWidth(rect->width());
		fillRect.setHeight(rect->height());
	} else {
		Rect32 rc;
		_gameRef->getCurrentViewportRect(&rc);
		fillRect.left = (int16)rc.left;
		fillRect.top = (int16)rc.top;
		fillRect.setWidth((int16)(rc.right - rc.left));
		fillRect.setHeight((int16)(rc.bottom - rc.top));
	}
	modTargetRect(&fillRect);

	//TODO: This is only here until I'm sure about the final pixelformat
	uint32 col = _renderSurface->format.ARGBToColor(a, r, g, b);

	Graphics::Surface surf;
	surf.create((uint16)fillRect.width(), (uint16)fillRect.height(), _renderSurface->format);
	Common::Rect sizeRect(fillRect);
	sizeRect.translate(-fillRect.top, -fillRect.left);
	surf.fillRect(fillRect, col);
	TransformStruct temp = TransformStruct();
	temp._alphaDisable = false;
	drawSurface(nullptr, &surf, &sizeRect, &fillRect, temp);
	surf.free();

	//SDL_SetRenderDrawColor(_renderer, r, g, b, a);
	//SDL_SetRenderDrawBlendMode(_renderer, SDL_BLENDMODE_BLEND);
	//SDL_RenderFillRect(_renderer, &fillRect);
}
Example #2
0
bool DXmlGuiWindow::eventFilter(QObject* obj, QEvent* ev)
{
    if (this && (obj == this))
    {
        if (ev && (ev->type() == QEvent::HoverMove) && fullScreenIsActive())
        {
            // We will handle a stand alone FullScreen button action on top/right corner of screen
            // only if managed window tool bar is hidden, and if we switched already in Full Screen mode.

            KToolBar* const mainbar = mainToolBar();

            if (mainbar)
            {
                if (((d->fsOptions & FS_TOOLBARS) && d->fullScreenHideToolBars) || !mainbar->isVisible())
                {
                    QHoverEvent* const mev = dynamic_cast<QHoverEvent*>(ev);

                    if (mev)
                    {
                        QPoint pos(mev->pos());
                        QRect  desktopRect = KGlobalSettings::desktopGeometry(this);

                        QRect sizeRect(QPoint(0, 0), d->fullScreenBtn->size());
                        QRect topLeft, topRight;
                        QRect topRightLarger;

                        desktopRect       = QRect(desktopRect.y(), desktopRect.y(), desktopRect.width(), desktopRect.height());
                        topLeft           = sizeRect;
                        topRight          = sizeRect;

                        topLeft.moveTo(desktopRect.x(), desktopRect.y());
                        topRight.moveTo(desktopRect.x() + desktopRect.width() - sizeRect.width() - 1, topLeft.y());

                        topRightLarger    = topRight.adjusted(-25, 0, 0, 10);

                        if (topRightLarger.contains(pos))
                        {
                            d->fullScreenBtn->move(topRight.topLeft());
                            d->fullScreenBtn->show();
                        }
                        else
                        {
                            d->fullScreenBtn->hide();
                        }

                        return false;
                    }
                }
            }
        }
    }

    // pass the event on to the parent class
    return QObject::eventFilter(obj, ev);
}
Example #3
0
bool TooltipPopup::initWithFile(const char * filename)
{
	if (Button::initWithFile(filename) == false)
	{
		return false;
	}

	m_scaleWhenTouch = false;
	setVisible(false);

	m_icon = NULL;

	m_nameLabel = CCLabelTTF::create();
	m_nameLabel->setFontSize(size(28));
	m_nameLabel->setAnchorPoint(ccp(0.5, 1));
	m_nameLabel->setPosition(ccp(getContentSize().width/2, getContentSize().height-size(12)));
	CCSprite::addChild(m_nameLabel);

	m_descLabel	= CCLabelTTF::create();
	m_descLabel->setDimensions(sizeRect(290, 230));
	m_descLabel->setFontSize(size(20));
	m_descLabel->setAnchorPoint(ccp(0,1));
	m_descLabel->setPosition(posLocalLT(this, 105, 60));
	CCSprite::addChild(m_descLabel);

	m_subDescLabel = CCLabelTTF::create();
	m_subDescLabel->setAnchorPoint(ccp(0,1));
	m_subDescLabel->setFontSize(size(20));
	CCSprite::addChild(m_subDescLabel);

	setPosition(screenCenter());
	setVisible(false);

	BaseLayer::inst()->addButton(this);
	BaseLayer::inst()->addChild(this, z_popup_ui);

	return true;
}
Example #4
0
QRect RectangularOverlay::getSizeRect( bool *ok, bool *widthOk, bool *heightOk  ) const
{
	bool t1,t2,t3;
	if (!ok)
		ok = &t1;
	if (!widthOk)
		widthOk = &t2;
	if (!heightOk)
		heightOk = &t3;
	
	int width = int(m_br->x() - m_tl->x());
	int height = int(m_br->y() - m_tl->y());
	
	QRect sizeRect( int(m_tl->x() - p_item->x()),
					int(m_tl->y() - p_item->y()),
					width, height );
	
	*widthOk = sizeRect.width() >= p_item->minimumSize().width();
	*heightOk = sizeRect.height() >= p_item->minimumSize().height();
	*ok = *widthOk && *heightOk;
	
	return sizeRect;
}
Example #5
0
    QSize TextEditEx::sizeHint() const
    {
        QSize sizeRect(document()->idealWidth(), document()->size().height());

        return sizeRect;
    }
Example #6
0
void WrapTextDelegate::paint( QPainter * p, const QStyleOptionViewItem & option, const QModelIndex & index ) const
{
	int x1, y1, x2, y2; //(x1, y1) is the upper-left corner, (x2, y2) the lower-right
	option.rect.getCoords(&x1, &y1, &x2, &y2);
	p->save();

	int lineWidths = 4;
	// draw a line below each row
	p->setPen( QPen( QBrush("#9CC"), lineWidths) );
	p->drawLine(x1, y2, x2, y2);
	// draw a line between each column
	p->setPen( QPen( QBrush("#CCC"), lineWidths) );
	p->drawLine( x2, y1+((y2-y1)/5), x2, y2-((y2-y1)/5));

	p->restore();

	if( index.isValid() && index.column() == BachAssetItem::Column_Info )
	{
		BachAsset ba = ((RecordSuperModel*)(index.model()))->getRecord(index);

		QRect pathRect(x1+5, y1+5, x2-x1-10, ((y2-y1)/3)-10);
		QRect tagsRect(pathRect.x(), pathRect.y()+pathRect.height()+10, x2-x1-10, y2-y1-10);
		QRect keywordsRect(pathRect.x(), pathRect.y()+pathRect.height()+30, x2-x1-10, y2-y1-10);
		QRect fullSize;

		p->save();
		QItemDelegate::drawBackground( p, option, index );
		if( option.state & QStyle::State_Selected )
			p->setPen( option.palette.highlightedText().color() );
		else
			p->setPen( option.palette.text().color() );

		p->drawText( pathRect, Qt::TextWordWrap, ba.path(), &fullSize );
		p->drawText( tagsRect, Qt::TextWordWrap, QString("Tags: ")+ba.tags(), &fullSize );
		p->drawText( keywordsRect, Qt::TextWordWrap, QString("Keywords: ")+ba.cachedKeywords(), &fullSize );

		p->setPen( QPen( QBrush("#9CC"), 2) );
		p->drawLine(x1+10, y1+((y2-y1)/3), x2-10, y1+((y2-y1)/3));

		//QRect dateRect(tagsRect.bottomRight().x()-40,tagsRect.bottomRight().y()-14, tagsRect.bottomRight().x(), tagsRect.bottomRight.y());

		QFont curFont = option.font;
		p->setFont( QFont(curFont.family(), curFont.pointSize()-2, curFont.weight(), true ) );
		curFont.setPointSize( curFont.pointSize()-1 );
		p->setPen( QColor("#CCC") );

		QRect sizeRect(x1+20,y2-20,x1+100,y2-4);
		p->drawText( sizeRect, Qt::TextWordWrap, QString::number(ba.width())+"x"+QString::number(ba.height()), &fullSize );

		p->setFont(option.font);

		p->restore();
		return;
	}
	else
	{
		QStyleOptionViewItem newOption = QStyleOptionViewItem(option);
		newOption.displayAlignment = Qt::AlignHCenter | Qt::AlignVCenter;
		newOption.decorationAlignment = Qt::AlignHCenter | Qt::AlignVCenter;
		return QItemDelegate::paint( p, newOption, index );
	}
}
Example #7
0
void PICComponent::initPackage( MicroInfo * microInfo )
{
	MicroPackage * microPackage = microInfo ? microInfo->package() : 0l;
	
	if ( microPackage )
	{
		m_bCreatedInitialPackage = true;
		
		//BEGIN Get pin IDs
		QStringList allPinIDs = microPackage->pinIDs();
		QStringList ioPinIDs = microPackage->pinIDs( PicPin::type_bidir | PicPin::type_input | PicPin::type_open );
	
		// Now, we make the unwanted pin ids blank, so a pin is not created for them
		const QStringList::iterator allPinIDsEnd = allPinIDs.end();
		for ( QStringList::iterator it = allPinIDs.begin(); it != allPinIDsEnd; ++it )
		{
			if ( !ioPinIDs.contains(*it) )
				*it = "";
		}
		//END Get pin IDs
	
	
		//BEGIN Remove old stuff
		// Remove old text
		TextMap textMapCopy = m_textMap;
		const TextMap::iterator textMapEnd = textMapCopy.end();
		for ( TextMap::iterator it = textMapCopy.begin(); it != textMapEnd; ++it )
			removeDisplayText(it.key());
	
		// Remove the old pins
		deletePICComponentPins();
	
		// Remove old nodes
		NodeInfoMap nodeMapCopy = m_nodeMap;
		const NodeInfoMap::iterator nodeMapEnd = nodeMapCopy.end();
		for ( NodeInfoMap::iterator it = nodeMapCopy.begin(); it != nodeMapEnd; ++it )
		{
			if ( !ioPinIDs.contains(it.key()) )
				removeNode( it.key() );
		}
	
		removeElements();
		//END Remove old stuff
	
	
	
		//BEGIN Create new stuff
		initDIPSymbol( allPinIDs, 80 );
		initDIP(allPinIDs);
	
		PicPinMap picPinMap = microPackage->pins( PicPin::type_bidir | PicPin::type_input | PicPin::type_open );
		const PicPinMap::iterator picPinMapEnd = picPinMap.end();
		for ( PicPinMap::iterator it = picPinMap.begin(); it != picPinMapEnd; ++it )
			m_picComponentPinMap[it.key()] = new PICComponentPin( this, it.value() );
		//END Create new stuff
	
	
		removeDisplayText( "no_file" );
		addDisplayText( "picid", QRect(offsetX(), offsetY()-16, width(), 16), microInfo->id() );
	}
	else
	{
		setSize( -48, -72, 96, 144 );
		removeDisplayText( "picid" );
		addDisplayText( "no_file", sizeRect(), i18n("(No\nprogram\nloaded)") );
	}
	
	
	//BEGIN Update button positions
	int leftpos = (width()-88)/2+offsetX();
	button("run")->setOriginalRect( QRect( leftpos, height()+4+offsetY(), 20, 20 ) );
	button("pause")->setOriginalRect( QRect( leftpos+23, height()+4+offsetY(), 20, 20 ) );
	button("reset")->setOriginalRect( QRect( leftpos+46, height()+4+offsetY(), 20, 20 ) );
	button("reload")->setOriginalRect( QRect( leftpos+69, height()+4+offsetY(), 20, 20 ) );
	updateAttachedPositioning();
	//END Update button positions
}
LandscapeToolsPanelHeightmap::LandscapeToolsPanelHeightmap(LandscapeToolsPanelDelegate *newDelegate, const Rect & rect)
    :   LandscapeToolsPanel(newDelegate, rect)
{
    Rect sizeRect(rect.dx - TEXTFIELD_WIDTH, 
                  0, TEXTFIELD_WIDTH, ControlsFactory::TOOLS_HEIGHT / 2);
    sizeValue = CreateTextField(sizeRect);
    AddControl(sizeValue);
    
    Rect strengthRect(sizeRect);
    strengthRect.y = sizeRect.y + sizeRect.dy;
    strengthValue = CreateTextField(strengthRect);
    AddControl(strengthValue);
    
    Rect lineRect;
    lineRect.x = strengthSlider->GetRect().x + strengthSlider->GetRect().dx/2;
    lineRect.dx = 2;
    lineRect.y = strengthSlider->GetRect().y - 2;
    lineRect.dy = strengthSlider->GetRect().dy + 4;
    line = ControlsFactory::CreateLine(lineRect);
    AddControl(line);

    showGrid = CreateCkeckbox(Rect(0, ControlsFactory::TOOLS_HEIGHT, ControlsFactory::TOOLS_HEIGHT/2, ControlsFactory::TOOLS_HEIGHT/2), 
                              LocalizedString(L"landscapeeditor.showgrid"));
    
    float32 x = 0;
    float32 y = ControlsFactory::TOOLS_HEIGHT + ControlsFactory::TOOLS_HEIGHT/2.f;
    relative = CreateCkeckbox(Rect(x, y, ControlsFactory::TOOLS_HEIGHT/2.f, ControlsFactory::TOOLS_HEIGHT/2.f), 
                              LocalizedString(L"landscapeeditor.relative"));
    x += (ControlsFactory::TOOLS_HEIGHT/2.f + OFFSET + TEXT_WIDTH);
    average = CreateCkeckbox(Rect(x, y, ControlsFactory::TOOLS_HEIGHT/2.f, ControlsFactory::TOOLS_HEIGHT/2.f), 
                              LocalizedString(L"landscapeeditor.average"));
    
    x += (ControlsFactory::TOOLS_HEIGHT/2.f + OFFSET + TEXT_WIDTH);
    absoluteDropper = CreateCkeckbox(Rect(x, y, ControlsFactory::TOOLS_HEIGHT/2.f, ControlsFactory::TOOLS_HEIGHT/2.f), 
                             LocalizedString(L"landscapeeditor.absolutedropper"));

    Rect heightRect;
    heightRect.x = showGrid->GetRect().x + showGrid->GetRect().dx + TEXT_WIDTH + OFFSET;
    heightRect.y = ControlsFactory::TOOLS_HEIGHT;
    heightRect.dx = TEXTFIELD_WIDTH;
    heightRect.dy = average->GetRect().dy;
    heightValue = CreateTextField(Rect(heightRect));
    heightValue->SetText(L"0");
    AddControl(heightValue);
    
    heightRect.x = heightRect.x + heightRect.dx + ControlsFactory::OFFSET/2.f;
    heightRect.dx = TEXT_WIDTH;
    
    UIStaticText *textControl = new UIStaticText(heightRect);
    textControl->SetText(LocalizedString(L"landscapeeditor.height"));
    textControl->SetFont(ControlsFactory::GetFontLight());
    textControl->SetAlign(ALIGN_VCENTER | ALIGN_LEFT);
    AddControl(textControl);
    SafeRelease(textControl);
    
    averageStrength = CreateSlider(Rect(rect.dx - SLIDER_WIDTH, heightRect.y, 
                                        SLIDER_WIDTH, ControlsFactory::TOOLS_HEIGHT / 2));
    averageStrength->AddEvent(UIControl::EVENT_VALUE_CHANGED, Message(this, &LandscapeToolsPanelHeightmap::OnAverageSizeChanged));
    AddControl(averageStrength);
    AddSliderHeader(averageStrength, LocalizedString(L"landscapeeditor.averagestrength"));

    
    dropperTool = new LandscapeTool(-1, LandscapeTool::TOOL_DROPPER, "~res:/LandscapeEditor/SpecialTools/dropper.png");
    dropperTool->size = 1.0f;
    dropperTool->height = prevHeightValue = 0.f;
    
    Rect dropperRect = brushIcon->GetRect();
    dropperRect.x = (dropperRect.x + dropperRect.dx + ControlsFactory::OFFSET);
    dropperIcon = new UIControl(dropperRect);
    dropperIcon->AddEvent(UIControl::EVENT_TOUCH_UP_INSIDE, Message(this, &LandscapeToolsPanelHeightmap::OnDropperTool));
    dropperIcon->GetBackground()->SetDrawType(UIControlBackground::DRAW_SCALE_PROPORTIONAL);
    dropperIcon->SetSprite(dropperTool->sprite, 0);
    AddControl(dropperIcon);
    

    copypasteTool = new LandscapeTool(-1, LandscapeTool::TOOL_COPYPASTE, "~res:/LandscapeEditor/SpecialTools/copypaste.png");
    
    Rect copypasteRect = dropperRect;
    copypasteRect.x = (copypasteRect.x + copypasteRect.dx + ControlsFactory::OFFSET);
    copypasteIcon = new UIControl(copypasteRect);
    copypasteIcon->AddEvent(UIControl::EVENT_TOUCH_UP_INSIDE, Message(this, &LandscapeToolsPanelHeightmap::OnCopypasteTool));
    copypasteIcon->GetBackground()->SetDrawType(UIControlBackground::DRAW_SCALE_PROPORTIONAL);
    copypasteIcon->SetSprite(copypasteTool->sprite, 0);
    AddControl(copypasteIcon);
    
    copypasteRect.x = (copypasteRect.x + copypasteRect.dx + ControlsFactory::OFFSET);
    copypasteRect.dx = copypasteRect.dy = ControlsFactory::TOOLS_HEIGHT / 2;
    copyHeightmap = CreateCkeckbox(copypasteRect, L"Height");
    copypasteRect.y += copypasteRect.dy;
    copyTilemask = CreateCkeckbox(copypasteRect, L"Tilemask");
    
    sizeValue->SetText(Format(L"%.3f", LandscapeTool::SizeHeightMax()));
    strengthValue->SetText(Format(L"%.3f", LandscapeTool::StrengthHeightMax()));
    
    relative->SetChecked(true, false);
    average->SetChecked(false, false);
    absoluteDropper->SetChecked(false, false);

    sizeSlider->SetMinMaxValue(0.f, LandscapeTool::SizeHeightMax());
    sizeSlider->SetValue(LandscapeTool::DefaultSizeHeight());

    strengthSlider->SetMinMaxValue(-LandscapeTool::StrengthHeightMax(), LandscapeTool::StrengthHeightMax());
    strengthSlider->SetValue(LandscapeTool::DefaultStrengthHeight());
    
    averageStrength->SetMinMaxValue(0.f, 1.f);
    averageStrength->SetValue(0.5f);
    
    copyHeightmap->SetChecked(true, false);    
    copyTilemask->SetChecked(true, false);    
}
 QSize TextEditExWithTrScrollBar::contentSize() const
 {
     QSize sizeRect(document()->size().width(), document()->size().height());
     return sizeRect;
 }