From e4cff8cb4bb6cac4c08c35a926b5e009f0e01095 Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Fri, 23 Apr 2021 18:54:50 +0300 Subject: [PATCH] Added photo editor hint to EditCaptionBox. --- Telegram/Resources/langs/lang.strings | 1 + Telegram/SourceFiles/boxes/boxes.style | 14 +++++--- .../SourceFiles/boxes/edit_caption_box.cpp | 36 +++++++++++++++++-- Telegram/SourceFiles/boxes/edit_caption_box.h | 1 + 4 files changed, 45 insertions(+), 7 deletions(-) diff --git a/Telegram/Resources/langs/lang.strings b/Telegram/Resources/langs/lang.strings index 92c2b8997f..3a3990e76e 100644 --- a/Telegram/Resources/langs/lang.strings +++ b/Telegram/Resources/langs/lang.strings @@ -184,6 +184,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "lng_edit_media_album_error" = "This file cannot be saved as a part of an album."; "lng_edit_media_invalid_file" = "Sorry, no way to use this file."; +"lng_edit_photo_editor_hint" = "Left-click on the photo to edit."; "lng_edit_caption_attach" = "Sorry, you can't attach a new media while you're editing your message."; "lng_edit_caption_voice" = "Sorry, you can't edit your message while you're having an unsent voice message."; diff --git a/Telegram/SourceFiles/boxes/boxes.style b/Telegram/SourceFiles/boxes/boxes.style index 3f75569edd..d5a18fb251 100644 --- a/Telegram/SourceFiles/boxes/boxes.style +++ b/Telegram/SourceFiles/boxes/boxes.style @@ -424,6 +424,10 @@ backgroundScroll: ScrollArea(boxScroll) { deltab: 10px; } +sendMediaPreviewSize: 308px; +sendMediaPreviewHeightMax: 1280; +sendMediaRowSkip: 10px; + editMediaButtonSize: 28px; editMediaButtonSkip: 8px; editMediaButtonFileSkipRight: 1px; @@ -441,6 +445,11 @@ editMediaButton: IconButton { ripple: defaultRippleAnimation; } +editMediaHintLabel: FlatLabel(defaultFlatLabel) { + textFg: windowSubTextFg; + minWidth: sendMediaPreviewSize; +} + // SendFilesBox sendBoxAlbumGroupEditInternalSkip: 8px; @@ -520,6 +529,7 @@ usernameTextStyle: TextStyle(boxTextStyle, passcodeTextStyle) { } usernameDefaultFg: windowSubTextFg; +editMediaLabelMargins: margins(0px, 11px, 0px, 0px); editMediaCheckboxMargins: margins(0px, 15px, 23px, 15px); downloadPathSkip: 10px; @@ -646,10 +656,6 @@ groupStickersField: InputField(defaultMultiSelectSearchField) { } groupStickersSubTitleHeight: 36px; -sendMediaPreviewSize: 308px; -sendMediaPreviewHeightMax: 1280; -sendMediaRowSkip: 10px; - proxyUsePadding: margins(22px, 6px, 22px, 5px); proxyTryIPv6Padding: margins(22px, 8px, 22px, 5px); proxyRowPadding: margins(22px, 8px, 8px, 8px); diff --git a/Telegram/SourceFiles/boxes/edit_caption_box.cpp b/Telegram/SourceFiles/boxes/edit_caption_box.cpp index 9a919c24cc..f9cbfdcad2 100644 --- a/Telegram/SourceFiles/boxes/edit_caption_box.cpp +++ b/Telegram/SourceFiles/boxes/edit_caption_box.cpp @@ -384,6 +384,16 @@ EditCaptionBox::EditCaptionBox( InitSpellchecker(_controller, _field); + auto label = object_ptr>( + this, + object_ptr( + this, + tr::lng_edit_photo_editor_hint(tr::now), + st::editMediaHintLabel), + st::editMediaLabelMargins); + _hintLabel = label.data(); + _hintLabel->toggle(_photo, anim::type::instant); + auto r = object_ptr>( this, object_ptr( @@ -639,6 +649,7 @@ void EditCaptionBox::updateEditPreview() { const auto showCheckbox = _photo && (_albumType == Ui::AlbumType::None); _wayWrap->toggle(showCheckbox, anim::type::instant); + _hintLabel->toggle(_photo, anim::type::instant); _photoEditorButton->setVisible(_photo); if (!_doc) { @@ -838,7 +849,7 @@ void EditCaptionBox::updateCaptionMaxHeight() { _field->setMaxHeight(_doc ? st::confirmCaptionArea.heightMax - : st::confirmEditCaptionAreaHeightMax); + : (st::confirmEditCaptionAreaHeightMax - (_hintLabel->height() / 2))); // Restore. _field->setTextWithTags(text); @@ -922,6 +933,9 @@ void EditCaptionBox::updateBoxSize() { if (_photo) { newHeight += _wayWrap->height() / 2; } + if (_hintLabel->toggled()) { + newHeight += _hintLabel->height(); + } const auto &st = isThumbedLayout() ? st::msgFileThumbLayout : st::msgFileLayout; @@ -1083,18 +1097,34 @@ void EditCaptionBox::paintEvent(QPaintEvent *e) { void EditCaptionBox::resizeEvent(QResizeEvent *e) { BoxContent::resizeEvent(e); + const auto previewBottom = st::boxPhotoPadding.top() + _thumbh; + const auto hintToggled = _hintLabel->toggled(); + + if (hintToggled) { + _hintLabel->resize(st::sendMediaPreviewSize, _hintLabel->height()); + _hintLabel->moveToLeft(st::boxPhotoPadding.left(), previewBottom); + } + if (_photo) { _wayWrap->resize(st::sendMediaPreviewSize, _wayWrap->height()); _wayWrap->moveToLeft( st::boxPhotoPadding.left(), - st::boxPhotoPadding.top() + _thumbh); + hintToggled + ? _hintLabel->y() + _hintLabel->height() + : previewBottom); _photoEditorButton->resize(_thumbw, _thumbh); _photoEditorButton->moveToLeft(_thumbx, st::boxPhotoPadding.top()); } _field->resize(st::sendMediaPreviewSize, _field->height()); - _field->moveToLeft(st::boxPhotoPadding.left(), height() - st::normalFont->height - errorTopSkip() - _field->height()); + _field->moveToLeft( + st::boxPhotoPadding.left(), + height() + - st::normalFont->height + - errorTopSkip() + - _field->height()); + _emojiToggle->moveToLeft( (st::boxPhotoPadding.left() + st::sendMediaPreviewSize diff --git a/Telegram/SourceFiles/boxes/edit_caption_box.h b/Telegram/SourceFiles/boxes/edit_caption_box.h index 8f619eece3..0a034628a1 100644 --- a/Telegram/SourceFiles/boxes/edit_caption_box.h +++ b/Telegram/SourceFiles/boxes/edit_caption_box.h @@ -144,6 +144,7 @@ private: object_ptr _editMedia = nullptr; Ui::SlideWrap *_wayWrap = nullptr; + Ui::SlideWrap *_hintLabel = nullptr; QString _newMediaPath; Ui::AlbumType _albumType = Ui::AlbumType(); bool _isAllowedEditMedia = false;