mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Improve popup menu dimensions.
This commit is contained in:
parent
a377364621
commit
2733b12cff
1 changed files with 25 additions and 15 deletions
|
@ -233,14 +233,6 @@ Action::Action(
|
||||||
|
|
||||||
setAcceptBoth(true);
|
setAcceptBoth(true);
|
||||||
initResizeHook(parent->sizeValue());
|
initResizeHook(parent->sizeValue());
|
||||||
resolveMinWidth();
|
|
||||||
|
|
||||||
_userpics->widthValue(
|
|
||||||
) | rpl::start_with_next([=](int width) {
|
|
||||||
_userpicsWidth = width;
|
|
||||||
refreshDimensions();
|
|
||||||
update();
|
|
||||||
}, lifetime());
|
|
||||||
|
|
||||||
std::move(
|
std::move(
|
||||||
content
|
content
|
||||||
|
@ -263,6 +255,15 @@ Action::Action(
|
||||||
update();
|
update();
|
||||||
}, lifetime());
|
}, lifetime());
|
||||||
|
|
||||||
|
resolveMinWidth();
|
||||||
|
|
||||||
|
_userpics->widthValue(
|
||||||
|
) | rpl::start_with_next([=](int width) {
|
||||||
|
_userpicsWidth = width;
|
||||||
|
refreshDimensions();
|
||||||
|
update();
|
||||||
|
}, lifetime());
|
||||||
|
|
||||||
paintRequest(
|
paintRequest(
|
||||||
) | rpl::start_with_next([=] {
|
) | rpl::start_with_next([=] {
|
||||||
Painter p(this);
|
Painter p(this);
|
||||||
|
@ -295,14 +296,20 @@ void Action::resolveMinWidth() {
|
||||||
const auto width = [&](const QString &text) {
|
const auto width = [&](const QString &text) {
|
||||||
return _st.itemStyle.font->width(text);
|
return _st.itemStyle.font->width(text);
|
||||||
};
|
};
|
||||||
const auto maxTextWidth = std::max({
|
const auto maxText = (_content.type == WhoReadType::Listened)
|
||||||
width(tr::lng_context_seen_reacted(
|
? tr::lng_context_seen_listened(tr::now, lt_count, 999)
|
||||||
|
: (_content.type == WhoReadType::Watched)
|
||||||
|
? tr::lng_context_seen_watched(tr::now, lt_count, 999)
|
||||||
|
: (_content.type == WhoReadType::Seen)
|
||||||
|
? tr::lng_context_seen_text(tr::now, lt_count, 999)
|
||||||
|
: QString();
|
||||||
|
const auto maxReacted = (_content.fullReactionsCount > 0)
|
||||||
|
? tr::lng_context_seen_reacted(
|
||||||
tr::now,
|
tr::now,
|
||||||
lt_count_short,
|
lt_count_short,
|
||||||
999'999'999)),
|
_content.fullReactionsCount)
|
||||||
width(tr::lng_context_seen_text(tr::now, lt_count, 999)),
|
: QString();
|
||||||
width(tr::lng_context_seen_listened(tr::now, lt_count, 999)),
|
const auto maxTextWidth = std::max(width(maxText), width(maxReacted));
|
||||||
width(tr::lng_context_seen_watched(tr::now, lt_count, 999)) });
|
|
||||||
const auto maxWidth = st::defaultWhoRead.itemPadding.left()
|
const auto maxWidth = st::defaultWhoRead.itemPadding.left()
|
||||||
+ maxIconWidth
|
+ maxIconWidth
|
||||||
+ maxTextWidth
|
+ maxTextWidth
|
||||||
|
@ -480,6 +487,9 @@ void Action::refreshText() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Action::refreshDimensions() {
|
void Action::refreshDimensions() {
|
||||||
|
if (!minWidth()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
const auto textWidth = _text.maxWidth();
|
const auto textWidth = _text.maxWidth();
|
||||||
const auto &padding = st::defaultWhoRead.itemPadding;
|
const auto &padding = st::defaultWhoRead.itemPadding;
|
||||||
|
|
||||||
|
@ -491,7 +501,7 @@ void Action::refreshDimensions() {
|
||||||
const auto w = std::clamp(
|
const auto w = std::clamp(
|
||||||
goodWidth,
|
goodWidth,
|
||||||
_st.widthMin,
|
_st.widthMin,
|
||||||
minWidth());
|
std::max(minWidth(), _st.widthMin));
|
||||||
_textWidth = w - (goodWidth - textWidth);
|
_textWidth = w - (goodWidth - textWidth);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue