当前位置: 首页>>代码示例>>C++>>正文


C++ BaseSprite::getBoundingRect方法代码示例

本文整理汇总了C++中BaseSprite::getBoundingRect方法的典型用法代码示例。如果您正苦于以下问题:C++ BaseSprite::getBoundingRect方法的具体用法?C++ BaseSprite::getBoundingRect怎么用?C++ BaseSprite::getBoundingRect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BaseSprite的用法示例。


在下文中一共展示了BaseSprite::getBoundingRect方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: correctSize

void UIButton::correctSize() {
	Rect32 rect;

	BaseSprite *img = nullptr;
	if (_image) {
		img = _image;
	} else if (_imageDisable) {
		img = _imageDisable;
	} else if (_imageHover) {
		img = _imageHover;
	} else if (_imagePress) {
		img = _imagePress;
	} else if (_imageFocus) {
		img = _imageFocus;
	}

	if (_width <= 0) {
		if (img) {
			img->getBoundingRect(&rect, 0, 0);
			_width = rect.right - rect.left;
		} else {
			_width = 100;
		}
	}

	if (_height <= 0) {
		if (img) {
			img->getBoundingRect(&rect, 0, 0);
			_height = rect.bottom - rect.top;
		}
	}

	if (_text) {
		int textHeight;
		if (_font) {
			textHeight = _font->getTextHeight((byte *)_text, _width);
		} else {
			textHeight = _gameRef->getSystemFont()->getTextHeight((byte *)_text, _width);
		}

		if (textHeight > _height) {
			_height = textHeight;
		}
	}

	if (_height <= 0) {
		_height = 100;
	}

	if (_back) {
		_back->correctSize(&_width, &_height);
	}
}
开发者ID:CatalystG,项目名称:scummvm,代码行数:53,代码来源:ui_button.cpp

示例2: display

bool UIButton::display(int offsetX, int offsetY) {
	if (!_visible) {
		return STATUS_OK;
	}

	UITiledImage *back = nullptr;
	BaseSprite *image = nullptr;
	BaseFont *font = 0;

	//RECT rect;
	//BasePlatform::setRect(&rect, OffsetX + _posX, OffsetY + _posY, OffsetX+_posX+_width, OffsetY+_posY+_height);
	//_hover = (!_disable && BasePlatform::ptInRect(&rect, _gameRef->_mousePos)!=FALSE);
	_hover = (!_disable && _gameRef->_activeObject == this && (_gameRef->_interactive || _gameRef->_state == GAME_SEMI_FROZEN));

	if ((_press && _hover && !_gameRef->_mouseLeftDown) ||
	        (_oneTimePress && g_system->getMillis() - _oneTimePressTime >= 100)) {
		press();
	}


	if (_disable) {
		if (_backDisable) {
			back = _backDisable;
		}
		if (_imageDisable) {
			image = _imageDisable;
		}
		if (_text && _fontDisable) {
			font = _fontDisable;
		}
	} else if (_press || _oneTimePress || _stayPressed) {
		if (_backPress) {
			back = _backPress;
		}
		if (_imagePress) {
			image = _imagePress;
		}
		if (_text && _fontPress) {
			font = _fontPress;
		}
	} else if (_hover) {
		if (_backHover) {
			back = _backHover;
		}
		if (_imageHover) {
			image = _imageHover;
		}
		if (_text && _fontHover) {
			font = _fontHover;
		}
	} else if (_canFocus && isFocused()) {
		if (_backFocus) {
			back = _backFocus;
		}
		if (_imageFocus) {
			image = _imageFocus;
		}
		if (_text && _fontFocus) {
			font = _fontFocus;
		}
	}

	if (!back && _back) {
		back = _back;
	}
	if (!image && _image) {
		image = _image;
	}
	if (_text && !font) {
		if (_font) {
			font = _font;
		} else {
			font = _gameRef->getSystemFont();
		}
	}

	int imageX = offsetX + _posX;
	int imageY = offsetY + _posY;

	if (image && _centerImage) {
		Rect32 rc;
		image->getBoundingRect(&rc, 0, 0);
		imageX += (_width - (rc.right - rc.left)) / 2;
		imageY += (_height - (rc.bottom - rc.top)) / 2;
	}

	if (back) {
		back->display(offsetX + _posX, offsetY + _posY, _width, _height);
	}
	//if (image) image->Draw(ImageX +((_press||_oneTimePress)&&back?1:0), ImageY +((_press||_oneTimePress)&&back?1:0), nullptr);
	if (image) {
		image->draw(imageX + ((_press || _oneTimePress) && back ? 1 : 0), imageY + ((_press || _oneTimePress) && back ? 1 : 0), _pixelPerfect ? this : nullptr);
	}

	if (font && _text) {
		int text_offset = (_height - font->getTextHeight((byte *)_text, _width)) / 2;
		font->drawText((byte *)_text, offsetX + _posX + ((_press || _oneTimePress) ? 1 : 0), offsetY + _posY + text_offset + ((_press || _oneTimePress) ? 1 : 0), _width, _align);
	}

	if (!_pixelPerfect || !_image) {
//.........这里部分代码省略.........
开发者ID:CatalystG,项目名称:scummvm,代码行数:101,代码来源:ui_button.cpp


注:本文中的BaseSprite::getBoundingRect方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。