mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Slightly improved sponsored message bar for instant display.
This commit is contained in:
parent
6bc8daaeda
commit
8b535c58fa
1 changed files with 14 additions and 10 deletions
|
@ -95,7 +95,7 @@ public:
|
||||||
int colorIndex) {
|
int colorIndex) {
|
||||||
const auto controller = FindSessionController(widget);
|
const auto controller = FindSessionController(widget);
|
||||||
if (!controller) {
|
if (!controller) {
|
||||||
return [] -> Colors {
|
return []() -> Colors {
|
||||||
return { st::windowBgActive->c, st::windowActiveTextFg->c };
|
return { st::windowBgActive->c, st::windowActiveTextFg->c };
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -111,7 +111,7 @@ public:
|
||||||
state->theme = std::move(theme);
|
state->theme = std::move(theme);
|
||||||
}, widget->lifetime());
|
}, widget->lifetime());
|
||||||
|
|
||||||
return [=] -> Colors {
|
return [=]() -> Colors {
|
||||||
if (!state->theme) {
|
if (!state->theme) {
|
||||||
return { st::windowBgActive->c, st::windowActiveTextFg->c };
|
return { st::windowBgActive->c, st::windowActiveTextFg->c };
|
||||||
}
|
}
|
||||||
|
@ -183,10 +183,8 @@ void FillSponsoredMessageBar(
|
||||||
.customEmojiRepaint = [=] { widget->update(); },
|
.customEmojiRepaint = [=] { widget->update(); },
|
||||||
});
|
});
|
||||||
const auto kLinesForPhoto = 3;
|
const auto kLinesForPhoto = 3;
|
||||||
const auto rightPhotoSize = titleSt.font->ascent
|
const auto rightPhotoSize = titleSt.font->ascent * kLinesForPhoto;
|
||||||
* kLinesForPhoto;
|
const auto rightPhotoPlaceholder = titleSt.font->height * kLinesForPhoto;
|
||||||
const auto rightPhotoPlaceholder = titleSt.font->height
|
|
||||||
* kLinesForPhoto;
|
|
||||||
const auto hasRightPhoto = from.photoId > 0;
|
const auto hasRightPhoto = from.photoId > 0;
|
||||||
if (hasRightPhoto) {
|
if (hasRightPhoto) {
|
||||||
state->rightPhoto = Ui::MakePhotoThumbnail(
|
state->rightPhoto = Ui::MakePhotoThumbnail(
|
||||||
|
@ -221,9 +219,7 @@ void FillSponsoredMessageBar(
|
||||||
});
|
});
|
||||||
removeButton->show();
|
removeButton->show();
|
||||||
|
|
||||||
widget->paintRequest(
|
const auto draw = [=](QPainter &p) {
|
||||||
) | rpl::start_with_next([=] {
|
|
||||||
auto p = QPainter(widget);
|
|
||||||
const auto r = widget->rect();
|
const auto r = widget->rect();
|
||||||
p.fillRect(r, st::historyPinnedBg);
|
p.fillRect(r, st::historyPinnedBg);
|
||||||
widget->paintRipple(p, 0, 0);
|
widget->paintRipple(p, 0, 0);
|
||||||
|
@ -327,6 +323,10 @@ void FillSponsoredMessageBar(
|
||||||
topPadding + (rightPhotoPlaceholder - rightPhotoSize) / 2,
|
topPadding + (rightPhotoPlaceholder - rightPhotoSize) / 2,
|
||||||
state->rightPhotoImage);
|
state->rightPhotoImage);
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
widget->paintRequest() | rpl::start_with_next([=] {
|
||||||
|
auto p = QPainter(widget);
|
||||||
|
draw(p);
|
||||||
}, widget->lifetime());
|
}, widget->lifetime());
|
||||||
rpl::combine(
|
rpl::combine(
|
||||||
state->lastPaintedContentTop.value(),
|
state->lastPaintedContentTop.value(),
|
||||||
|
@ -348,7 +348,11 @@ void FillSponsoredMessageBar(
|
||||||
minHeight,
|
minHeight,
|
||||||
st::sponsoredMessageBarMaxHeight));
|
st::sponsoredMessageBarMaxHeight));
|
||||||
}, widget->lifetime());
|
}, widget->lifetime());
|
||||||
container->resize(widget->width(), 1);
|
{ // Calculate a good size for container.
|
||||||
|
auto dummy = QImage(1, 1, QImage::Format_ARGB32);
|
||||||
|
auto p = QPainter(&dummy);
|
||||||
|
draw(p);
|
||||||
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
const auto top = Ui::CreateChild<PlainShadow>(widget);
|
const auto top = Ui::CreateChild<PlainShadow>(widget);
|
||||||
|
|
Loading…
Add table
Reference in a new issue