mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Allow more file attach layout customization.
This commit is contained in:
parent
b13471672d
commit
dd52c53ec0
5 changed files with 28 additions and 23 deletions
|
@ -138,8 +138,8 @@ QSize Contact::countOptimalSize() {
|
||||||
|
|
||||||
const auto &st = _userId ? st::msgFileThumbLayout : st::msgFileLayout;
|
const auto &st = _userId ? st::msgFileThumbLayout : st::msgFileLayout;
|
||||||
|
|
||||||
const auto tleft = st.padding.left() + st.thumbSize + st.padding.right();
|
const auto tleft = st.padding.left() + st.thumbSize + st.thumbSkip;
|
||||||
const auto tright = st.padding.left();
|
const auto tright = st.padding.right();
|
||||||
if (_userId) {
|
if (_userId) {
|
||||||
accumulate_max(maxWidth, tleft + _phonew + tright);
|
accumulate_max(maxWidth, tleft + _phonew + tright);
|
||||||
} else {
|
} else {
|
||||||
|
@ -168,9 +168,9 @@ void Contact::draw(Painter &p, const PaintContext &context) const {
|
||||||
|
|
||||||
const auto &st = _userId ? st::msgFileThumbLayout : st::msgFileLayout;
|
const auto &st = _userId ? st::msgFileThumbLayout : st::msgFileLayout;
|
||||||
const auto topMinus = isBubbleTop() ? 0 : st::msgFileTopMinus;
|
const auto topMinus = isBubbleTop() ? 0 : st::msgFileTopMinus;
|
||||||
const auto nameleft = st.padding.left() + st.thumbSize + st.padding.right();
|
const auto nameleft = st.padding.left() + st.thumbSize + st.thumbSkip;
|
||||||
const auto nametop = st.nameTop - topMinus;
|
const auto nametop = st.nameTop - topMinus;
|
||||||
const auto nameright = st.padding.left();
|
const auto nameright = st.padding.right();
|
||||||
const auto statustop = st.statusTop - topMinus;
|
const auto statustop = st.statusTop - topMinus;
|
||||||
const auto linkshift = st::msgDateFont->height / 2;
|
const auto linkshift = st::msgDateFont->height / 2;
|
||||||
const auto linktop = st.linkTop - topMinus - linkshift;
|
const auto linktop = st.linkTop - topMinus - linkshift;
|
||||||
|
@ -216,7 +216,7 @@ TextState Contact::textState(QPoint point, StateRequest request) const {
|
||||||
if (_userId) {
|
if (_userId) {
|
||||||
const auto &st = _userId ? st::msgFileThumbLayout : st::msgFileLayout;
|
const auto &st = _userId ? st::msgFileThumbLayout : st::msgFileLayout;
|
||||||
const auto topMinus = isBubbleTop() ? 0 : st::msgFileTopMinus;
|
const auto topMinus = isBubbleTop() ? 0 : st::msgFileTopMinus;
|
||||||
const auto nameleft = st.padding.left() + st.thumbSize + st.padding.right();
|
const auto nameleft = st.padding.left() + st.thumbSize + st.thumbSkip;
|
||||||
const auto linkshift = st::msgDateFont->height / 2;
|
const auto linkshift = st::msgDateFont->height / 2;
|
||||||
const auto linktop = st.linkTop - topMinus - linkshift;
|
const auto linktop = st.linkTop - topMinus - linkshift;
|
||||||
if (style::rtlrect(nameleft, linktop, _linkw, st::semiboldFont->height, width()).contains(point)) {
|
if (style::rtlrect(nameleft, linktop, _linkw, st::semiboldFont->height, width()).contains(point)) {
|
||||||
|
|
|
@ -337,8 +337,8 @@ QSize Document::countOptimalSize() {
|
||||||
|
|
||||||
auto maxWidth = st::msgFileMinWidth;
|
auto maxWidth = st::msgFileMinWidth;
|
||||||
|
|
||||||
const auto tleft = st.padding.left() + st.thumbSize + st.padding.right();
|
const auto tleft = st.padding.left() + st.thumbSize + st.thumbSkip;
|
||||||
const auto tright = st.padding.left();
|
const auto tright = st.padding.right();
|
||||||
if (thumbed) {
|
if (thumbed) {
|
||||||
accumulate_max(maxWidth, tleft + MaxStatusWidth(_data) + tright);
|
accumulate_max(maxWidth, tleft + MaxStatusWidth(_data) + tright);
|
||||||
} else {
|
} else {
|
||||||
|
@ -458,9 +458,9 @@ void Document::draw(
|
||||||
const auto &st = (mode == LayoutMode::Full)
|
const auto &st = (mode == LayoutMode::Full)
|
||||||
? (thumbed ? st::msgFileThumbLayout : st::msgFileLayout)
|
? (thumbed ? st::msgFileThumbLayout : st::msgFileLayout)
|
||||||
: (thumbed ? st::msgFileThumbLayoutGrouped : st::msgFileLayoutGrouped);
|
: (thumbed ? st::msgFileThumbLayoutGrouped : st::msgFileLayoutGrouped);
|
||||||
const auto nameleft = st.padding.left() + st.thumbSize + st.padding.right();
|
const auto nameleft = st.padding.left() + st.thumbSize + st.thumbSkip;
|
||||||
const auto nametop = st.nameTop - topMinus;
|
const auto nametop = st.nameTop - topMinus;
|
||||||
const auto nameright = st.padding.left();
|
const auto nameright = st.padding.right();
|
||||||
const auto statustop = st.statusTop - topMinus;
|
const auto statustop = st.statusTop - topMinus;
|
||||||
const auto linktop = st.linkTop - topMinus;
|
const auto linktop = st.linkTop - topMinus;
|
||||||
const auto bottom = st.padding.top() + st.thumbSize + st.padding.bottom() - topMinus;
|
const auto bottom = st.padding.top() + st.thumbSize + st.padding.bottom() - topMinus;
|
||||||
|
@ -852,9 +852,9 @@ TextState Document::textState(
|
||||||
const auto &st = (mode == LayoutMode::Full)
|
const auto &st = (mode == LayoutMode::Full)
|
||||||
? (thumbed ? st::msgFileThumbLayout : st::msgFileLayout)
|
? (thumbed ? st::msgFileThumbLayout : st::msgFileLayout)
|
||||||
: (thumbed ? st::msgFileThumbLayoutGrouped : st::msgFileLayoutGrouped);
|
: (thumbed ? st::msgFileThumbLayoutGrouped : st::msgFileLayoutGrouped);
|
||||||
const auto nameleft = st.padding.left() + st.thumbSize + st.padding.right();
|
const auto nameleft = st.padding.left() + st.thumbSize + st.thumbSkip;
|
||||||
const auto nametop = st.nameTop - topMinus;
|
const auto nametop = st.nameTop - topMinus;
|
||||||
const auto nameright = st.padding.left();
|
const auto nameright = st.padding.right();
|
||||||
const auto linktop = st.linkTop - topMinus;
|
const auto linktop = st.linkTop - topMinus;
|
||||||
auto bottom = st.padding.top() + st.thumbSize + st.padding.bottom() - topMinus;
|
auto bottom = st.padding.top() + st.thumbSize + st.padding.bottom() - topMinus;
|
||||||
const auto rthumb = style::rtlrect(st.padding.left(), st.padding.top() - topMinus, st.thumbSize, st.thumbSize, width);
|
const auto rthumb = style::rtlrect(st.padding.left(), st.padding.top() - topMinus, st.thumbSize, st.thumbSize, width);
|
||||||
|
@ -975,8 +975,8 @@ void Document::updatePressed(QPoint point) {
|
||||||
if (voice->seeking()) {
|
if (voice->seeking()) {
|
||||||
const auto thumbed = Get<HistoryDocumentThumbed>();
|
const auto thumbed = Get<HistoryDocumentThumbed>();
|
||||||
const auto &st = thumbed ? st::msgFileThumbLayout : st::msgFileLayout;
|
const auto &st = thumbed ? st::msgFileThumbLayout : st::msgFileLayout;
|
||||||
const auto nameleft = st.padding.left() + st.thumbSize + st.padding.right();
|
const auto nameleft = st.padding.left() + st.thumbSize + st.thumbSkip;
|
||||||
const auto nameright = st.padding.left();
|
const auto nameright = st.padding.right();
|
||||||
voice->setSeekingCurrent(std::clamp(
|
voice->setSeekingCurrent(std::clamp(
|
||||||
(point.x() - nameleft)
|
(point.x() - nameleft)
|
||||||
/ float64(width() - nameleft - nameright),
|
/ float64(width() - nameleft - nameright),
|
||||||
|
@ -1170,7 +1170,7 @@ QMargins Document::bubbleMargins() const {
|
||||||
return st::msgPadding;
|
return st::msgPadding;
|
||||||
}
|
}
|
||||||
const auto padding = st::msgFileThumbLayout.padding;
|
const auto padding = st::msgFileThumbLayout.padding;
|
||||||
return QMargins(padding.left(), padding.top(), padding.left(), padding.bottom());
|
return QMargins(padding.left(), padding.top(), padding.right(), padding.bottom());
|
||||||
}
|
}
|
||||||
|
|
||||||
QSize Document::sizeForGroupingOptimal(int maxWidth) const {
|
QSize Document::sizeForGroupingOptimal(int maxWidth) const {
|
||||||
|
|
|
@ -86,7 +86,7 @@ void AbstractSingleFilePreview::paintEvent(QPaintEvent *e) {
|
||||||
const auto &st = !isThumbedLayout(_data)
|
const auto &st = !isThumbedLayout(_data)
|
||||||
? st::attachPreviewLayout
|
? st::attachPreviewLayout
|
||||||
: st::attachPreviewThumbLayout;
|
: st::attachPreviewThumbLayout;
|
||||||
const auto nameleft = st.thumbSize + st.padding.right();
|
const auto nameleft = st.thumbSize + st.thumbSkip;
|
||||||
const auto nametop = st.nameTop;
|
const auto nametop = st.nameTop;
|
||||||
const auto statustop = st.statusTop;
|
const auto statustop = st.statusTop;
|
||||||
const auto x = (width() - w) / 2, y = 0;
|
const auto x = (width() - w) / 2, y = 0;
|
||||||
|
@ -164,7 +164,7 @@ void AbstractSingleFilePreview::updateTextWidthFor(Data &data) {
|
||||||
: 0;
|
: 0;
|
||||||
const auto availableFileWidth = st::sendMediaPreviewSize
|
const auto availableFileWidth = st::sendMediaPreviewSize
|
||||||
- st.thumbSize
|
- st.thumbSize
|
||||||
- st.padding.right()
|
- st.thumbSkip
|
||||||
// Right buttons.
|
// Right buttons.
|
||||||
- st::sendBoxAlbumGroupButtonFile.width * buttonsCount
|
- st::sendBoxAlbumGroupButtonFile.width * buttonsCount
|
||||||
- st::sendBoxAlbumGroupEditInternalSkip * buttonsCount
|
- st::sendBoxAlbumGroupEditInternalSkip * buttonsCount
|
||||||
|
|
|
@ -768,20 +768,23 @@ HistoryFileLayout {
|
||||||
statusTop: pixels;
|
statusTop: pixels;
|
||||||
linkTop: pixels;
|
linkTop: pixels;
|
||||||
thumbSize: pixels;
|
thumbSize: pixels;
|
||||||
|
thumbSkip: pixels;
|
||||||
}
|
}
|
||||||
|
|
||||||
msgFileLayout: HistoryFileLayout {
|
msgFileLayout: HistoryFileLayout {
|
||||||
padding: margins(14px, 10px, 11px, 10px);
|
padding: margins(12px, 8px, 10px, 8px);
|
||||||
nameTop: 16px;
|
nameTop: 16px;
|
||||||
statusTop: 37px;
|
statusTop: 37px;
|
||||||
thumbSize: 44px;
|
thumbSize: 44px;
|
||||||
|
thumbSkip: 11px;
|
||||||
}
|
}
|
||||||
msgFileThumbLayout: HistoryFileLayout {
|
msgFileThumbLayout: HistoryFileLayout {
|
||||||
padding: margins(10px, 10px, 14px, 10px);
|
padding: margins(10px, 10px, 10px, 10px);
|
||||||
nameTop: 12px;
|
nameTop: 12px;
|
||||||
statusTop: 32px;
|
statusTop: 32px;
|
||||||
linkTop: 60px;
|
linkTop: 60px;
|
||||||
thumbSize: 72px;
|
thumbSize: 72px;
|
||||||
|
thumbSkip: 14px;
|
||||||
}
|
}
|
||||||
msgFileLayoutGrouped: HistoryFileLayout(msgFileLayout) {
|
msgFileLayoutGrouped: HistoryFileLayout(msgFileLayout) {
|
||||||
padding: margins(14px, 7px, 11px, 7px);
|
padding: margins(14px, 7px, 11px, 7px);
|
||||||
|
@ -795,16 +798,18 @@ msgFileThumbLayoutGrouped: HistoryFileLayout(msgFileThumbLayout) {
|
||||||
linkTop: 57px;
|
linkTop: 57px;
|
||||||
}
|
}
|
||||||
attachPreviewLayout: HistoryFileLayout {
|
attachPreviewLayout: HistoryFileLayout {
|
||||||
padding: margins(0px, 0px, 11px, 0px);
|
padding: margins(0px, 0px, 0px, 0px);
|
||||||
nameTop: 6px;
|
nameTop: 6px;
|
||||||
statusTop: 27px;
|
statusTop: 27px;
|
||||||
thumbSize: 44px;
|
thumbSize: 44px;
|
||||||
|
thumbSkip: 11px;
|
||||||
}
|
}
|
||||||
attachPreviewThumbLayout: HistoryFileLayout {
|
attachPreviewThumbLayout: HistoryFileLayout {
|
||||||
padding: margins(0px, 0px, 10px, 0px);
|
padding: margins(0px, 0px, 0px, 0px);
|
||||||
nameTop: 7px;
|
nameTop: 7px;
|
||||||
statusTop: 37px;
|
statusTop: 37px;
|
||||||
thumbSize: 64px;
|
thumbSize: 64px;
|
||||||
|
thumbSkip: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
msgFileMenuSize: size(36px, 36px);
|
msgFileMenuSize: size(36px, 36px);
|
||||||
|
|
|
@ -259,7 +259,7 @@ void Generator::addAudioBubble(QVector<int> waveform, int waveactive, QString wa
|
||||||
|
|
||||||
auto width = st::msgFileMinWidth;
|
auto width = st::msgFileMinWidth;
|
||||||
const auto &st = st::msgFileLayout;
|
const auto &st = st::msgFileLayout;
|
||||||
auto tleft = st.padding.left() + st.thumbSize + st.padding.right();
|
auto tleft = st.padding.left() + st.thumbSize + st.thumbSkip;
|
||||||
accumulate_max(width, tleft + st::normalFont->width(wavestatus) + skipBlock.width() + st::msgPadding.right());
|
accumulate_max(width, tleft + st::normalFont->width(wavestatus) + skipBlock.width() + st::msgPadding.right());
|
||||||
accumulate_min(width, st::msgMaxWidth);
|
accumulate_min(width, st::msgMaxWidth);
|
||||||
|
|
||||||
|
@ -839,8 +839,8 @@ void Generator::paintBubble(const Bubble &bubble) {
|
||||||
bubble.text.draw(*_p, trect.x(), trect.y(), trect.width());
|
bubble.text.draw(*_p, trect.x(), trect.y(), trect.width());
|
||||||
} else if (!bubble.waveform.isEmpty()) {
|
} else if (!bubble.waveform.isEmpty()) {
|
||||||
const auto &st = st::msgFileLayout;
|
const auto &st = st::msgFileLayout;
|
||||||
auto nameleft = x + st.padding.left() + st.thumbSize + st.padding.right();
|
auto nameleft = x + st.padding.left() + st.thumbSize + st.thumbSkip;
|
||||||
auto nameright = st.padding.left();
|
auto nameright = st.padding.right();
|
||||||
auto statustop = y + st.statusTop;
|
auto statustop = y + st.statusTop;
|
||||||
|
|
||||||
auto inner = style::rtlrect(x + st.padding.left(), y + st.padding.top(), st.thumbSize, st.thumbSize, _rect.width());
|
auto inner = style::rtlrect(x + st.padding.left(), y + st.padding.top(), st.thumbSize, st.thumbSize, _rect.width());
|
||||||
|
|
Loading…
Add table
Reference in a new issue