mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-17 22:57:11 +02:00
Improve quotes / code blocks geometries.
This commit is contained in:
parent
9661bac876
commit
575684670c
11 changed files with 29 additions and 30 deletions
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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),
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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),
|
||||
|
|
|
@ -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
|
Loading…
Add table
Reference in a new issue