Improve quotes / code blocks geometries.

This commit is contained in:
John Preston 2023-10-13 18:24:22 +04:00
parent 9661bac876
commit 575684670c
11 changed files with 29 additions and 30 deletions

View File

@ -1622,8 +1622,8 @@ void Message::paintText(
.position = trect.topLeft(),
.availableWidth = trect.width(),
.palette = &stm->textPalette,
.pre = stm->preBlockCache.get(),
.blockquote = stm->blockquoteBlockCache.get(),
.pre = stm->preCache.get(),
.blockquote = stm->blockquoteCache.get(),
.colors = context.st->highlightColors(),
.spoiler = Ui::Text::DefaultSpoilerCache(),
.now = context.now,

View File

@ -748,8 +748,8 @@ void Document::draw(
.position = { st::msgPadding.left(), captiontop },
.availableWidth = captionw,
.palette = &stm->textPalette,
.pre = stm->preBlockCache.get(),
.blockquote = stm->blockquoteBlockCache.get(),
.pre = stm->preCache.get(),
.blockquote = stm->blockquoteCache.get(),
.colors = context.st->highlightColors(),
.spoiler = Ui::Text::DefaultSpoilerCache(),
.now = context.now,

View File

@ -235,8 +235,8 @@ void ExtendedPreview::draw(Painter &p, const PaintContext &context) const {
painty + painth + st::mediaCaptionSkip),
.availableWidth = captionw,
.palette = &stm->textPalette,
.pre = stm->preBlockCache.get(),
.blockquote = stm->blockquoteBlockCache.get(),
.pre = stm->preCache.get(),
.blockquote = stm->blockquoteCache.get(),
.colors = context.st->highlightColors(),
.spoiler = Ui::Text::DefaultSpoilerCache(),
.now = context.now,

View File

@ -709,8 +709,8 @@ void Gif::draw(Painter &p, const PaintContext &context) const {
.position = QPoint(st::msgPadding.left(), top),
.availableWidth = captionw,
.palette = &stm->textPalette,
.pre = stm->preBlockCache.get(),
.blockquote = stm->blockquoteBlockCache.get(),
.pre = stm->preCache.get(),
.blockquote = stm->blockquoteCache.get(),
.colors = context.st->highlightColors(),
.spoiler = Ui::Text::DefaultSpoilerCache(),
.now = context.now,

View File

@ -367,8 +367,8 @@ void GroupedMedia::draw(Painter &p, const PaintContext &context) const {
captiony),
.availableWidth = captionw,
.palette = &stm->textPalette,
.pre = stm->preBlockCache.get(),
.blockquote = stm->blockquoteBlockCache.get(),
.pre = stm->preCache.get(),
.blockquote = stm->blockquoteCache.get(),
.colors = context.st->highlightColors(),
.spoiler = Ui::Text::DefaultSpoilerCache(),
.now = context.now,

View File

@ -405,8 +405,8 @@ void Photo::draw(Painter &p, const PaintContext &context) const {
.position = QPoint(st::msgPadding.left(), top),
.availableWidth = captionw,
.palette = &stm->textPalette,
.pre = stm->preBlockCache.get(),
.blockquote = stm->blockquoteBlockCache.get(),
.pre = stm->preCache.get(),
.blockquote = stm->blockquoteCache.get(),
.colors = context.st->highlightColors(),
.spoiler = Ui::Text::DefaultSpoilerCache(),
.now = context.now,

View File

@ -78,8 +78,8 @@ private:
[[nodiscard]] style::font scaled(
const style::font &value,
int size) const;
[[nodiscard]] style::ParagraphStyle scaled(
const style::ParagraphStyle &value) const;
[[nodiscard]] style::QuoteStyle scaled(
const style::QuoteStyle &value) const;
[[nodiscard]] style::TextStyle scaled(
const style::TextStyle &value,
int fontSize) const;
@ -327,8 +327,7 @@ style::font Preview::scaled(const style::font &font, int size) const {
return style::font(scaled(size), font->flags(), font->family());
}
style::ParagraphStyle Preview::scaled(
const style::ParagraphStyle &value) const {
style::QuoteStyle Preview::scaled(const style::QuoteStyle &value) const {
return {
.padding = scaled(value.padding),
.verticalSkip = scaled(value.verticalSkip),

View File

@ -40,19 +40,19 @@ msgDateDelta: point(2px, 5px);
msgDateImgDelta: 4px;
msgDateImgPadding: point(8px, 2px);
messageParagraphStyle: ParagraphStyle(defaultParagraphStyle) {
messageQuoteStyle: QuoteStyle(defaultQuoteStyle) {
padding: margins(10px, 2px, 4px, 2px);
verticalSkip: 4px;
outline: 3px;
radius: 5px;
}
messageTextStyle: TextStyle(defaultTextStyle) {
blockquote: ParagraphStyle(messageParagraphStyle) {
blockquote: QuoteStyle(messageQuoteStyle) {
padding: margins(10px, 2px, 20px, 2px);
icon: icon{{ "chat/mini_quote", windowFg }};
iconPosition: point(4px, 2px);
}
pre: ParagraphStyle(messageParagraphStyle) {
pre: QuoteStyle(messageQuoteStyle) {
header: 20px;
headerPosition: point(10px, 2px);
scrollable: true;

View File

@ -30,12 +30,12 @@ void EnsureCorners(
}
void EnsureBlockquoteCache(
std::unique_ptr<Text::BlockPaintCache> &cache,
std::unique_ptr<Text::QuotePaintCache> &cache,
const style::color &color) {
if (cache) {
return;
}
cache = std::make_unique<Text::BlockPaintCache>();
cache = std::make_unique<Text::QuotePaintCache>();
cache->bg = color->c;
cache->bg.setAlphaF(0.12);
cache->outline = color->c;
@ -44,13 +44,13 @@ void EnsureBlockquoteCache(
}
void EnsurePreCache(
std::unique_ptr<Text::BlockPaintCache> &cache,
std::unique_ptr<Text::QuotePaintCache> &cache,
const style::color &color,
Fn<std::optional<QColor>()> bgOverride) {
if (cache) {
return;
}
cache = std::make_unique<Text::BlockPaintCache>();
cache = std::make_unique<Text::QuotePaintCache>();
const auto bg = bgOverride();
cache->bg = bg.value_or(color->c);
if (!bg) {
@ -521,8 +521,8 @@ void ChatStyle::assignPalette(not_null<const style::palette*> palette) {
for (auto &style : _messageStyles) {
style.msgBgCornersSmall = {};
style.msgBgCornersLarge = {};
style.blockquoteBlockCache = nullptr;
style.preBlockCache = nullptr;
style.blockquoteCache = nullptr;
style.preCache = nullptr;
}
for (auto &style : _imageStyles) {
style.msgDateImgBgCorners = {};
@ -578,7 +578,7 @@ const MessageStyle &ChatStyle::messageStyle(bool outbg, bool selected) const {
result.msgBg,
&result.msgShadow);
EnsureBlockquoteCache(
result.blockquoteBlockCache,
result.blockquoteCache,
result.msgReplyBarColor);
const auto preBgOverride = [&] {
@ -589,7 +589,7 @@ const MessageStyle &ChatStyle::messageStyle(bool outbg, bool selected) const {
return dark ? QColor(0, 0, 0, 192) : std::optional<QColor>();
};
EnsurePreCache(
result.preBlockCache,
result.preCache,
(selected
? result.textPalette.selectMonoFg
: result.textPalette.monoFg),

View File

@ -76,8 +76,8 @@ struct MessageStyle {
style::icon historyPollChoiceRight = { Qt::Uninitialized };
style::icon historyTranscribeIcon = { Qt::Uninitialized };
style::icon historyTranscribeHide = { Qt::Uninitialized };
std::unique_ptr<Text::BlockPaintCache> blockquoteBlockCache;
std::unique_ptr<Text::BlockPaintCache> preBlockCache;
std::unique_ptr<Text::QuotePaintCache> blockquoteCache;
std::unique_ptr<Text::QuotePaintCache> preCache;
};

@ -1 +1 @@
Subproject commit 46465fc5ce14c4ca356870f0a8d51eb0285112a9
Subproject commit 9eb9fcf043276bb3a73f1fc25531e4f4862d6fc9