2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-31 14:45:14 +00:00

Most of the new Settings sections filled with widgets.

Some animations added: new scale slider, widget_slide_wrap<TWidget>.
Any TWidget now can resizeToWidth() with overriden resizeGetHeight().
This commit is contained in:
John Preston
2016-08-22 19:16:21 +02:00
parent b9e22f59a1
commit 993b91ac15
50 changed files with 1516 additions and 181 deletions

View File

@@ -60,6 +60,9 @@ void InnerWidget::refreshBlocks() {
_blocks.push_back(new Settings::PrivacyWidget(this, _self));
}
_blocks.push_back(new Settings::AdvancedWidget(this, _self));
for_const (auto block, _blocks) {
connect(block, SIGNAL(heightUpdated()), this, SLOT(onBlockHeightUpdated()));
}
}
void InnerWidget::showFinished() {
@@ -68,32 +71,40 @@ void InnerWidget::showFinished() {
}
}
void InnerWidget::resizeToWidth(int newWidth, int contentLeft) {
int newHeight = resizeGetHeight(newWidth, contentLeft);
resize(newWidth, newHeight);
int InnerWidget::resizeGetHeight(int newWidth) {
if (_cover) {
_cover->setContentLeft(_contentLeft);
_cover->resizeToWidth(newWidth);
}
for_const (auto block, _blocks) {
block->setContentLeft(_contentLeft);
block->resizeToWidth(newWidth);
}
int result = refreshBlocksPositions();
return result;
}
int InnerWidget::resizeGetHeight(int newWidth, int contentLeft) {
int result = 0;
if (_cover) {
_cover->setContentLeft(contentLeft);
_cover->resizeToWidth(newWidth);
result += _cover->height();
}
result += st::settingsBlocksTop;
int InnerWidget::refreshBlocksPositions() {
int result = (_cover ? _cover->height() : 0) + st::settingsBlocksTop;
for_const (auto block, _blocks) {
if (block->isHidden()) {
continue;
}
block->moveToLeft(0, result);
block->setContentLeft(contentLeft);
block->resizeToWidth(newWidth);
result += block->height();
}
return result;
}
void InnerWidget::onBlockHeightUpdated() {
int newHeight = refreshBlocksPositions();
if (newHeight != height()) {
resize(width(), newHeight);
}
}
void InnerWidget::setVisibleTopBottom(int visibleTop, int visibleBottom) {
_visibleTop = visibleTop;
_visibleBottom = visibleBottom;