Пример #1
0
void ScrollArea::onScrolled() {
	myEnsureResized(widget());

	bool em = false;
	int32 horValue = horizontalScrollBar()->value(), vertValue = verticalScrollBar()->value();
	if (_horValue != horValue) {
		if (_disabled) {
			horizontalScrollBar()->setValue(_horValue);
		} else {
			_horValue = horValue;
			if (_st.hiding) {
				hor.hideTimeout(_st.hiding);
			}
			em = true;
		}
	}
	if (_vertValue != vertValue) {
		if (_disabled) {
			verticalScrollBar()->setValue(_vertValue);
		} else {
			_vertValue = vertValue;
			if (_st.hiding) {
				vert.hideTimeout(_st.hiding);
			}
			em = true;
		}
	}
	if (em) emit scrolled();
}
Пример #2
0
void ScrollArea::onScrolled() {
	myEnsureResized(widget());

	bool em = false;
	int horizontalValue = horizontalScrollBar()->value();
	int verticalValue = verticalScrollBar()->value();
	if (_horizontalValue != horizontalValue) {
		if (_disabled) {
			horizontalScrollBar()->setValue(_horizontalValue);
		} else {
			_horizontalValue = horizontalValue;
			if (_st.hiding) {
				_horizontalBar->hideTimeout(_st.hiding);
			}
			em = true;
		}
	}
	if (_verticalValue != verticalValue) {
		if (_disabled) {
			verticalScrollBar()->setValue(_verticalValue);
		} else {
			_verticalValue = verticalValue;
			if (_st.hiding) {
				_verticalBar->hideTimeout(_st.hiding);
			}
			em = true;
		}
	}
	if (em) {
		emit scrolled();
		if (!_movingByScrollBar) {
			sendSynteticMouseEvent(this, QEvent::MouseMove, Qt::NoButton);
		}
	}
}
Пример #3
0
QPixmap myGrab(QWidget *target, const QRect &rect) {
    if (!cRetina()) return target->grab(rect);
    
	myEnsureResized(target);
    
    qreal dpr = App::app()->devicePixelRatio();
    QPixmap result(rect.size() * dpr);
    result.setDevicePixelRatio(dpr);
    result.fill(Qt::transparent);
    target->render(&result, QPoint(), QRegion(rect), QWidget::DrawWindowBackground | QWidget::DrawChildren | QWidget::IgnoreMask);
    return result;
}
Пример #4
0
QPixmap myGrab(TWidget *target, QRect rect) {
	myEnsureResized(target);
	if (rect.isNull()) rect = target->rect();

    QPixmap result(rect.size() * cRetinaFactor());
    result.setDevicePixelRatio(cRetinaFactor());
    result.fill(Qt::transparent);

	target->grabStart();
    target->render(&result, QPoint(), QRegion(rect), QWidget::DrawChildren | QWidget::IgnoreMask);
	target->grabFinish();

	return result;
}
Пример #5
0
QImage InnerDropdown::grabForPanelAnimation() {
	myEnsureResized(this);
	auto result = QImage(size() * cIntRetinaFactor(), QImage::Format_ARGB32_Premultiplied);
	result.setDevicePixelRatio(cRetinaFactor());
	result.fill(Qt::transparent);
	{
		Painter p(&result);
		App::roundRect(p, rect().marginsRemoved(_st.padding), _st.bg, ImageRoundRadius::Small);
		for (auto child : children()) {
			if (auto widget = qobject_cast<QWidget*>(child)) {
				widget->render(&p, widget->pos(), widget->rect(), QWidget::DrawChildren | QWidget::IgnoreMask);
			}
		}
	}
	return result;
}
Пример #6
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);
}
Пример #7
0
bool FlatTextarea::heightAutoupdated() {
	if (_minHeight < 0 || _maxHeight < 0 || _inHeightCheck) return false;
	_inHeightCheck = true;

	myEnsureResized(this);

	int newh = ceil(document()->size().height()) + 2 * fakeMargin();
	if (newh > _maxHeight) {
		newh = _maxHeight;
	} else if (newh < _minHeight) {
		newh = _minHeight;
	}
	if (height() != newh) {
		resize(width(), newh);
		_inHeightCheck = false;
		return true;
	}
	_inHeightCheck = false;
	return false;
}
Пример #8
0
QImage PopupMenu::grabForPanelAnimation() {
	myEnsureResized(this);
	auto result = QImage(size() * cIntRetinaFactor(), QImage::Format_ARGB32_Premultiplied);
	result.setDevicePixelRatio(cRetinaFactor());
	result.fill(Qt::transparent);
	{
		Painter p(&result);
		if (_useTransparency) {
			App::roundRect(p, _inner, _st.menu.itemBg, ImageRoundRadius::Small);
		} else {
			p.fillRect(_inner, _st.menu.itemBg);
		}
		for (auto child : children()) {
			if (auto widget = qobject_cast<QWidget*>(child)) {
				widget->render(&p, widget->pos(), widget->rect(), QWidget::DrawChildren | QWidget::IgnoreMask);
			}
		}
	}
	return result;
}
Пример #9
0
void ScrollArea::scrollToY(int toTop, int toBottom) {
	myEnsureResized(widget());

	int toMin = 0, toMax = scrollTopMax();
	if (toTop < toMin) {
		toTop = toMin;
	} else if (toTop > toMax) {
		toTop = toMax;
	}
	bool exact = (toBottom < 0);

	int curTop = scrollTop(), curHeight = height(), curBottom = curTop + curHeight, scToTop = toTop;
	if (!exact && toTop >= curTop) {
		if (toBottom < toTop) toBottom = toTop;
		if (toBottom <= curBottom) return;

		scToTop = toBottom - curHeight;
		if (scToTop > toTop) scToTop = toTop;
		if (scToTop == curTop) return;
	} else {
		scToTop = toTop;
	}
	verticalScrollBar()->setValue(scToTop);
}
Пример #10
0
void Widget::setInternalState(const SectionMemento *memento) {
	myEnsureResized(this);
	_scroll->scrollToY(memento->_scrollTop);
	_fixedBarShadow->setMode(memento->_scrollTop > 0 ? ToggleableShadow::Mode::ShownFast : ToggleableShadow::Mode::HiddenFast);
}