示例#1
0
Slider::Slider(float length, Vec2d &valueScale, bool callOnMove, float defaultpos, Color backcolor, Color forecolor, Color selectcolor)
{
	mLength = length;
	mValueScale = valueScale;
	
	mTargetPosition = constrain(convertScale(defaultpos, mValueScale.X(), mValueScale.Y(), 0, mLength), 0, mLength);
	mSliderPosition = constrain(convertScale(defaultpos, mValueScale.X(), mValueScale.Y(), 0, mLength), 0, mLength);

	mCallOnMove = callOnMove;

	mForeColor = forecolor;
	mBackColor = backcolor;
	mSelectedColor = selectcolor;
	
	mDimensions.setX(length);
	
	mDimensions.setY(32);

	mEnabled = true;
	mHover = false;
	mPressed = false;

	mTouched = false;

	checkListeners();
}
示例#2
0
QSize StickerPreviewWidget::currentDimensions() const {
	if (!_doc) return QSize(_cache.width() / cIntRetinaFactor(), _cache.height() / cIntRetinaFactor());

	QSize result(qMax(convertScale(_doc->dimensions.width()), 1), qMax(convertScale(_doc->dimensions.height()), 1));
	if (gif() && _gif->ready()) {
		result = QSize(qMax(convertScale(_gif->width()), 1), qMax(convertScale(_gif->height()), 1));
	}
	if (result.width() > st::maxStickerSize) {
		result.setHeight(qMax(qRound((st::maxStickerSize * result.height()) / result.width()), 1));
		result.setWidth(st::maxStickerSize);
	}
	if (result.height() > st::maxStickerSize) {
		result.setWidth(qMax(qRound((st::maxStickerSize * result.width()) / result.height()), 1));
		result.setHeight(st::maxStickerSize);
	}
	return result;
}
void LocationManager::getData(LocationData *data) {
	if (!manager) {
		DEBUG_LOG(("App Error: getting image link data without manager init!"));
		return failed(data);
	}

	int32 w = st::locationSize.width(), h = st::locationSize.height();
	int32 zoom = 13, scale = 1;
	if (cScale() == dbisTwo || cRetina()) {
		scale = 2;
	} else {
		w = convertScale(w);
		h = convertScale(h);
	}
	QString coords = qsl("%1,%2").arg(data->coords.lat).arg(data->coords.lon);
	QString url = qsl("https://maps.googleapis.com/maps/api/staticmap?center=") + coords + qsl("&zoom=%1&size=%2x%3&maptype=roadmap&scale=%4&markers=color:red|size:big|").arg(zoom).arg(w).arg(h).arg(scale) + coords + qsl("&sensor=false");
	QNetworkReply *reply = manager->get(QNetworkRequest(QUrl(url)));
	imageLoadings[reply] = data;
}
示例#4
0
QSize MediaPreviewWidget::currentDimensions() const {
	if (!_cachedSize.isEmpty()) {
		return _cachedSize;
	}
	if (!_document && !_photo) {
		_cachedSize = QSize(_cache.width() / cIntRetinaFactor(), _cache.height() / cIntRetinaFactor());
		return _cachedSize;
	}

	QSize result, box;
	if (_photo) {
		result = QSize(_photo->full->width(), _photo->full->height());
		box = QSize(width() - 2 * st::boxVerticalMargin, height() - 2 * st::boxVerticalMargin);
	} else {
		result = _document->dimensions;
		if (gif() && _gif->ready()) {
			result = QSize(_gif->width(), _gif->height());
		}
		if (_document->sticker()) {
			box = QSize(st::maxStickerSize, st::maxStickerSize);
		} else {
			box = QSize(2 * st::maxStickerSize, 2 * st::maxStickerSize);
		}
	}
	result = QSize(qMax(convertScale(result.width()), 1), qMax(convertScale(result.height()), 1));
	if (result.width() > box.width()) {
		result.setHeight(qMax((box.width() * result.height()) / result.width(), 1));
		result.setWidth(box.width());
	}
	if (result.height() > box.height()) {
		result.setWidth(qMax((box.height() * result.width()) / result.height(), 1));
		result.setHeight(box.height());
	}
	if (_photo) {
		_cachedSize = result;
	}
	return result;
}
示例#5
0
void Sprite::drawPlain(Vec2d &location, Vec2d &bounds, Vec2d &scale)
{
	GLfloat left = convertScale(mTexPosition.X(), 0, mpTexture->getWidth(), 0.0f, 1.0f);
	GLfloat right = convertScale(mTexPosition.X() + bounds.X(), 0, mpTexture->getWidth(), 0.0f, 1.0f);

	GLfloat up = convertScale(mTexPosition.Y() + bounds.Y(), 0, mpTexture->getHeight(), 1.0f, 0.0f);
	GLfloat down = convertScale(mTexPosition.Y(), 0, mpTexture->getHeight(), 1.0f, 0.0f);

	// Front Face

	glTexCoord2f(left,up);
	glVertex3f(-((bounds.X()/bounds.Y()) * scale.X())/2, -scale.Y()/2, 0.0f);              // Top Left

	glTexCoord2f(right,up);
	glVertex3f(/*mpTexture->getRatio()*/((bounds.X()/bounds.Y()) * scale.X())/2, -scale.Y()/2, 0.0f);              // Top Right

	glTexCoord2f(right,down);
	glVertex3f( /*mpTexture->getRatio()*/((bounds.X()/bounds.Y()) * scale.X())/2, scale.Y()/2, 0.0f);              // Bottom Right

	glTexCoord2f(left,down);
	glVertex3f(-((bounds.X()/bounds.Y()) * scale.X())/2,scale.Y()/2, 0.0f);              // Bottom Left

}
示例#6
0
void InitMessageField(
		not_null<Window::Controller*> controller,
		not_null<Ui::InputField*> field) {
	field->setMinHeight(st::historySendSize.height() - 2 * st::historySendPadding);
	field->setMaxHeight(st::historyComposeFieldMaxHeight);

	field->setTagMimeProcessor(std::make_unique<FieldTagMimeProcessor>());

	field->document()->setDocumentMargin(4.);
	field->setAdditionalMargin(convertScale(4) - 4);

	field->customTab(true);
	field->setInstantReplaces(Ui::InstantReplaces::Default());
	field->setInstantReplacesEnabled(Global::ReplaceEmojiValue());
	field->setMarkdownReplacesEnabled(rpl::single(true));
	field->setEditLinkCallback(
		DefaultEditLinkCallback(controller, field));
}
示例#7
0
void convertScaleThread(void* targetScale)
{
	convertScale(*static_cast<char*>(targetScale));
	resultChanged = true;
	delete targetScale;
}
示例#8
0
void Slider::setValue(float value)
{
	mTargetPosition = constrain(convertScale(value, mValueScale.X(), mValueScale.Y(), 0, mLength), 0, mLength);
}
示例#9
0
float Slider::getValue()
{
	return convertScale(mSliderPosition, 0, mLength, mValueScale.X(), mValueScale.Y());
}
示例#10
0
//Peter: Used great billboard drawing trick from http://www.lighthouse3d.com/opengl/billboarding/index.php?billCheat.
void Sprite::draw(Vec3d &location)
{

	GLfloat left = convertScale(mTexPosition.X(), 0, mpTexture->getWidth(), 0.0f, 1.0f);
	GLfloat right = convertScale(mTexPosition.X() + mSize.X(), 0, mpTexture->getWidth(), 0.0f, 1.0f);

	GLfloat up = convertScale(mTexPosition.Y() + mSize.Y(), 0, mpTexture->getHeight(), 1.0f, 0.0f);
	GLfloat down = convertScale(mTexPosition.Y(), 0, mpTexture->getHeight(), 1.0f, 0.0f);

	glPushMatrix();

	glTranslatef(location.X, location.Y, location.Z);

	glPushMatrix();

	//glTranslatef(mpTexture->getRatio()*0.5,0,0);

	mpTexture->setAsActiveTexture();

	float modelview[16];
	int i,j;

	// save the current modelview matrix
	glPushMatrix();

	// get the current modelview matrix
	glGetFloatv(GL_MODELVIEW_MATRIX , modelview);

	// undo all rotations
	// beware all scaling is lost as well 
	for( i=0; i<3; i++ ) 
		for( j=0; j<3; j++ ) 
		{
			if ( i==j )
				modelview[i*4+j] = 1.0;
			else
				modelview[i*4+j] = 0.0;
		}

	// set the modelview with no rotations and scaling
	glLoadMatrixf(modelview);

	glBegin(GL_QUADS);
	// Front Face
	glColor3f(1,1,1);

	glTexCoord2f(left,up);
	glVertex3f(0.0f, -0.5f, 0.0f);              // Top Left

	glTexCoord2f(right,up);
	glVertex3f( /*mpTexture->getRatio()*/(mSize.X()/mSize.Y())*1.0f, -0.5f, 0.0f);              // Top Right

	glTexCoord2f(right,down);
	glVertex3f( /*mpTexture->getRatio()*/(mSize.X()/mSize.Y())*1.0f,0.5f, 0.0f);              // Bottom Right

	glTexCoord2f(left,down);
	glVertex3f(0.0f,0.5f, 0.0f);              // Bottom Left

	glEnd();

	glPopMatrix();

	// restores the modelview matrix
	glPopMatrix();

	glPopMatrix();
}
示例#11
0
//Peter: Used great billboard drawing trick from http://www.lighthouse3d.com/opengl/billboarding/index.php?billCheat.
void Sprite::drawScaledTintedRotated(Vec3d &location, Vec2d &scale, Color &color, float rotation)
{

	GLfloat left = convertScale(mTexPosition.X(), 0, mpTexture->getWidth(), 0.0f, 1.0f);
	GLfloat right = convertScale(mTexPosition.X() + mSize.X(), 0, mpTexture->getWidth(), 0.0f, 1.0f);

	GLfloat up = convertScale(mTexPosition.Y() + mSize.Y(), 0, mpTexture->getHeight(), 1.0f, 0.0f);
	GLfloat down = convertScale(mTexPosition.Y(), 0, mpTexture->getHeight(), 1.0f, 0.0f);

	glPushMatrix();

	glTranslatef(location.X, location.Y, location.Z);

	glPushMatrix();

	//glTranslatef(mpTexture->getRatio()*0.5,0,0);

	mpTexture->setAsActiveTexture();

	float modelview[16];
	int i,j;

	// save the current modelview matrix
	glPushMatrix();

	// get the current modelview matrix
	glGetFloatv(GL_MODELVIEW_MATRIX , modelview);

	// undo all rotations
	// beware all scaling is lost as well 
	for( i=0; i<3; i++ ) 
		for( j=0; j<3; j++ ) 
		{
			if ( i==j )
				modelview[i*4+j] = 1.0;
			else
				modelview[i*4+j] = 0.0;
		}

	// set the modelview with no rotations and scaling
	glLoadMatrixf(modelview);

	glRotatef(rotation, 0.0, 0.0, 1.0);

	//cwc::glShader *shader = (*game->getShaderManager())[0];

	//shader->begin();

	glBegin(GL_QUADS);
	// Front Face

	//Set tint.
	glColor3f(color.r, color.g, color.b);

	glTexCoord2f(left,up);
	glVertex3f(-((mSize.X()/mSize.Y()) * scale.X())/2, -scale.Y()/2, 0.0f);              // Top Left

	glTexCoord2f(right,up);
	glVertex3f(/*mpTexture->getRatio()*/((mSize.X()/mSize.Y()) * scale.X())/2, -scale.Y()/2, 0.0f);              // Top Right

	glTexCoord2f(right,down);
	glVertex3f( /*mpTexture->getRatio()*/((mSize.X()/mSize.Y()) * scale.X())/2, scale.Y()/2, 0.0f);              // Bottom Right

	glTexCoord2f(left,down);
	glVertex3f(-((mSize.X()/mSize.Y()) * scale.X())/2,scale.Y()/2, 0.0f);              // Bottom Left

	glEnd();

	//shader->end();

	if(game->getWireframeBoundingBoxMode())
	{
		glDisable(GL_TEXTURE_2D);

		glLineWidth(10);

		glBegin(GL_LINES);
		// Front Face

		//Set tint.
		glColor3f(color.r, color.g, color.b);

		glTexCoord2f(left,up);
		glVertex3f(-((mSize.X()/mSize.Y()) * scale.X())/2, -scale.Y()/2, 0.0f);              // Top Left
		glVertex3f(/*mpTexture->getRatio()*/((mSize.X()/mSize.Y()) * scale.X())/2, -scale.Y()/2, 0.0f);

		glTexCoord2f(right,up);
		glVertex3f(/*mpTexture->getRatio()*/((mSize.X()/mSize.Y()) * scale.X())/2, -scale.Y()/2, 0.0f);              // Top Right
		glVertex3f( /*mpTexture->getRatio()*/((mSize.X()/mSize.Y()) * scale.X())/2, scale.Y()/2, 0.0f);

		glTexCoord2f(right,down);
		glVertex3f( /*mpTexture->getRatio()*/((mSize.X()/mSize.Y()) * scale.X())/2, scale.Y()/2, 0.0f);              // Bottom Right
		glVertex3f(-((mSize.X()/mSize.Y()) * scale.X())/2,scale.Y()/2, 0.0f);

		glTexCoord2f(left,down);
		glVertex3f(-((mSize.X()/mSize.Y()) * scale.X())/2,scale.Y()/2, 0.0f);              // Bottom Left
		glVertex3f(-((mSize.X()/mSize.Y()) * scale.X())/2, -scale.Y()/2, 0.0f);

		glEnd();

		glEnable(GL_TEXTURE_2D);
	}

	glPopMatrix();

	// restores the modelview matrix
	glPopMatrix();

	glPopMatrix();
}