mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-03-30 07:18:28 +00:00
Adding emoji in SendFilesBox and EditCaptionBox.
This commit is contained in:
parent
8d3f5820ca
commit
0a754b8982
@ -535,7 +535,7 @@ autoDownloadTitlePosition: point(23px, 18px);
|
|||||||
autoDownloadTitleFont: font(15px semibold);
|
autoDownloadTitleFont: font(15px semibold);
|
||||||
|
|
||||||
confirmCaptionArea: InputField(defaultInputField) {
|
confirmCaptionArea: InputField(defaultInputField) {
|
||||||
textMargins: margins(1px, 26px, 1px, 4px);
|
textMargins: margins(1px, 26px, 31px, 4px);
|
||||||
heightMax: 78px;
|
heightMax: 78px;
|
||||||
}
|
}
|
||||||
confirmBg: windowBgOver;
|
confirmBg: windowBgOver;
|
||||||
|
@ -10,6 +10,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||||||
#include "ui/widgets/input_fields.h"
|
#include "ui/widgets/input_fields.h"
|
||||||
#include "ui/image/image.h"
|
#include "ui/image/image.h"
|
||||||
#include "ui/text_options.h"
|
#include "ui/text_options.h"
|
||||||
|
#include "ui/special_buttons.h"
|
||||||
#include "media/media_clip_reader.h"
|
#include "media/media_clip_reader.h"
|
||||||
#include "history/history.h"
|
#include "history/history.h"
|
||||||
#include "history/history_item.h"
|
#include "history/history_item.h"
|
||||||
@ -17,7 +18,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||||||
#include "data/data_photo.h"
|
#include "data/data_photo.h"
|
||||||
#include "data/data_document.h"
|
#include "data/data_document.h"
|
||||||
#include "lang/lang_keys.h"
|
#include "lang/lang_keys.h"
|
||||||
|
#include "core/event_filter.h"
|
||||||
#include "chat_helpers/message_field.h"
|
#include "chat_helpers/message_field.h"
|
||||||
|
#include "chat_helpers/tabbed_panel.h"
|
||||||
|
#include "chat_helpers/tabbed_selector.h"
|
||||||
#include "chat_helpers/emoji_suggestions_widget.h"
|
#include "chat_helpers/emoji_suggestions_widget.h"
|
||||||
#include "window/window_controller.h"
|
#include "window/window_controller.h"
|
||||||
#include "mainwidget.h"
|
#include "mainwidget.h"
|
||||||
@ -25,6 +29,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||||||
#include "auth_session.h"
|
#include "auth_session.h"
|
||||||
#include "styles/style_history.h"
|
#include "styles/style_history.h"
|
||||||
#include "styles/style_boxes.h"
|
#include "styles/style_boxes.h"
|
||||||
|
#include "styles/style_chat_helpers.h"
|
||||||
|
|
||||||
EditCaptionBox::EditCaptionBox(
|
EditCaptionBox::EditCaptionBox(
|
||||||
QWidget*,
|
QWidget*,
|
||||||
@ -219,6 +224,25 @@ EditCaptionBox::EditCaptionBox(
|
|||||||
_field->setEditLinkCallback(DefaultEditLinkCallback(_field));
|
_field->setEditLinkCallback(DefaultEditLinkCallback(_field));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool EditCaptionBox::emojiFilter(not_null<QEvent*> event) {
|
||||||
|
const auto type = event->type();
|
||||||
|
if (type == QEvent::Move || type == QEvent::Resize) {
|
||||||
|
// updateEmojiPanelGeometry uses not only container geometry, but
|
||||||
|
// also container children geometries that will be updated later.
|
||||||
|
crl::on_main(this, [=] { updateEmojiPanelGeometry(); });
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void EditCaptionBox::updateEmojiPanelGeometry() {
|
||||||
|
const auto parent = _emojiPanel->parentWidget();
|
||||||
|
const auto global = _emojiToggle->mapToGlobal({ 0, 0 });
|
||||||
|
const auto local = parent->mapFromGlobal(global);
|
||||||
|
_emojiPanel->moveBottomRight(
|
||||||
|
local.y(),
|
||||||
|
local.x() + _emojiToggle->width() * 3);
|
||||||
|
}
|
||||||
|
|
||||||
void EditCaptionBox::prepareGifPreview(not_null<DocumentData*> document) {
|
void EditCaptionBox::prepareGifPreview(not_null<DocumentData*> document) {
|
||||||
if (_gifPreview) {
|
if (_gifPreview) {
|
||||||
return;
|
return;
|
||||||
@ -266,6 +290,8 @@ void EditCaptionBox::prepare() {
|
|||||||
getDelegate()->outerContainer(),
|
getDelegate()->outerContainer(),
|
||||||
_field);
|
_field);
|
||||||
|
|
||||||
|
setupEmojiPanel();
|
||||||
|
|
||||||
auto cursor = _field->textCursor();
|
auto cursor = _field->textCursor();
|
||||||
cursor.movePosition(QTextCursor::End);
|
cursor.movePosition(QTextCursor::End);
|
||||||
_field->setTextCursor(cursor);
|
_field->setTextCursor(cursor);
|
||||||
@ -274,9 +300,40 @@ void EditCaptionBox::prepare() {
|
|||||||
void EditCaptionBox::captionResized() {
|
void EditCaptionBox::captionResized() {
|
||||||
updateBoxSize();
|
updateBoxSize();
|
||||||
resizeEvent(0);
|
resizeEvent(0);
|
||||||
|
updateEmojiPanelGeometry();
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EditCaptionBox::setupEmojiPanel() {
|
||||||
|
const auto container = getDelegate()->outerContainer();
|
||||||
|
_emojiPanel = base::make_unique_q<ChatHelpers::TabbedPanel>(
|
||||||
|
container,
|
||||||
|
_controller,
|
||||||
|
object_ptr<ChatHelpers::TabbedSelector>(
|
||||||
|
nullptr,
|
||||||
|
_controller,
|
||||||
|
ChatHelpers::TabbedSelector::Mode::EmojiOnly));
|
||||||
|
_emojiPanel->setDesiredHeightValues(
|
||||||
|
1.,
|
||||||
|
st::emojiPanMinHeight / 2,
|
||||||
|
st::emojiPanMinHeight);
|
||||||
|
_emojiPanel->hide();
|
||||||
|
_emojiPanel->getSelector()->emojiChosen(
|
||||||
|
) | rpl::start_with_next([=](EmojiPtr emoji) {
|
||||||
|
Ui::InsertEmojiAtCursor(_field->textCursor(), emoji);
|
||||||
|
}, lifetime());
|
||||||
|
|
||||||
|
_emojiFilter.reset(Core::InstallEventFilter(
|
||||||
|
container,
|
||||||
|
[=](not_null<QEvent*> event) { return emojiFilter(event); }));
|
||||||
|
|
||||||
|
_emojiToggle.create(this, st::boxAttachEmoji);
|
||||||
|
_emojiToggle->installEventFilter(_emojiPanel);
|
||||||
|
_emojiToggle->addClickHandler([=] {
|
||||||
|
_emojiPanel->toggleAnimated();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
void EditCaptionBox::updateBoxSize() {
|
void EditCaptionBox::updateBoxSize() {
|
||||||
auto newHeight = st::boxPhotoPadding.top() + st::boxPhotoCaptionSkip + _field->height() + errorTopSkip() + st::normalFont->height;
|
auto newHeight = st::boxPhotoPadding.top() + st::boxPhotoCaptionSkip + _field->height() + errorTopSkip() + st::normalFont->height;
|
||||||
if (_photo || _animated) {
|
if (_photo || _animated) {
|
||||||
@ -393,6 +450,11 @@ void EditCaptionBox::resizeEvent(QResizeEvent *e) {
|
|||||||
BoxContent::resizeEvent(e);
|
BoxContent::resizeEvent(e);
|
||||||
_field->resize(st::sendMediaPreviewSize, _field->height());
|
_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
|
||||||
|
- _emojiToggle->width()),
|
||||||
|
_field->y() + st::boxAttachEmojiTop);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditCaptionBox::setInnerFocus() {
|
void EditCaptionBox::setInnerFocus() {
|
||||||
|
@ -9,6 +9,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||||||
|
|
||||||
#include "boxes/abstract_box.h"
|
#include "boxes/abstract_box.h"
|
||||||
|
|
||||||
|
namespace ChatHelpers {
|
||||||
|
class TabbedPanel;
|
||||||
|
} // namespace ChatHelpers
|
||||||
|
|
||||||
namespace Window {
|
namespace Window {
|
||||||
class Controller;
|
class Controller;
|
||||||
} // namespace Window
|
} // namespace Window
|
||||||
@ -19,6 +23,7 @@ class Media;
|
|||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class InputField;
|
class InputField;
|
||||||
|
class EmojiButton;
|
||||||
} // namespace Ui
|
} // namespace Ui
|
||||||
|
|
||||||
namespace Window {
|
namespace Window {
|
||||||
@ -44,6 +49,10 @@ private:
|
|||||||
void prepareGifPreview(not_null<DocumentData*> document);
|
void prepareGifPreview(not_null<DocumentData*> document);
|
||||||
void clipCallback(Media::Clip::Notification notification);
|
void clipCallback(Media::Clip::Notification notification);
|
||||||
|
|
||||||
|
void setupEmojiPanel();
|
||||||
|
void updateEmojiPanelGeometry();
|
||||||
|
bool emojiFilter(not_null<QEvent*> event);
|
||||||
|
|
||||||
void save();
|
void save();
|
||||||
void captionResized();
|
void captionResized();
|
||||||
|
|
||||||
@ -65,6 +74,9 @@ private:
|
|||||||
Media::Clip::ReaderPointer _gifPreview;
|
Media::Clip::ReaderPointer _gifPreview;
|
||||||
|
|
||||||
object_ptr<Ui::InputField> _field = { nullptr };
|
object_ptr<Ui::InputField> _field = { nullptr };
|
||||||
|
object_ptr<Ui::EmojiButton> _emojiToggle = { nullptr };
|
||||||
|
base::unique_qptr<ChatHelpers::TabbedPanel> _emojiPanel;
|
||||||
|
base::unique_qptr<QObject> _emojiFilter;
|
||||||
|
|
||||||
int _thumbx = 0;
|
int _thumbx = 0;
|
||||||
int _thumbw = 0;
|
int _thumbw = 0;
|
||||||
|
@ -14,8 +14,11 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||||||
#include "history/history_media_types.h"
|
#include "history/history_media_types.h"
|
||||||
#include "chat_helpers/message_field.h"
|
#include "chat_helpers/message_field.h"
|
||||||
#include "chat_helpers/emoji_suggestions_widget.h"
|
#include "chat_helpers/emoji_suggestions_widget.h"
|
||||||
|
#include "chat_helpers/tabbed_panel.h"
|
||||||
|
#include "chat_helpers/tabbed_selector.h"
|
||||||
#include "core/file_utilities.h"
|
#include "core/file_utilities.h"
|
||||||
#include "core/mime_type.h"
|
#include "core/mime_type.h"
|
||||||
|
#include "core/event_filter.h"
|
||||||
#include "ui/widgets/checkbox.h"
|
#include "ui/widgets/checkbox.h"
|
||||||
#include "ui/widgets/buttons.h"
|
#include "ui/widgets/buttons.h"
|
||||||
#include "ui/widgets/input_fields.h"
|
#include "ui/widgets/input_fields.h"
|
||||||
@ -23,11 +26,13 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||||||
#include "ui/wrap/fade_wrap.h"
|
#include "ui/wrap/fade_wrap.h"
|
||||||
#include "ui/grouped_layout.h"
|
#include "ui/grouped_layout.h"
|
||||||
#include "ui/text_options.h"
|
#include "ui/text_options.h"
|
||||||
|
#include "ui/special_buttons.h"
|
||||||
#include "media/media_clip_reader.h"
|
#include "media/media_clip_reader.h"
|
||||||
#include "window/window_controller.h"
|
#include "window/window_controller.h"
|
||||||
|
#include "layout.h"
|
||||||
#include "styles/style_history.h"
|
#include "styles/style_history.h"
|
||||||
#include "styles/style_boxes.h"
|
#include "styles/style_boxes.h"
|
||||||
#include "layout.h"
|
#include "styles/style_chat_helpers.h"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
@ -1587,11 +1592,63 @@ void SendFilesBox::setupCaption() {
|
|||||||
Ui::Emoji::SuggestionsController::Init(
|
Ui::Emoji::SuggestionsController::Init(
|
||||||
getDelegate()->outerContainer(),
|
getDelegate()->outerContainer(),
|
||||||
_caption);
|
_caption);
|
||||||
|
|
||||||
|
setupEmojiPanel();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SendFilesBox::setupEmojiPanel() {
|
||||||
|
const auto container = getDelegate()->outerContainer();
|
||||||
|
_emojiPanel = base::make_unique_q<ChatHelpers::TabbedPanel>(
|
||||||
|
container,
|
||||||
|
_controller,
|
||||||
|
object_ptr<ChatHelpers::TabbedSelector>(
|
||||||
|
nullptr,
|
||||||
|
_controller,
|
||||||
|
ChatHelpers::TabbedSelector::Mode::EmojiOnly));
|
||||||
|
_emojiPanel->setDesiredHeightValues(
|
||||||
|
1.,
|
||||||
|
st::emojiPanMinHeight / 2,
|
||||||
|
st::emojiPanMinHeight);
|
||||||
|
_emojiPanel->hide();
|
||||||
|
_emojiPanel->getSelector()->emojiChosen(
|
||||||
|
) | rpl::start_with_next([=](EmojiPtr emoji) {
|
||||||
|
Ui::InsertEmojiAtCursor(_caption->textCursor(), emoji);
|
||||||
|
}, lifetime());
|
||||||
|
|
||||||
|
_emojiFilter.reset(Core::InstallEventFilter(
|
||||||
|
container,
|
||||||
|
[=](not_null<QEvent*> event) { return emojiFilter(event); }));
|
||||||
|
|
||||||
|
_emojiToggle.create(this, st::boxAttachEmoji);
|
||||||
|
_emojiToggle->installEventFilter(_emojiPanel);
|
||||||
|
_emojiToggle->addClickHandler([=] {
|
||||||
|
_emojiPanel->toggleAnimated();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SendFilesBox::emojiFilter(not_null<QEvent*> event) {
|
||||||
|
const auto type = event->type();
|
||||||
|
if (type == QEvent::Move || type == QEvent::Resize) {
|
||||||
|
// updateEmojiPanelGeometry uses not only container geometry, but
|
||||||
|
// also container children geometries that will be updated later.
|
||||||
|
crl::on_main(this, [=] { updateEmojiPanelGeometry(); });
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SendFilesBox::updateEmojiPanelGeometry() {
|
||||||
|
const auto parent = _emojiPanel->parentWidget();
|
||||||
|
const auto global = _emojiToggle->mapToGlobal({ 0, 0 });
|
||||||
|
const auto local = parent->mapFromGlobal(global);
|
||||||
|
_emojiPanel->moveBottomRight(
|
||||||
|
local.y(),
|
||||||
|
local.x() + _emojiToggle->width() * 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SendFilesBox::captionResized() {
|
void SendFilesBox::captionResized() {
|
||||||
updateBoxSize();
|
updateBoxSize();
|
||||||
updateControlsGeometry();
|
updateControlsGeometry();
|
||||||
|
updateEmojiPanelGeometry();
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1747,6 +1804,12 @@ void SendFilesBox::updateControlsGeometry() {
|
|||||||
st::boxPhotoPadding.left(),
|
st::boxPhotoPadding.left(),
|
||||||
bottom - _caption->height());
|
bottom - _caption->height());
|
||||||
bottom -= st::boxPhotoCaptionSkip + _caption->height();
|
bottom -= st::boxPhotoCaptionSkip + _caption->height();
|
||||||
|
|
||||||
|
_emojiToggle->moveToLeft(
|
||||||
|
(st::boxPhotoPadding.left()
|
||||||
|
+ st::sendMediaPreviewSize
|
||||||
|
- _emojiToggle->width()),
|
||||||
|
_caption->y() + st::boxAttachEmojiTop);
|
||||||
}
|
}
|
||||||
const auto pointers = {
|
const auto pointers = {
|
||||||
_sendAlbum.data(),
|
_sendAlbum.data(),
|
||||||
|
@ -16,6 +16,10 @@ namespace Window {
|
|||||||
class Controller;
|
class Controller;
|
||||||
} // namespace Window
|
} // namespace Window
|
||||||
|
|
||||||
|
namespace ChatHelpers {
|
||||||
|
class TabbedPanel;
|
||||||
|
} // namespace ChatHelpers
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
template <typename Enum>
|
template <typename Enum>
|
||||||
class Radioenum;
|
class Radioenum;
|
||||||
@ -24,6 +28,7 @@ class RadioenumGroup;
|
|||||||
class RoundButton;
|
class RoundButton;
|
||||||
class InputField;
|
class InputField;
|
||||||
struct GroupMediaLayout;
|
struct GroupMediaLayout;
|
||||||
|
class EmojiButton;
|
||||||
} // namespace Ui
|
} // namespace Ui
|
||||||
|
|
||||||
namespace Window {
|
namespace Window {
|
||||||
@ -80,6 +85,10 @@ private:
|
|||||||
not_null<Ui::ScrollArea*> wrap,
|
not_null<Ui::ScrollArea*> wrap,
|
||||||
not_null<AlbumPreview*> content);
|
not_null<AlbumPreview*> content);
|
||||||
|
|
||||||
|
void setupEmojiPanel();
|
||||||
|
void updateEmojiPanelGeometry();
|
||||||
|
bool emojiFilter(not_null<QEvent*> event);
|
||||||
|
|
||||||
void refreshAlbumMediaCount();
|
void refreshAlbumMediaCount();
|
||||||
void preparePreview();
|
void preparePreview();
|
||||||
void prepareSingleFilePreview();
|
void prepareSingleFilePreview();
|
||||||
@ -116,6 +125,10 @@ private:
|
|||||||
bool _confirmed = false;
|
bool _confirmed = false;
|
||||||
|
|
||||||
object_ptr<Ui::InputField> _caption = { nullptr };
|
object_ptr<Ui::InputField> _caption = { nullptr };
|
||||||
|
object_ptr<Ui::EmojiButton> _emojiToggle = { nullptr };
|
||||||
|
base::unique_qptr<ChatHelpers::TabbedPanel> _emojiPanel;
|
||||||
|
base::unique_qptr<QObject> _emojiFilter;
|
||||||
|
|
||||||
object_ptr<Ui::Radioenum<SendFilesWay>> _sendAlbum = { nullptr };
|
object_ptr<Ui::Radioenum<SendFilesWay>> _sendAlbum = { nullptr };
|
||||||
object_ptr<Ui::Radioenum<SendFilesWay>> _sendPhotos = { nullptr };
|
object_ptr<Ui::Radioenum<SendFilesWay>> _sendPhotos = { nullptr };
|
||||||
object_ptr<Ui::Radioenum<SendFilesWay>> _sendFiles = { nullptr };
|
object_ptr<Ui::Radioenum<SendFilesWay>> _sendFiles = { nullptr };
|
||||||
|
@ -151,6 +151,9 @@ emojiPanHover: windowBgOver;
|
|||||||
emojiPanSlideDuration: 200;
|
emojiPanSlideDuration: 200;
|
||||||
emojiPanDesiredSize: 45px;
|
emojiPanDesiredSize: 45px;
|
||||||
|
|
||||||
|
inlineResultsMinHeight: 278px;
|
||||||
|
inlineResultsMaxHeight: 640px;
|
||||||
|
|
||||||
emojiPanHeader: 42px;
|
emojiPanHeader: 42px;
|
||||||
emojiPanHeaderFont: semiboldFont;
|
emojiPanHeaderFont: semiboldFont;
|
||||||
emojiPanHeaderLeft: 22px;
|
emojiPanHeaderLeft: 22px;
|
||||||
|
@ -679,9 +679,13 @@ bool SuggestionsController::outerFilter(not_null<QEvent*> event) {
|
|||||||
switch (type) {
|
switch (type) {
|
||||||
case QEvent::Move:
|
case QEvent::Move:
|
||||||
case QEvent::Resize: {
|
case QEvent::Resize: {
|
||||||
if (_shown) {
|
// updateGeometry uses not only container geometry, but also
|
||||||
updateGeometry();
|
// container children geometries that will be updated later.
|
||||||
}
|
InvokeQueued(_container, [=] {
|
||||||
|
if (_shown) {
|
||||||
|
updateGeometry();
|
||||||
|
}
|
||||||
|
});
|
||||||
} break;
|
} break;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -38,7 +38,10 @@ TabbedPanel::TabbedPanel(
|
|||||||
object_ptr<TabbedSelector> selector)
|
object_ptr<TabbedSelector> selector)
|
||||||
: RpWidget(parent)
|
: RpWidget(parent)
|
||||||
, _controller(controller)
|
, _controller(controller)
|
||||||
, _selector(std::move(selector)) {
|
, _selector(std::move(selector))
|
||||||
|
, _heightRatio(st::emojiPanHeightRatio)
|
||||||
|
, _minContentHeight(st::emojiPanMinHeight)
|
||||||
|
, _maxContentHeight(st::emojiPanMaxHeight) {
|
||||||
_selector->setParent(this);
|
_selector->setParent(this);
|
||||||
_selector->setRoundRadius(st::buttonRadius);
|
_selector->setRoundRadius(st::buttonRadius);
|
||||||
_selector->setAfterShownCallback([this](SelectorTab tab) {
|
_selector->setAfterShownCallback([this](SelectorTab tab) {
|
||||||
@ -97,8 +100,19 @@ TabbedPanel::TabbedPanel(
|
|||||||
hideChildren();
|
hideChildren();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TabbedPanel::moveBottom(int bottom) {
|
void TabbedPanel::moveBottomRight(int bottom, int right) {
|
||||||
_bottom = bottom;
|
_bottom = bottom;
|
||||||
|
_right = right;
|
||||||
|
updateContentHeight();
|
||||||
|
}
|
||||||
|
|
||||||
|
void TabbedPanel::setDesiredHeightValues(
|
||||||
|
float64 ratio,
|
||||||
|
int minHeight,
|
||||||
|
int maxHeight) {
|
||||||
|
_heightRatio = ratio;
|
||||||
|
_minContentHeight = minHeight;
|
||||||
|
_maxContentHeight = maxHeight;
|
||||||
updateContentHeight();
|
updateContentHeight();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -110,8 +124,11 @@ void TabbedPanel::updateContentHeight() {
|
|||||||
auto addedHeight = innerPadding().top() + innerPadding().bottom();
|
auto addedHeight = innerPadding().top() + innerPadding().bottom();
|
||||||
auto marginsHeight = _selector->marginTop() + _selector->marginBottom();
|
auto marginsHeight = _selector->marginTop() + _selector->marginBottom();
|
||||||
auto availableHeight = _bottom - marginsHeight;
|
auto availableHeight = _bottom - marginsHeight;
|
||||||
auto wantedContentHeight = qRound(st::emojiPanHeightRatio * availableHeight) - addedHeight;
|
auto wantedContentHeight = qRound(_heightRatio * availableHeight) - addedHeight;
|
||||||
auto contentHeight = marginsHeight + snap(wantedContentHeight, st::emojiPanMinHeight, st::emojiPanMaxHeight);
|
auto contentHeight = marginsHeight + snap(
|
||||||
|
wantedContentHeight,
|
||||||
|
_minContentHeight,
|
||||||
|
_maxContentHeight);
|
||||||
auto resultTop = _bottom - addedHeight - contentHeight;
|
auto resultTop = _bottom - addedHeight - contentHeight;
|
||||||
if (contentHeight == _contentHeight) {
|
if (contentHeight == _contentHeight) {
|
||||||
move(x(), resultTop);
|
move(x(), resultTop);
|
||||||
@ -169,7 +186,8 @@ void TabbedPanel::paintEvent(QPaintEvent *e) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void TabbedPanel::moveByBottom() {
|
void TabbedPanel::moveByBottom() {
|
||||||
moveToRight(0, y());
|
const auto right = std::max(parentWidget()->width() - _right, 0);
|
||||||
|
moveToRight(right, y());
|
||||||
updateContentHeight();
|
updateContentHeight();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -369,6 +387,7 @@ void TabbedPanel::showStarted() {
|
|||||||
if (isHidden()) {
|
if (isHidden()) {
|
||||||
_selector->showStarted();
|
_selector->showStarted();
|
||||||
moveByBottom();
|
moveByBottom();
|
||||||
|
raise();
|
||||||
show();
|
show();
|
||||||
startShowAnimation();
|
startShowAnimation();
|
||||||
} else if (_hiding) {
|
} else if (_hiding) {
|
||||||
|
@ -25,11 +25,18 @@ class TabbedSelector;
|
|||||||
class TabbedPanel : public Ui::RpWidget {
|
class TabbedPanel : public Ui::RpWidget {
|
||||||
public:
|
public:
|
||||||
TabbedPanel(QWidget *parent, not_null<Window::Controller*> controller);
|
TabbedPanel(QWidget *parent, not_null<Window::Controller*> controller);
|
||||||
TabbedPanel(QWidget *parent, not_null<Window::Controller*> controller, object_ptr<TabbedSelector> selector);
|
TabbedPanel(
|
||||||
|
QWidget *parent,
|
||||||
|
not_null<Window::Controller*> controller,
|
||||||
|
object_ptr<TabbedSelector> selector);
|
||||||
|
|
||||||
object_ptr<TabbedSelector> takeSelector();
|
object_ptr<TabbedSelector> takeSelector();
|
||||||
QPointer<TabbedSelector> getSelector() const;
|
QPointer<TabbedSelector> getSelector() const;
|
||||||
void moveBottom(int bottom);
|
void moveBottomRight(int bottom, int right);
|
||||||
|
void setDesiredHeightValues(
|
||||||
|
float64 ratio,
|
||||||
|
int minHeight,
|
||||||
|
int maxHeight);
|
||||||
|
|
||||||
void hideFast();
|
void hideFast();
|
||||||
bool hiding() const {
|
bool hiding() const {
|
||||||
@ -86,6 +93,10 @@ private:
|
|||||||
int _contentMaxHeight = 0;
|
int _contentMaxHeight = 0;
|
||||||
int _contentHeight = 0;
|
int _contentHeight = 0;
|
||||||
int _bottom = 0;
|
int _bottom = 0;
|
||||||
|
int _right = 0;
|
||||||
|
float64 _heightRatio = 1.;
|
||||||
|
int _minContentHeight = 0;
|
||||||
|
int _maxContentHeight = 0;
|
||||||
|
|
||||||
std::unique_ptr<Ui::PanelAnimation> _showAnimation;
|
std::unique_ptr<Ui::PanelAnimation> _showAnimation;
|
||||||
Animation _a_show;
|
Animation _a_show;
|
||||||
|
@ -213,7 +213,7 @@ historyAttach: IconButton {
|
|||||||
historyAttachEmoji: IconButton(historyAttach) {
|
historyAttachEmoji: IconButton(historyAttach) {
|
||||||
icon: icon {{ "send_control_emoji", historyComposeIconFg }};
|
icon: icon {{ "send_control_emoji", historyComposeIconFg }};
|
||||||
iconOver: icon {{ "send_control_emoji", historyComposeIconFgOver }};
|
iconOver: icon {{ "send_control_emoji", historyComposeIconFgOver }};
|
||||||
iconPosition: point(15px, 15px);
|
iconPosition: point(-1px, -1px);
|
||||||
}
|
}
|
||||||
historyAttachEmojiFgActive: windowActiveTextFg;
|
historyAttachEmojiFgActive: windowActiveTextFg;
|
||||||
historyAttachEmojiActive: icon {{ "send_control_emoji", historyAttachEmojiFgActive }};
|
historyAttachEmojiActive: icon {{ "send_control_emoji", historyAttachEmojiFgActive }};
|
||||||
@ -478,3 +478,10 @@ historyAboutProxyPadding: margins(20px, 10px, 20px, 10px);
|
|||||||
|
|
||||||
historyMapPoint: icon {{ "map_point", mapPointDrop }};
|
historyMapPoint: icon {{ "map_point", mapPointDrop }};
|
||||||
historyMapPointInner: icon {{ "map_point_inner", mapPointDot }};
|
historyMapPointInner: icon {{ "map_point_inner", mapPointDot }};
|
||||||
|
|
||||||
|
boxAttachEmoji: IconButton(historyAttachEmoji) {
|
||||||
|
width: 30px;
|
||||||
|
height: 30px;
|
||||||
|
rippleAreaSize: 0px;
|
||||||
|
}
|
||||||
|
boxAttachEmojiTop: 20px;
|
||||||
|
@ -4091,7 +4091,7 @@ void HistoryWidget::moveFieldControls() {
|
|||||||
_inlineResults->moveBottom(_field->y() - st::historySendPadding);
|
_inlineResults->moveBottom(_field->y() - st::historySendPadding);
|
||||||
}
|
}
|
||||||
if (_tabbedPanel) {
|
if (_tabbedPanel) {
|
||||||
_tabbedPanel->moveBottom(buttonsBottom);
|
_tabbedPanel->moveBottomRight(buttonsBottom, width());
|
||||||
}
|
}
|
||||||
|
|
||||||
auto fullWidthButtonRect = myrtlrect(
|
auto fullWidthButtonRect = myrtlrect(
|
||||||
|
@ -43,7 +43,7 @@ Inner::Inner(QWidget *parent, not_null<Window::Controller*> controller) : TWidge
|
|||||||
, _controller(controller)
|
, _controller(controller)
|
||||||
, _updateInlineItems([=] { updateInlineItems(); })
|
, _updateInlineItems([=] { updateInlineItems(); })
|
||||||
, _previewTimer([=] { showPreview(); }) {
|
, _previewTimer([=] { showPreview(); }) {
|
||||||
resize(st::emojiPanWidth - st::emojiScroll.width - st::buttonRadius, st::emojiPanMinHeight);
|
resize(st::emojiPanWidth - st::emojiScroll.width - st::buttonRadius, st::inlineResultsMinHeight);
|
||||||
|
|
||||||
setMouseTracking(true);
|
setMouseTracking(true);
|
||||||
setAttribute(Qt::WA_OpaquePaintEvent);
|
setAttribute(Qt::WA_OpaquePaintEvent);
|
||||||
@ -760,7 +760,7 @@ void Widget::moveBottom(int bottom) {
|
|||||||
void Widget::updateContentHeight() {
|
void Widget::updateContentHeight() {
|
||||||
auto addedHeight = innerPadding().top() + innerPadding().bottom();
|
auto addedHeight = innerPadding().top() + innerPadding().bottom();
|
||||||
auto wantedContentHeight = qRound(st::emojiPanHeightRatio * _bottom) - addedHeight;
|
auto wantedContentHeight = qRound(st::emojiPanHeightRatio * _bottom) - addedHeight;
|
||||||
auto contentHeight = snap(wantedContentHeight, st::emojiPanMinHeight, st::emojiPanMaxHeight);
|
auto contentHeight = snap(wantedContentHeight, st::inlineResultsMinHeight, st::inlineResultsMaxHeight);
|
||||||
accumulate_min(contentHeight, _bottom - addedHeight);
|
accumulate_min(contentHeight, _bottom - addedHeight);
|
||||||
accumulate_min(contentHeight, _contentMaxHeight);
|
accumulate_min(contentHeight, _contentMaxHeight);
|
||||||
auto resultTop = _bottom - addedHeight - contentHeight;
|
auto resultTop = _bottom - addedHeight - contentHeight;
|
||||||
|
@ -140,9 +140,9 @@ QPoint HistoryDownButton::prepareRippleStartPosition() const {
|
|||||||
void HistoryDownButton::paintEvent(QPaintEvent *e) {
|
void HistoryDownButton::paintEvent(QPaintEvent *e) {
|
||||||
Painter p(this);
|
Painter p(this);
|
||||||
|
|
||||||
auto ms = getms();
|
const auto ms = getms();
|
||||||
auto over = isOver();
|
const auto over = isOver();
|
||||||
auto down = isDown();
|
const auto down = isDown();
|
||||||
((over || down) ? _st.iconBelowOver : _st.iconBelow).paint(p, _st.iconPosition, width());
|
((over || down) ? _st.iconBelowOver : _st.iconBelow).paint(p, _st.iconPosition, width());
|
||||||
paintRipple(p, _st.rippleAreaPosition.x(), _st.rippleAreaPosition.y(), ms);
|
paintRipple(p, _st.rippleAreaPosition.x(), _st.rippleAreaPosition.y(), ms);
|
||||||
((over || down) ? _st.iconAboveOver : _st.iconAbove).paint(p, _st.iconPosition, width());
|
((over || down) ? _st.iconAboveOver : _st.iconAbove).paint(p, _st.iconPosition, width());
|
||||||
@ -190,13 +190,20 @@ void EmojiButton::paintEvent(QPaintEvent *e) {
|
|||||||
if (loadingState.shown < 1.) {
|
if (loadingState.shown < 1.) {
|
||||||
p.setOpacity(1. - loadingState.shown);
|
p.setOpacity(1. - loadingState.shown);
|
||||||
|
|
||||||
auto icon = _iconOverride ? _iconOverride : &(over ? _st.iconOver : _st.icon);
|
const auto icon = _iconOverride ? _iconOverride : &(over ? _st.iconOver : _st.icon);
|
||||||
icon->paint(p, _st.iconPosition, width());
|
auto position = _st.iconPosition;
|
||||||
|
if (position.x() < 0) {
|
||||||
|
position.setX((width() - icon->width()) / 2);
|
||||||
|
}
|
||||||
|
if (position.y() < 0) {
|
||||||
|
position.setY((height() - icon->height()) / 2);
|
||||||
|
}
|
||||||
|
icon->paint(p, position, width());
|
||||||
|
|
||||||
p.setOpacity(1.);
|
p.setOpacity(1.);
|
||||||
}
|
}
|
||||||
|
|
||||||
QRect inner(QPoint((width() - st::historyEmojiCircle.width()) / 2, st::historyEmojiCircleTop), st::historyEmojiCircle);
|
QRect inner(QPoint((width() - st::historyEmojiCircle.width()) / 2, (height() - st::historyEmojiCircle.height()) / 2), st::historyEmojiCircle);
|
||||||
const auto color = (_colorOverride
|
const auto color = (_colorOverride
|
||||||
? *_colorOverride
|
? *_colorOverride
|
||||||
: (over
|
: (over
|
||||||
@ -261,6 +268,9 @@ void EmojiButton::onStateChanged(State was, StateChangeSource source) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
QPoint EmojiButton::prepareRippleStartPosition() const {
|
QPoint EmojiButton::prepareRippleStartPosition() const {
|
||||||
|
if (!_st.rippleAreaSize) {
|
||||||
|
return DisabledRippleStartPosition();
|
||||||
|
}
|
||||||
return mapFromGlobal(QCursor::pos()) - _st.rippleAreaPosition;
|
return mapFromGlobal(QCursor::pos()) - _st.rippleAreaPosition;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user