void InnerDropdown::paintEvent(QPaintEvent *e) {
	Painter p(this);

	if (_a_show.animating()) {
		if (auto opacity = _a_opacity.value(_hiding ? 0. : 1.)) {
			// _a_opacity.current(ms)->opacityAnimationCallback()->_showAnimation.reset()
			if (_showAnimation) {
				_showAnimation->paintFrame(p, 0, 0, width(), _a_show.value(1.), opacity);
			}
		}
	} else if (_a_opacity.animating()) {
		p.setOpacity(_a_opacity.value(0.));
		p.drawPixmap(0, 0, _cache);
	} else if (_hiding || isHidden()) {
		hideFinished();
	} else if (_showAnimation) {
		_showAnimation->paintFrame(p, 0, 0, width(), 1., 1.);
		_showAnimation.reset();
		showChildren();
	} else {
		if (!_cache.isNull()) _cache = QPixmap();
		const auto inner = rect().marginsRemoved(_st.padding);
		Shadow::paint(p, inner, width(), _st.shadow);
		App::roundRect(p, inner, _st.bg, ImageRoundRadius::Small);
	}
}
示例#2
0
void ConfirmPhoneBox::prepare() {

	_about.create(this, st::confirmPhoneAboutLabel);
	TextWithEntities aboutText;
	auto formattedPhone = App::formatPhone(_phone);
	aboutText.text = lng_confirm_phone_about(lt_phone, formattedPhone);
	auto phonePosition = aboutText.text.indexOf(formattedPhone);
	if (phonePosition >= 0) {
		aboutText.entities.push_back(EntityInText(EntityInTextBold, phonePosition, formattedPhone.size()));
	}
	_about->setMarkedText(aboutText);

	_code.create(this, st::confirmPhoneCodeField, lang(lng_code_ph));

	setTitle(lang(lng_confirm_phone_title));

	addButton(lang(lng_confirm_phone_send), [this] { onSendCode(); });
	addButton(lang(lng_cancel), [this] { closeBox(); });

	setDimensions(st::boxWidth, st::usernamePadding.top() + _code->height() + st::usernameSkip + _about->height() + st::usernameSkip);

	connect(_code, SIGNAL(changed()), this, SLOT(onCodeChanged()));
	connect(_code, SIGNAL(submitted(bool)), this, SLOT(onSendCode()));

	connect(_callTimer, SIGNAL(timeout()), this, SLOT(onCallStatusTimer()));

	showChildren();
}
示例#3
0
void PopupMenu::startShowAnimation() {
	if (!_useTransparency) {
		_a_show.finish();
		update();
		return;
	}
	if (!_a_show.animating()) {
		auto opacityAnimation = base::take(_a_opacity);
		showChildren();
		auto cache = grabForPanelAnimation();
		_a_opacity = base::take(opacityAnimation);

		_showAnimation = std::make_unique<PanelAnimation>(_st.animation, _origin);
		_showAnimation->setFinalImage(std::move(cache), QRect(_inner.topLeft() * cIntRetinaFactor(), _inner.size() * cIntRetinaFactor()));
		if (_useTransparency) {
			auto corners = App::cornersMask(ImageRoundRadius::Small);
			_showAnimation->setCornerMasks(QImage(*corners[0]), QImage(*corners[1]), QImage(*corners[2]), QImage(*corners[3]));
		} else {
			_showAnimation->setSkipShadow(true);
		}
		_showAnimation->start();
	}
	hideChildren();
	_a_show.start([this] { showAnimationCallback(); }, 0., 1., _st.showDuration);
}
示例#4
0
void PopupMenu::paintEvent(QPaintEvent *e) {
	Painter p(this);

#ifdef OS_MAC_OLD
	p.setCompositionMode(QPainter::CompositionMode_Source);
	p.fillRect(e->rect(), Qt::transparent);
	p.setCompositionMode(QPainter::CompositionMode_SourceOver);
#endif // OS_MAC_OLD

	auto ms = getms();
	if (_a_show.animating(ms)) {
		if (auto opacity = _a_opacity.current(ms, _hiding ? 0. : 1.)) {
			_showAnimation->paintFrame(p, 0, 0, width(), _a_show.current(1.), opacity);
		}
	} else if (_a_opacity.animating(ms)) {
		p.setOpacity(_a_opacity.current(0.));
		p.drawPixmap(0, 0, _cache);
	} else if (_hiding || isHidden()) {
		hideFinished();
	} else if (_showAnimation) {
		_showAnimation->paintFrame(p, 0, 0, width(), 1., 1.);
		_showAnimation.reset();
		showChildren();
	} else {
		paintBg(p);
	}
}
void WarningWidget::paintEvent(QPaintEvent *e) {
	Painter p(this);

	if (!_cache.isNull()) {
		if (!_animation.animating()) {
			if (isHidden()) {
				return;
			}
		}
		p.setOpacity(_animation.value(_hiding ? 0. : 1.));
		p.drawPixmap(_outer.topLeft(), _cache);
		if (!_animation.animating()) {
			_cache = QPixmap();
			showChildren();
			_started = crl::now();
			_timer.callOnce(100);
		}
		return;
	}

	Ui::Shadow::paint(p, _inner, width(), st::boxRoundShadow);
	App::roundRect(p, _inner, st::boxBg, BoxCorners);

	p.setFont(st::boxTitleFont);
	p.setPen(st::boxTitleFg);
	p.drawTextLeft(_inner.x() + st::boxTitlePosition.x(), _inner.y() + st::boxTitlePosition.y(), width(), lang(lng_theme_sure_keep));

	p.setFont(st::boxTextFont);
	p.setPen(st::boxTextFg);
	p.drawTextLeft(_inner.x() + st::boxTitlePosition.x(), _inner.y() + st::themeWarningTextTop, width(), _text);
}
void BookmarkFolder::buttonClicked(Button* btnThatClicked)
{
    if (btnThatClicked == triBtn)
    {
        bExpanded = triBtn->getArrowDirection() == 0.0f;
    }
    bExpanded ? showChildren() : hideChildren();
    setNewSize();
}
示例#7
0
void SectionWidget::showFinished() {
	_showAnimation.reset();
	if (isHidden()) return;

	showChildren();
	showFinishedHook();

	setInnerFocus();
}
void InnerDropdown::showFast() {
	_hideTimer.stop();
	finishAnimating();
	if (isHidden()) {
		showChildren();
		show();
	}
	_hiding = false;
}
示例#9
0
void PopupMenu::prepareCache() {
	if (_a_opacity.animating()) return;

	auto showAnimation = base::take(_a_show);
	auto showAnimationData = base::take(_showAnimation);
	showChildren();
	_cache = myGrab(this);
	_showAnimation = base::take(showAnimationData);
	_a_show = base::take(showAnimation);
}
示例#10
0
void InnerDropdown::startAnimation() {
	auto from = _hiding ? 1. : 0.;
	auto to = _hiding ? 0. : 1.;
	if (!_a_appearance.animating()) {
		showChildren();
		_cache = myGrab(this);
	}
	hideChildren();
	_a_appearance.start([this] { repaintCallback(); }, from, to, _st.duration);
}
示例#11
0
void PopupMenu::opacityAnimationCallback() {
	update();
	if (!_a_opacity.animating()) {
		if (_hiding) {
			_hiding = false;
			hideFinished();
		} else {
			showChildren();
		}
	}
}
示例#12
0
void InnerDropdown::opacityAnimationCallback() {
	update();
	if (!_a_opacity.animating()) {
		if (_hiding) {
			_hiding = false;
			hideFinished();
		} else if (!_a_show.animating()) {
			showChildren();
		}
	}
}
示例#13
0
void AddContactBox::onRetry() {
	_addRequest = 0;
	_contactId = 0;
	showChildren();
	_retrying = false;
	updateButtons();
	_first->setText(QString());
	_last->setText(QString());
	_phone->clearText();
	_phone->setDisabled(false);
	_first->setFocus();
	update();
}
示例#14
0
void InnerDropdown::prepareCache() {
	if (_a_opacity.animating()) return;

	auto showAnimation = base::take(_a_show);
	auto showAnimationData = base::take(_showAnimation);
	showChildren();
	_cache = GrabWidget(this);
	_showAnimation = base::take(showAnimationData);
	_a_show = base::take(showAnimation);
	if (_a_show.animating()) {
		hideChildren();
	}
}
void Controller::paintEvent(QPaintEvent *e) {
	Painter p(this);

	if (_fadeAnimation->paint(p)) {
		return;
	}
	if (_childrenHidden) {
		showChildren();
		_playbackSlider->setFadeOpacity(1.);
		_childrenHidden = false;
	}
	App::roundRect(p, rect(), st::mediaviewSaveMsgBg, MediaviewSaveCorners);
}
示例#16
0
Map2::MapGroup::~MapGroup()
{
	pParent->pChildGroups.removeAll(this);

	if(dtorPolicy() == DP_ShowChildren)
	{
		showChildren();

		foreach(MapObject *obj, mChildren)
		{
			obj->pParentGroup = 0;
		}

	}
示例#17
0
void InnerDropdown::finishAnimating() {
	if (_a_show.animating()) {
		_a_show.stop();
		showAnimationCallback();
	}
	if (_showAnimation) {
		_showAnimation.reset();
		showChildren();
	}
	if (_a_opacity.animating()) {
		_a_opacity.stop();
		opacityAnimationCallback();
	}
}
示例#18
0
void SectionWidget::showAnimated(SlideDirection direction, const SectionSlideParams &params) {
	if (_showAnimation) return;

	showChildren();
	auto myContentCache = grabForShowAnimation(params);
	hideChildren();
	showAnimatedHook();

	_showAnimation = std_::make_unique<SlideAnimation>();
	_showAnimation->setDirection(direction);
	_showAnimation->setRepaintCallback([this] { update(); });
	_showAnimation->setFinishedCallback([this] { showFinished(); });
	_showAnimation->setPixmaps(params.oldContentCache, myContentCache);
	_showAnimation->setTopBarShadow(params.withTopBarShadow);
	_showAnimation->start();

	show();
}
void Controller::startFading(Callback start) {
	if (!_fadeAnimation->animating()) {
		showChildren();
		_playbackSlider->disablePaint(true);
		_childrenHidden = false;
	}
	start();
	if (_fadeAnimation->animating()) {
		for (const auto child : children()) {
			if (child->isWidgetType() && child != _playbackSlider) {
				static_cast<QWidget*>(child)->hide();
			}
		}
		_childrenHidden = true;
	} else {
		fadeFinished();
	}
	_playbackSlider->disablePaint(false);
}
void WarningWidget::startAnimation(bool hiding) {
	_timer.cancel();
	_hiding = hiding;
	if (_cache.isNull()) {
		showChildren();
		Ui::SendPendingMoveResizeEvents(this);
		_cache = Ui::GrabWidget(this, _outer);
	}
	hideChildren();
	_animation.start([this] {
		update();
		if (_hiding) {
			hide();
			if (_hiddenCallback) {
				_hiddenCallback();
			}
		}
	}, _hiding ? 1. : 0., _hiding ? 0. : 1., st::boxDuration);
}
示例#21
0
void WarningWidget::startAnimation(bool hiding) {
	_timer.stop();
	_hiding = hiding;
	if (_cache.isNull()) {
		showChildren();
		myEnsureResized(this);
		_cache = myGrab(this, _outer);
	}
	hideChildren();
	_animation.start([this] {
		update();
		if (_hiding) {
			hide();
			if (_hiddenCallback) {
				_hiddenCallback();
			}
		}
	}, _hiding ? 1. : 0., _hiding ? 0. : 1., st::boxDuration);
}
示例#22
0
void InnerDropdown::startShowAnimation() {
	if (_showStartCallback) {
		_showStartCallback();
	}
	if (!_a_show.animating()) {
		auto opacityAnimation = base::take(_a_opacity);
		showChildren();
		auto cache = grabForPanelAnimation();
		_a_opacity = base::take(opacityAnimation);

		_showAnimation = std::make_unique<PanelAnimation>(_st.animation, _origin);
		auto inner = rect().marginsRemoved(_st.padding);
		_showAnimation->setFinalImage(std::move(cache), QRect(inner.topLeft() * cIntRetinaFactor(), inner.size() * cIntRetinaFactor()));
		auto corners = App::cornersMask(ImageRoundRadius::Small);
		_showAnimation->setCornerMasks(corners[0], corners[1], corners[2], corners[3]);
		_showAnimation->start();
	}
	hideChildren();
	_a_show.start([this] { showAnimationCallback(); }, 0., 1., _st.showDuration);
}
示例#23
0
void InnerDropdown::paintEvent(QPaintEvent *e) {
	Painter p(this);

	if (!_cache.isNull()) {
		bool animating = _a_appearance.animating(getms());
		if (animating) {
			p.setOpacity(_a_appearance.current(_hiding));
		} else if (_hiding) {
			hidingFinished();
			return;
		}
		p.drawPixmap(0, 0, _cache);
		if (!animating) {
			showChildren();
			_cache = QPixmap();
		}
		return;
	}

	// draw shadow
	QRect shadowedRect = rect().marginsRemoved(_st.padding);
	_shadow.paint(p, shadowedRect, _st.shadowShift);
	p.fillRect(shadowedRect, st::windowBg);
}
示例#24
0
void LocalStorageBox::showAll() {
	showChildren();
	_clear->setVisible(_imagesCount > 0 || _audiosCount > 0);
}