mirror of
https://github.com/Qz3rK/tdesktop.git
synced 2026-07-03 14:15:08 +02:00
Exposed text selection methods on MediaGenericPart and text part.
This commit is contained in:
@@ -55,6 +55,21 @@ auto MediaGenericPart::stickerTakePlayer(
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
uint16 MediaGenericPart::fullSelectionLength() const {
|
||||
return 0;
|
||||
}
|
||||
|
||||
TextSelection MediaGenericPart::adjustSelection(
|
||||
TextSelection selection,
|
||||
TextSelectType type) const {
|
||||
return selection;
|
||||
}
|
||||
|
||||
TextForMimeData MediaGenericPart::selectedText(
|
||||
TextSelection selection) const {
|
||||
return {};
|
||||
}
|
||||
|
||||
MediaGeneric::MediaGeneric(
|
||||
not_null<Element*> parent,
|
||||
Fn<void(
|
||||
@@ -282,6 +297,7 @@ void MediaGenericTextPart::draw(
|
||||
.now = context.now,
|
||||
.pausedEmoji = context.paused || On(PowerSaving::kEmojiChat),
|
||||
.pausedSpoiler = context.paused || On(PowerSaving::kChatSpoiler),
|
||||
.selection = context.selection,
|
||||
.elisionLines = elisionLines(),
|
||||
});
|
||||
}
|
||||
@@ -311,11 +327,24 @@ TextState MediaGenericTextPart::textState(
|
||||
: _margins.left()),
|
||||
_margins.top(),
|
||||
};
|
||||
auto result = TextState();
|
||||
auto forText = request.forText();
|
||||
forText.align = _align;
|
||||
result.link = _text.getState(point, use, forText).link;
|
||||
return result;
|
||||
return TextState(nullptr, _text.getState(point, use, forText));
|
||||
}
|
||||
|
||||
uint16 MediaGenericTextPart::fullSelectionLength() const {
|
||||
return _text.length();
|
||||
}
|
||||
|
||||
TextSelection MediaGenericTextPart::adjustSelection(
|
||||
TextSelection selection,
|
||||
TextSelectType type) const {
|
||||
return _text.adjustSelection(selection, type);
|
||||
}
|
||||
|
||||
TextForMimeData MediaGenericTextPart::selectedText(
|
||||
TextSelection selection) const {
|
||||
return _text.toTextForMimeData(selection);
|
||||
}
|
||||
|
||||
QSize MediaGenericTextPart::countOptimalSize() {
|
||||
|
||||
@@ -55,6 +55,13 @@ public:
|
||||
not_null<DocumentData*> data,
|
||||
const Lottie::ColorReplacements *replacements
|
||||
) -> std::unique_ptr<StickerPlayer>;
|
||||
|
||||
[[nodiscard]] virtual uint16 fullSelectionLength() const;
|
||||
[[nodiscard]] virtual TextSelection adjustSelection(
|
||||
TextSelection selection,
|
||||
TextSelectType type) const;
|
||||
[[nodiscard]] virtual TextForMimeData selectedText(
|
||||
TextSelection selection) const;
|
||||
};
|
||||
|
||||
struct MediaGenericDescriptor {
|
||||
@@ -158,6 +165,13 @@ public:
|
||||
StateRequest request,
|
||||
int outerWidth) const override;
|
||||
|
||||
[[nodiscard]] uint16 fullSelectionLength() const override;
|
||||
[[nodiscard]] TextSelection adjustSelection(
|
||||
TextSelection selection,
|
||||
TextSelectType type) const override;
|
||||
[[nodiscard]] TextForMimeData selectedText(
|
||||
TextSelection selection) const override;
|
||||
|
||||
QSize countOptimalSize() override;
|
||||
QSize countCurrentSize(int newWidth) override;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user